incubator-deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@redhat.com
Subject [PATCH core] UI: Improved hardware profile selection
Date Tue, 11 Oct 2011 10:17:38 GMT
From: Michal Fojtik <mfojtik@redhat.com>


Signed-off-by: Michal fojtik <mfojtik@redhat.com>
---
 server/public/javascripts/application.js |    5 ++++
 server/public/stylesheets/new.css        |    4 +++
 server/views/instances/new.html.haml     |   33 ++++++++++++++++-------------
 3 files changed, 27 insertions(+), 15 deletions(-)

diff --git a/server/public/javascripts/application.js b/server/public/javascripts/application.js
index dc23e34..937690a 100644
--- a/server/public/javascripts/application.js
+++ b/server/public/javascripts/application.js
@@ -30,6 +30,11 @@ $(document).ready(function() {
 
 })
 
+function expandHWP(id) {
+  $('div.hwp_properties .property_block').appendTo('.hidden_content');
+  $('div#hwp_properties_'+id).hide().appendTo('div#property_container_'+id).fadeIn();
+}
+
 // NOTE: This code was copied from http://phpjs.org/functions/base64_encode:358
 // phpjs.org license it under the MIT and GPL licenses
 
diff --git a/server/public/stylesheets/new.css b/server/public/stylesheets/new.css
index 4590a46..085c382 100644
--- a/server/public/stylesheets/new.css
+++ b/server/public/stylesheets/new.css
@@ -51,3 +51,7 @@ form.link {
 p.right-float {
   float : right;
 }
+
+.hidden_content {
+  display : none;
+}
diff --git a/server/views/instances/new.html.haml b/server/views/instances/new.html.haml
index 7b98341..2347022 100644
--- a/server/views/instances/new.html.haml
+++ b/server/views/instances/new.html.haml
@@ -1,6 +1,22 @@
 =header "Launch new instance"
 =subheader "#{@image.id}"
 
+.hidden_content
+  - @hardware_profiles.each do |profile|
+    %div{ :'data-role' => :fieldcontain, :id => "hwp_properties_#{profile.name}", :class
=> 'property_block'}
+      - profile.properties.reject { |prop| prop.fixed? }.each do |prop|
+        %label{ :for => "#{prop.param}_#{profile.name}", :class => 'ui-input-text'
}=prop.name
+        %span.radio-group-details
+          - if prop.kind == :enum
+            %select{ :size => 1, :name => prop.param }
+              - for v in prop.values
+                %option= v
+                = prop.unit
+          - elsif prop.kind == :range
+            %input{ :type => :range, :value => prop.first, :min => prop.first, :max
=> prop.last, :name => prop.param}
+          - else
+            %input{ :name => prop.param, :size => 10, :value => "#{prop.default}"
}= prop.unit
+
 %div{ :'data-role' => :content, :'data-theme' => 'c', :class => 'middle-dialog'}
   %form{ :action => instances_url, :method => :post, :class => :new_instance, :'data-ajax'
=> 'false'}
     %input{ :name => :image_id, :type => :hidden, :value => @instance.image_id }/
@@ -59,21 +75,8 @@
         %fieldset{ :'data-role' => :fieldcontain}
           - @hardware_profiles.each do |profile|
             %input{ :type => :radio, :name => 'hwp_id', :value => profile.name,
:id => profile.name, :'data-theme' => 'b'}/
-            %label{ :for => profile.name}=profile.name
-            - profile.properties.reject { |prop| prop.fixed? }.each do |prop|
-              %div{ :'data-role' => :fieldcontain}
-                %label{ :for => "#{prop.param}_#{profile.name}", :class => 'ui-input-text'
}=prop.name
-                %span.radio-group-details
-                  - if prop.kind == :enum
-                    %select{ :size => 1, :name => prop.param }
-                      - for v in prop.values
-                        %option= v
-                    = prop.unit
-                  - elsif prop.kind == :range
-                    %input{ :type => :range, :value => prop.first, :min => prop.first,
:max => prop.last, :name => prop.param}
-                  - else
-                    %input{ :name => prop.param, :size => 10, :value => "#{prop.default}"
}
-                    = prop.unit
+            %label{ :for => profile.name, :onclick => "expandHWP('#{profile.name}');"}=profile.name
+            %div{ :'data-role' => :fieldcontain, :id => "property_container_#{profile.name}",
:class => 'hwp_properties'}
 
     - if !@realms.empty?
       %div{ 'data-role' => :fieldcontain }
-- 
1.7.4.4


Mime
View raw message