aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2010-11-05 14:12:34 +0000
committersimonbrandhof <simon.brandhof@gmail.com>2010-11-05 14:12:34 +0000
commit5138d2d7772ec1e41faa39d12fa94bf98a4dd667 (patch)
treebd0c259fe475f6709880458483435177c7c0ecf2
parent08ccd27af288390ae9da2c8161bc608f04b470b3 (diff)
downloadsonarqube-5138d2d7772ec1e41faa39d12fa94bf98a4dd667.tar.gz
sonarqube-5138d2d7772ec1e41faa39d12fa94bf98a4dd667.zip
fix edition of dashboard properties
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_configure_widget.html.erb109
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget_properties.html.erb33
3 files changed, 76 insertions, 68 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb
index 289bb1b7138..16ce6551bac 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb
@@ -135,7 +135,7 @@ class DashboardController < ApplicationController
widget.configured=false
widget.save
render :update do |page|
- page.alert('errors ' + errors_by_property_key.inspect)
+ page.replace_html "widget_props_#{widget.id}", :partial => 'dashboard/widget_properties', :locals => {:widget => widget, :definition => definition, :errors_by_property_key => errors_by_property_key}
end
end
end
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_configure_widget.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_configure_widget.html.erb
index 86472f3de6b..0a26417284d 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_configure_widget.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_configure_widget.html.erb
@@ -1,73 +1,48 @@
-<%
- begin
- widget_body=render :inline => definition.getTarget().getTemplate(), :locals => {:widget_properties => widget.properties_as_hash, :widget => widget, :dashboard => @dashboard}
- rescue => error
- logger.error("Can not render widget #{definition.getId()}: " + error)
- logger.error(error.backtrace.join("\n"))
- widget_body=""
- end
-%>
+ <%
+ begin
+ widget_body=render :inline => definition.getTarget().getTemplate(), :locals => {:widget_properties => widget.properties_as_hash, :widget => widget, :dashboard => @dashboard}
+ rescue => error
+ logger.error("Can not render widget #{definition.getId()}: " + error)
+ logger.error(error.backtrace.join("\n"))
+ widget_body=""
+ end
+ %>
-<div class="handle" style="//overflow:hidden;//zoom:1;">
- <%= definition.getTitle() -%>
- <a class="block-remove" onclick="portal.deleteWidget(this);return false;">Delete</a>
- <% if definition.isEditable() %>
- <a class="block-view-toggle" onclick="portal.editWidget(<%= widget.id -%>);return false;">Edit</a>
- <% end %>
-</div>
+ <div class="handle" style="//overflow:hidden;//zoom:1;">
+ <%= definition.getTitle() -%>
+ <a class="block-remove" onclick="portal.deleteWidget(this);return false;">Delete</a>
+ <% if definition.isEditable() %>
+ <a class="block-view-toggle" onclick="portal.editWidget(<%= widget.id -%>);return false;">Edit</a>
+ <% end %>
+ </div>
-<div class="widget_props" id="widget_props_<%= widget.id -%>" style="<%= 'display:none' if widget.configured -%>">
- <% form_remote_tag :url => {:action => 'save_widget', :wid => widget.id, :id => params[:id]}, :method => :post do -%>
- <table class="form">
- <tbody>
- <% definition.getWidgetProperties().each do |property_def|
- value=widget.property_value(property_def.key(), property_def.defaultValue())
- %>
- <tr>
- <td valign="top" nowrap><b><%= property_def.key() -%></b><%= "*" unless property_def.optional()==true -%>: </td>
- <td id="row_<%= property_def.key() -%>">
- <%= property_value_field(property_def, value) -%>
- <span class="note"><%= property_def.description() -%></span>
- </td>
- </tr>
- <% end %>
- <tr>
- <td colspan="2">
- <%= submit_tag 'Save' %>
- <% if widget.configured %>
- <a href="#" onClick="portal.cancelEditWidget(<%= widget.id -%>);return false;">Cancel</a>
- <% end %>
- </td>
- </tr>
- </tbody>
- </table>
- <%= hidden_field_tag "widgetid", "", :class => "widgetid" %>
-<% end -%>
-</div>
+ <div class="widget_props" id="widget_props_<%= widget.id -%>" style="<%= 'display:none' if widget.configured -%>">
+ <%= render :partial => 'dashboard/widget_properties', :locals => {:widget => widget, :definition => definition} -%>
+ </div>
-<div id="widget_<%= widget.id -%>" class="configure_widget <%= definition.getId() -%>" style="height:100%;<%= 'display:none;' if !widget.configured -%>">
- <!--[if lte IE 6]>
- <style type="text/css">
- #dashboard .block .content .transparent {
- display: none;
- }
- </style>
- <![endif]-->
-<div class="transparent"></div>
- <% if widget_body.include? '<' %>
- <%
- default_layout=(definition.getWidgetLayout().name()=='DEFAULT')
- if default_layout
- %>
- <div class="widget">
- <% end %>
- <%= widget_body -%>
- <% if default_layout %><div class="clear"> </div></div><% end %>
- <% else %>
- <div class="widget"><p>No data</p></div>
- <% end %>
-<div style="clear: both;"></div>
-</div>
+ <div id="widget_<%= widget.id -%>" class="configure_widget <%= definition.getId() -%>" style="height:100%;<%= 'display:none;' if !widget.configured -%>">
+ <!--[if lte IE 6]>
+ <style type="text/css">
+ #dashboard .block .content .transparent {
+ display: none;
+ }
+ </style>
+ <![endif]-->
+ <div class="transparent"></div>
+ <% if widget_body.include? '<' %>
+ <%
+ default_layout=(definition.getWidgetLayout().name()=='DEFAULT')
+ if default_layout
+ %>
+ <div class="widget">
+ <% end %>
+ <%= widget_body -%>
+ <% if default_layout %><div class="clear"> </div></div><% end %>
+ <% else %>
+ <div class="widget"><p>No data</p></div>
+ <% end %>
+ <div style="clear: both;"></div>
+ </div>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget_properties.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget_properties.html.erb
new file mode 100644
index 00000000000..a1a5d8ae52a
--- /dev/null
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget_properties.html.erb
@@ -0,0 +1,33 @@
+<% form_remote_tag :url => {:action => 'save_widget', :wid => widget.id, :id => params[:id]}, :method => :post do -%>
+ <% if defined?(errors_by_property_key) && errors_by_property_key %>
+ <ul>
+ <% errors_by_property_key.each_pair do |property_key, error| %>
+ <li class="error"><%= property_key -%>: <%= h(error)-%></li>
+ </ul>
+ <% end %>
+ <% end %>
+ <table class="form width100">
+ <tbody>
+ <% definition.getWidgetProperties().each do |property_def|
+ value=widget.property_value(property_def.key(), property_def.defaultValue())
+ %>
+ <tr>
+ <td valign="top" class="thin nowrap"><b><%= property_def.key() -%></b><%= "*" unless property_def.optional()==true -%>: </td>
+ <td id="row_<%= property_def.key() -%>">
+ <%= property_value_field(property_def, value) -%>
+ <span class="note"><%= property_def.description() -%></span>
+ </td>
+ </tr>
+ <% end %>
+ <tr>
+ <td colspan="2">
+ <%= submit_tag 'Save' %>
+ <% if widget.configured %>
+ <a href="#" onClick="portal.cancelEditWidget(<%= widget.id -%>);return false;">Cancel</a>
+ <% end %>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ <%= hidden_field_tag "widgetid", "", :class => "widgetid" %>
+<% end -%> \ No newline at end of file