Announcement

Collapse
No announcement yet.

clientDefs checkVisibilityFunction is not working properly

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

  • clientDefs checkVisibilityFunction is not working properly

    Hi! I'm trying show / hide my button in dropdown menu. But I have problems with visibility update in real-time.
    This is piece of my clientDefs of task entity
    PHP Code:
    "detailActionList": [
        
    "__APPEND__",
        {
            
    "label""ReAssignExecutor",
            
    "name""reassignExecutorButton",
            
    "data": {
                
    "handler""custom:handlers/buttons/reassign-executor-button-handler"
            
    },
            
    "checkVisibilityFunction""controlReassignExecutorButtonVisibility"
        
    }

    And this is my handler
    PHP Code:
    define('custom:handlers/buttons/reassign-executor-button-handler', ['action-handler'], function (Dep) {

        return 
    Dep.extend({

            
    actionReassignExecutorButton: function () {
                
    //some action
            
    },

            
    controlReassignExecutorButtonVisibility: function () {
                const 
    user this.view.getUser();
                
    let result this.view.model.get('assignedUserId') != null
                                  
    && (this.view.model.get('status') === 'New' || this.view.model.get('status') === 'Assigned executor')
                                  && (
                                         (
    user.get('isSupervisor') && user.get('teamsIds').includes(this.view.model.get('primaryTeamId')))
                                          || 
    user.get('type') === "admin"
                
    );
                
    console.log(result);
                return 
    result;
            },
        });
    });
    ​ 
    The problem is that when view is rendered, handler is doing its job, but when model is changed, and with my logic button visibility should change, actually it doesn't. For testing purpose, I'm outputing result to console, and see that conditions work good, when should be true it returns true and vise versa, also after model change method is called, but button visibility is not being changed at this time. To take affect, I need to reload page manually. What am I doing wrong?

  • #2
    lol,
    A new parameter checkVisibilityFunction. A handler function that checks whether the action is available. Should return a bool value. No need to use an initFunction method that hides/shows items. { ...


    i see : yurikuzn added this to the Version 8.1.0 milestone 3 weeks ago

    Have you 8.1.0 version ?

    But certainly, you are ready for the next release

    Comment


    • #3
      I found this parameter at https://docs.espocrm.com/development.../#definition_1
      As of v7.2 it's possible to define a checkVisibilityFunction parameter. The values should be a handler method name that returns a boolean value. The method determines whether the action is visible. It will be called every time the record is synced with the backend and will hide or show the action depending on a value returned by the method. The initFunction is not needed in this case.​
      P.S. I forgot to edmit I'm using the latest version of EspoCRM (8.0.5 for the time of writing)
      Last edited by a.slyzhko; 11-28-2023, 07:07 AM.

      Comment


      • #4
        I can only say that on the master branch we now utilize this logic of the Case entity type and it works fine.

        Comment

        Working...
        X