Hi,
I need to synchronize views based on options selected in drop down(enum field) in one of the custom module, once the record is saved.
Scenario:
1. If approved is selected in the dropdown, edit/ remove options will be disabled for non-admin users(current code as below for custom/model.js).
isEditable: function () {
if (!this.isNew()) {
if (!this.getUser().isAdmin()){
if (this.get('registrationStatus') == 'Approved') {
return false;
}
}
}
return true;
},
isRemovable: function () {
if (!this.isNew()) {
if (!this.getUser().isAdmin()){
if (this.get('registrationStatus') == 'Approved') {
return false;
}
}
}
return true;
}
2. if rejected is selected in the dropdown, then there will be only few options pushed into the dropdown.(current code as below for custom/src/views/custom_entity/customfield.js)
setup: function () {
if (this.model.get('registrationStatus') == 'Rejected') {
this.params.options = ["Pending","Incomplete","On Going","Rejected"];
this.params.translation = 'Registration.options.registrationStatus';
}
Dep.prototype.setup.call(this);
}
For both the cases, the views are not getting synchronized/ updated immediately upon document save, and a manual refresh would be required. Any guidance or a code snippet would be helpful.
I need to synchronize views based on options selected in drop down(enum field) in one of the custom module, once the record is saved.
Scenario:
1. If approved is selected in the dropdown, edit/ remove options will be disabled for non-admin users(current code as below for custom/model.js).
isEditable: function () {
if (!this.isNew()) {
if (!this.getUser().isAdmin()){
if (this.get('registrationStatus') == 'Approved') {
return false;
}
}
}
return true;
},
isRemovable: function () {
if (!this.isNew()) {
if (!this.getUser().isAdmin()){
if (this.get('registrationStatus') == 'Approved') {
return false;
}
}
}
return true;
}
2. if rejected is selected in the dropdown, then there will be only few options pushed into the dropdown.(current code as below for custom/src/views/custom_entity/customfield.js)
setup: function () {
if (this.model.get('registrationStatus') == 'Rejected') {
this.params.options = ["Pending","Incomplete","On Going","Rejected"];
this.params.translation = 'Registration.options.registrationStatus';
}
Dep.prototype.setup.call(this);
}
For both the cases, the views are not getting synchronized/ updated immediately upon document save, and a manual refresh would be required. Any guidance or a code snippet would be helpful.
Comment