0001-Bug-537-Improved-the-context-section-making-it-more-.patch

patch - Hector Sanjuan, 03/21/2011 05:08 PM

Download (4.14 KB)

View differences:

src/sunstone/public/js/one-ui_views.js
1718 1718
				$('fieldset',section_context).toggle();
1719 1719
                return false;
1720 1720
		});
1721
              
1722
        $('#add_context_button', section_context).click(function(){
1723
            var name = $('#var_name',section_context).val();
1724
            var value = $('#var_value',section_context).val();
1725
            if (!name.length || !value.length) {
1726
                notifyError("Context variable name and value must be filled in");
1727
                return false;
1728
            }
1729
            option= '<option value=\''+value+'\' name=\''+name+'\'>'+
1730
            name+'='+value+
1731
            '</option>';
1732
            $('select#context_box',section_context).append(option);
1733
            return false; 
1734
        });
1735
        
1736
        $('#remove_context_button', section_context).click(function(){
1737
           box_remove_element(section_context,'#context_box');
1738
           return false; 
1739
        });
1721 1740

  
1722 1741
	};
1723 1742

  
......
1879 1898
		vm_json["GRAPHICS"] = {};
1880 1899
		addSectionJSON(vm_json["GRAPHICS"],scope);
1881 1900

  
1882
		//context -> include
1901
		//context
1883 1902
		scope = section_context;
1884
        var context = $('#CONTEXT',scope).val();
1885
        if (context)
1886
            vm_json["CONTEXT"] = context;
1903
        vm_json["CONTEXT"] = {};
1904
        var pair;
1905
        $('#context_box option',scope).each(function(){
1906
            name = $(this).attr("name");
1907
            value = $(this).val();
1908
            vm_json["CONTEXT"][name]=value;
1909
        });
1887 1910

  
1888 1911
		//placement -> fetch with value
1889 1912
		scope = section_placement;
src/sunstone/public/js/one-ui_views.templates.js
693 693
			  <!--context textarea? -->\
694 694
			  <div class="vm_section" id="context">\
695 695
			  	<div class="show_hide" id="add_context_cb">\
696
			  	  <h3>Add context <a id="add_context" class="icon_left" href="#"><span class="ui-icon ui-icon-plus" /></a></h3>\
696
			  	  <h3>Add context variables <a id="add_context" class="icon_left" href="#"><span class="ui-icon ui-icon-plus" /></a></h3>\
697 697
			    </div>\
698 698
			  <fieldset><legend>Context</legend>\
699
			  <div class="vm_param kvm_opt xen_opt">\
700
			  <label for="CONTEXT">Context:</label>\
701
			  <input type="text" id="CONTEXT" name="context" />\
702
			  <!--<textarea id="CONTEXT" style="width:320px;height:15em;"></textarea>-->\
703
			  </div>\
699
              <div class="vm_param kvm_opt xen_opt">\
700
				  <label for="var_name">Name:</label>\
701
				  <input type="text" id="var_name" name="var_name" />\
702
				  <div class="tip">Name for the context variable</div>\
703
			    </div>\
704
			    <div class="vm_param kvm_opt xen_opt">\
705
				  <label for="var_value">Value:</label>\
706
				  <input type="text" id="var_value" name="var_value" />\
707
				  <div class="tip">Value of the context variable</div>\
708
              </div>\
709
                <div class="">\
710
					<button class="add_remove_button add_button" id="add_context_button" value="add_context">Add</button>\
711
					<button class="add_remove_button" id="remove_context_button" value="remove_input">Remove selected</button>\
712
					<div class="clear"></div>\
713
					<label for="context_box">Current variables:</label>\
714
					<select id="context_box" name="context_box" style="width:150px;height:100px;" multiple>\
715
					</select>\
716
                </div>\
704 717
			  </fieldset>\
705 718
			  </div>\
706 719
\
707
-