Skip to content

EspoCRM – Open Source CRM Application

ref

Yuri Kuznetsovde93e83abe1c
diff --git a/client/src/views/modals/select-records.js b/client/src/views/modals/select-records.js
index a78ebd57cc..71f8679d46 100644
--- a/client/src/views/modals/select-records.js
+++ b/client/src/views/modals/select-records.js
@@ -30,6 +30,7 @@
import ModalView from 'views/modal';
import SearchManager from 'search-manager';
+import RecordModal from 'helpers/record-modal';
/**
* A select-records modal.
@@ -119,6 +120,9 @@ class SelectRecordsModalView extends ModalView {
/** @private */
this.onCreate = options.onCreate;
}
+
+ /** @private */
+ this.createAttributesProvider = options.createAttributesProvider;
}
data() {
@@ -393,7 +397,7 @@ class SelectRecordsModalView extends ModalView {
this.wait(promise);
}
- create() {
+ async create() {
if (this.onCreate) {
this.onCreate();
@@ -407,46 +411,36 @@ class SelectRecordsModalView extends ModalView {
return;
}
- Espo.Ui.notifyWait();
-
- const viewName = this.getMetadata()
- .get(['clientDefs', this.scope, 'modalViews', 'edit']) ||
- 'views/modals/edit';
+ let attributes;
- new Promise(resolve => {
- if (this.options.createAttributesProvider) {
- this.options.createAttributesProvider().then(attributes => {
- resolve(attributes)
- });
-
- return;
- }
-
- resolve(this.options.createAttributes || {});
- })
- .then(attributes => {
- this.createView('quickCreate', viewName, {
- scope: this.scope,
- fullFormDisabled: true,
- attributes: attributes,
- }, view => {
- view.render()
- .then(() => Espo.Ui.notify(false));
+ if (this.options.createAttributesProvider) {
+ attributes = await this.createAttributesProvider();
+ } else {
+ attributes = this.options.createAttributes || {};
+ }
- this.listenToOnce(view, 'leave', () => {
- view.close();
- this.close();
- });
+ const helper = new RecordModal();
- this.listenToOnce(view, 'after:save', (model) => {
- view.close();
+ await helper.showCreate(this, {
+ entityType: this.entityType,
+ fullFormDisabled: true,
+ attributes: attributes,
+ afterSave: model => {
+ this.trigger('select', model);
- this.trigger('select', model);
+ if (this.onSelect) {
+ this.onSelect([model]);
+ }
- setTimeout(() => this.close(), 10);
- });
+ setTimeout(() => this.close(), 10);
+ },
+ beforeRender: view => {
+ this.listenToOnce(view, 'leave', () => {
+ view.close();
+ this.close();
});
- });
+ },
+ });
}
actionSelect() {