possible to override specific functions of a client js Views/Models without completely overriding the component?

v7.7.0

I need to add some additional functionality to a client js View (/sugarcrm/modules/Emails/clients/base/views/compose/compose.js) on one of the methods. Is it possible to override a single method of this View without completely overriding it? I'd also prefer not to create a new View that extends from the original since it's a small change and I don't want to replace the component everywhere it's used in the app. Thanks!

  • You should be able to with something along these lines:

    ({
         /* File: ./custom/modules/Emails/clients/base/views/compose/compose.js */
         extendsFrom: 'EmailsComposeView',
    
         theMethodToOverride: function(){
              //My code to run before invoking parent controller's version of method would go here
              this._super('theMethodToOverride');
              //Code to execute after invoking parent controller's version of method goes here
         }
    })
    

    Notice that I can easily invoke the parent controller's version of the method, but if I need to change something embedded within say line 5 of the 10 lines in that method, I would need to copy the parent controller's version of the method to the custom controller. The problem with that is that we might change that code in the future and you would have to port those changes over. Assuming you don't have that need, changes we introduce shouldn't be a problem.

  • EDIT: Originally I was using the wrong view name in the extendsFrom property but now using EmailsComposeView or BaseEmailsComposeView it's working as expected. Thanks much!