diff options
author | Endi S. Dewata <edewata@redhat.com> | 2016-02-06 04:08:44 +0100 |
---|---|---|
committer | Endi S. Dewata <edewata@redhat.com> | 2016-03-17 00:24:50 +0100 |
commit | f65188e4df1ecc080bfca18bd8244f6df9177adc (patch) | |
tree | 5cdf5f1d49b5268fbdbc9a35a072c450582108ab /base/server/share/webapps/pki/js/pki-ui.js | |
parent | 68bfe81d7892c26d2e9485084c430575a921bddc (diff) | |
download | pki-f65188e4df1ecc080bfca18bd8244f6df9177adc.tar.gz pki-f65188e4df1ecc080bfca18bd8244f6df9177adc.tar.xz pki-f65188e4df1ecc080bfca18bd8244f6df9177adc.zip |
Replaced confirmation dialog with HTML dialog.
The TPS UI has been modified such that it will use an HTML-based
dialog instead of the browser's built-in dialog such that the
option to "prevent this page from creating additional dialogs"
will no longer appear.
https://fedorahosted.org/pki/ticket/1685
Diffstat (limited to 'base/server/share/webapps/pki/js/pki-ui.js')
-rw-r--r-- | base/server/share/webapps/pki/js/pki-ui.js | 58 |
1 files changed, 52 insertions, 6 deletions
diff --git a/base/server/share/webapps/pki/js/pki-ui.js b/base/server/share/webapps/pki/js/pki-ui.js index 0729895aa..96c92f3f1 100644 --- a/base/server/share/webapps/pki/js/pki-ui.js +++ b/base/server/share/webapps/pki/js/pki-ui.js @@ -197,11 +197,13 @@ var Dialog = Backbone.View.extend({ self.body = self.$(".modal-body"); self.title = options.title; + self.content = options.content; - self.readonly = options.readonly; + // list of readonly fields // by default all fields are editable - if (self.readonly == undefined) self.readonly = []; + self.readonly = options.readonly || []; + // list of active actions self.actions = options.actions; if (self.actions == undefined) { // by default all buttons are active @@ -232,6 +234,10 @@ var Dialog = Backbone.View.extend({ self.$(".modal-title").text(self.title); } + if (self.content) { + self.body.html(self.content); + } + // setup input fields // TODO: handle drop-down lists $("input, textarea", self.body).each(function(index) { @@ -533,7 +539,7 @@ var Table = Backbone.View.extend({ // setup remove button handler self.removeButton.click(function(e) { var items = []; - var message = "Are you sure you want to remove the following entries?\n"; + var message = "<p>Are you sure you want to remove the following entries?</p>\n<ul>\n"; // get selected items $("input:checked", self.tbody).each(function(index) { @@ -541,13 +547,24 @@ var Table = Backbone.View.extend({ var id = input.val(); if (id == "") return; items.push(id); - message = message + " - " + id + "\n"; + message = message + "<li>" + id + "</li>\n"; }); + message = message + "</ul>\n"; + if (items.length == 0) return; - if (!confirm(message)) return; - self.remove(items); + var dialog = new Dialog({ + el: $("#confirm-dialog"), + content: message + }); + + dialog.handler("ok", function() { + self.remove(items); + dialog.close(); + }); + + dialog.open(); }); // setup select all handler @@ -1149,5 +1166,34 @@ var EntryPage = Page.extend({ var value = input.val(); // save all values including empty ones self.entry[name] = value; + }, + changeStatus: function(action, message) { + var self = this; + + var dialog = new Dialog({ + el: $("#confirm-dialog"), + content: message + }); + + dialog.handler("ok", function() { + + self.model.changeStatus(action, { + success: function(data, textStatus, jqXHR) { + self.entry = _.clone(self.model.attributes); + self.render(); + }, + error: function(jqXHR, textStatus, errorThrown) { + new ErrorDialog({ + el: $("#error-dialog"), + title: "HTTP Error " + jqXHR.responseJSON.Code, + content: jqXHR.responseJSON.Message + }).open(); + } + }); + + dialog.close(); + }); + + dialog.open(); } }); |