AnsweredAssumed Answered

How to safely extend js views in packages?

Question asked by Karel Čech on Nov 26, 2017
Latest reply on Dec 1, 2017 by Karel Čech

Hi, I just can't figure out how to do this in a safe way.

 

Lets say I want to extend accounts recordView - I create a file custom/modules/Accounts/clients/base/views/record/record.js. Easy.

 

And now I want to install this file using a package - this package will take the file (using copy installdefs) and put it on it's place and everything works...

 

But does it? What if there already was a different file from a different package? It would be overwritten right? So the previous functionality would be lost? How can I avoid this? And how can I ensure some other package won't overwrite my files?

 

All that comes to my mind is not to create files in custom/modules/*/clients/base/views/, but rather to extend the class directly in some JSGroupings file. But that's kinda ugly and I would still run to problems if there were methods with same names (at least initialize method...), so i would like like to avoid that...

 

What is the best practice for this?

 

Thanks for suggestions

Karel

Outcomes