From 1bcb8349deb2e45fc83a74a396299dd8dec79455 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Fri, 21 Feb 2025 16:22:06 +0200 Subject: [PATCH] ref --- client/src/views/fields/link-multiple.js | 31 +++++++++--------------- client/src/views/fields/link.js | 31 +++++++++--------------- 2 files changed, 22 insertions(+), 40 deletions(-) diff --git a/client/src/views/fields/link-multiple.js b/client/src/views/fields/link-multiple.js index 2bdbc4d98d..8ff91511f1 100644 --- a/client/src/views/fields/link-multiple.js +++ b/client/src/views/fields/link-multiple.js @@ -1221,28 +1221,19 @@ class LinkMultipleFieldView extends BaseFieldView { }); } - actionCreateLink() { - const viewName = this.getMetadata().get(['clientDefs', this.foreignScope, 'modalViews', 'edit']) || - 'views/modals/edit'; + /** + * @protected + */ + async actionCreateLink() { + const helper = new RecordModal(); - Espo.Ui.notifyWait(); + const attributes = await this.getCreateAttributesProvider()(); - this.getCreateAttributesProvider()().then(attributes => { - this.createView('dialog', viewName, { - scope: this.foreignScope, - fullFormDisabled: true, - attributes: attributes, - }, view => { - view.render() - .then(() => Espo.Ui.notify(false)); - - this.listenToOnce(view, 'after:save', model => { - view.close(); - this.clearView('dialog'); - - this.select([model]); - }); - }); + await helper.showCreate(this, { + entityType: this.foreignScope, + fullFormDisabled: true, + attributes: attributes, + afterSave: model => this.select([model]), }); } diff --git a/client/src/views/fields/link.js b/client/src/views/fields/link.js index 3db0b96d1b..8f57e7fa60 100644 --- a/client/src/views/fields/link.js +++ b/client/src/views/fields/link.js @@ -1333,28 +1333,19 @@ class LinkFieldView extends BaseFieldView { return undefined; } - actionCreateLink() { - const viewName = this.getMetadata().get(['clientDefs', this.foreignScope, 'modalViews', 'edit']) || - 'views/modals/edit'; + /** + * @protected + */ + async actionCreateLink() { + const helper = new RecordModal(); - Espo.Ui.notifyWait(); + const attributes = await this.getCreateAttributesProvider()(); - this.getCreateAttributesProvider()().then(attributes => { - this.createView('dialog', viewName, { - scope: this.foreignScope, - fullFormDisabled: true, - attributes: attributes, - }, view => { - view.render() - .then(() => Espo.Ui.notify(false)); - - this.listenToOnce(view, 'after:save', model => { - view.close(); - this.clearView('dialog'); - - this.select(model); - }); - }); + await helper.showCreate(this, { + entityType: this.foreignScope, + fullFormDisabled: true, + attributes: attributes, + afterSave: model => this.select(model), }); }