Hi all,
I'm trying to createView to Edit Lead Record with Field condition by role. I'm looking for the way to set Field to not readonly after click my custom button to createView Edit But It doesn't work anyway. Can you pls help me to do it.
This is my custom code to extend detail view of Lead Entity
ALWAYS RECEIVE ALERT THAT THIS IS NOT A FUNCTION
I'm trying to createView to Edit Lead Record with Field condition by role. I'm looking for the way to set Field to not readonly after click my custom button to createView Edit But It doesn't work anyway. Can you pls help me to do it.
This is my custom code to extend detail view of Lead Entity
PHP Code:
define('custom:views/lead/detail', ['views/detail','moment'], function (Dep, Moment) {
return Dep.extend({
setup: function () {
Dep.prototype.setup.call(this);
// console.log(this);
this.addMenuItem('buttons',{
name: 'superEdit',
text: this.translate('Edit', 'labels' , 'Lead'),
acl: 'edit',
hidden: true,
style: 'success',
action: 'superEdit',
});
/* Connected */
this.hideHeaderActionItem('convert');
this.hideHeaderActionItem('unfollow');
this.hideHeaderActionItem('follow');
this.listenTo(this.model, 'sync' ,() => this.hideHeaderActionItem('follow'));
this.listenTo(this.model, 'sync' ,() => this.hideHeaderActionItem('unfollow'));
this.controlSuperEditButton();
this.listenTo(this.model, 'sync',() => this.controlSuperEditButton());
},
/* Action template */
controlSuperEditButton: function () {
let dateEnd = this.model.get('editEndedAt');
let checkDate = this.getDateTime()
.toMoment(dateEnd)
.isBefore(moment.now());
if (checkDate) {
this.updateMenuItem('superEdit', {
hidden: false,
});
}
},
actionSuperEdit: function () {
var Lead = this.getMetadata().get('clientDefs.Lead.modelViews.edit') || 'views/modals/edit';
this.createView('LeadSuperEdit', Lead, {
scope: 'Lead',
fullFormDisabled: true,
headerText: this.translate('Edit', 'labels' , 'Lead') + ' → '+ this.model.get('name'),
backdrop: false,
id: this.model.get('id'),
},(view) => {
view.render(() => {
console.log("View Setup", view);
view.setFieldNotReadOnly('source',true); // ALWAYS RECEIVE ALERT THAT THIS IS NOT A FUNCTION
});
view.notify(false);
view.once('after:save', models => {
view.close();
this.model.fetch();
});
});
},
});
});
ALWAYS RECEIVE ALERT THAT THIS IS NOT A FUNCTION
PHP Code:
view.render(() => {
console.log("View Setup", view);
view.setFieldNotReadOnly('source',true);
});
Comment