Skip to content

EspoCRM – Open Source CRM Application

TS fix

Yurii1c0f9aab85e7
diff --git a/client/src/helpers/mass-action.js b/client/src/helpers/mass-action.js
index f04f2e529b..8574050451 100644
--- a/client/src/helpers/mass-action.js
+++ b/client/src/helpers/mass-action.js
@@ -54,15 +54,34 @@ class MassActionHelper {
* A view.
*
* @private
- * @type {import('view').default & {scope?: string, entityType?: string}}
+ * @type {import('view').default}}
*/
view
/**
- * @param {import('view').default & {scope?: string, entityType?: string}} view A view.
+ * @private
+ * @type {string}
+ */
+ entityType
+
+ /**
+ * @param {import('view').default} view A view.
+ * @param {{entityType?: string}} [options] Options.
*/
- constructor(view) {
+ constructor(view, options = {}) {
this.view = view;
+
+ let entityType = options.entityType;
+
+ if (!entityType) {
+ if ('entityType' in view) {
+ entityType = view.entityType;
+ } else if ('scope' in view) {
+ entityType = view.scope;
+ }
+ }
+
+ this.entityType = entityType;
}
/**
@@ -98,28 +117,24 @@ class MassActionHelper {
process(id, action) {
Ui.notify();
- return new Promise(resolve => {
- const entityType = this.view.scope || this.view.entityType;
+ return new Promise(async resolve => {
+ const view = await this.view.createView('dialog', 'views/modals/mass-action', {
+ id: id,
+ action: action,
+ scope: this.entityType,
+ })
- this.view
- .createView('dialog', 'views/modals/mass-action', {
- id: id,
- action: action,
- scope: entityType,
- })
- .then(view => {
- view.render();
+ view.render().then(() => {});
- resolve(view);
+ resolve(view);
- this.view.listenToOnce(view, 'success', data => {
- resolve(data);
+ this.view.listenToOnce(view, 'success', data => {
+ resolve(data);
- this.view.listenToOnce(view, 'close', () => {
- view.trigger('close:success', data);
- });
- });
+ this.view.listenToOnce(view, 'close', () => {
+ view.trigger('close:success', data);
});
+ });
});
}
}
diff --git a/client/src/views/record/list-base.ts b/client/src/views/record/list-base.ts
index 757fe08c6b..24e14863db 100644
--- a/client/src/views/record/list-base.ts
+++ b/client/src/views/record/list-base.ts
@@ -1199,7 +1199,7 @@ abstract class ListBaseRecordView<
return where;
}
- private getMassActionSelectionPostData(): Record<string, any> {
+ getMassActionSelectionPostData(): Record<string, any> {
const data = {} as any;
if (this.allResultIsChecked) {
@@ -1288,7 +1288,11 @@ abstract class ListBaseRecordView<
Ui.notifyWait();
- const helper = new MassActionHelper(this);
+ if (!this.entityType) {
+ throw new Error("No entity type.");
+ }
+
+ const helper = new MassActionHelper(this, {entityType: this.entityType});
const params = this.getMassActionSelectionPostData();
const idle = !!params.searchParams && helper.checkIsIdle(this.collection.total);
@@ -1653,7 +1657,8 @@ abstract class ListBaseRecordView<
Ui.success(this.translate('Unlinked'));
- this.collection.fetch();
+ this.collection.fetch().then(() => {});
+
(this.model ?? this.collection.parentModel)?.trigger('after:unrelate');
}