Skip to content

Commit

Permalink
PATCH: Mass link/unlink with Target List
Browse files Browse the repository at this point in the history
  • Loading branch information
alasdaircr committed Nov 4, 2015
1 parent 5fb0ddb commit 23e1855
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 1 deletion.
4 changes: 4 additions & 0 deletions application/Espo/Resources/i18n/en_US/Global.json
Expand Up @@ -200,6 +200,8 @@
"removeRecordConfirmation": "Are you sure you want to remove the record?",
"unlinkRecordConfirmation": "Are you sure you want to unlink the related record?",
"removeSelectedRecordsConfirmation": "Are you sure you want to remove selected records?",
"linkSelectedRecordsConfirmation": "Are you sure you want to link the record(s)?",
"unlinkSelectedRecordsConfirmation": "Are you sure you want to unlink the record(s)?",
"massUpdateResult": "{count} records have been updated",
"massUpdateResultSingle": "{count} record has been updated",
"noRecordsUpdated": "No records were updated",
Expand All @@ -224,6 +226,8 @@
"remove": "Remove",
"merge": "Merge",
"massUpdate": "Mass Update",
"massLink": "Link to Target List",
"massUnLink": "Unlink from Target List",
"export": "Export"
},
"fields": {
Expand Down
86 changes: 85 additions & 1 deletion frontend/client/src/views/record/list.js
Expand Up @@ -214,7 +214,7 @@ Espo.define('views/record/list', 'view', function (Dep) {

showMore: true,

massActionList: ['remove', 'merge', 'massUpdate', 'export'],
massActionList: ['remove', 'merge', 'massUpdate', 'massLink', 'massUnLink', 'export'],

checkAllResultMassActionList: ['remove', 'massUpdate', 'export'],

Expand All @@ -224,6 +224,10 @@ Espo.define('views/record/list', 'view', function (Dep) {

massUpdateAction: true,

massLinkAction: false,

massUnLinkAction: false,

exportAction: true,

quickDetailDisabled: false,
Expand Down Expand Up @@ -498,6 +502,86 @@ Espo.define('views/record/list', 'view', function (Dep) {
}.bind(this));
},

massActionMassLink: function () {
if (!this.getAcl().check(this.scope, 'edit')) {
this.notify('Access denied', 'error');
return false;
}

this.notify('Loading...');
var ids = false;

var allResultIsChecked = this.allResultIsChecked;
if (!allResultIsChecked) {
ids = this.checkedList;
}

this.createView('dialog', 'Modals.SelectRecords', {
scope: 'TargetList',
multiple: false,
createButton: true,
filters: null
}, function (dialog) {
dialog.render();
this.notify(false);
dialog.once('select', function (selectObj) {
if (confirm(this.translate('linkSelectedRecordsConfirmation', 'messages'))) {
$.ajax({
url: 'TargetList' + '/' + selectObj.id + '/' + this.scope.toLowerCase() + 's',
type: 'POST',
data: JSON.stringify({ ids: ids }),
success: function () {
Espo.Ui.success('Added to list(s)');
},
error: function () {
Espo.Ui.warning('Unknown error occurred');
},
});
}
}.bind(this));
}.bind(this));
},

massActionMassUnLink: function () {
if (!this.getAcl().check(this.scope, 'edit')) {
this.notify('Access denied', 'error');
return false;
}

this.notify('Loading...');
var ids = false;

var allResultIsChecked = this.allResultIsChecked;
if (!allResultIsChecked) {
ids = this.checkedList;
}

this.createView('dialog', 'Modals.SelectRecords', {
scope: 'TargetList',
multiple: false,
createButton: true,
filters: null
}, function (dialog) {
dialog.render();
this.notify(false);
dialog.once('select', function (selectObj) {
if (confirm(this.translate('unlinkSelectedRecordsConfirmation', 'messages'))) {
$.ajax({
url: 'TargetList' + '/' + selectObj.id + '/' + this.scope.toLowerCase() + 's',
type: 'DELETE',
data: JSON.stringify({ ids: ids }),
success: function () {
Espo.Ui.success('Removed from list(s)');
},
error: function () {
Espo.Ui.warning('Unknown error occurred');
},
});
}
}.bind(this));
}.bind(this));
},

massActionExport: function () {
if (!this.getConfig().get('exportDisabled') || this.getUser().get('isAdmin')) {
this.export();
Expand Down

0 comments on commit 23e1855

Please sign in to comment.