diff --git a/client/src/views/modals/mass-update.js b/client/src/views/modals/mass-update.js
index 8ad384ae37..206dd26b17 100644
--- a/client/src/views/modals/mass-update.js
+++ b/client/src/views/modals/mass-update.js
@@ -26,7 +26,7 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
-Espo.define('views/modals/mass-update', 'views/modal', function (Dep) {
+define('views/modals/mass-update', 'views/modal', function (Dep) {
return Dep.extend({
@@ -34,10 +34,13 @@ Espo.define('views/modals/mass-update', 'views/modal', function (Dep) {
template: 'modals/mass-update',
+ layoutName: 'massUpdate',
+
data: function () {
return {
scope: this.scope,
- fields: this.fields
+ fieldList: this.fieldList,
+ entityType: this.entityType,
};
},
@@ -68,7 +71,9 @@ Espo.define('views/modals/mass-update', 'views/modal', function (Dep) {
}
];
- this.scope = this.options.scope;
+ this.entityType = this.options.entityType || this.options.scope;
+ this.scope = this.options.scope || this.entityType;
+
this.ids = this.options.ids;
this.where = this.options.where;
this.selectData = this.options.selectData;
@@ -76,18 +81,18 @@ Espo.define('views/modals/mass-update', 'views/modal', function (Dep) {
this.headerHtml = this.translate(this.scope, 'scopeNamesPlural') + ' » ' + this.translate('Mass Update');
- var fobiddenList = this.getAcl().getScopeForbiddenFieldList(this.scope, 'edit') || [];
+ var fobiddenList = this.getAcl().getScopeForbiddenFieldList(this.entityType, 'edit') || [];
this.wait(true);
- this.getModelFactory().create(this.scope, function (model) {
+ this.getModelFactory().create(this.entityType, function (model) {
this.model = model;
- this.getHelper().layoutManager.get(this.scope, 'massUpdate', function (layout) {
+ this.getHelper().layoutManager.get(this.entityType, this.layoutName, function (layout) {
layout = layout || [];
- this.fields = [];
+ this.fieldList = [];
layout.forEach(function (field) {
if (~fobiddenList.indexOf(field)) return;
if (model.hasField(field)) {
- this.fields.push(field);
+ this.fieldList.push(field);
}
}, this);
@@ -95,7 +100,7 @@ Espo.define('views/modals/mass-update', 'views/modal', function (Dep) {
}.bind(this));
}.bind(this));
- this.fieldList = [];
+ this.addedFieldList = [];
},
addField: function (name) {
@@ -110,7 +115,7 @@ Espo.define('views/modals/mass-update', 'views/modal', function (Dep) {
}
this.notify('Loading...');
- var label = this.translate(name, 'fields', this.scope);
+ var label = this.translate(name, 'fields', this.entityType);
var html = '
';
this.$el.find('.fields-container').append(html);
@@ -126,7 +131,7 @@ Espo.define('views/modals/mass-update', 'views/modal', function (Dep) {
},
mode: 'edit'
}, function (view) {
- this.fieldList.push(name);
+ this.addedFieldList.push(name);
view.render();
view.notify(false);
}.bind(this));
@@ -138,7 +143,7 @@ Espo.define('views/modals/mass-update', 'views/modal', function (Dep) {
var self = this;
var attributes = {};
- this.fieldList.forEach(function (field) {
+ this.addedFieldList.forEach(function (field) {
var view = self.getView(field);
_.extend(attributes, view.fetch());
});
@@ -146,7 +151,7 @@ Espo.define('views/modals/mass-update', 'views/modal', function (Dep) {
this.model.set(attributes);
var notValid = false;
- this.fieldList.forEach(function (field) {
+ this.addedFieldList.forEach(function (field) {
var view = self.getView(field);
notValid = view.validate() || notValid;
});
@@ -154,7 +159,7 @@ Espo.define('views/modals/mass-update', 'views/modal', function (Dep) {
if (!notValid) {
self.notify('Saving...');
$.ajax({
- url: this.scope + '/action/massUpdate',
+ url: this.entityType + '/action/massUpdate',
type: 'PUT',
data: JSON.stringify({
attributes: attributes,
@@ -181,12 +186,12 @@ Espo.define('views/modals/mass-update', 'views/modal', function (Dep) {
},
reset: function () {
- this.fieldList.forEach(function (field) {
+ this.addedFieldList.forEach(function (field) {
this.clearView(field);
this.$el.find('.cell[data-name="'+field+'"]').remove();
}, this);
- this.fieldList = [];
+ this.addedFieldList = [];
this.model.clear();
diff --git a/client/src/views/record/list.js b/client/src/views/record/list.js
index 6e64d66222..359bdd7ff3 100644
--- a/client/src/views/record/list.js
+++ b/client/src/views/record/list.js
@@ -795,12 +795,16 @@ define('views/record/list', 'view', function (Dep) {
ids = this.checkedList;
}
- this.createView('massUpdate', 'views/modals/mass-update', {
- scope: this.entityType,
+ var viewName = this.getMetadata().get(['clientDefs', this.entityType, 'modalViews', 'massUpdate']) ||
+ 'views/modals/mass-update';
+
+ this.createView('massUpdate', viewName, {
+ scope: this.scope,
+ entityType: this.entityType,
ids: ids,
where: this.collection.getWhere(),
selectData: this.collection.data,
- byWhere: this.allResultIsChecked
+ byWhere: this.allResultIsChecked,
}, function (view) {
view.render();
view.notify(false);
diff --git a/client/src/views/user/modals/mass-update.js b/client/src/views/user/modals/mass-update.js
new file mode 100644
index 0000000000..4bb0268350
--- /dev/null
+++ b/client/src/views/user/modals/mass-update.js
@@ -0,0 +1,44 @@
+/************************************************************************
+ * This file is part of EspoCRM.
+ *
+ * EspoCRM - Open Source CRM application.
+ * Copyright (C) 2014-2019 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
+ * Website: https://www.espocrm.com
+ *
+ * EspoCRM is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * EspoCRM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with EspoCRM. If not, see http://www.gnu.org/licenses/.
+ *
+ * The interactive user interfaces in modified source and object code versions
+ * of this program must display Appropriate Legal Notices, as required under
+ * Section 5 of the GNU General Public License version 3.
+ *
+ * In accordance with Section 7(b) of the GNU General Public License version 3,
+ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
+ ************************************************************************/
+
+define('views/user/modals/mass-update', 'views/modals/mass-update', function (Dep) {
+
+ return Dep.extend({
+
+ setup: function () {
+
+ if (this.options.scope === 'ApiUser') {
+ this.layoutName = 'massUpdateApi';
+ } else if (this.options.scope === 'PortalUser') {
+ this.layoutName = 'massUpdatePortal';
+ }
+ Dep.prototype.setup.call(this);
+ },
+
+ });
+});