Skip to content

Instantly share code, notes, and snippets.

@AjayKumar01
Created April 9, 2016 07:15
Show Gist options
  • Save AjayKumar01/91cef1aea4f2da80c70632eb7e7dda3c to your computer and use it in GitHub Desktop.
Save AjayKumar01/91cef1aea4f2da80c70632eb7e7dda3c to your computer and use it in GitHub Desktop.
Disabling edit button and un link button action based on parent module field value.
({
/* Disabling edit button and un link button action based on parent module field value.
* Ajay Kumar
* Path: sugar/custom/modules/Leads/clients/base/views/subpanel-list/subpanel-list.js
*/
extendsFrom: 'SubpanelListView',
initialize: function(options) {
this._super('initialize', [options]);
this.on('render', this._disableActions, this);
},
_disableActions: function() {
var industryValue = this.context.parent.get('model').get("industry");
var parentModule = this.context.parent.get('module');
if (!_.isEqual(industryValue, 'Construction') && _.isEqual(parentModule, "Accounts")) {
_.each(this.meta.rowactions.actions, function(action) {
if (!_.isEqual(action['icon'], "fa-eye")) { // for preview button
delete action['event'];
action['css_class'] = 'disabled btn';
}
});
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment