From 3556acab2be08df2e1851abb9d295aed5ae58626 Mon Sep 17 00:00:00 2001
From: "Endi S. Dewata" <edewata@redhat.com>
Date: Fri, 11 Apr 2014 14:10:18 -0400
Subject: [PATCH] Replaced group dialog with group page.

The dialog used to edit group 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/group.js    | 70 +++++++++++++++++------
 base/tps-tomcat/shared/webapps/tps/ui/group.html  | 44 ++++++++++++++
 base/tps-tomcat/shared/webapps/tps/ui/groups.html | 21 -------
 base/tps-tomcat/shared/webapps/tps/ui/index.html  |  2 +-
 4 files changed, 98 insertions(+), 39 deletions(-)
 create mode 100644 base/tps-tomcat/shared/webapps/tps/ui/group.html

diff --git a/base/tps-tomcat/shared/webapps/tps/js/group.js b/base/tps-tomcat/shared/webapps/tps/js/group.js
index feaaa435d21583f3642700aafb4ab710fdaac53c..81812b370145af43569111f3e5e83d0783e32f49 100644
--- a/base/tps-tomcat/shared/webapps/tps/js/group.js
+++ b/base/tps-tomcat/shared/webapps/tps/js/group.js
@@ -55,28 +55,64 @@ var GroupCollection = Collection.extend({
     }
 });
 
-var GroupPage = Page.extend({
+var GroupPage = EntryPage.extend({
+    initialize: function(options) {
+        var self = this;
+        GroupPage.__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 GroupsTable = ModelTable.extend({
+    initialize: function(options) {
+        var self = this;
+        GroupsTable.__super__.initialize.call(self, options);
+        self.parentPage = options.parentPage;
+    },
+    open: function(item, column) {
+        var self = this;
+
+        var page = new GroupPage({
+            el: self.parentPage.$el,
+            url: "group.html",
+            model: self.collection.get(item.entry.id),
+            editable: ["description"]
+        });
+
+        page.open();
+    },
+    add: function() {
+        var self = this;
+
+        var page = new GroupPage({
+            el: self.parentPage.$el,
+            url: "group.html",
+            model: new GroupModel(),
+            mode: "add",
+            editable: ["groupID", "description"],
+            parentPage: self.parentPage
+        });
+
+        page.open();
+    }
+});
+
+var GroupsPage = Page.extend({
     load: function() {
         var self = this;
 
-        var addDialog = new Dialog({
-            el: $("#group-dialog"),
-            title: "Add Group",
-            actions: ["cancel", "add"]
-        });
-
-        var editDialog = new Dialog({
-            el: $("#group-dialog"),
-            title: "Edit Group",
-            readonly: ["groupID"],
-            actions: ["cancel", "save"]
-        });
-
-        var table = new ModelTable({
+        var table = new GroupsTable({
             el: $("table[name='groups']"),
             collection: new GroupCollection(),
-            addDialog: addDialog,
-            editDialog: editDialog
+            parentPage: self
         });
 
         table.render();
diff --git a/base/tps-tomcat/shared/webapps/tps/ui/group.html b/base/tps-tomcat/shared/webapps/tps/ui/group.html
new file mode 100644
index 0000000000000000000000000000000000000000..a33969185ea4103be36d802d8a3956a9016272ea
--- /dev/null
+++ b/base/tps-tomcat/shared/webapps/tps/ui/group.html
@@ -0,0 +1,44 @@
+<!-- --- 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">Group <span name="id"></span></span>
+
+<span class="pki-actions">
+
+<span class="pki-menu" style="display: none;">
+<a name="edit" href="#">Edit</a><br>
+</span>
+
+<span class="pki-buttons" style="display: none;">
+<button name="cancel">Cancel</button>
+<button name="save" class="primary">Save</button>
+</span>
+
+</span>
+
+</div>
+
+<div name="group" class="pki-fields">
+<fieldset>
+    <label>Group ID</label>
+    <input name="groupID" readonly="readonly"><br>
+    <label>Description</label>
+    <input name="description" readonly="readonly"><br>
+</fieldset>
+</div>
diff --git a/base/tps-tomcat/shared/webapps/tps/ui/groups.html b/base/tps-tomcat/shared/webapps/tps/ui/groups.html
index ccf84bdfc842ac798ae161fd66afed32f010979b..34dacbc9b5b47a94a7599e5d7e7e1eb9700965eb 100644
--- a/base/tps-tomcat/shared/webapps/tps/ui/groups.html
+++ b/base/tps-tomcat/shared/webapps/tps/ui/groups.html
@@ -68,24 +68,3 @@
     </tr>
 </tfoot>
 </table>
-
-<div id="group-dialog" class="rcue-dialog-background">
-    <div class="rcue-dialog">
-        <header>
-            <h1>Group</h1>
-            <a class="rcue-button-close" href="#"></a>
-        </header>
-        <fieldset>
-            <label>Group ID</label>
-            <input name="groupID" readonly="readonly"><br>
-            <label>Description</label>
-            <input name="description" readonly="readonly"><br>
-        </fieldset>
-        <footer>
-            <button name="add" class="primary">Add</button>
-            <button name="save" class="primary">Save</button>
-            <button name="remove" class="primary">Remove</button>
-            <button name="cancel">Cancel</button>
-        </footer>
-    </div>
-</div>
diff --git a/base/tps-tomcat/shared/webapps/tps/ui/index.html b/base/tps-tomcat/shared/webapps/tps/ui/index.html
index 1d7a69b487e55d090e99d2f3b02c50412340b516..391a11a0ae21264cd50df3109439f9f3e1216167 100644
--- a/base/tps-tomcat/shared/webapps/tps/ui/index.html
+++ b/base/tps-tomcat/shared/webapps/tps/ui/index.html
@@ -91,7 +91,7 @@ $(function() {
         url: "connections.html"
     }));
 
-    navigation.page("groups", new GroupPage({
+    navigation.page("groups", new GroupsPage({
         el: content,
         url: "groups.html"
     }));
-- 
1.8.4.2

