Skip to content

EspoCRM – Open Source CRM Application

onMassSelect

Yuri Kuznetsov20ea95238b3d
diff --git a/client/src/collection.js b/client/src/collection.js
index af201b9abc..b583ffc95d 100644
--- a/client/src/collection.js
+++ b/client/src/collection.js
@@ -66,6 +66,15 @@ import _ from 'underscore';
* @since 9.1.0
*/
+/**
+ * @typedef {Object} module:collection~Data
+ * @property {string|null} [primaryFilter]
+ * @property {string[]} [boolFilterList]
+ * @property {string} [textFilter]
+ * @property {string} [select]
+ * @property {string} [q]
+ */
+
/**
* A collection.
*
@@ -220,13 +229,7 @@ class Collection {
this.defs = options.defs || {};
/**
- * @type {{
- * primaryFilter?: string,
- * boolFilterList?: string[],
- * textFilter?: string,
- * select?: string,
- * q?: string,
- * } | Record<string, *>}
+ * @type {module:collection~Data | Record<string, *>}
*/
this.data = {};
diff --git a/client/src/views/modals/select-records.js b/client/src/views/modals/select-records.js
index b3d54de6dd..ce2c4221a3 100644
--- a/client/src/views/modals/select-records.js
+++ b/client/src/views/modals/select-records.js
@@ -101,6 +101,8 @@ class SelectRecordsModalView extends ModalView {
* @property {function(): Promise<Record>} [createAttributesProvider] Create-attributes provider.
* @property {Record} [createAttributes] Create-attributes.
* @property {function(import('model').default[])} [onSelect] On record select. As of 9.0.0.
+ * @property {function({where: Record[], searchParams: module:collection~Data})} [onMassSelect]
+ * On record select. As of 9.1.0.
* @property {function()} [onCreate] On create click. As of 9.0.5.
*/
@@ -116,6 +118,11 @@ class SelectRecordsModalView extends ModalView {
this.onSelect = options.onSelect;
}
+ if (options.onMassSelect) {
+ /** @private */
+ this.onMassSelect = options.onMassSelect;
+ }
+
if (options.onCreate) {
/** @private */
this.onCreate = options.onCreate;
@@ -455,11 +462,17 @@ class SelectRecordsModalView extends ModalView {
const listView = this.getRecordView();
if (listView.allResultIsChecked) {
- this.trigger('select', {
+ const data = {
massRelate: true,
where: this.collection.getWhere(),
searchParams: this.collection.data,
- });
+ };
+
+ this.trigger('select', data);
+
+ if (this.onMassSelect) {
+ this.onMassSelect(data)
+ }
this.close();