summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/server/share/webapps/pki/js/pki-ui.js58
-rw-r--r--base/tps/shared/webapps/tps/js/audit.js36
-rw-r--r--base/tps/shared/webapps/tps/js/tps.js108
-rw-r--r--base/tps/shared/webapps/tps/ui/index.html19
4 files changed, 79 insertions, 142 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();
}
});
diff --git a/base/tps/shared/webapps/tps/js/audit.js b/base/tps/shared/webapps/tps/js/audit.js
index cc0be4628..902daef27 100644
--- a/base/tps/shared/webapps/tps/js/audit.js
+++ b/base/tps/shared/webapps/tps/js/audit.js
@@ -133,45 +133,13 @@ var AuditPage = EntryPage.extend({
self.disableAction = $("[name='disable']", self.viewMenu);
$("a", self.enableAction).click(function(e) {
-
e.preventDefault();
-
- var message = "Are you sure you want to enable this entry?";
- if (!confirm(message)) return;
- self.model.changeStatus("enable", {
- 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();
- }
- });
+ self.changeStatus("enable", "Are you sure you want to enable this entry?");
});
$("a", self.disableAction).click(function(e) {
-
e.preventDefault();
-
- var message = "Are you sure you want to disable this entry?";
- if (!confirm(message)) return;
- self.model.changeStatus("disable", {
- 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();
- }
- });
+ self.changeStatus("disable", "Are you sure you want to disable this entry?");
});
self.eventsTable = new Table({
diff --git a/base/tps/shared/webapps/tps/js/tps.js b/base/tps/shared/webapps/tps/js/tps.js
index cf1cc0b83..ac9330d6b 100644
--- a/base/tps/shared/webapps/tps/js/tps.js
+++ b/base/tps/shared/webapps/tps/js/tps.js
@@ -168,129 +168,33 @@ var ConfigEntryPage = EntryPage.extend({
self.disableAction = $("[name='disable']", self.viewMenu);
$("a", self.submitAction).click(function(e) {
-
e.preventDefault();
-
- var message = "Are you sure you want to submit this entry?";
- if (!confirm(message)) return;
- self.model.changeStatus("submit", {
- 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();
- }
- });
+ self.changeStatus("submit", "Are you sure you want to submit this entry?");
});
$("a", self.cancelAction).click(function(e) {
-
e.preventDefault();
-
- var message = "Are you sure you want to cancel this entry?";
- if (!confirm(message)) return;
- self.model.changeStatus("cancel", {
- 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();
- }
- });
+ self.changeStatus("cancel", "Are you sure you want to cancel this entry?");
});
$("a", self.approveAction).click(function(e) {
-
e.preventDefault();
-
- var message = "Are you sure you want to approve this entry?";
- if (!confirm(message)) return;
- self.model.changeStatus("approve", {
- 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();
- }
- });
+ self.changeStatus("approve", "Are you sure you want to approve this entry?");
});
$("a", self.rejectAction).click(function(e) {
-
e.preventDefault();
-
- var message = "Are you sure you want to reject this entry?";
- if (!confirm(message)) return;
- self.model.changeStatus("reject", {
- 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();
- }
- });
+ self.changeStatus("reject", "Are you sure you want to reject this entry?");
});
$("a", self.enableAction).click(function(e) {
-
e.preventDefault();
-
- var message = "Are you sure you want to enable this entry?";
- if (!confirm(message)) return;
- self.model.changeStatus("enable", {
- 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();
- }
- });
+ self.changeStatus("enable", "Are you sure you want to enable this entry?");
});
$("a", self.disableAction).click(function(e) {
-
e.preventDefault();
-
- var message = "Are you sure you want to disable this entry?";
- if (!confirm(message)) return;
- self.model.changeStatus("disable", {
- 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();
- }
- });
+ self.changeStatus("disable", "Are you sure you want to disable this entry?");
});
var dialog = self.$("#property-dialog");
diff --git a/base/tps/shared/webapps/tps/ui/index.html b/base/tps/shared/webapps/tps/ui/index.html
index 8080a125c..8c6092098 100644
--- a/base/tps/shared/webapps/tps/ui/index.html
+++ b/base/tps/shared/webapps/tps/ui/index.html
@@ -444,6 +444,25 @@ $(function() {
<div id="content">
</div>
+<div id="confirm-dialog" class="modal">
+ <div class="modal-dialog">
+ <div class="modal-content">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
+ <span class="pficon pficon-close"></span>
+ </button>
+ <h4 class="modal-title">Confirmation</h4>
+ </div>
+ <div class="modal-body">
+ </div>
+ <div class="modal-footer">
+ <button name="ok" class="btn btn-danger">OK</button>
+ <button name="cancel" class="btn btn-default" data-dismiss="modal">Cancel</button>
+ </div>
+ </div>
+ </div>
+</div>
+
<div id="error-dialog" class="modal">
<div class="modal-dialog">
<div class="modal-content">