incubator-deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lut...@apache.org
Subject svn commit: r1160499 - in /incubator/deltacloud/trunk/server: public/javascripts/application.js views/firewalls/new_rule.html.haml
Date Mon, 22 Aug 2011 23:25:37 GMT
Author: lutter
Date: Mon Aug 22 23:25:37 2011
New Revision: 1160499

URL: http://svn.apache.org/viewvc?rev=1160499&view=rev
Log:
views (firewalls/new_rule): fix the new_rule form

The form had two problems:

  * the source fields (address/group) were generated outside the <form> tag
    and hence the fields were never submitted
  * the names for the port_from and port_to fields were incorrect

Modified:
    incubator/deltacloud/trunk/server/public/javascripts/application.js
    incubator/deltacloud/trunk/server/views/firewalls/new_rule.html.haml

Modified: incubator/deltacloud/trunk/server/public/javascripts/application.js
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/public/javascripts/application.js?rev=1160499&r1=1160498&r2=1160499&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/public/javascripts/application.js (original)
+++ incubator/deltacloud/trunk/server/public/javascripts/application.js Mon Aug 22 23:25:37
2011
@@ -108,33 +108,27 @@ var addresses = 0;
 var groups = 0;
 function make_fields(type)
 {
-  form = document.getElementById("new_rule_form")
-  button = document.getElementById("submit_button")
-  if(type == "address")
+  if (type == "address")
   {
     name = "ip_address" + eval(++addresses)
-    create_rule_source_field(name, "Address " + eval(addresses) + " [use CIDR notation 0.0.0.0/0]",
form, button)
+    create_rule_source_field(name, "Address " + eval(addresses),
+                             "[use CIDR notation 0.0.0.0/0]")
   }
-  else if(type == "group")
+  else if (type == "group")
   {
     name = "group" + eval(++groups)
-    create_rule_source_field(name, "Name of group " + eval(groups), form, button)
+    create_rule_source_field(name, "Name of group " + eval(groups), "")
     name = "group" + eval(groups) + "owner"
-    create_rule_source_field(name, "Group " + eval(groups) + " owner (required)", form, button)
+    create_rule_source_field(name, "Group " + eval(groups) + " owner", "(required)")
   }
 }
 
-function create_rule_source_field(name, label, form, button)
+function create_rule_source_field(name, label, hint)
 {
-    element = document.createElement("INPUT")
-    element.type = "input"
-    element.size = 35
-    element.name = name
-    text = document.createTextNode(label)
-    form.insertBefore(element, button)
-    form.insertBefore(text, element)
-    form.insertBefore(document.createElement('BR'), element)
-    form.insertBefore(document.createElement('BR'), button)
-    form.insertBefore(document.createElement('BR'), button)
-    form.insertBefore(document.createElement('BR'), button)
+  html = "<br/>" +
+    "<label>" + label + "</label>&nbsp;" +
+    "<input name='" + name + "' size=35 type='text'/>" +
+    "<span>&nbsp;" + hint + "</span>"
+
+  $(html).insertBefore("#new_rule_form_fields")
 }

Modified: incubator/deltacloud/trunk/server/views/firewalls/new_rule.html.haml
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/views/firewalls/new_rule.html.haml?rev=1160499&r1=1160498&r2=1160499&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/views/firewalls/new_rule.html.haml (original)
+++ incubator/deltacloud/trunk/server/views/firewalls/new_rule.html.haml Mon Aug 22 23:25:37
2011
@@ -7,13 +7,14 @@
       %input{ :type => :text, :id => :protocol, :name => :protocol, :value =>
'', :size => 10 }
     %div{ 'data-role' => :fieldcontain }
       %label{ :for => :name} From port:
-      %input{ :type => :text, :id => :from_port, :name => :from_port, :value =>
'', :size => 10 }
+      %input{ :type => :text, :id => :port_from, :name => :port_from, :value =>
'', :size => 10 }
     %div{ 'data-role' => :fieldcontain }
       %label{ :for => :name} To port:
-      %input{ :type => :text, :id => :to_port, :name => :to_port, :value => '',
:size => 10 }
+      %input{ :type => :text, :id => :port_to, :name => :port_to, :value => '',
:size => 10 }
     %div{ 'data-role' => :fieldcontain }
       %a{ :href => "javascript:;", :onclick => "make_fields('address');"} Add source
IP address
       %br
       %a{ :href => "javascript:;", :onclick => "make_fields('group');"} Add source
group
+      %br
+      #new_rule_form_fields
     %button{ :type => :submit} Create
-



Mime
View raw message