>From 231887797876a8462bb92f5119742a6dc785b819 Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Fri, 10 Apr 2015 22:51:22 -0400 Subject: [PATCH] Fixed action menu in TPS UI. The TPS UI has been modified to display the appropriate actions menu based on the roles of the user. TPS agent can only enable and disable profiles, and also approve or reject pending requests. TPS admin can only edit disabled profiles, then submit it for approval, or cancel the request. https://fedorahosted.org/pki/ticket/1292 --- base/server/share/webapps/pki/css/pki-ui.css | 20 +++ base/server/share/webapps/pki/js/pki-ui.js | 24 ++-- base/tps/shared/webapps/tps/js/account.js | 30 ++++- base/tps/shared/webapps/tps/js/audit.js | 41 +++--- base/tps/shared/webapps/tps/js/authenticator.js | 17 +-- base/tps/shared/webapps/tps/js/config.js | 66 +++++++++- base/tps/shared/webapps/tps/js/connector.js | 17 +-- base/tps/shared/webapps/tps/js/profile-mapping.js | 17 +-- base/tps/shared/webapps/tps/js/profile.js | 102 ++++++++++++--- base/tps/shared/webapps/tps/js/token.js | 12 +- base/tps/shared/webapps/tps/js/tps.js | 145 ++++++++++++++++++--- base/tps/shared/webapps/tps/ui/audit.html | 9 +- base/tps/shared/webapps/tps/ui/authenticator.html | 21 ++- base/tps/shared/webapps/tps/ui/config.html | 14 +- base/tps/shared/webapps/tps/ui/connector.html | 21 ++- base/tps/shared/webapps/tps/ui/group.html | 6 +- base/tps/shared/webapps/tps/ui/home.html | 14 +- base/tps/shared/webapps/tps/ui/index.html | 4 +- .../tps/shared/webapps/tps/ui/profile-mapping.html | 21 ++- base/tps/shared/webapps/tps/ui/profile.html | 21 ++- base/tps/shared/webapps/tps/ui/token.html | 10 +- base/tps/shared/webapps/tps/ui/user.html | 6 +- 22 files changed, 452 insertions(+), 186 deletions(-) diff --git a/base/server/share/webapps/pki/css/pki-ui.css b/base/server/share/webapps/pki/css/pki-ui.css index 0d5edd7fd59f38c31932473fbe20e51c9bdbd2c6..6042dc3ee97af8e52048a7f14ab8dd2b2a1d1c31 100644 --- a/base/server/share/webapps/pki/css/pki-ui.css +++ b/base/server/share/webapps/pki/css/pki-ui.css @@ -42,8 +42,13 @@ } .pki-menu { + display: inline-block; +} + +.pki-menu ul { padding: 0; list-style-type: none; + list-style-position: inside; } .pki-actions { @@ -51,6 +56,13 @@ display: inline-block; } +.pki-actions ul { + padding: 0; + list-style-type: none; + list-style-position: inside; + text-align: right; +} + .pki-fields { margin-bottom: 5px; } @@ -79,6 +91,14 @@ input[readonly="readonly"]:enabled:hover { border-color: #FFFFFF; } +textarea { + background-color: #FFFFFF; +} + +textarea[readonly="readonly"] { + background-color: #F8F8F8; +} + table tfoot tr th { padding: 6px 15px; font-size: 11.5px; diff --git a/base/server/share/webapps/pki/js/pki-ui.js b/base/server/share/webapps/pki/js/pki-ui.js index 98e3330c0bcba248e0ee76dacf1839e19927eb94..c1c57793ce4605ced961c8f06453fd89d71a3d51 100644 --- a/base/server/share/webapps/pki/js/pki-ui.js +++ b/base/server/share/webapps/pki/js/pki-ui.js @@ -485,6 +485,8 @@ var Table = Backbone.View.extend({ self.thead = $("thead", self.$el); self.buttons = $(".pki-table-buttons", self.thead); + self.addButton = $("[name='add']", self.buttons); + self.removeButton = $("[name='remove']", self.buttons); // setup search field handler self.searchField = $("input[name='search']", self.thead); @@ -497,12 +499,12 @@ var Table = Backbone.View.extend({ }); // setup add button handler - $("button[name='add']", self.buttons).click(function(e) { + self.addButton.click(function(e) { self.add(); }); // setup remove button handler - $("button[name='remove']", self.buttons).click(function(e) { + self.removeButton.click(function(e) { var items = []; var message = "Are you sure you want to remove the following entries?\n"; @@ -625,10 +627,12 @@ var Table = Backbone.View.extend({ var self = this; if (self.mode == "view") { - self.buttons.hide(); + self.addButton.hide(); + self.removeButton.hide(); } else { // self.mode == "edit" - self.buttons.show(); + self.addButton.show(); + self.removeButton.show(); } // clear selection @@ -928,27 +932,27 @@ var EntryPage = Page.extend({ self.actions = self.$(".pki-actions"); self.viewMenu = $(".pki-actions-menu[name='view']", self.actions); - self.editLink = $("a[name='edit']", self.viewMenu); + self.editAction = $("[name='edit']", self.viewMenu); self.editMenu = $(".pki-actions-menu[name='edit']", self.actions); - self.cancelButton = $("button[name='cancel']", self.editMenu); - self.saveButton = $("button[name='save']", self.editMenu); + self.cancelAction = $("[name='cancel']", self.editMenu); + self.saveAction = $("[name='save']", self.editMenu); self.idField = self.$("input[name='id']"); self.statusField = self.$("input[name='status']"); - self.editLink.click(function(e) { + $("a", self.editAction).click(function(e) { self.mode = "edit"; self.render(); e.preventDefault(); }); - self.cancelButton.click(function(e) { + self.cancelAction.click(function(e) { self.cancel(); e.preventDefault(); }); - self.saveButton.click(function(e) { + self.saveAction.click(function(e) { self.save(); e.preventDefault(); }); diff --git a/base/tps/shared/webapps/tps/js/account.js b/base/tps/shared/webapps/tps/js/account.js index 97b222aaa07b42056395ddb9baaec4d85381a252..8960ff731d1faec646dac0763a35aa2c40b3eb9a 100644 --- a/base/tps/shared/webapps/tps/js/account.js +++ b/base/tps/shared/webapps/tps/js/account.js @@ -24,14 +24,30 @@ function Account() { this.url = "/tps/rest/account"; this.login = function(options) { - var jqxhr = $.get(this.url + "/login", null, null, "json"); - jqxhr.done(options.success); - jqxhr.fail(options.error); + var self = this; + + $.ajax({ + type: "GET", + url: self.url + "/login", + dataType: "json" + }).done(function(data, textStatus, jqXHR) { + if (options.success) options.success.call(self, data, textStatus, jqXHR); + }).fail(function(jqXHR, textStatus, errorThrown) { + if (options.error) options.error.call(self, jqXHR, textStatus, errorThrown); + }); }; this.logout = function(options) { - var jqxhr = $.get(this.url + "/logout"); - jqxhr.done(options.success); - jqxhr.fail(options.error); + var self = this; + + $.ajax({ + type: "GET", + url: self.url + "/logout", + dataType: "json" + }).done(function(data, textStatus, jqXHR) { + if (options.success) options.success.call(self, data, textStatus, jqXHR); + }).fail(function(jqXHR, textStatus, errorThrown) { + if (options.error) options.error.call(self, jqXHR, textStatus, errorThrown); + }); }; -}; \ No newline at end of file +}; diff --git a/base/tps/shared/webapps/tps/js/audit.js b/base/tps/shared/webapps/tps/js/audit.js index 62e6b099e72f5ca48ab4c3b2decd01fa3c5c818b..cc0be46280f15aff14fa5aee8229af5b9f2756ef 100644 --- a/base/tps/shared/webapps/tps/js/audit.js +++ b/base/tps/shared/webapps/tps/js/audit.js @@ -44,24 +44,11 @@ var AuditModel = Model.extend({ } }; }, - enable: function(options) { + changeStatus: function(action, options) { var self = this; $.ajax({ type: "POST", - url: self.url() + "?action=enable", - dataType: "json" - }).done(function(data, textStatus, jqXHR) { - self.set(self.parseResponse(data)); - if (options.success) options.success.call(self, data, textStatus, jqXHR); - }).fail(function(jqXHR, textStatus, errorThrown) { - if (options.error) options.error.call(self, jqXHR, textStatus, errorThrown); - }); - }, - disable: function(options) { - var self = this; - $.ajax({ - type: "POST", - url: self.url() + "?action=disable", + url: self.url() + "?action=" + action, dataType: "json" }).done(function(data, textStatus, jqXHR) { self.set(self.parseResponse(data)); @@ -142,16 +129,16 @@ var AuditPage = EntryPage.extend({ AuditPage.__super__.setup.call(self); - self.enableLink = $("a[name='enable']", self.viewMenu); - self.disableLink = $("a[name='disable']", self.viewMenu); + self.enableAction = $("[name='enable']", self.viewMenu); + self.disableAction = $("[name='disable']", self.viewMenu); - self.enableLink.click(function(e) { + $("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.enable({ + self.model.changeStatus("enable", { success: function(data, textStatus, jqXHR) { self.entry = _.clone(self.model.attributes); self.render(); @@ -166,13 +153,13 @@ var AuditPage = EntryPage.extend({ }); }); - self.disableLink.click(function(e) { + $("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.disable({ + self.model.changeStatus("disable", { success: function(data, textStatus, jqXHR) { self.entry = _.clone(self.model.attributes); self.render(); @@ -204,12 +191,14 @@ var AuditPage = EntryPage.extend({ var status = self.entry.status; if (status == "Disabled") { - self.enableLink.show(); - self.disableLink.hide(); + self.editAction.show(); + self.enableAction.show(); + self.disableAction.hide(); - } else if (status == "Enabled") { - self.enableLink.hide(); - self.disableLink.show(); + } else { + self.editAction.hide(); + self.enableAction.hide(); + self.disableAction.show(); } if (self.mode == "edit") { diff --git a/base/tps/shared/webapps/tps/js/authenticator.js b/base/tps/shared/webapps/tps/js/authenticator.js index f91cf6bfeb3ad7046710cb227bf8c1a253b55926..b83838c67546e6f9c147d6a57bee3f80bc9f9769 100644 --- a/base/tps/shared/webapps/tps/js/authenticator.js +++ b/base/tps/shared/webapps/tps/js/authenticator.js @@ -38,24 +38,11 @@ var AuthenticatorModel = Model.extend({ } }; }, - enable: function(options) { + changeStatus: function(action, options) { var self = this; $.ajax({ type: "POST", - url: self.url() + "?action=enable", - dataType: "json" - }).done(function(data, textStatus, jqXHR) { - self.set(self.parseResponse(data)); - if (options.success) options.success.call(self, data, textStatus, jqXHR); - }).fail(function(jqXHR, textStatus, errorThrown) { - if (options.error) options.error.call(self, jqXHR, textStatus, errorThrown); - }); - }, - disable: function(options) { - var self = this; - $.ajax({ - type: "POST", - url: self.url() + "?action=disable", + url: self.url() + "?action=" + action, dataType: "json" }).done(function(data, textStatus, jqXHR) { self.set(self.parseResponse(data)); diff --git a/base/tps/shared/webapps/tps/js/config.js b/base/tps/shared/webapps/tps/js/config.js index 5b651a09d40279eb9d73c9fdf321fea8c67955e4..749821b3c6c8612ae41dc8c390baea9f79854f79 100644 --- a/base/tps/shared/webapps/tps/js/config.js +++ b/base/tps/shared/webapps/tps/js/config.js @@ -40,12 +40,72 @@ var ConfigModel = Model.extend({ } }); -var ConfigPage = ConfigEntryPage.extend({ +var ConfigPage = EntryPage.extend({ initialize: function(options) { var self = this; options.model = new ConfigModel(); - options.tableItem = PropertiesTableItem; - options.tableSize = 15; ConfigPage.__super__.initialize.call(self, options); + self.tableItem = options.tableItem || PropertiesTableItem; + self.tableSize = options.tableSize || 15; + }, + setup: function() { + var self = this; + + ConfigPage.__super__.setup.call(self); + + var dialog = self.$("#property-dialog"); + + var addDialog = new Dialog({ + el: dialog, + title: "Add Property", + actions: ["cancel", "add"] + }); + + var propertiesSection = self.$("[name='properties']"); + self.propertiesList = $("[name='list']", propertiesSection); + + self.propertiesTable = new PropertiesTable({ + el: self.propertiesList, + addDialog: addDialog, + tableItem: self.tableItem, + pageSize: self.tableSize, + parent: self + }); + }, + renderContent: function() { + var self = this; + + ConfigPage.__super__.renderContent.call(self); + + if (self.mode == "add") { + self.propertiesTable.mode = "edit"; + self.setProperties([]); + + } else if (self.mode == "edit") { + self.propertiesTable.mode = "edit"; + self.setProperties(self.entry.properties); + + } else { // self.mode == "view" + self.propertiesTable.mode = "view"; + self.setProperties(self.entry.properties); + } + }, + saveFields: function() { + var self = this; + + ConfigPage.__super__.saveFields.call(self); + + self.entry.properties = self.getProperties(); + }, + setProperties: function(properties) { + var self = this; + + self.propertiesTable.entries = properties; + self.propertiesTable.render(); + }, + getProperties: function() { + var self = this; + + return self.propertiesTable.entries; } }); diff --git a/base/tps/shared/webapps/tps/js/connector.js b/base/tps/shared/webapps/tps/js/connector.js index bc7e4c2bd371f2b6fa210bea39302d7cd21aaaa8..1095ecd741cd1f2d44bab9f56c625a32f4be44f8 100644 --- a/base/tps/shared/webapps/tps/js/connector.js +++ b/base/tps/shared/webapps/tps/js/connector.js @@ -38,24 +38,11 @@ var ConnectorModel = Model.extend({ } }; }, - enable: function(options) { + changeStatus: function(action, options) { var self = this; $.ajax({ type: "POST", - url: self.url() + "?action=enable", - dataType: "json" - }).done(function(data, textStatus, jqXHR) { - self.set(self.parseResponse(data)); - if (options.success) options.success.call(self, data, textStatus, jqXHR); - }).fail(function(jqXHR, textStatus, errorThrown) { - if (options.error) options.error.call(self, jqXHR, textStatus, errorThrown); - }); - }, - disable: function(options) { - var self = this; - $.ajax({ - type: "POST", - url: self.url() + "?action=disable", + url: self.url() + "?action=" + action, dataType: "json" }).done(function(data, textStatus, jqXHR) { self.set(self.parseResponse(data)); diff --git a/base/tps/shared/webapps/tps/js/profile-mapping.js b/base/tps/shared/webapps/tps/js/profile-mapping.js index 54c04256279b5e4fcb92e12cb5cb202644aa62f8..8df3b393ff149c5d51799e632a9cae95e3386146 100644 --- a/base/tps/shared/webapps/tps/js/profile-mapping.js +++ b/base/tps/shared/webapps/tps/js/profile-mapping.js @@ -38,24 +38,11 @@ var ProfileMappingModel = Model.extend({ } }; }, - enable: function(options) { + changeStatus: function(action, options) { var self = this; $.ajax({ type: "POST", - url: self.url() + "?action=enable", - dataType: "json" - }).done(function(data, textStatus, jqXHR) { - self.set(self.parseResponse(data)); - if (options.success) options.success.call(self, data, textStatus, jqXHR); - }).fail(function(jqXHR, textStatus, errorThrown) { - if (options.error) options.error.call(self, jqXHR, textStatus, errorThrown); - }); - }, - disable: function(options) { - var self = this; - $.ajax({ - type: "POST", - url: self.url() + "?action=disable", + url: self.url() + "?action=" + action, dataType: "json" }).done(function(data, textStatus, jqXHR) { self.set(self.parseResponse(data)); diff --git a/base/tps/shared/webapps/tps/js/profile.js b/base/tps/shared/webapps/tps/js/profile.js index 0454686a9993560909cd4d350488a2ac823fc769..0182a80632b61289e56a22da31ee8328a07853f8 100644 --- a/base/tps/shared/webapps/tps/js/profile.js +++ b/base/tps/shared/webapps/tps/js/profile.js @@ -38,24 +38,11 @@ var ProfileModel = Model.extend({ } }; }, - enable: function(options) { + changeStatus: function(action, options) { var self = this; $.ajax({ type: "POST", - url: self.url() + "?action=enable", - dataType: "json" - }).done(function(data, textStatus, jqXHR) { - self.set(self.parseResponse(data)); - if (options.success) options.success.call(self, data, textStatus, jqXHR); - }).fail(function(jqXHR, textStatus, errorThrown) { - if (options.error) options.error.call(self, jqXHR, textStatus, errorThrown); - }); - }, - disable: function(options) { - var self = this; - $.ajax({ - type: "POST", - url: self.url() + "?action=disable", + url: self.url() + "?action=" + action, dataType: "json" }).done(function(data, textStatus, jqXHR) { self.set(self.parseResponse(data)); @@ -94,6 +81,91 @@ var ProfilesTable = ModelTable.extend({ } }); +var ProfilePage = ConfigEntryPage.extend({ + renderContent: function() { + var self = this; + + ProfilePage.__super__.renderContent.call(self); + + var roles = tps.user.Roles.Role; + var status = self.entry.status; + + if (_.contains(roles, "Administrators")) { + + // admins can edit disabled entries + if (status == "Disabled") { + self.editAction.show(); + } else { + self.editAction.hide(); + } + + } else { + self.editAction.hide(); + } + + if (_.contains(roles, "TPS Agents")) { + + // agents can enable or disable entries + if (status == "Disabled") { + self.approveAction.hide(); + self.rejectAction.hide(); + self.enableAction.show(); + self.disableAction.hide(); + + } else if (status == "Enabled") { + self.approveAction.hide(); + self.rejectAction.hide(); + self.enableAction.hide(); + self.disableAction.show(); + + } else if (status == "Pending_Approval") { + self.approveAction.show(); + self.rejectAction.show(); + self.enableAction.hide(); + self.disableAction.hide(); + + } else { + self.approveAction.hide(); + self.rejectAction.hide(); + self.enableAction.hide(); + self.disableAction.hide(); + } + + self.submitAction.hide(); + self.cancelAction.hide(); + + } else if (_.contains(roles, "Administrators")) { + + // admins can submit or cancel entries + if (status == "Disabled") { + self.submitAction.show(); + self.cancelAction.hide(); + + } else if (status == "Pending_Approval") { + self.submitAction.hide(); + self.cancelAction.show(); + + } else { + self.submitAction.hide(); + self.cancelAction.hide(); + } + + self.approveAction.hide(); + self.rejectAction.hide(); + self.enableAction.hide(); + self.disableAction.hide(); + + } else { + self.enableAction.hide(); + self.disableAction.hide(); + self.approveAction.hide(); + self.rejectAction.hide(); + self.submitAction.hide(); + self.cancelAction.hide(); + } + } +}); + var ProfilesPage = Page.extend({ load: function() { var self = this; diff --git a/base/tps/shared/webapps/tps/js/token.js b/base/tps/shared/webapps/tps/js/token.js index 4cc3b5bcf01c77ca5cc479e5ee5e8bb293999bdd..f4d2d8a78e46b92fd1e0ae9a87136f0e63e3e2c8 100644 --- a/base/tps/shared/webapps/tps/js/token.js +++ b/base/tps/shared/webapps/tps/js/token.js @@ -110,9 +110,9 @@ var TokenPage = EntryPage.extend({ TokenPage.__super__.setup.call(self); - self.changeStatusLink = $("a[name='changeStatus']", self.viewMenu); + self.changeStatusAction = $("[name='changeStatus']", self.viewMenu); - self.changeStatusLink.click(function(e) { + $("a", self.changeStatusAction).click(function(e) { e.preventDefault(); @@ -154,9 +154,9 @@ var TokenPage = EntryPage.extend({ dialog.open(); }); - self.showCertsLink = $("a[name='showCerts']", self.viewMenu); + self.showCertsAction = $("[name='showCerts']", self.viewMenu); - self.showCertsLink.click(function(e) { + $("a", self.showCertsAction).click(function(e) { e.preventDefault(); window.location.hash = window.location.hash + "/certs"; @@ -168,9 +168,9 @@ var TokenPage = EntryPage.extend({ TokenPage.__super__.renderContent.call(self); if (self.mode == "add") { - self.changeStatusLink.hide(); + self.changeStatusAction.hide(); } else { - self.changeStatusLink.show(); + self.changeStatusAction.show(); } } }); diff --git a/base/tps/shared/webapps/tps/js/tps.js b/base/tps/shared/webapps/tps/js/tps.js index 85d1751eb7cb0e721f94d8619dc1a914f21464da..35fac3ec9e1cc8e01ccc4d54136ec8d3a29d0f15 100644 --- a/base/tps/shared/webapps/tps/js/tps.js +++ b/base/tps/shared/webapps/tps/js/tps.js @@ -146,16 +146,104 @@ var ConfigEntryPage = EntryPage.extend({ ConfigEntryPage.__super__.setup.call(self); - self.enableLink = $("a[name='enable']", self.viewMenu); - self.disableLink = $("a[name='disable']", self.viewMenu); + self.submitAction = $("[name='submit']", self.viewMenu); + self.cancelAction = $("[name='cancel']", self.viewMenu); + self.approveAction = $("[name='approve']", self.viewMenu); + self.rejectAction = $("[name='reject']", self.viewMenu); + self.enableAction = $("[name='enable']", self.viewMenu); + self.disableAction = $("[name='disable']", self.viewMenu); - self.enableLink.click(function(e) { + $("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(); + } + }); + }); + + $("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(); + } + }); + }); + + $("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(); + } + }); + }); + + $("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(); + } + }); + }); + + $("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.enable({ + self.model.changeStatus("enable", { success: function(data, textStatus, jqXHR) { self.entry = _.clone(self.model.attributes); self.render(); @@ -170,13 +258,13 @@ var ConfigEntryPage = EntryPage.extend({ }); }); - self.disableLink.click(function(e) { + $("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.disable({ + self.model.changeStatus("disable", { success: function(data, textStatus, jqXHR) { self.entry = _.clone(self.model.attributes); self.render(); @@ -199,12 +287,11 @@ var ConfigEntryPage = EntryPage.extend({ actions: ["cancel", "add"] }); - var table = self.$("table[name='properties']"); - self.addButton = $("button[name='add']", table); - self.removeButton = $("button[name='remove']", table); + var propertiesSection = self.$("[name='properties']"); + self.propertiesList = $("[name='list']", propertiesSection); self.propertiesTable = new PropertiesTable({ - el: table, + el: self.propertiesList, addDialog: addDialog, tableItem: self.tableItem, pageSize: self.tableSize, @@ -218,34 +305,50 @@ var ConfigEntryPage = EntryPage.extend({ var status = self.entry.status; if (status == "Disabled") { - self.enableLink.show(); - self.disableLink.hide(); + self.editAction.show(); + self.enableAction.show(); + self.disableAction.hide(); - } else if (status == "Enabled") { - self.enableLink.hide(); - self.disableLink.show(); + } else { + self.editAction.hide(); + self.enableAction.hide(); + self.disableAction.show(); } + self.submitAction.hide(); + self.cancelAction.hide(); + self.approveAction.hide(); + self.rejectAction.hide(); + if (self.mode == "add") { self.propertiesTable.mode = "edit"; - self.propertiesTable.entries = []; + self.setProperties([]); } else if (self.mode == "edit") { self.propertiesTable.mode = "edit"; - self.propertiesTable.entries = self.entry.properties; + self.setProperties(self.entry.properties); } else { // self.mode == "view" self.propertiesTable.mode = "view"; - self.propertiesTable.entries = self.entry.properties; + self.setProperties(self.entry.properties); } - - self.propertiesTable.render(); }, saveFields: function() { var self = this; ConfigEntryPage.__super__.saveFields.call(self); - self.entry.properties = self.propertiesTable.entries; + self.entry.properties = self.getProperties(); + }, + setProperties: function(properties) { + var self = this; + + self.propertiesTable.entries = properties; + self.propertiesTable.render(); + }, + getProperties: function() { + var self = this; + + return self.propertiesTable.entries; } }); diff --git a/base/tps/shared/webapps/tps/ui/audit.html b/base/tps/shared/webapps/tps/ui/audit.html index f9da85196df4a0a01f8ca9ebe0a1da6838ae5658..06457de62a6e2b0c5cb2f32faf7b8f55fac45e17 100644 --- a/base/tps/shared/webapps/tps/ui/audit.html +++ b/base/tps/shared/webapps/tps/ui/audit.html @@ -25,10 +25,11 @@ - -Edit
-EnableDisable
-
+