is menu > actions still working?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • trungtvmso
    Member
    • Jun 2022
    • 70

    is menu > actions still working?

    Dear Yuri,

    I found out that we can add MenuItem as 'actions' button, but it could not load data-action. I've tried to look for docs or search some sample script but I got nothing else to guide me to use this one. I would like to use this custom button because it's seem clearer than dropdown menu. This is my custom code for the button + its function + what the view rendered:

    Click image for larger version

Name:	image.png
Views:	181
Size:	11.8 KB
ID:	108565
    Click image for larger version

Name:	image.png
Views:	116
Size:	4.2 KB
ID:	108566
    Click image for larger version

Name:	image.png
Views:	115
Size:	9.7 KB
ID:	108567​​​

    Also if I want to add more than one of list in dropdown action button like this :

    [Follow][DropDownAction1][DropDownAction2]

    So how can I do that, can you pls help?
    Last edited by trungtvmso; 07-18-2024, 05:49 AM.
  • trungtvmso
    Member
    • Jun 2022
    • 70

    #2
    Originally posted by trungtvmso
    Dear Yuri,

    I found out that we can add MenuItem as 'actions' button, but it could not load data-action. I've tried to look for docs or search some sample script but I got nothing else to guide me to use this one. I would like to use this custom button because it's seem clearer than dropdown menu. This is my custom code for the button + its function + what the view rendered:

    Click image for larger version  Name:	image.png Views:	3 Size:	11.8 KB ID:	108565
    Click image for larger version  Name:	image.png Views:	3 Size:	4.2 KB ID:	108566
    Click image for larger version  Name:	image.png Views:	3 Size:	9.7 KB ID:	108567​​​

    Also if I want to add more than one of list in dropdown action button like this :

    [Follow][DropDownAction1][DropDownAction2]

    So how can I do that, can you pls help?


    I resolved already the first question. Here is my guide for anyone need to add menu.actions > buttons list into views/entity/detail

    Option 1: Directly create menu.actions in detail view by js:
    1. Create/Edit custom detail view for your Entity by following this path:
    PHP Code:
    client/custom/src/views/{Entity}/detail.js 
    



    2. Use this Script:

    PHP Code:
    
    define('custom:views/{Entity}/detail', ['views/detail','views/modal','model'], function (Dep) {
        return Dep.extend({
    
            setup() {
                Dep.prototype.setup.call(this);
    
                this.addMenuItem('actions',{
                    name: 'buttonName',
                    text: this.translate('buttonName', 'labels' , 'Scope'),
                    acl: 'read',
                    hidden: false,
                    style: 'primary',
                    action: 'buttonName',
                });            
              
            },
    
            actionButtonName () {
                console.log('Test action here'); //Can fire anything here
    
            },
    
        });
    });
    

    Option 2: Registering menu.actions button from clientDefs

    1. Create/Edit clientDefs entity file by following this path:
    PHP Code:
    custom/Espo/Custom/Resources/metadata/clientDefs/{Entity}.json 
    


    2. Use this script in clientDefs file just create/open:
    PHP Code:
    
    {
        "menu": {
            "detail": {
                "actions": [
                    "__APPEND__",
                    {
                        "label": "buttonName",
                        "labelTranslation": "Scope.labels.buttonName",
                        "name": "buttonName",
                        "action": "buttonName",
                        "hidden": false,
                        "acl": "read"
                    }
                ]
            }
        }
    }
    Dont forget to register your new label in l18n.



    3. Create/Edit custom detail view for your Entity by following the path as same as Option 1.1
    Use the script like create handler class right this link: https://docs.espocrm.com/development...#handler-class
    But must remember that you are extending entity detail view so that you must define your custom class for detail view, not for custom handler like this:

    Right define for extending:
    PHP Code:
    define('custom:views/{Entity}/detail', ['views/detail','views/modal','model'], function (Dep) 
    
    Last edited by trungtvmso; 07-18-2024, 07:53 AM.

    Comment

    • trungtvmso
      Member
      • Jun 2022
      • 70

      #3
      Noted: some other params like iconHtml, html, etc... we might use be like dropdown and buttons register but can not use handler param due to the button uses action function directly define in views/detail.

      I hope my sharing can help you guys could do anything helpful

      Comment

      • rabii
        Active Community Member
        • Jun 2016
        • 1250

        #4
        This is the recommended way to do it. https://docs.espocrm.com/development...ist-edit-views
        Rabii
        Web Dev

        Comment

        • yuri
          Member
          • Mar 2014
          • 8442

          #5
          Items by the actions key are no officially supported. Use 'dropdown' key instead.
          If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

          Comment


          • trungtvmso
            trungtvmso commented
            Editing a comment
            thank you for your reply, I've just relized that actions key is not having fully function as dropdown (not hide when buttons inside are all in hidden). But if I still want to use that one, can I customize and use it? it would not be effected to other part of view, right?

          • yuri
            yuri commented
            Editing a comment
            It's hard to tell. They were added in the very beginning and were never used or maintained since. So I would avoid using it.
        • esforim
          Active Community Member
          • Jan 2020
          • 2204

          #6
          Just want to say, it look like you are doing very neat thing trungtvmso

          Hopefully once you polished it or happy with it, you can share.

          Comment

          • trungtvmso
            Member
            • Jun 2022
            • 70

            #7
            Originally posted by espcrm
            Just want to say, it look like you are doing very neat thing trungtvmso

            Hopefully once you polished it or happy with it, you can share.
            Sure bro, I will share everything I've been learnt or found out when trying to customize my Espo. I'm planning to use this actions menu for a scenario that:

            if screen width >= 768px >>>>> all the buttons will be defined in buttons type.
            if screen width < 768px >>>>> all the buttons will be definded in this actions button instead of dropdown menu due to we are currently having one more dropdown menu at the left side (beside Edit button of every record view)

            Comment

            • Kharg
              Senior Member
              • Jun 2021
              • 410

              #8
              I was able to make it work in a rather hacky way.
              Yuri, please don't hate me
              Attached Files
              Last edited by Kharg; 08-07-2024, 11:03 PM.

              Comment

              Working...