From dc527c2cf697663a76d4a416b3bf90b67735a7bc Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Fri, 21 Feb 2025 16:09:03 +0200 Subject: [PATCH] ref --- client/src/views/site/navbar/quick-create.js | 32 ++++++++++++++++---- schema/metadata/clientDefs.json | 4 +++ 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/client/src/views/site/navbar/quick-create.js b/client/src/views/site/navbar/quick-create.js index 20a8ab6c1e..2a10843e32 100644 --- a/client/src/views/site/navbar/quick-create.js +++ b/client/src/views/site/navbar/quick-create.js @@ -27,6 +27,7 @@ ************************************************************************/ import View from 'view'; +import RecordModal from 'helpers/record-modal'; class QuickCreateNavbarView extends View { @@ -90,15 +91,34 @@ class QuickCreateNavbarView extends View { return this.list.length > 0; } - processCreate(scope) { + /** + * @private + * @param {string} scope + */ + async processCreate(scope) { Espo.Ui.notifyWait(); - const type = this.getMetadata().get(['clientDefs', scope, 'quickCreateModalType']) || 'edit'; - const viewName = this.getMetadata().get(['clientDefs', scope, 'modalViews', type]) || 'views/modals/edit'; + const type = this.getMetadata().get(`clientDefs.${scope}.quickCreateModalType`); - this.createView('dialog', viewName , {scope: scope}) - .then(view => view.render()) - .then(() => Espo.Ui.notify(false)); + if (type) { + const viewName = this.getMetadata().get(`clientDefs.${scope}.modalViews.${type}`); + + if (viewName) { + const view = await this.createView('modal', viewName , {scope: scope}); + + await view.render(); + + Espo.Ui.notify(); + + return; + } + } + + const helper = new RecordModal(); + + await helper.showCreate(this, { + entityType: scope, + }); } } diff --git a/schema/metadata/clientDefs.json b/schema/metadata/clientDefs.json index 4c1a4f1c16..2d63defef3 100644 --- a/schema/metadata/clientDefs.json +++ b/schema/metadata/clientDefs.json @@ -74,6 +74,10 @@ "type": "string" } }, + "quickCreateModalType": { + "type": "string", + "description": "A modal view type to be used for quick create." + }, "listViewModeList": { "type": "array", "items": {