]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-1794: Handle a new type of "text" property value in the Quality Profile service
authorGodin <mandrikov@gmail.com>
Thu, 4 Nov 2010 11:26:13 +0000 (11:26 +0000)
committerGodin <mandrikov@gmail.com>
Thu, 4 Nov 2010 11:26:13 +0000 (11:26 +0000)
sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_rule_param.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/index.html.erb

index 9428a80b60a16ef902f31f6f26501a17a1a0e7d7..c695a0218b7b8a350fd3c969b7615575c65f4ee0 100644 (file)
         <%= form_remote_tag :url => {:action => 'update_param', :id => active_param_id, :profile_id => profile.id, :param_id => parameter.id, :active_rule_id => active_rule_id},
             :update => "param_#{parameter.id}",
             :loading => "$('param_loading_#{parameter.id}').show();" %>
-        <input name="value" type="text" size="<%= parameter.input_box_size -%>" value="<%= h param_value -%>" <%= 'disabled' unless active_rule && enable_modification %> />
-        <% if active_rule && enable_modification %>
+
+        <% span_id = "text_#{parameter.id}" %>
+        <% read_only = !active_rule || !enable_modification %>
+        <% textfield = text_field_tag parameter.id, param_value, :size => parameter.input_box_size, :name => "value", :disabled => read_only %>
+        <% textfield += link_to_function(image_tag("zoom.png"), "replaceTextField('#{span_id}', '#{parameter.id}')", :id => "toggle_text", :class => 'nolink') unless read_only %>
+        <% textarea = text_area_tag parameter.id, param_value, :size => "100x10", :name => "value", :disabled => read_only %>
+        <% textarea += "<br/>" %>
+        <span id="<%= span_id %>"><%= (param_value.length < 50) ? textfield : textarea %></span>
+
+        <% if !read_only %>
             <%= submit_tag 'update' %>
             <img src="<%= ApplicationController.root_context -%>/images/loading.gif" style="display:none;" id="param_loading_<%= parameter.id -%>">
             <% if active_parameter and active_parameter.errors.size>0 %>
index f185119243108c81a9823d921a0f2f24c9313970..64534a0049c5dcf2ecf9c7220bea78fe42220858 100644 (file)
 <% end %>
 </tbody>
 </table>
+<script type="text/javascript">
+    function replaceTextField(span_id, key) {
+      var text_field_value = $F(key);
+      var text_area = '<textarea cols="100" id="' + key + '" name="value" rows="10">' + text_field_value + '</textarea><br/>';
+      $(span_id).replace(text_area);
+    }
+</script>