Skip to content
This repository has been archived by the owner on Nov 18, 2022. It is now read-only.

Commit

Permalink
#98: showing number of selected items in confirmation box
Browse files Browse the repository at this point in the history
…when deleting or performing other actions on multiple items in
web-interface.
  • Loading branch information
hugbug committed Nov 14, 2015
1 parent fc3c906 commit 322b08e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
6 changes: 3 additions & 3 deletions webui/downloads.js
Expand Up @@ -524,7 +524,7 @@ var Downloads = (new function($)
}
};

DownloadsUI.deleteConfirm(deleteGroups, true, hasNzb, hasUrl);
DownloadsUI.deleteConfirm(deleteGroups, true, hasNzb, hasUrl, downloadIDs.length);
}

this.moveClick = function(action)
Expand Down Expand Up @@ -856,7 +856,7 @@ var DownloadsUI = (new function($)
return categoryColumnWidth;
}

this.deleteConfirm = function(actionCallback, multi, hasNzb, hasUrl)
this.deleteConfirm = function(actionCallback, multi, hasNzb, hasUrl, selCount)
{
var dupeCheck = Options.option('DupeCheck') === 'yes';
var cleanupDisk = Options.option('DeleteCleanupDisk') === 'yes';
Expand Down Expand Up @@ -895,6 +895,6 @@ var DownloadsUI = (new function($)
actionCallback(command);
}

ConfirmDialog.showModal('DownloadsDeleteConfirmDialog', action, init);
ConfirmDialog.showModal('DownloadsDeleteConfirmDialog', action, init, selCount);
}
}(jQuery));
12 changes: 7 additions & 5 deletions webui/history.js
Expand Up @@ -289,7 +289,7 @@ var History = (new function($)
{
case 'DELETE':
notification = '#Notif_History_Deleted';
HistoryUI.deleteConfirm(historyAction, hasNzb, hasDup, hasFailed, true);
HistoryUI.deleteConfirm(historyAction, hasNzb, hasDup, hasFailed, true, checkedCount);
break;

case 'REPROCESS':
Expand All @@ -311,7 +311,8 @@ var History = (new function($)
notification = '#Notif_History_Returned';
ConfirmDialog.showModal('HistoryEditRedownloadConfirmDialog',
function () { historyAction('HistoryRedownload') },
function () { HistoryUI.confirmMulti(checkedCount > 1); });
function () { HistoryUI.confirmMulti(checkedCount > 1); },
checkedCount);
break;

case 'MARKSUCCESS':
Expand All @@ -334,7 +335,8 @@ var History = (new function($)
function (_dialog) // init
{
HistoryUI.confirmMulti(checkedCount > 1);
}
},
checkedCount
);
break;
}
Expand Down Expand Up @@ -497,7 +499,7 @@ var HistoryUI = (new function($)
return '<span class="label label-status ' + badgeClass + '">' + statusText + '</span>';
}

this.deleteConfirm = function(actionCallback, hasNzb, hasDup, hasFailed, multi)
this.deleteConfirm = function(actionCallback, hasNzb, hasDup, hasFailed, multi, selCount)
{
var dupeCheck = Options.option('DupeCheck') === 'yes';
var cleanupDisk = Options.option('DeleteCleanupDisk') === 'yes';
Expand All @@ -524,7 +526,7 @@ var HistoryUI = (new function($)
actionCallback(command);
}

ConfirmDialog.showModal('HistoryDeleteConfirmDialog', action, init);
ConfirmDialog.showModal('HistoryDeleteConfirmDialog', action, init, selCount);
}

this.confirmMulti = function(multi)
Expand Down
11 changes: 9 additions & 2 deletions webui/index.js
Expand Up @@ -791,15 +791,22 @@ var ConfirmDialog = (new function($)
$('#ConfirmDialog_OK').click(click);
}

this.showModal = function(id, _actionCallback, initCallback)
this.showModal = function(id, _actionCallback, initCallback, selCount)
{
$('#ConfirmDialog_Title').html($('#' + id + '_Title').html());
$('#ConfirmDialog_Text').html($('#' + id + '_Text').html());
$('#ConfirmDialog_OK').html($('#' + id + '_OK').html());
var helpId = $('#' + id + '_Help').html();
$('#ConfirmDialog_Help').attr('href', '#' + helpId);
Util.show('#ConfirmDialog_Help', helpId !== null);


if (selCount > 1)
{
var html = $('#ConfirmDialog_Text').html();
html = html.replace(/selected/g, selCount + ' selected');
$('#ConfirmDialog_Text').html(html);
}

actionCallback = _actionCallback;
if (initCallback)
{
Expand Down

0 comments on commit 322b08e

Please sign in to comment.