Skip to content

EspoCRM – Open Source CRM Application

ref

Yuri Kuznetsov6405ab2b17a5
diff --git a/client/modules/crm/src/views/record/panels/activities.js b/client/modules/crm/src/views/record/panels/activities.js
index 199fde163f..fd97555497 100644
--- a/client/modules/crm/src/views/record/panels/activities.js
+++ b/client/modules/crm/src/views/record/panels/activities.js
@@ -28,6 +28,7 @@
import RelationshipPanelView from 'views/record/panels/relationship';
import MultiCollection from 'multi-collection';
+import RecordModal from 'helpers/record-modal';
class ActivitiesPanelView extends RelationshipPanelView {
@@ -446,6 +447,10 @@ class ActivitiesPanelView extends RelationshipPanelView {
this.actionCreateActivity(data);
}
+ /**
+ * @protected
+ * @param {Record} data
+ */
actionCreateActivity(data) {
const link = data.link;
let foreignLink;
@@ -458,33 +463,22 @@ class ActivitiesPanelView extends RelationshipPanelView {
scope = data.scope;
}
- const o = {
- scope: scope
- };
-
- if (link) {
- o.relate = {
- model: this.model,
- link: foreignLink
- };
- }
-
Espo.Ui.notifyWait();
- const viewName = this.getMetadata().get('clientDefs.' + scope + '.modalViews.edit') ||
- 'views/modals/edit';
-
this.getCreateActivityAttributes(scope, data, attributes => {
- o.attributes = attributes;
-
- this.createView('quickCreate', viewName, o, (view) => {
- view.render();
- view.notify(false);
-
- this.listenToOnce(view, 'after:save', () => {
+ const helper = new RecordModal();
+
+ helper.showCreate(this, {
+ entityType: scope,
+ relate: link ? {
+ model: this.model,
+ link: foreignLink
+ } : undefined,
+ attributes: attributes,
+ afterSave: () => {
this.model.trigger(`update-related:${link}`);
this.model.trigger('after:relate');
- });
+ },
});
});
}
diff --git a/client/src/helpers/record-modal.js b/client/src/helpers/record-modal.js
index ef03725f67..a96f49a6d4 100644
--- a/client/src/helpers/record-modal.js
+++ b/client/src/helpers/record-modal.js
@@ -205,6 +205,7 @@ class RecordModalHelper {
* relate?: model:model~setRelateItem | model:model~setRelateItem[],
* attributes?: Record.<string, *>,
* afterSave?: function(import('model').default, {bypassClose: boolean}),
+ * focusForCreate?: boolean,
* returnDispatchParams?: {
* controller: string,
* action: string|null,
@@ -228,6 +229,7 @@ class RecordModalHelper {
returnDispatchParams: params.returnDispatchParams,
relate: params.relate,
attributes: params.attributes,
+ focusForCreate: params.focusForCreate,
};
if (params.rootUrl) {
diff --git a/client/src/views/list.js b/client/src/views/list.js
index 9a0f15a33d..972c39c3c8 100644
--- a/client/src/views/list.js
+++ b/client/src/views/list.js
@@ -30,6 +30,7 @@
import MainView from 'views/main';
import SearchManager from 'search-manager';
+import RecordModal from 'helpers/record-modal';
/**
* A list view.
@@ -799,24 +800,6 @@ class ListView extends MainView {
const attributes = this.getCreateAttributes() || {};
- Espo.Ui.notifyWait();
-
- const viewName = this.getMetadata().get('clientDefs.' + this.scope + '.modalViews.edit') ||
- 'views/modals/edit';
-
- let options = {
- scope: this.scope,
- attributes: attributes,
- };
-
- if (this.keepCurrentRootUrl) {
- options.rootUrl = this.getRouter().getCurrentUrl();
- }
-
- if (data.focusForCreate) {
- options.focusForCreate = true;
- }
-
const returnDispatchParams = {
controller: this.scope,
action: null,
@@ -825,20 +808,18 @@ class ListView extends MainView {
this.prepareCreateReturnDispatchParams(returnDispatchParams);
- options = {
- ...options,
+ const helper = new RecordModal();
+
+ helper.showCreate(this, {
+ entityType: this.scope,
+ attributes: attributes,
+ rootUrl: this.keepCurrentRootUrl ? this.getRouter().getCurrentUrl() : undefined,
+ focusForCreate: data.focusForCreate,
returnUrl: this.getRouter().getCurrentUrl(),
returnDispatchParams: returnDispatchParams,
- };
-
- // noinspection JSValidateTypes
- return this.createView('quickCreate', viewName, options, (view) => {
- view.render();
- view.notify(false);
-
- this.listenToOnce(view, 'after:save', () => {
- this.collection.fetch();
- });
+ afterSave: () => {
+ this.collection.fetch()
+ },
});
}