mass relate dev 2

This commit is contained in:
yuri
2015-02-26 17:14:44 +02:00
parent a0203d3310
commit ff2ca7f18c
5 changed files with 54 additions and 10 deletions
@@ -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",
@@ -33,7 +33,7 @@
<tr>
{{#if checkboxes}}
<th width="5%">
<input type="checkbox" class="selectAll">
<input type="checkbox" class="select-all">
{{#if checkAllResultEnabled}}
<div class="btn-group checkbox-dropdown">
<a class="btn btn-link btn-sm dropdown-toggle" data-toggle="dropdown">
+6 -1
View File
@@ -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,
@@ -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();
+30 -4
View File
@@ -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);