From 58e546c1cc803dbe676b394bc1dac186130f055e Mon Sep 17 00:00:00 2001
From: "Endi S. Dewata" <edewata@redhat.com>
Date: Fri, 11 Apr 2014 14:25:40 -0400
Subject: [PATCH] Replaced self test dialog with self test page.

The dialog used to view self test attributes has been replaced with
a details page since it will be required for breadcrumbs. A new HTML
template has been added for this page.

Ticket #654
---
 base/tps-tomcat/shared/webapps/tps/js/selftest.js  | 47 +++++++++++++++++-----
 base/tps-tomcat/shared/webapps/tps/ui/index.html   |  2 +-
 .../tps-tomcat/shared/webapps/tps/ui/selftest.html | 37 +++++++++++++++++
 .../shared/webapps/tps/ui/selftests.html           | 25 ------------
 4 files changed, 76 insertions(+), 35 deletions(-)
 create mode 100644 base/tps-tomcat/shared/webapps/tps/ui/selftest.html

diff --git a/base/tps-tomcat/shared/webapps/tps/js/selftest.js b/base/tps-tomcat/shared/webapps/tps/js/selftest.js
index 89f18bcbf17a6ccc902c5da02f5c310debe22fc8..df8204e716cf252836c0c676ab5395274a84eba5 100644
--- a/base/tps-tomcat/shared/webapps/tps/js/selftest.js
+++ b/base/tps-tomcat/shared/webapps/tps/js/selftest.js
@@ -60,20 +60,49 @@ var SelfTestCollection = Collection.extend({
     }
 });
 
-var SelfTestPage = Page.extend({
+var SelfTestPage = EntryPage.extend({
+    initialize: function(options) {
+        var self = this;
+        SelfTestPage.__super__.initialize.call(self, options);
+        self.parentPage = options.parentPage;
+    },
+    close: function() {
+        var self = this;
+        if (self.parentPage) {
+            self.parentPage.open();
+        } else {
+            GroupPage.__super__.close.call(self);
+        }
+    }
+});
+
+var SelfTestsTable = ModelTable.extend({
+    initialize: function(options) {
+        var self = this;
+        SelfTestsTable.__super__.initialize.call(self, options);
+        self.parentPage = options.parentPage;
+    },
+    open: function(item, column) {
+        var self = this;
+
+        var page = new SelfTestPage({
+            el: self.parentPage.$el,
+            url: "selftest.html",
+            model: self.collection.get(item.entry.id)
+        });
+
+        page.open();
+    }
+});
+
+var SelfTestsPage = Page.extend({
     load: function() {
         var self = this;
 
-        var editDialog = new Dialog({
-            el: $("#selftest-dialog"),
-            title: "Edit Self Test",
-            readonly: ["id", "enabledAtStartup", "criticalAtStartup", "enabledOnDemand", "criticalOnDemand"]
-        });
-
-        var table = new ModelTable({
+        var table = new SelfTestsTable({
             el: $("table[name='selftests']"),
             collection: new SelfTestCollection(),
-            editDialog: editDialog
+            parentPage: self
         });
 
         table.render();
diff --git a/base/tps-tomcat/shared/webapps/tps/ui/index.html b/base/tps-tomcat/shared/webapps/tps/ui/index.html
index 391a11a0ae21264cd50df3109439f9f3e1216167..8de7e5bff711ba3b0eb7985acbcd5e6ea952f3a3 100644
--- a/base/tps-tomcat/shared/webapps/tps/ui/index.html
+++ b/base/tps-tomcat/shared/webapps/tps/ui/index.html
@@ -106,7 +106,7 @@ $(function() {
         url: "profile-mappings.html"
     }));
 
-    navigation.page("selftests", new SelfTestPage({
+    navigation.page("selftests", new SelfTestsPage({
         el: content,
         url: "selftests.html"
     }));
diff --git a/base/tps-tomcat/shared/webapps/tps/ui/selftest.html b/base/tps-tomcat/shared/webapps/tps/ui/selftest.html
new file mode 100644
index 0000000000000000000000000000000000000000..d61f056aaf5a12e905dc00e727a7ddd004339d01
--- /dev/null
+++ b/base/tps-tomcat/shared/webapps/tps/ui/selftest.html
@@ -0,0 +1,37 @@
+<!-- --- BEGIN COPYRIGHT BLOCK ---
+     This program is free software; you can redistribute it and/or modify
+     it under the terms of the GNU General Public License as published by
+     the Free Software Foundation; version 2 of the License.
+
+     This program is distributed in the hope that it will be useful,
+     but WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+     GNU General Public License for more details.
+
+     You should have received a copy of the GNU General Public License along
+     with this program; if not, write to the Free Software Foundation, Inc.,
+     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+     Copyright (C) 2014 Red Hat, Inc.
+     All rights reserved.
+     --- END COPYRIGHT BLOCK --- -->
+<div class="pki-header">
+
+<span class="pki-title">Self Test <span name="id"></span></span>
+
+</div>
+
+<div name="user" class="pki-fields">
+<fieldset>
+    <label>Self Test ID</label>
+    <input name="id" readonly="readonly"><br>
+    <label>Enabled at Startup</label>
+    <input name="enabledAtStartup" readonly="readonly"><br>
+    <label>Critical at Startup</label>
+    <input name="criticalAtStartup" readonly="readonly"><br>
+    <label>Enabled on Demand</label>
+    <input name="enabledOnDemand" readonly="readonly"><br>
+    <label>Critical on Demand</label>
+    <input name="criticalOnDemand" readonly="readonly"><br>
+</fieldset>
+</div>
diff --git a/base/tps-tomcat/shared/webapps/tps/ui/selftests.html b/base/tps-tomcat/shared/webapps/tps/ui/selftests.html
index c4d0edb33cb22a5e23e047d5685c0eb4c3485ddd..60796ca602f57ded47d0ddc16f03ada0c99db4d3 100644
--- a/base/tps-tomcat/shared/webapps/tps/ui/selftests.html
+++ b/base/tps-tomcat/shared/webapps/tps/ui/selftests.html
@@ -72,28 +72,3 @@
     </tr>
 </tfoot>
 </table>
-
-<div id="selftest-dialog" class="rcue-dialog-background">
-    <div class="rcue-dialog">
-        <header>
-            <h1>Self Test</h1>
-            <a class="rcue-button-close" href="#"></a>
-        </header>
-        <fieldset>
-            <label>Self Test ID</label>
-            <input name="id" readonly="readonly"><br>
-            <label>Enabled at Startup</label>
-            <input name="enabledAtStartup" readonly="readonly"><br>
-            <label>Critical at Startup</label>
-            <input name="criticalAtStartup" readonly="readonly"><br>
-            <label>Enabled on Demand</label>
-            <input name="enabledOnDemand" readonly="readonly"><br>
-            <label>Critical on Demand</label>
-            <input name="criticalOnDemand" readonly="readonly"><br>
-        </fieldset>
-        <footer>
-            <button name="save" class="primary">Save</button>
-            <button name="cancel">Cancel</button>
-        </footer>
-    </div>
-</div>
-- 
1.8.4.2

