calendar create enum fix

This commit is contained in:
Yuri Kuznetsov
2022-04-07 12:44:53 +03:00
parent e6beedbffd
commit efaf1fab79
@@ -60,6 +60,8 @@ define('crm:views/calendar/modals/edit', 'views/modals/edit', function (Dep) {
attributes = _.extend(attributes, this.getView('edit').model.toJSON());
this.filterAttributesForEntityType(attributes, scope);
model.set(attributes);
this.model = model;
@@ -74,6 +76,25 @@ define('crm:views/calendar/modals/edit', 'views/modals/edit', function (Dep) {
},
},
filterAttributesForEntityType: function (attributes, entityType) {
this.getHelper()
.fieldManager
.getEntityTypeFieldList(entityType, {type: 'enum'})
.forEach(field => {
if (!(field in attributes)) {
return;
}
let options = this.getMetadata().get(['entityDefs', entityType, 'fields', field, 'options']) || [];
let value = attributes[field];
if (!~options.indexOf(value)) {
delete attributes[field];
}
});
},
createRecordView: function (model, callback) {
if (!this.id && !this.dateIsChanged) {
if (this.options.dateStart && this.options.dateEnd) {