mass update for portal users
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
[
|
||||
"portalRoles",
|
||||
"isActive"
|
||||
]
|
||||
@@ -0,0 +1,3 @@
|
||||
[
|
||||
"isActive"
|
||||
]
|
||||
@@ -14,7 +14,8 @@
|
||||
"list":"views/user/record/list"
|
||||
},
|
||||
"modalViews": {
|
||||
"detail": "views/user/modals/detail"
|
||||
"detail": "views/user/modals/detail",
|
||||
"massUpdate": "views/user/modals/mass-update"
|
||||
},
|
||||
"defaultSidePanel": {
|
||||
"detail": {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{{#unless fields}}
|
||||
{{#unless fieldList}}
|
||||
{{translate 'No fields available for Mass Update'}}
|
||||
{{else}}
|
||||
<div class="button-container">
|
||||
@@ -6,8 +6,8 @@
|
||||
<div class="btn-group">
|
||||
<button class="btn btn-default dropdown-toggle select-field" data-toggle="dropdown" tabindex="-1">{{translate 'Select Field'}} <span class="caret"></span></button>
|
||||
<ul class="dropdown-menu pull-left filter-list">
|
||||
{{#each ../fields}}
|
||||
<li data-name="{{./this}}"><a href="javascript:" data-name="{{./this}}" data-action="add-field">{{translate this scope=../../scope category='fields'}}</a></li>
|
||||
{{#each ../fieldList}}
|
||||
<li data-name="{{./this}}"><a href="javascript:" data-name="{{./this}}" data-action="add-field">{{translate this scope=../../entityType category='fields'}}</a></li>
|
||||
{{/each}}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@@ -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 = '<div class="cell form-group col-sm-6" data-name="'+name+'"><label class="control-label">'+label+'</label><div class="field" data-name="'+name+'" /></div>';
|
||||
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();
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
},
|
||||
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user