EspoCRM – Open Source CRM Application
PHP calendarcontactscrmcrm-platformcrm-systemcustomer-portalcustomer-supportcustomizabledocumentsemail-marketingkanbanleadsopen-sourcephpplatformsales-automationsingle-page-applicationsupport
ref
Yuri Kuznetsovd39a732d1705
diff --git a/client/src/helpers/record-modal.js b/client/src/helpers/record-modal.jsindex a96f49a6d4..aea726c525 100644--- a/client/src/helpers/record-modal.js+++ b/client/src/helpers/record-modal.js@@ -70,6 +70,8 @@ class RecordModalHelper {* rootUrl?: string,* afterSave?: function(import('model').default, {bypassClose: boolean}),* afterDestroy?: function(import('model').default),+ * beforeRender?: function(import('views/modals/detail').default),+ * onClose?: function(),* }} params* @return {Promise<import('views/modals/detail').default>}*/@@ -122,6 +124,14 @@ class RecordModalHelper {modalView.listenToOnce(modalView, 'after:destroy', model => params.afterDestroy(model));}+ if (params.beforeRender) {+ params.beforeRender(modalView);+ }++ if (params.onClose) {+ view.listenToOnce(modalView, 'close', () => params.onClose());+ }+await modalView.render();Espo.Ui.notify();@@ -141,6 +151,8 @@ class RecordModalHelper {* noFullForm?: boolean,* returnUrl?: string,* afterSave?: function(import('model').default, {bypassClose: boolean}),+ * beforeRender?: function(import('views/modals/edit').default),+ * onClose?: function(),* returnDispatchParams?: {* controller: string,* action: string|null,@@ -186,6 +198,14 @@ class RecordModalHelper {});}+ if (params.beforeRender) {+ params.beforeRender(modalView);+ }++ if (params.onClose) {+ view.listenToOnce(modalView, 'close', () => params.onClose());+ }+await modalView.render();Espo.Ui.notify();@@ -205,6 +225,8 @@ class RecordModalHelper {* relate?: model:model~setRelateItem | model:model~setRelateItem[],* attributes?: Record.<string, *>,* afterSave?: function(import('model').default, {bypassClose: boolean}),+ * beforeRender?: function(import('views/modals/edit').default),+ * onClose?: function(),* focusForCreate?: boolean,* returnDispatchParams?: {* controller: string,@@ -239,8 +261,7 @@ class RecordModalHelper {Espo.Ui.notifyWait();const modalView = /** @type {import('views/modals/edit').default} */- await view.createView('modal', viewName, options)-+ await view.createView('modal', viewName, options);// @todo Revise.modalView.listenToOnce(modalView, 'remove', () => view.clearView('modal'));@@ -251,6 +272,14 @@ class RecordModalHelper {});}+ if (params.beforeRender) {+ params.beforeRender(modalView);+ }++ if (params.onClose) {+ view.listenToOnce(modalView, 'close', () => params.onClose());+ }+await modalView.render();Espo.Ui.notify();diff --git a/client/src/views/email/fields/from-address-varchar.js b/client/src/views/email/fields/from-address-varchar.jsindex 5eb96cf8b7..20a9301607 100644--- a/client/src/views/email/fields/from-address-varchar.js+++ b/client/src/views/email/fields/from-address-varchar.js@@ -399,22 +399,18 @@ class EmailFromAddressVarchar extends BaseFieldView {attributes.lastName = lastName;}- const viewName = this.getMetadata().get(`clientDefs.${scope}.modalViews.edit`) ||- 'views/modals/edit';-- this.createView('create', viewName, {- scope: scope,- attributes: attributes- }, view => {- view.render();+ const helper = new RecordModal();- this.listenTo(view, 'after:save', (model) => {+ helper.showCreate(this, {+ entityType: scope,+ attributes: attributes,+ afterSave: model => {const nameHash = Espo.Utils.clone(this.model.get('nameHash') || {});const typeHash = Espo.Utils.clone(this.model.get('typeHash') || {});const idHash = Espo.Utils.clone(this.model.get('idHash') || {});idHash[address] = model.id;- nameHash[address] = model.get('name');+ nameHash[address] = model.attributes.name;typeHash[address] = scope;this.idHash = idHash;@@ -424,17 +420,17 @@ class EmailFromAddressVarchar extends BaseFieldView {const attributes = {nameHash: nameHash,idHash: idHash,- typeHash: typeHash+ typeHash: typeHash,};setTimeout(() => {this.model.set(attributes);- if (this.model.get('icsContents')) {+ if (this.model.attributes.icsContents) {this.model.fetch();}}, 50);- });+ },});}diff --git a/client/src/views/record/kanban.js b/client/src/views/record/kanban.jsindex 2bbaf82331..45df63a013 100644--- a/client/src/views/record/kanban.js+++ b/client/src/views/record/kanban.js@@ -29,6 +29,7 @@/** @module views/record/kanban */import ListRecordView from 'views/record/list';+import RecordModal from 'helpers/record-modal';/*** A kanban record view.@@ -385,6 +386,7 @@ class KanbanRecordView extends ListRecordView {this._renderEmpty = false;if (this.hasView('modal') && this.getView('modal').isRendered()) {+ // @todo Find a way to not to re-render modals.return;}@@ -1271,9 +1273,6 @@ class KanbanRecordView extends ListRecordView {return;}- const viewName = this.getMetadata().get(`clientDefs.${this.scope}.modalViews.edit`) ||- 'views/modals/edit';-const getCreateAttributes = () => {if (this.getCreateAttributes) {return this.getCreateAttributes(group);@@ -1284,28 +1283,25 @@ class KanbanRecordView extends ListRecordView {const attributes = await getCreateAttributes();- const options = {- attributes: attributes,- scope: this.scope,- };-- const view = /** @type {module:views/modals/edit} */- await this.createView('quickCreate', viewName, options);-- view.getRecordView().setFieldReadOnly(this.statusField, true);+ const helper = new RecordModal();- this.listenToOnce(view, 'after:save', () => {- if (this.orderDisabled) {- this.collection.fetch({maxSize: this.collection.maxSize});+ await helper.showCreate(this, {+ attributes: attributes ,+ entityType: this.scope,+ afterSave: async model => {+ if (this.orderDisabled) {+ await this.collection.fetch({maxSize: this.collection.maxSize});- return;- }+ return;+ }- this.storeGroupOrder(group, view.model.id)- .then(() => this.collection.fetch({maxSize: this.collection.maxSize}));+ await this.storeGroupOrder(group, model.id)+ await this.collection.fetch({maxSize: this.collection.maxSize});+ },+ beforeRender: view => {+ view.getRecordView().setFieldReadOnly(this.statusField, true);+ },});-- await view.render();}/**diff --git a/client/src/views/record/list.js b/client/src/views/record/list.jsindex f74026cbf3..6d0bd5775c 100644--- a/client/src/views/record/list.js+++ b/client/src/views/record/list.js@@ -2063,6 +2063,7 @@ class ListRecordView extends View {this._renderEmpty = false;if (this.hasView('modal') && this.getView('modal').isRendered()) {+ // @todo Find a way to not to re-render modals.return;}