Announcement

Collapse
No announcement yet.

Extend Views Setup Handlers add (entity-manager/record/edit)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • yuri
    commented on 's reply
    App timestamp updating busts the cache timestamp. So it also works.

  • rabii
    commented on 's reply
    It was just cache, had to clear it twice using cli and also cleared cache from browser and it start to work.

  • rabii
    replied
    Got it to work now, cleared cache from UI and cache of browser and it worked

    Thanks Yuri appreciate your time

    Leave a comment:


  • yuri
    replied
    If the JS file is cached by the browser, open it in a tab and Ctrl + F5.

    Leave a comment:


  • Kharg
    commented on 's reply
    Maybe try updating the app timestamp from CLI?

  • yuri
    replied
    You should be able to see your script in the html source. Ctrl + U in the browser.

    Leave a comment:


  • rabii
    replied
    Yes,

    It is enabled (i did clear cache both from UI and also through CLI)

    here is my app > client.json
    PHP Code:
    {
        
    "scriptList": [
            
    "__APPEND__",
            
    "client/custom/modules/{@nameHyphen}/lib/init.js",
            
    "client/custom/modules/plus-extension/src/plus-script.js"
        
    ],
        
    "developerModeScriptList": [
            
    "__APPEND__",
            
    "client/custom/modules/plus-extension/src/plus-script.js"
        
    ]
    }
    ​ 

    and my plus-script.js under src folder in my files / client/custom/modules/plus-extension/src/plus-script.js

    PHP Code:
    require(['views/admin/entity-manager/record/index'], View => {

        const 
    defaultSetup View.prototype.setup;

        
    View.prototype.setup = function () {
            
    defaultSetup.call(this);
            
            
    console.log('custom setup'this.name);
        };
    });
    ​ 

    That is weird still not working, even if i console log outside the method nothing shows in the console.

    Leave a comment:


  • yuri
    replied
    Developer mode enabled? I tried, it worked for me in the developer mode. Clearing cache required.

    Code:
    {
        "developerModeScriptList": [
            "__APPEND__",
            "client/custom/src/test.js"
        ]
    }
    ​

    Leave a comment:


  • rabii
    replied
    by the way iam using ext-template / es6 enabled transpil

    Leave a comment:


  • rabii
    commented on 's reply
    already did that

  • yuri
    replied
    Added to both scriptList and developerModeScriptList ?

    Leave a comment:


  • rabii
    commented on 's reply
    tried still nothing in the console

  • yuri
    replied
    Is the file called? Try the console.log outside the method.

    Leave a comment:


  • rabii
    replied
    I understand, Thanks for your time and explanation, so based on this conversation here https://github.com/espocrm/espocrm/i...ent-1801495815 and also https://forum.espocrm.com/forum/deve...522#post100522 i am trying this code below to monkey patch but didn't succeed. is there any related article/conversation about how to get it up working properly. Thanks

    PHP Code:
    require(['views/admin/entity-manager/record/edit'], View => {

        const 
    defaultSetup View.prototype.setup;

        
    View.prototype.setup = function () {
            
    defaultSetup.call(this);
            
            
    console.log('custom setup'this.name);
        };
    });
    ​ 

    Because i am using es6 i also tried below

    PHP Code:
    import EntityManagerRecordEditView from 'views/admin/entity-manager/record/edit';

    const 
    defaultSetup EntityManagerRecordEditView.prototype.setup;

    EntityManagerRecordEditView.prototype.setup = function () {
        
    // Call the original setup method
        
    defaultSetup.call(this);

        
    // Your custom logic
        
    console.log('Custom setup for Entity Manager Index View:'this.name);
    };

    export default EntityManagerRecordEditView;​ 
    This was added in a script in my extension but when running node build --copy and go to edit record in entity manager nothing in the console.

    Any help would be appreciated and i know how much busy you are
    Last edited by rabii; 09-27-2024, 12:44 PM.

    Leave a comment:


  • yuri
    replied
    If you monkey patch a "setup" method and access only 'public' members of the view, that would be an equivalent of a using view-setup-handler.
    Last edited by yuri; 09-27-2024, 12:39 PM.

    Leave a comment:

Working...
X