From 4e41ddde813062abc99b6be2092f4d8689bcc59e Mon Sep 17 00:00:00 2001
From: Bence Dányi <madbence@gmail.com>
Date: Wed, 8 May 2013 13:43:37 +0200
Subject: [PATCH] firewall_gui: provide generic typeahead for model relationships

---
 firewall_gui/static/partials/host-edit.html      | 10 +++++-----
 firewall_gui/static/partials/rule-edit.html      |  2 +-
 firewall_gui/static/partials/vlan-edit.html      |  2 +-
 firewall_gui/static/partials/vlangroup-edit.html |  2 +-
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/firewall_gui/static/partials/host-edit.html b/firewall_gui/static/partials/host-edit.html
index 24f0fbb..e33485e 100644
--- a/firewall_gui/static/partials/host-edit.html
+++ b/firewall_gui/static/partials/host-edit.html
@@ -57,7 +57,7 @@
     <div class="control-group">
       <label class="control-label" for="vlan">Vlan</label>
       <div class="controls">
-        <input type="text" data-provide="typeahead" autocomplete="off" id="vlan" ng-model="entity.vlan.name" />
+        <input type="text" data-provide="typeahead" autocomplete="off" class="vlan" id="vlan" ng-model="entity.vlan.name" />
       </div>
     </div>
   </div>
@@ -87,14 +87,14 @@
       <label class="control-label" for="hostgroups">Host groups</label>
       <div class="controls">
         <div class="well well-small">
-          <span class="label label-info" ng-repeat="group in entity.groups">
+          <span class="label label-info" ng-repeat="group in entity.groups | filter: destroyed">
             <a href="#/hostgroups/{{group.id}}">{{group.name}}</a>
-            <a href><i class="icon-remove"></i></a>
+            <a href ng-click="removeHostGroup(group)"><i class="icon-remove"></i></a>
           </span>
         </div>
         <div class="input-append">
-          <input class="span2" id="hostgroup" type="text">
-          <button class="btn" type="button">Add</button>
+          <input class="span2 hostgroup" id="hostgroup" type="text" ng-model="newGroup">
+          <button class="btn" type="button" ng-click="addHostGroup(newGroup)">Add</button>
         </div>
       </div>
     </div>
diff --git a/firewall_gui/static/partials/rule-edit.html b/firewall_gui/static/partials/rule-edit.html
index a76fe4b..b54d0bd 100644
--- a/firewall_gui/static/partials/rule-edit.html
+++ b/firewall_gui/static/partials/rule-edit.html
@@ -60,7 +60,7 @@
     <div class="control-group">
       <label class="control-label" for="foreignNetwork">Foreign network</label>
       <div class="controls">
-        <input type="text" data-provide="typeahead" autocomplete="off" id="foreignNetwork" ng-model="entity.foreignNetwork.name" />
+        <input type="text" data-provide="typeahead" autocomplete="off" id="foreignNetwork" class="vlangroup" ng-model="entity.foreignNetwork.name" />
       </div>
     </div>
   </div>
diff --git a/firewall_gui/static/partials/vlan-edit.html b/firewall_gui/static/partials/vlan-edit.html
index ccc18be..0da50d3 100644
--- a/firewall_gui/static/partials/vlan-edit.html
+++ b/firewall_gui/static/partials/vlan-edit.html
@@ -65,7 +65,7 @@
     <div class="control-group">
       <label class="control-label" for="domain">Domain</label>
       <div class="controls">
-        <input type="text" autocomplete="off" id="domain" ng-model="entity.domain.name" />
+        <input type="text" class="domain" data-provide="typeahead" autocomplete="off" id="domain" ng-model="entity.domain.name" />
       </div>
     </div>
     <div class="control-group">
diff --git a/firewall_gui/static/partials/vlangroup-edit.html b/firewall_gui/static/partials/vlangroup-edit.html
index 8e59f05..5ebb7e3 100644
--- a/firewall_gui/static/partials/vlangroup-edit.html
+++ b/firewall_gui/static/partials/vlangroup-edit.html
@@ -49,7 +49,7 @@
           </span>
         </div>
         <div class="input-append">
-          <input class="span2" id="vlan" type="text">
+          <input class="span2 vlan" id="vlan" type="text" data-provide="typeahead">
           <button class="btn" type="button">Add</button>
         </div>
       </div>
--
libgit2 0.26.0