diff --git a/application/Espo/Controllers/Export.php b/application/Espo/Controllers/Export.php index 764bcca4eb..ba1053bbcd 100644 --- a/application/Espo/Controllers/Export.php +++ b/application/Espo/Controllers/Export.php @@ -74,7 +74,7 @@ class Export $params['entityType'] = $entityType; $where = $data->where ?? null; - $searchParams = $data->searchParams ?? null; + $searchParams = $data->searchParams ?? $data->selectData ?? null; $ids = $data->ids ?? null; if (!is_null($where) || !is_null($searchParams)) { diff --git a/application/Espo/Controllers/MassAction.php b/application/Espo/Controllers/MassAction.php index dba4b59b8e..e216b67b1c 100644 --- a/application/Espo/Controllers/MassAction.php +++ b/application/Espo/Controllers/MassAction.php @@ -87,7 +87,7 @@ class MassAction private function prepareMassActionParams(stdClass $data): array { $where = $data->where ?? null; - $searchParams = $data->searchParams ?? null; + $searchParams = $data->searchParams ?? $data->selectData ?? null; $ids = $data->ids ?? null; if (!is_null($where) || !is_null($searchParams)) { diff --git a/client/src/views/admin/auth-token/record/list.js b/client/src/views/admin/auth-token/record/list.js index 4bf7b56e99..0d19100901 100644 --- a/client/src/views/admin/auth-token/record/list.js +++ b/client/src/views/admin/auth-token/record/list.js @@ -62,14 +62,14 @@ define('views/admin/auth-token/record/list', 'views/record/list', function (Dep) params: { ids: ids || null, where: (!ids || ids.length === 0) ? this.collection.getWhere() : null, - selectData: (!ids || ids.length === 0) ? this.collection.data : null, + searchParams: (!ids || ids.length === 0) ? this.collection.data : null, }, data: attributes, - }).then(function () { + }).then(() => { var result = result || {}; this.collection.fetch(); - }.bind(this)); + }); }, actionSetInactive: function (data) { @@ -85,11 +85,13 @@ define('views/admin/auth-token/record/list', 'views/record/list', function (Dep) Espo.Ui.notify(this.translate('pleaseWait', 'messages')); - model.save({ - 'isActive': false - }, {patch: true}).then(function () { - Espo.Ui.notify(false); - }); + model + .save({ + 'isActive': false + }, {patch: true}) + .then(() => { + Espo.Ui.notify(false); + }); } }); diff --git a/client/src/views/modals/mass-convert-currency.js b/client/src/views/modals/mass-convert-currency.js index 6c3b91400b..68b03cf3a9 100644 --- a/client/src/views/modals/mass-convert-currency.js +++ b/client/src/views/modals/mass-convert-currency.js @@ -110,7 +110,7 @@ define('views/modals/mass-convert-currency', ['views/modal', 'model'], function params: { ids: this.options.ids || null, where: hasWhere ? this.options.where : null, - searchParams: hasWhere ? this.options.selectData : null, + searchParams: hasWhere ? this.options.searchParams : null, }, data: { fieldList: this.options.fieldList || null, @@ -119,13 +119,13 @@ define('views/modals/mass-convert-currency', ['views/modal', 'model'], function rates: currencyRates, }, }) - .then(function (result) { + .then(result => { this.trigger('after:update', result.count); this.close(); - }.bind(this)) - .fail(function () { + }) + .catch(() => { this.enableButton('convert'); - }.bind(this)); + }); }, }); diff --git a/client/src/views/modals/mass-update.js b/client/src/views/modals/mass-update.js index 8a90dec853..c51280a66a 100644 --- a/client/src/views/modals/mass-update.js +++ b/client/src/views/modals/mass-update.js @@ -76,7 +76,7 @@ define('views/modals/mass-update', 'views/modal', function (Dep) { this.ids = this.options.ids; this.where = this.options.where; - this.selectData = this.options.selectData; + this.searchParams = this.options.searchParams; this.byWhere = this.options.byWhere; this.headerHtml = this.translate(this.scope, 'scopeNamesPlural') + @@ -86,15 +86,15 @@ define('views/modals/mass-update', 'views/modal', function (Dep) { this.wait(true); - this.getModelFactory().create(this.entityType, function (model) { + this.getModelFactory().create(this.entityType, (model) => { this.model = model; - this.getHelper().layoutManager.get(this.entityType, this.layoutName, function (layout) { + this.getHelper().layoutManager.get(this.entityType, this.layoutName, (layout) => { layout = layout || []; this.fieldList = []; - layout.forEach(function (field) { + layout.forEach((field) => { if (~forbiddenList.indexOf(field)) { return; } @@ -102,11 +102,11 @@ define('views/modals/mass-update', 'views/modal', function (Dep) { if (model.hasField(field)) { this.fieldList.push(field); } - }, this); + }); this.wait(false); - }.bind(this)); - }.bind(this)); + }); + }); this.addedFieldList = []; }, @@ -143,13 +143,13 @@ define('views/modals/mass-update', 'views/modal', function (Dep) { name: name, }, mode: 'edit', - }, function (view) { + }, (view) => { this.addedFieldList.push(name); view.render(); view.notify(false); - }.bind(this)); + }); }, actionUpdate: function () { @@ -159,7 +159,7 @@ define('views/modals/mass-update', 'views/modal', function (Dep) { var attributes = {}; - this.addedFieldList.forEach(function (field) { + this.addedFieldList.forEach((field) => { var view = self.getView(field); _.extend(attributes, view.fetch()); @@ -169,7 +169,7 @@ define('views/modals/mass-update', 'views/modal', function (Dep) { var notValid = false; - this.addedFieldList.forEach(function (field) { + this.addedFieldList.forEach((field) => { var view = self.getView(field); notValid = view.validate() || notValid; @@ -186,20 +186,20 @@ define('views/modals/mass-update', 'views/modal', function (Dep) { params: { ids: self.ids || null, where: (!self.ids || self.ids.length === 0) ? self.options.where : null, - selectData: (!self.ids || self.ids.length === 0) ? self.options.selectData : null, + searchParams: (!self.ids || self.ids.length === 0) ? self.options.searchParams : null, }, data: attributes, }) .then( - function (result) { + (result) => { var result = result || {}; var count = result.count; self.trigger('after:update', count); } ) - .fail( - function () { + .catch( + () =>{ self.notify('Error occurred', 'error'); self.enableButton('update'); @@ -213,11 +213,11 @@ define('views/modals/mass-update', 'views/modal', function (Dep) { }, reset: function () { - this.addedFieldList.forEach(function (field) { + this.addedFieldList.forEach((field) => { this.clearView(field); this.$el.find('.cell[data-name="'+field+'"]').remove(); - }, this); + }); this.addedFieldList = []; diff --git a/client/src/views/record/list.js b/client/src/views/record/list.js index d8cec4ab51..327bc0e410 100644 --- a/client/src/views/record/list.js +++ b/client/src/views/record/list.js @@ -583,7 +583,8 @@ define('views/record/list', 'view', function (Dep) { if (this.allResultIsChecked) { data.where = this.collection.getWhere(); - data.searchData = this.collection.data || {}; + data.searchParams = this.collection.data || {}; + data.searchData = this.collection.data || {}; // for bc; } else { data.ids = this.checkedList; @@ -679,7 +680,7 @@ define('views/record/list', 'view', function (Dep) { if (this.allResultIsChecked) { data.where = this.collection.getWhere(); - data.searchData = this.collection.data || {}; + data.searchParams = this.collection.data || {}; data.selectData = data.searchData; // for bc; data.byWhere = true; // for bc } @@ -736,8 +737,9 @@ define('views/record/list', 'view', function (Dep) { if (this.allResultIsChecked) { data.where = this.collection.getWhere(); - data.selectData = this.collection.data || {}; - data.byWhere = true; + data.searchParams = this.collection.data || {}; + data.selectData = this.collection.data || {}; // for bc; + data.byWhere = true; // for bc; } else { data.ids = []; @@ -1046,7 +1048,7 @@ define('views/record/list', 'view', function (Dep) { entityType: this.entityType, ids: ids, where: this.collection.getWhere(), - selectData: this.collection.data, + searchParams: this.collection.data, byWhere: this.allResultIsChecked, }, (view) => { view.render(); @@ -1123,7 +1125,7 @@ define('views/record/list', 'view', function (Dep) { entityType: this.entityType, ids: ids, where: this.collection.getWhere(), - selectData: this.collection.data, + searchParams: this.collection.data, byWhere: this.allResultIsChecked, }, (view) => { view.render(); diff --git a/tests/unit/Espo/Core/MassAction/ParamsTest.php b/tests/unit/Espo/Core/MassAction/ParamsTest.php index fbc95f7405..a97f54be18 100644 --- a/tests/unit/Espo/Core/MassAction/ParamsTest.php +++ b/tests/unit/Espo/Core/MassAction/ParamsTest.php @@ -91,7 +91,7 @@ class ParamsTest extends \PHPUnit\Framework\TestCase $params = Params::fromRaw( [ 'where' => $where, - 'selectData' => [ + 'searchParams' => [ 'primaryFilter' => 'testFilter', ], ],