From efaf1fab79d0d1d9f5a7a0e8786586522e308057 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Thu, 7 Apr 2022 12:44:53 +0300 Subject: [PATCH] calendar create enum fix --- .../crm/src/views/calendar/modals/edit.js | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/client/modules/crm/src/views/calendar/modals/edit.js b/client/modules/crm/src/views/calendar/modals/edit.js index c2c0b5c5e4..4444b1c251 100644 --- a/client/modules/crm/src/views/calendar/modals/edit.js +++ b/client/modules/crm/src/views/calendar/modals/edit.js @@ -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) {