diff --git a/application/Espo/Resources/i18n/en_US/Global.json b/application/Espo/Resources/i18n/en_US/Global.json
index 24427eb13b..9193071d15 100644
--- a/application/Espo/Resources/i18n/en_US/Global.json
+++ b/application/Espo/Resources/i18n/en_US/Global.json
@@ -140,7 +140,8 @@
"Close": "Close",
"Yes": "Yes",
"No": "No",
- "View": "View"
+ "View": "View",
+ "Select All Result": "Select All Result"
},
"messages": {
"notModified": "You have not modified the record",
diff --git a/frontend/client/res/templates/record/list.tpl b/frontend/client/res/templates/record/list.tpl
index 4ecb676e49..c716551381 100644
--- a/frontend/client/res/templates/record/list.tpl
+++ b/frontend/client/res/templates/record/list.tpl
@@ -33,7 +33,7 @@
{{#if checkboxes}}
-
+
{{#if checkAllResultEnabled}}
diff --git a/frontend/client/src/views/detail.js b/frontend/client/src/views/detail.js
index 0a61818d33..52ecdd5b92 100644
--- a/frontend/client/src/views/detail.js
+++ b/frontend/client/src/views/detail.js
@@ -268,7 +268,12 @@ Espo.define('Views.Detail', 'Views.Main', function (Dep) {
});
data.ids = ids;
} else {
- data.id = selectObj.id;
+ if (selectObj.massRelate) {
+ data.massRelate = true;
+ data.where = selectObj.where;
+ } else {
+ data.id = selectObj.id;
+ }
}
$.ajax({
url: self.scope + '/' + self.model.id + '/' + link,
diff --git a/frontend/client/src/views/modals/select-records.js b/frontend/client/src/views/modals/select-records.js
index 1ec0df5c27..249b8c9dd4 100644
--- a/frontend/client/src/views/modals/select-records.js
+++ b/frontend/client/src/views/modals/select-records.js
@@ -77,9 +77,19 @@ Espo.define('Views.Modals.SelectRecords', 'Views.Modal', function (Dep) {
style: 'primary',
label: 'Select',
onClick: function (dialog) {
- var list = this.getView('list').getSelected();
- if (list.length) {
- this.trigger('select', list);
+ var listView = this.getView('list');
+
+ if (listView.allResultIsChecked) {
+ var where = this.collection.where;
+ this.trigger('select', {
+ massRelate: true,
+ where: where
+ });
+ } else {
+ var list = listView.getSelected();
+ if (list.length) {
+ this.trigger('select', list);
+ }
}
dialog.close();
}.bind(this),
@@ -102,6 +112,8 @@ Espo.define('Views.Modals.SelectRecords', 'Views.Modal', function (Dep) {
collection.maxSize = this.getConfig().get('recordsPerPageSmall') || 5;
+ this.collection = collection;
+
var searchManager = new SearchManager(collection, 'listSelect', null, this.getDateTime());
searchManager.setAdvanced(this.filters);
collection.where = searchManager.getWhere();
diff --git a/frontend/client/src/views/record/list.js b/frontend/client/src/views/record/list.js
index da5446ac1b..a1c2a84e47 100644
--- a/frontend/client/src/views/record/list.js
+++ b/frontend/client/src/views/record/list.js
@@ -84,7 +84,7 @@ Espo.define('Views.Record.List', 'View', function (Dep) {
this.collection.once('sync', function () {
this.notify(false);
this.trigger('sort', {sortBy: field, asc: asc});
- }.bind(this));
+ }, this);
this.collection.sort(field, asc);
this.deactivate();
},
@@ -112,18 +112,21 @@ Espo.define('Views.Record.List', 'View', function (Dep) {
var id = target.data('id');
this._checkRecord(id, e.currentTarget.checked, target);
},
- 'click .selectAll': function (e) {
+ 'click .select-all': function (e) {
this.checkedList = [];
if (e.currentTarget.checked) {
this.$el.find('input.record-checkbox').prop('checked', true);
this.$el.find('.actions-button').removeAttr('disabled');
- _.each(this.collection.models, function (model) {
+ this.collection.models.forEach(function (model) {
this.checkedList.push(model.id);
- }.bind(this));
+ }, this);
this.$el.find('.list > table tbody tr').addClass('active');
} else {
+ if (this.allResultIsChecked) {
+ this.unselectAllResult();
+ }
this.$el.find('input.record-checkbox').prop('checked', false);
this.$el.find('.actions-button').attr('disabled', true);
this.$el.find('.list > table tbody tr').removeClass('active');
@@ -142,6 +145,9 @@ Espo.define('Views.Record.List', 'View', function (Dep) {
var data = $target.data();
this.quickRemove(id, data);
},
+ 'click .checkbox-dropdown [data-action="selectAllResult"]': function (e) {
+ this.selectAllResult();
+ },
},
actions: [],
@@ -220,6 +226,20 @@ Espo.define('Views.Record.List', 'View', function (Dep) {
}
},
+ selectAllResult: function () {
+ this.allResultIsChecked = true;
+
+ this.$el.find('input.record-checkbox').prop('checked', true).attr('disabled', 'disabled');
+ this.$el.find('input.select-all').prop('checked', true);
+ },
+
+ unselectAllResult: function () {
+ this.allResultIsChecked = false;
+
+ this.$el.find('input.record-checkbox').prop('checked', false).removeAttr('disabled');
+ this.$el.find('input.select-all').prop('checked', false);
+ },
+
deactivate: function () {
if (this.$el) {
this.$el.find(".pagination li").addClass('disabled');
@@ -426,6 +446,8 @@ Espo.define('Views.Record.List', 'View', function (Dep) {
this.noRebuild = null;
return;
}
+ this.checkedList = [];
+ this.allResultIsChecked = false;
this.buildRows(function () {
this.render();
}.bind(this));
@@ -720,6 +742,10 @@ Espo.define('Views.Record.List', 'View', function (Dep) {
}
$showMore.children('a').removeClass('disabled');
+ if (this.allResultIsChecked) {
+ this.$el.find('input.record-checkbox').attr('disabled', 'disabled').prop('checked', true);
+ }
+
this.notify(false);
}.bind(this);
|