summaryrefslogtreecommitdiffstats
path: root/base/server/share/webapps/pki
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2014-03-13 22:40:43 -0400
committerEndi S. Dewata <edewata@redhat.com>2014-03-17 11:22:28 -0400
commitf312aa2df1216a083bdc4c31d9be23bdd41898e1 (patch)
tree0717aba7fe3a8505ca0ee86fba9370536345b04f /base/server/share/webapps/pki
parent4c1ce953681c3cac9c6d0b4325a48ba66619f553 (diff)
downloadpki-f312aa2df1216a083bdc4c31d9be23bdd41898e1.tar.gz
pki-f312aa2df1216a083bdc4c31d9be23bdd41898e1.tar.xz
pki-f312aa2df1216a083bdc4c31d9be23bdd41898e1.zip
Added remove button handler for TPS UI.
The Table class has been modified to handle the remove button. When the button is clicked, it will get the list of items selected for deletion. If there is nothing selected it will not do anything. If there are some items selected, it will display the list in a dialog box and ask the user to confirm the deletion. If the operation is confirmed, the items will be deleted one by one. The table will be refreshed after the process is done. In some pages the buttons have been updated to reflect the availability of the add/remove operations for the corresponding REST resources. Ticket #654
Diffstat (limited to 'base/server/share/webapps/pki')
-rw-r--r--base/server/share/webapps/pki/js/pki-ui.js35
1 files changed, 34 insertions, 1 deletions
diff --git a/base/server/share/webapps/pki/js/pki-ui.js b/base/server/share/webapps/pki/js/pki-ui.js
index 73ba63b26..44e0444da 100644
--- a/base/server/share/webapps/pki/js/pki-ui.js
+++ b/base/server/share/webapps/pki/js/pki-ui.js
@@ -391,14 +391,19 @@ var TableItem = Backbone.View.extend({
var name = item.attr("name");
if (index == 0) {
- // setup select checkbox
+ // find the checkbox and label for this item
var checkbox = $("input[type='checkbox']", item);
var id = checkbox.attr("id");
var label = $("label[for='" + id + "']", item);
+
+ // replace checkbox and label id with a unique id
id = id + "_" + self.model.id;
checkbox.attr("id", id);
label.attr("for", id);
+ // store item id as checkbox value
+ checkbox.val(self.model.id);
+
} else if (index == 1) {
// setup link to edit dialog
item.empty();
@@ -437,6 +442,8 @@ var Table = Backbone.View.extend({
self.editDialog = options.editDialog;
self.thead = $("thead", self.$el);
+
+ // setup add button handler
$("button[name='add']", self.thead).click(function(e) {
var dialog = self.addDialog;
dialog.model = new self.collection.model();
@@ -446,6 +453,32 @@ var Table = Backbone.View.extend({
dialog.open();
});
+ // setup remove button handler
+ $("button[name='remove']", self.thead).click(function(e) {
+ var items = [];
+ var message = "Are you sure you want to remove the following entries?\n";
+
+ // get selected items
+ $("input:checked", self.tbody).each(function(index) {
+ var input = $(this);
+ var id = input.val();
+ items.push(id);
+ message = message + " - " + id + "\n";
+ });
+
+ if (items.length == 0) return;
+ if (!confirm(message)) return;
+
+ _.each(items, function(id, index) {
+ var model = self.collection.get(id);
+ model.destroy({
+ wait: true
+ });
+ });
+
+ self.render();
+ });
+
$("input[type='checkbox']", self.thead).click(function(e) {
var checked = $(this).is(":checked");
$("input[type='checkbox']", self.tbody).prop("checked", checked);