Hide "Remove" button from a list view

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ThomasB
    Senior Member
    • Mar 2022
    • 163

    Hide "Remove" button from a list view

    Hi,

    I need to hide the remove button from a list view. (Espo crm 7.5.4)

    I have a custom entity called IncidentsReportings which holds records of incidents (incident 1, incident 2, etc). Each incident report can be linked (One-to-Many relation) to accounts to see which customers were affected by the incidents.

    The accounts are now listed at the bottom panel and I have options to "View, Edit, Unlist and Remove" (small arrow down button of each entry) and "Create, View list and Select"

    I want at least to hide the "Remove" button, because this actually deletes an account entry when a user maybe only wants to unlist an entry. Mistakes can happen easily.

    I tried to follow this guide: https://forum.espocrm.com/forum/deve...based-on-value

    but had to change it a bit because I think there were mistakes in the example. Missing Brackets and a comma at the end of rowActonsView
    This is the my code now.

    1) client/custom/src/views/record/list.js

    Code:
     define('custom:views/record/list', 'views/record/list', function (Dep) {
    
        return Dep.extend({
    
            rowActionsView: 'views/record/row-actions/view-and-edit'
    
        });
    
    });


    2) custom/Espo/Custom/Resources/metadata/clientDefs/IncidentReporting.json

    Code:
    {
        ...
         "recordViews": {
            "list" : "custom:views/record/list"
        }
    
    }​

    This finally worked but only on the list with the records of all incidents. But I need to remove the button from the list of accounts inside each individual incident report.

    What to I need to do? Add a custom view on field level: https://docs.espocrm.com/development...s/#field-views ?


    So code snippet 2 would look like this?


    custom/Espo/Custom/Resources/metadata/entityDefs/IncidentReporting.json

    Code:
    {
        "fields": {
            "accounts": {
                "view": "custom:views/incidentreporting/fields/accounts"
            }
        }
    }
    ​
    And what about snippet 1?

    client/custom/src/views/account/incidentreporting/accounts.js​ ?

  • rabii
    Active Community Member
    • Jun 2016
    • 1250

    #2
    i see that you are using latest version, there is no need to create all these custom files, just go to your entity clientDefs of your incidentsReprts and go the relationships section, you will find the relationships between accounts and incidentsReports then you can just define the "rowActionsView" like below:

    PHP Code:
    "rowActionsView": "views/record/row-actions/relationship-no-remove" 
    
    This row actions allows to view - edit - unlink but not remove. this should do the trick without the need to create more files.
    Rabii
    Web Dev

    Comment

    • ThomasB
      Senior Member
      • Mar 2022
      • 163

      #3
      Thanks,

      First I thought it would work. but I had delete permissions removed. I added permissons now and the remove button is still there.

      Guess I added the modifications at the wrong place.

      I edited: /custom/Espo/Custom/Resources/metadata/entityDefs/IncidentReporting.json

      Code:
      ...
      "links": {
              "createdBy": {
                  "type": "belongsTo",
                  "entity": "User"
              },
              "modifiedBy": {
                  "type": "belongsTo",
                  "entity": "User"
              },
              "assignedUser": {
                  "type": "belongsTo",
                  "entity": "User"
              },
              "teams": {
                  "type": "hasMany",
                  "entity": "Team",
                  "relationName": "EntityTeam",
                  "layoutRelationshipsDisabled": true
              },
              "accounts": {
                  "type": "hasMany",
                  "foreign": "incidentReporting",
                  "entity": "Account",
                  "audited": false,
                  "isCustom": true,
                  "rowActionsView": "views/record/row-actions/relationship-no-remove"
              }
          },
      I assume that's what you meant?
      Last edited by ThomasB; 06-26-2023, 03:19 PM.

      Comment


      • rabii
        rabii commented
        Editing a comment
        no not entityDefs i said you should check the relationships in clientDefs
    • rabii
      Active Community Member
      • Jun 2016
      • 1250

      #4
      you should edit

      custom\Espo\Custom\Resources\metadata\clientDefs\I ncidentReporting.json

      You will find relationships which defines custom relationships you have added to the system and then just add the rowActionsView to the correct relationship i assume it should called accounts and then just clear cach and rebuild the system and it should work.

      make sure to revert what you have changed in all previous places including the entityDefs
      Rabii
      Web Dev

      Comment

      • ThomasB
        Senior Member
        • Mar 2022
        • 163

        #5
        Hm, in customs? Because in entityDefs I see no relations.

        custom/Espo/Custom/Resources/metadata/clientDefs/IncidentReporting.json

        Code:
        {
            "controller": "controllers/record",
            "boolFilterList": [
                "onlyMy"
            ],
            "iconClass": "fas fa-exclamation-triangle",
            "kanbanViewMode": false,
            "color": "#fa0059"
        }

        Comment

        • rabii
          Active Community Member
          • Jun 2016
          • 1250

          #6
          if it doesn't exist just add it like below: make sure that you provide the right name of the relationship i assumed it is accounts (also if you wish to disable selecting you can add it as below) otherwise just make the select to true.

          PHP Code:
          "relationshipPanels": {
                  "accounts": {
                      "rowActionsView": "views/record/row-actions/relationship-no-remove",
                      "select": false
                  }
              },
          Rabii
          Web Dev

          Comment


          • zerosix
            zerosix commented
            Editing a comment
            Hello Rabii, this code work fine for "rowActionsView": "views/record/row-actions/relationship-no-remove" or "rowActionsView": "views/record/row-actions/relationship-no-unlink" , how can we apply both of them? thanks in advance

          • rabii
            rabii commented
            Editing a comment
            you can try views/record/row-actions/relationship-view-and-edit this will allow only view and edit (No remove and No unlink)

          • zerosix
            zerosix commented
            Editing a comment
            Yes, It worked ? ? ? ? ? ?
        • ThomasB
          Senior Member
          • Mar 2022
          • 163

          #7
          Yes, that worked! Thanks a lot!

          Comment

          • rabii
            Active Community Member
            • Jun 2016
            • 1250

            #8
            you are welcome read this if you want to add more customisation to your relationship panels https://docs.espocrm.com/development...tionshippanels
            Rabii
            Web Dev

            Comment


            • esforim
              esforim commented
              Editing a comment
              Interesting, didn't notice this. I'll play with this setting:

              "selectPrimaryFilterName": "filterName",
          Working...