Coding Tutorial: How to package a custom implementation as an installable extension.

Collapse
X
 
  • Time
  • Show
Clear All
new posts

  • telecastg
    commented on 's reply
    You're welcome

  • shalmaxb
    commented on 's reply
    Thanks, I will try that tomorrow.

  • telecastg
    replied
    Hi shalmaxb ,

    Actually you can use your old (pre Espo 7) or the new (Espo 7) module structure and the system will recognize it.

    You can have the pre Espo 7 structure like this:
    application/Espo/Modules/{MyModule}/(back end folders like Controllers, Services,Resources, etc)
    client/modules/{my-module}/(front end folders like libs, res. src, etc)
    For an example of this structure you can check the Chats extension (which I believe you have) folder structure https://payhip.com/b/tq62X

    Or you can have the Espo 7 way like this:
    custom/Espo/Modules/{MyModule}/(back end folders)
    client/custom/modules/{my-module}/(front end folders)
    For an example of this structure you can check the List Plus extension (that I believe that you also have) folder structure https://payhip.com/b/ZGQMH

    yuri stated that the "old" way would continue working maybe indefinitely so perhaps it is not necessary to alter the old structure but for new extensions I would recommend using the new way just in case there is another major code refactoring and the "old" way is no longer available

    Leave a comment:


  • shalmaxb
    replied
    Hi, telecastg , seems, that the process to create custom modules changed with 7.0.x.
    Any hints, how I can create modules from my custom entities? I succeeded with that in 6.x but the file structure changed.

    Leave a comment:


  • shalmaxb
    replied
    Meanwhile I found the error. It is caused by a wrong path for the js-file. In a former post the file should be here:

    files/client/modules/recalculate-formula/src/unrestricted-recalculate-formula-handler.js

    but it works only, if the path looks like this:

    files/client/modules/formula-refresh/src/unrestricted-recalculate-formula-handler.js

    Here is the extension ready to use: formula-refresh-for-espocrm-1.0.0.zip
    Be aware, that this is not my extension, it was made by the tutorial and files from telecastg in this thread.
    Attached Files
    Last edited by shalmaxb; 07-26-2021, 05:09 PM.

    Leave a comment:


  • shalmaxb
    replied
    I get this error in Browser console:

    Code:
    loader.js:421 Uncaught Error: Could not load file 'client/modules/formula-refresh/src/unrestricted-recalculate-formula-handler.js?r=1627310483'
    at Object.error (loader.js:421)
    at j (jquery-2.1.4.min.js:2)
    at Object.fireWith [as rejectWith] (jquery-2.1.4.min.js:2)
    at x (jquery-2.1.4.min.js:4)
    at XMLHttpRequest.<anonymous> (jquery-2.1.4.min.js:4)
    error @ loader.js:421

    Leave a comment:


  • shalmaxb
    commented on 's reply
    Unfortunately, it does not work. When I insert the handler-code into the clientDef of an entity, the record of that entity won`t open. There appears for one second "load" on top and after that nothing.
    No error in log-file.

  • telecastg
    commented on 's reply
    Thanks for the heads up.

  • emillod
    replied
    There are some changes 6.2. We'll have to keep ext in custom directory
    Supporting modules in the custom directories for both back-end and front-end: custom/Espo/Modules/{ModuleName} client/custom/modules/{module-name} The system will automatically recognize when the m...


    Leave a comment:


  • telecastg
    replied
    Hello,

    Yes, that code is still necessary to be added to the clientDefs of each entity where you want to display the "Recalculate" button. The only change is the reference to the custom handler

    from:
    Code:
    "data": { "handler": "custom:basic-recalculate-formula-handler" },
    to:
    Code:
    "data": { "handler": "formula-refresh:unrestricted-recalculate-formula-handler" },
    The extension allows you to add the button but you still need to let Espo know which entities should have the custom button.

    Leave a comment:


  • shalmaxb
    replied
    Hi, I have been using the customization itself (in the custom`s folder) quite a while now and it works as desired.
    Today I tried to built this as an extension as described here. Unfortunately I did not have success. The button does not appear, no error in the log file or in the app itself.

    I see, that in the files, when implemeted in folder custom, there you will have to append this code:


    Code:
    { ... "menu":
    { "detail":
    { "buttons":
    [ "__APPEND__",
    {
    "label": "Recalculate Formula",
    "name": "recalculateFormula",
    "action": "recalculate",
    "style": "default",
    "acl": "read",
    "aclScope":
    "Basic",
    "data": { "handler": "custom:basic-recalculate-formula-handler" },
    "initFunction": "initRecalculate" } ] } }, ... }
    in every entity, where you want the button to appear. Is this not necessary, when packing as extension, because in the description above, there is nothing about that?

    Leave a comment:


  • emillod
    commented on 's reply
    I'm using git not that long, but now it's big part of my job as a developer.
    I store everything important on github, i have to enter "git clone XYZ" to prepare a dev workflow

    And that history of changes is bless

  • telecastg
    commented on 's reply
    Thanks so much emillod !

    I am a total beginner using git but I will educate myself more and will try.

  • emillod
    replied
    telecastg sure, of course.
    I'm using for that wsl on my computer. I'm using windows 10 with WSL, so it's not rocket science

    I believe you should have packages like php, git, node.
    If you have everything, just:
    1. Open CLI (i love Microsoft terminal )
    2. Fetch espo template: git clone https://github.com/espocrm/ext-template.git (ss: https://i.imgur.com/orZpSWj.png)
    3. Move to the directory (ss: https://i.imgur.com/0PQsN4i.png)
    4. Initiate php script: php init.php (ss: https://i.imgur.com/ITSA0UU.png) and provide basic information
    5. Run npm install command

    That's all. Now you can remove .git directory and init.php file because everything is ready.
    This init.php script will prepare all folders which you need to work on your extension.

    After that you can open your edit, for me it's visual studio code, so i have to enter "code -n ." to open vscode in that directory.

    I've also tried to use everything manually, but it's simpler. I can upgrade version with one command, i can build a package also with one command.
    I can prepare temporary instance with one command thanks to which i have EspoCRM instance for specific extension.

    There is also one command to move all changes from Custom to Extension. Unfortunatelly it can't merge changes, so after you move everything from Custom, and you'll change something from GUI(for example you'll create new field) it can't merge changes from custom with already existing module.

    And of course if you're git-guy, working with github in vscode is a blessing

    Leave a comment:


  • telecastg
    commented on 's reply
    esforim lol !
Working...