EspoCRM – Open Source CRM Application
PHP calendarcontactscrmcrm-platformcrm-systemcustomer-portalcustomer-supportcustomizabledocumentsemail-marketingkanbanleadsopen-sourcephpplatformsales-automationsingle-page-applicationsupport
collapsable edit modal
Yuri Kuznetsov5cdcb8bd742a
diff --git a/application/Espo/Resources/i18n/en_US/Global.json b/application/Espo/Resources/i18n/en_US/Global.jsonindex a1d2496662..66c35994c5 100644--- a/application/Espo/Resources/i18n/en_US/Global.json+++ b/application/Espo/Resources/i18n/en_US/Global.json@@ -434,7 +434,8 @@"selectAtLeastOneRecord": "Select at least one record","duplicateConflict": "A record already exists.","cannotRemoveCategoryWithChildCategory": "Cannot remove a category that has a child category.",- "cannotRemoveNotEmptyCategory": "Cannot remove a non-empty category."+ "cannotRemoveNotEmptyCategory": "Cannot remove a non-empty category.",+ "sameRecordIsAlreadyBeingEdited": "The record is already being edited."},"boolFilters": {"onlyMy": "Only My",diff --git a/client/src/helpers/record-modal.js b/client/src/helpers/record-modal.jsindex 1b177de3e9..134a58977a 100644--- a/client/src/helpers/record-modal.js+++ b/client/src/helpers/record-modal.js@@ -30,6 +30,9 @@ import {inject} from 'di';import Metadata from 'metadata';import AclManager from 'acl-manager';import Router from 'router';+import ModalBarProvider from 'helpers/site/modal-bar-provider';+import EditModalView from 'views/modals/edit';+import Language from 'language';/*** A record-modal helper. Use to render the quick view and quick edit modals.@@ -57,6 +60,20 @@ class RecordModalHelper {@inject(Router)router+ /**+ * @private+ * @type {Language}+ */+ @inject(Language)+ language++ /**+ * @private+ * @type {ModalBarProvider}+ */+ @inject(ModalBarProvider)+ modalBarProvider+/*** Show the 'detail' modal.*@@ -178,6 +195,25 @@ class RecordModalHelper {const entityType = params.entityType;const model = params.model;+ if (this.modalBarProvider.get()) {+ const barView = this.modalBarProvider.get();++ const foundModalView = barView.getModalViewList().find(view => {+ console.log(view);++ return view instanceof EditModalView &&+ view.id === id && view.entityType === entityType;+ });++ if (foundModalView) {+ const message = this.language.translate('sameRecordIsAlreadyBeingEdited', 'messages');++ Espo.Ui.warning(message);++ throw new Error();+ }+ }+const viewName = this.metadata.get(`clientDefs.${entityType}.modalViews.edit`) ||'views/modals/edit';diff --git a/client/src/views/collapsed-modal-bar.js b/client/src/views/collapsed-modal-bar.jsindex 3be2201b8c..143630b10f 100644--- a/client/src/views/collapsed-modal-bar.js+++ b/client/src/views/collapsed-modal-bar.js@@ -44,6 +44,18 @@ class CollapsedModalBarView extends View {*/maxNumberToDisplay = 3+ /**+ * @private+ * @type {number[]}+ */+ numberList++ /**+ * @private+ * @type {number}+ */+ lastNumber+data() {return {dataList: this.getDataList(),@@ -103,7 +115,7 @@ class CollapsedModalBarView extends View {let duplicateNumber = 0;for (const number of this.numberList) {- const view = this.getModalViewByNumber(number);+ const view = this.getCollapsedModalViewByNumber(number);if (!view) {continue;@@ -123,14 +135,24 @@ class CollapsedModalBarView extends View {/*** @param {number} number- * @return {import('views/modal').default|null}+ * @return {import('views/collapsed-modal').default|null}*/- getModalViewByNumber(number) {+ getCollapsedModalViewByNumber(number) {const key = this.composeKey(number);return this.getView(key);}+ /**+ * @type {import('views/modal').default[]}+ */+ getModalViewList() {+ return this.numberList+ .map(number => this.getCollapsedModalViewByNumber(number))+ .filter(it => it)+ .map(it => it.modalView);+ }+/*** @param {import('views/modal').default} modalView* @param {{title: string}} options@@ -145,6 +167,7 @@ class CollapsedModalBarView extends View {this.lastNumber++;const view = new CollapsedModalView({+ modalView: modalView,title: options.title,duplicateNumber: this.calculateDuplicateNumber(options.title),onClose: () => this.removeModalView(number),diff --git a/client/src/views/collapsed-modal.js b/client/src/views/collapsed-modal.jsindex 84d9f51ffa..c3cd8e446e 100644--- a/client/src/views/collapsed-modal.js+++ b/client/src/views/collapsed-modal.js@@ -57,6 +57,7 @@ class CollapsedModalView extends View {/*** @param {{+ * modalView: import('views/modal').default,* onClose: function(),* onExpand: function(),* duplicateNumber?: number|null,@@ -67,6 +68,8 @@ class CollapsedModalView extends View {super(options);this.options = options;++ this.modalView = options.modalView;}data() {diff --git a/client/src/views/modals/edit.js b/client/src/views/modals/edit.jsindex 7ed2099882..51613edace 100644--- a/client/src/views/modals/edit.js+++ b/client/src/views/modals/edit.js@@ -52,6 +52,8 @@ class EditModalView extends ModalView {/** @protected */bottomDisabled = false+ isCollapsable = true+/*** @private* @type {boolean}