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
And this is my handler
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?
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"
}
]
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;
},
});
});
Comment