]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-1927 Dashboard and Detached controller and views are now almost the same
authorDavid Gageot <david@gageot.net>
Thu, 3 May 2012 13:34:35 +0000 (15:34 +0200)
committerDavid Gageot <david@gageot.net>
Thu, 3 May 2012 14:00:31 +0000 (16:00 +0200)
16 files changed:
sonar-server/src/main/webapp/WEB-INF/app/helpers/dashboard_helper.rb
sonar-server/src/main/webapp/WEB-INF/app/helpers/detached_helper.rb [new file with mode: 0644]
sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_header.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget_definition.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/configure.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/edit_layout.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/detached/_configure_widget.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/detached/_header.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/detached/_widget.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/detached/_widget_definition.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/detached/_widget_definitions.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/detached/_widget_properties.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/detached/configure.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/detached/edit_layout.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/detached/no_dashboard.html.erb [new file with mode: 0644]

index a5082f7087c998c517db138ee87ba1fd607735ac..0688adfd6435b0ecbe449facc4c251e733fa025d 100644 (file)
@@ -21,59 +21,63 @@ module DashboardHelper
   include WidgetPropertiesHelper
   include MetricsHelper
 
+  def dashboard_action(action_name, opts={})
+    { :action => action_name, :did => @dashboard.id, :id => @resource.id }.merge!(opts)
+  end
+
   def formatted_value(measure, default='')
-    measure ? measure.formatted_value : default
+       measure ? measure.formatted_value : default
   end
 
   def measure(metric_key)
-    @snapshot.measure(metric_key)
+       @snapshot.measure(metric_key)
   end
 
   def period_select_options(snapshot, index)
-    label=period_label(snapshot, index)
-    if label
-      selected=(params[:period]==index.to_s ? 'selected' : '')
-      "<option value='#{index}' #{selected}>&Delta; #{label}</option>"
-    else
-      nil
-    end
+       label=period_label(snapshot, index)
+       if label
+         selected=(params[:period]==index.to_s ? 'selected' : '')
+         "<option value='#{index}' #{selected}>&Delta; #{label}</option>"
+       else
+         nil
+       end
   end
 
   def violation_period_select_options(snapshot, index)
-    return nil if snapshot.nil? || snapshot.project_snapshot.nil?
-    mode=snapshot.project_snapshot.send "period#{index}_mode"
-    mode_param=snapshot.project_snapshot.send "period#{index}_param"
-    date=snapshot.project_snapshot.send "period#{index}_date"
+       return nil if snapshot.nil? || snapshot.project_snapshot.nil?
+       mode=snapshot.project_snapshot.send "period#{index}_mode"
+       mode_param=snapshot.project_snapshot.send "period#{index}_param"
+       date=snapshot.project_snapshot.send "period#{index}_date"
 
-    if mode
-      if mode=='days'
-        label = message('added_over_x_days', :params => mode_param.to_s)
-      elsif mode=='version'
-        label = message('added_since_version', :params => mode_param.to_s)
-      elsif mode=='previous_analysis'
-        if !date.nil?
-          label = message('added_since_previous_analysis_detailed', :params => date.strftime("%Y %b. %d").to_s)
-        else
-          label = message('added_since_previous_analysis')
-        end
-      elsif mode=='date'
-        label = message('added_since', :params => date.strftime("%Y %b %d").to_s)
-      end
-      if label
-        selected=(params[:period]==index.to_s ? 'selected' : '')
-        "<option value='#{index}' #{selected}>#{label}</option>"
-      end
-    else
-      nil
-    end
+       if mode
+         if mode=='days'
+               label = message('added_over_x_days', :params => mode_param.to_s)
+         elsif mode=='version'
+               label = message('added_since_version', :params => mode_param.to_s)
+         elsif mode=='previous_analysis'
+               if !date.nil?
+                 label = message('added_since_previous_analysis_detailed', :params => date.strftime("%Y %b. %d").to_s)
+               else
+                 label = message('added_since_previous_analysis')
+               end
+         elsif mode=='date'
+               label = message('added_since', :params => date.strftime("%Y %b %d").to_s)
+         end
+         if label
+               selected=(params[:period]==index.to_s ? 'selected' : '')
+               "<option value='#{index}' #{selected}>#{label}</option>"
+         end
+       else
+         nil
+       end
 
   end
 
   def measure_or_variation_value(measure)
-    if measure
-      @period_index ? measure.variation(@period_index) : measure.value
-    else
-      nil
-    end
+       if measure
+         @period_index ? measure.variation(@period_index) : measure.value
+       else
+         nil
+       end
   end
-end
\ No newline at end of file
+end
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/detached_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/detached_helper.rb
new file mode 100644 (file)
index 0000000..0dbdb73
--- /dev/null
@@ -0,0 +1,24 @@
+#
+# Sonar, entreprise quality control tool.
+# Copyright (C) 2008-2012 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# Sonar is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 3 of the License, or (at your option) any later version.
+#
+# Sonar is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with Sonar; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
+#
+module DetachedHelper
+  def dashboard_action(action_name, opts={})
+    { :action => action_name, :id => @dashboard.id }.merge!(opts)
+  end
+end
index 2d45e7756bb61bf44694357201335d59002241c9..4b380a85f580c549d936ef3b6b50655c7ed559cb 100644 (file)
@@ -2,11 +2,11 @@
 <% if logged_in? %>
   <ul class="operations">
     <% if back %>
-      <li class="last"><%= link_to message('dashboard.back_to_dashboard'), {:action => 'index', :did => @dashboard.id, :id => @resource.id } -%></li>
+      <li class="last"><%= link_to message('dashboard.back_to_dashboard'), dashboard_action(:index) -%></li>
     <% else %>
     <% if @dashboard.editable_by?(current_user) %>
-      <li><%= link_to message('dashboard.configure_widgets'), {:action => 'configure', :did => @dashboard.id, :id => @resource.id } -%></li>
-      <li><%= link_to message('dashboard.edit_layout'), {:action => 'edit_layout', :did => @dashboard.id, :id => @resource.id } -%></li>
+      <li><%= link_to message('dashboard.configure_widgets'), dashboard_action(:configure) -%></li>
+      <li><%= link_to message('dashboard.edit_layout'), dashboard_action(:edit_layout) -%></li>
       <% end %>
       <li class="last"><%= link_to message('dashboard.manage_dashboards'), {:controller => 'dashboards', :action => 'index', :resource => @resource.id } -%></li>
     <% end %>
index a2beaac861c04838181256fd7792f30a9292218a..79e4460e94164a4b6e12b2ae2d9fd61316967011 100644 (file)
@@ -27,9 +27,9 @@
   <% else %>
     <div class="widget">
       <p>
-        <a href="<%= url_for :action => :configure, :did => @dashboard.id, :id => @resource.id -%>"><%= message('dashboard.please_configure_the_widget_x', :params => widget.java_definition.getTitle()) -%></a>
+        <a href="<%= url_for(dashboard_action(:configure, :id => @dashboard.id)) -%>"><%= message('dashboard.please_configure_the_widget_x', :params => widget.java_definition.getTitle()) -%></a>
       </p>
     </div>
   <% end %>
   <div style="clear: both;"></div>
-</div>
\ No newline at end of file
+</div>
index 698515778704f7ed304a67836416bd555796326f..d26ecd1e825b6675ae1321b6bf69a16e5356f841 100644 (file)
@@ -3,9 +3,9 @@
     <p><b><%= h message('widget.' + definition.getId() + '.name', :default => definition.getTitle()) -%></b></p>
 
     <p><%= h message('widget.' + definition.getId() + '.description', :default => definition.getDescription()) -%></p>
-    <%= form_tag :action => 'add_widget', :did => dashboard_id, :id => resource_id, :widget => definition.getId() %>
-    <input type="hidden" name="category" value="<%= category -%>">
-    <input type="submit" value="<%= message('dashboard.add_widget') -%>" id="add-widget-<%= u(definition.getId()) -%>">
-    </form>
+    <% form_tag dashboard_action(:add_widget, :widget => definition.getId()) do -%>
+      <input type="hidden" name="category" value="<%= category -%>">
+      <input type="submit" value="<%= message('dashboard.add_widget') -%>" id="add-widget-<%= u(definition.getId()) -%>">
+    <% end -%>
   </div>
 </td>
index dd08b02822a01d7337fe446e5d42fe2244a57eba..66843e2872bf3d8a56334f72dbabc13dfeb3ff50 100644 (file)
@@ -14,7 +14,7 @@
     highlight_duration:2,
     highlight_startcolor:'#cae3f2',
     highlight_endcolor:'#ffffff',
-    saveurl:'<%= url_for :action => 'set_dashboard', :did => @dashboard.id, :id => @resource.id -%>'
+    saveurl:'<%= url_for dashboard_action(:set_dashboard) -%>'
   };
   var portal;
   function init_dashboard() {
index c1039f85f5b0c66d631112ef2732188deda70e40..cd3f8269ce5938df98feb8bd5f8bccca5b098d2f 100644 (file)
@@ -2,27 +2,19 @@
   <%= render :partial => 'header', :locals => {:back => true} %>
 
   <div id="edit-layout" class="admin">
-      <p class="note"><%= message('dashboard.click_to_choose_layout') -%>: </p><br/>
+    <p class="note"><%= message('dashboard.click_to_choose_layout') -%>: </p><br/>
 
-      <div class="select-layout <%= 'selected' if @dashboard.layout=='100%' -%>" style="text-align:center;width: 20%;">
-        <%= link_to image_tag('layout100.png'), {:action => 'set_layout', :did => @dashboard.id, :id => @resource.id, :layout => "100%"}, :method => :post %>
+    <% {'100%', 'layout100.png',
+        '50%-50%', 'layout5050.png',
+        '30%-70%', 'layout3070.png',
+        '70%-30%', 'layout7030.png',
+        '33%-33%-33%', 'layout333333.png'
+       }.each_pair do |layout, picto| %>
+      <div class="select-layout <%= 'selected' if @dashboard.layout==layout -%>" style="text-align:center;width: 20%;">
+        <%= link_to image_tag(picto), dashboard_action(:set_layout, :layout => layout), :method => :post %>
       </div>
+    <% end %>
 
-      <div class="select-layout <%= 'selected' if @dashboard.layout=="50%-50%" -%>"  style="text-align:center;width: 20%;">
-        <%= link_to image_tag('layout5050.png'), {:action => 'set_layout', :did => @dashboard.id, :id => @resource.id, :layout => "50%-50%"}, :method => :post %>
-      </div>
-
-      <div class="select-layout <%= 'selected' if @dashboard.layout=="30%-70%" -%>"  style="text-align:center;width: 20%;">
-        <%= link_to image_tag('layout3070.png'), {:action => 'set_layout', :did => @dashboard.id, :id => @resource.id, :layout => "30%-70%"}, :method => :post %>
-      </div>
-
-      <div class="select-layout <%= 'selected' if @dashboard.layout=="70%-30%" -%>" style="text-align:center;width: 20%;">
-        <%= link_to image_tag('layout7030.png'), {:action => 'set_layout', :did => @dashboard.id, :id => @resource.id, :layout => "70%-30%"}, :method => :post %>
-      </div>
-
-      <div class="select-layout <%= 'selected' if @dashboard.layout=="33%-33%-33%" -%>" style="text-align:center;width: 19%;">
-        <%= link_to image_tag('layout333333.png'), {:action => 'set_layout', :did => @dashboard.id, :id => @resource.id, :layout => "33%-33%-33%"}, :method => :post %>
-      </div>
-      <div style="clear:both;"></div>
+    <div style="clear:both;"></div>
   </div>
 </div>
index c32dd623af49f572e01dbc2897751e08eff30759..6fd94a29e6fbaacb0a82c52257eefb09d9595936 100644 (file)
@@ -11,7 +11,7 @@
 <div class="widget-header">
   <div class="widget-actions">
     <% if widget.java_definition.isEditable() %>
-        <a class="link-action" onclick="portal.editWidget(<%= widget.id -%>);return false;"><%= message('edit') -%></a>
+      <a class="link-action" onclick="portal.editWidget(<%= widget.id -%>);return false;"><%= message('edit') -%></a>
     <% end %>
     <a class="link-action" onclick="portal.deleteWidget(this);return false;"><%= message('delete') -%></a>
   </div>
 <div id="widget_<%= widget.id -%>" class="configure_widget <%= h widget.java_definition.getId() -%>" style="height:100%;<%= 'display:none;' if !widget.configured -%>">
   <!--[if lte IE 6]>
   <style type="text/css">
-      #dashboard .block .content .transparent {
-          display: none;
-      }
+    #dashboard .block .content .transparent {
+      display: none;
+    }
   </style>
   <![endif]-->
   <div class="transparent"></div>
   <% if widget_body.include? '<' %>
-      <%
-         default_layout=(widget.layout=='DEFAULT')
-         if default_layout
-      %>
-          <div class="widget">
-      <% end %>
-      <%= widget_body -%>
-      <% if default_layout %>
-          <div class="clear"></div>
-          </div>
-      <% end %>
+    <%
+       default_layout=(widget.layout=='DEFAULT')
+       if default_layout
+    %>
+      <div class="widget">
+    <% end %>
+    <%= widget_body -%>
+    <% if default_layout %>
+      <div class="clear"></div>
+      </div>
+    <% end %>
   <% else %>
-      <div class="widget"><p><%= message('no_data') -%></p></div>
+    <div class="widget"><p><%= message('no_data') -%></p></div>
   <% end %>
   <div style="clear: both;"></div>
 </div>
index 86032adc5176c5316fb19d094bdde0450c06bcca..ccb1744a9a6e99019f41e18b770c47b4cdf911a3 100644 (file)
@@ -1,15 +1,15 @@
 <div class="line-block">
   <% if logged_in? %>
-         <ul class="operations">
-               <% if back %>
-                       <li class="last"><%= link_to message('dashboard.back_to_dashboard'), {:action => 'index', :id => @dashboard.id } -%></li>
-               <% else %>
-                       <% if @dashboard.editable_by?(current_user) %>
-                               <li><%= link_to message('dashboard.configure_widgets'), {:action => 'configure', :id => @dashboard.id } -%></li>
-                               <li><%= link_to message('dashboard.edit_layout'), {:action => 'edit_layout', :id => @dashboard.id } -%></li>
-                       <% end %>
-               <% end %>
-         </ul>
+       <ul class="operations">
+       <% if back %>
+         <li class="last"><%= link_to message('dashboard.back_to_dashboard'), dashboard_action(:index) -%></li>
+       <% else %>
+         <% if @dashboard.editable_by?(current_user) %>
+               <li><%= link_to message('dashboard.configure_widgets'), dashboard_action(:configure) -%></li>
+               <li><%= link_to message('dashboard.edit_layout'), dashboard_action(:edit_layout) -%></li>
+         <% end %>
+       <% end %>
+       </ul>
   <% end %>
 
   <% if @snapshot %>
@@ -18,7 +18,7 @@
                  <%= link_to_favourite(@project) -%> <%= "Version #{@snapshot.version} - " if @snapshot.version.present? -%><%= l @snapshot.created_at -%>
                  <% if @snapshot.project_snapshot.periods? %>
                          <form method="GET" action="<%= url_for :controller => 'dashboard', :action => 'index', :id => @resource.id -%>" style="display: inline" class="spacer-left">
-                               <input type="hidden" name="did" value="<%= @dashboard.id -%>" />
+                               <input type="hidden" name="did" value="<%= @dashboard.id -%>"/>
                                <select id="select-comparison" name="period" onchange="submit()" class="small">
                                  <option value=""><%= message('time_changes') -%>...</option>
                                  <%= period_select_options(@snapshot, 1) -%>
index ec6f9d9140d6c0dede0d61e1d2c573e3a5069383..79e4460e94164a4b6e12b2ae2d9fd61316967011 100644 (file)
@@ -27,7 +27,7 @@
   <% else %>
     <div class="widget">
       <p>
-        <a href="<%= url_for :action => :configure, :id => @dashboard.id -%>"><%= message('dashboard.please_configure_the_widget_x', :params => widget.java_definition.getTitle()) -%></a>
+        <a href="<%= url_for(dashboard_action(:configure, :id => @dashboard.id)) -%>"><%= message('dashboard.please_configure_the_widget_x', :params => widget.java_definition.getTitle()) -%></a>
       </p>
     </div>
   <% end %>
index 247190a732c55405f13cc322758fcfae227e56b3..d26ecd1e825b6675ae1321b6bf69a16e5356f841 100644 (file)
@@ -3,9 +3,9 @@
     <p><b><%= h message('widget.' + definition.getId() + '.name', :default => definition.getTitle()) -%></b></p>
 
     <p><%= h message('widget.' + definition.getId() + '.description', :default => definition.getDescription()) -%></p>
-    <%= form_tag :action => 'add_widget', :id => dashboard_id, :widget => definition.getId() %>
-    <input type="hidden" name="category" value="<%= category -%>">
-    <input type="submit" value="<%= message('dashboard.add_widget') -%>" id="add-widget-<%= u(definition.getId()) -%>">
-    </form>
+    <% form_tag dashboard_action(:add_widget, :widget => definition.getId()) do -%>
+      <input type="hidden" name="category" value="<%= category -%>">
+      <input type="submit" value="<%= message('dashboard.add_widget') -%>" id="add-widget-<%= u(definition.getId()) -%>">
+    <% end -%>
   </div>
 </td>
index 2b0d25506ac02bff6aa3b3bef810095e977ac232..8be3f00e94a6a2fa23dc034d8f866f437a5d0bbb 100644 (file)
@@ -3,21 +3,21 @@
   <li><%= message('filter_verb') -%>: </li>
   <li class="<%= 'selected' if category.blank? -%>"><a href="#" onClick="return filterWidgets('')" id="widget-filter-none"><%= message('none') -%></a></li>
   <% @widget_categories.each do |c| %>
-      <li class="<%= 'selected' if category==c -%>"><a href="#" onClick="return filterWidgets('<%= escape_javascript(c) -%>')" id="widget-filter-<%= u(c) -%>"><%= h(c) -%></a></li>
+    <li class="<%= 'selected' if category==c -%>"><a href="#" onClick="return filterWidgets('<%= escape_javascript(c) -%>')" id="widget-filter-<%= u(c) -%>"><%= h(c) -%></a></li>
   <% end %>
 </ul>
 <%= image_tag 'loading.gif', :style=>'vertical-align: top;display: none', :id => 'filter-widgets-loading' -%>
 </p>
 <table width="100%">
   <% @widget_definitions.each_with_index do |definition, index| %>
-      <% if index%4==0 %><tr><% end %>
-         <%= render :partial => 'widget_definition', :locals => {:definition => definition, :dashboard_id => dashboard_id, :category => category} %>
-         <% if index%4==3 %></tr><% end %>
+    <% if index%4==0 %><tr><% end %>
+    <%= render :partial => 'widget_definition', :locals => {:definition => definition, :dashboard_id => dashboard_id, :category => category} %>
+    <% if index%4==3 %></tr><% end %>
   <% end %>
   <% for i in 0..(4-(@widget_definitions.size%4)) %>
-      <td> </td>
+    <td> </td>
   <% end %>
   <% if @widget_definitions.size%4<3 %>
-      </tr>
+    </tr>
   <% end %>
 </table>
index d4fa25887730632a264b197226cdbe5668eb4ef4..abcd69ca28d3d57ec2cbff48a97e3789db68652c 100644 (file)
@@ -2,29 +2,29 @@
                    :method => :post,
                    :update => {:failure => "error#{widget.id}"},
                    :failure => "$('error#{widget.id}').show()" do -%>
-    <div id="error<%= widget.id -%>" class="error" style="display: none"></div>
-    <table class="table width100">
-      <tbody>
-      <% widget.java_definition.getWidgetProperties().sort {|w1, w2| natural_comparison(w1.key, w2.key) }.each do |property_def| %>
-          <tr>
-            <td class="form-key-cell"><%= property_def.key() -%><%= "*" unless property_def.optional()==true -%></td>
-            <td class="form-val-cell" id="row_<%= property_def.key() -%>">
-              <%= property_value_field(property_def, widget.property_text_value(property_def.key())) -%>
-              <div class="form-val-note">
-                <%= message("widget." + widget.key + ".param." + property_def.key(), :default => property_def.description()) -%>
-              </div>
-            </td>
-          </tr>
-      <% end %>
+  <div id="error<%= widget.id -%>" class="error" style="display: none"></div>
+  <table class="table width100">
+    <tbody>
+    <% widget.java_definition.getWidgetProperties().sort {|w1, w2| natural_comparison(w1.key, w2.key) }.each do |property_def| %>
       <tr>
-        <td colspan="2">
-          <%= submit_tag message('save') %>
-          <% if widget.configured %>
-              <a href="#" onClick="portal.cancelEditWidget(<%= widget.id -%>);return false;"><%= message('cancel') -%></a>
-          <% end %>
+        <td class="form-key-cell"><%= property_def.key() -%><%= "*" unless property_def.optional()==true -%></td>
+        <td class="form-val-cell" id="row_<%= property_def.key() -%>">
+          <%= property_value_field(property_def, widget.property_text_value(property_def.key())) -%>
+          <div class="form-val-note">
+            <%= message("widget." + widget.key + ".param." + property_def.key(), :default => property_def.description()) -%>
+          </div>
         </td>
       </tr>
-      </tbody>
-    </table>
-    <%= hidden_field_tag "widgetid", "", :class => "widgetid" %>
-<% end -%>
+    <% end %>
+    <tr>
+      <td colspan="2">
+        <%= submit_tag message('save') %>
+        <% if widget.configured %>
+          <a href="#" onClick="portal.cancelEditWidget(<%= widget.id -%>);return false;"><%= message('cancel') -%></a>
+        <% end %>
+      </td>
+    </tr>
+    </tbody>
+  </table>
+  <%= hidden_field_tag "widgetid", "", :class => "widgetid" %>
+<% end -%>
\ No newline at end of file
index 037c71d66b86a638a7c934524c48f4530d515d68..a1dbbc595edc8aaffacf4b1f51d0dfac0100ec49 100644 (file)
@@ -14,7 +14,7 @@
     highlight_duration:2,
     highlight_startcolor:'#cae3f2',
     highlight_endcolor:'#ffffff',
-    saveurl:'<%= url_for :action => 'set_dashboard', :id => @dashboard.id -%>'
+    saveurl:'<%= url_for dashboard_action(:set_dashboard) -%>'
   };
   var portal;
   function init_dashboard() {
index 3023388e47d760a34e059cbb30c7b26479d226f5..cd3f8269ce5938df98feb8bd5f8bccca5b098d2f 100644 (file)
@@ -2,27 +2,19 @@
   <%= render :partial => 'header', :locals => {:back => true} %>
 
   <div id="edit-layout" class="admin">
-      <p class="note"><%= message('dashboard.click_to_choose_layout') -%>: </p><br/>
+    <p class="note"><%= message('dashboard.click_to_choose_layout') -%>: </p><br/>
 
-      <div class="select-layout <%= 'selected' if @dashboard.layout=='100%' -%>" style="text-align:center;width: 20%;">
-        <%= link_to image_tag('layout100.png'), {:action => 'set_layout', :id => @dashboard.id, :layout => "100%"}, :method => :post %>
+    <% {'100%', 'layout100.png',
+        '50%-50%', 'layout5050.png',
+        '30%-70%', 'layout3070.png',
+        '70%-30%', 'layout7030.png',
+        '33%-33%-33%', 'layout333333.png'
+       }.each_pair do |layout, picto| %>
+      <div class="select-layout <%= 'selected' if @dashboard.layout==layout -%>" style="text-align:center;width: 20%;">
+        <%= link_to image_tag(picto), dashboard_action(:set_layout, :layout => layout), :method => :post %>
       </div>
+    <% end %>
 
-      <div class="select-layout <%= 'selected' if @dashboard.layout=="50%-50%" -%>"  style="text-align:center;width: 20%;">
-        <%= link_to image_tag('layout5050.png'), {:action => 'set_layout', :id => @dashboard.id, :layout => "50%-50%"}, :method => :post %>
-      </div>
-
-      <div class="select-layout <%= 'selected' if @dashboard.layout=="30%-70%" -%>"  style="text-align:center;width: 20%;">
-        <%= link_to image_tag('layout3070.png'), {:action => 'set_layout', :id => @dashboard.id, :layout => "30%-70%"}, :method => :post %>
-      </div>
-
-      <div class="select-layout <%= 'selected' if @dashboard.layout=="70%-30%" -%>" style="text-align:center;width: 20%;">
-        <%= link_to image_tag('layout7030.png'), {:action => 'set_layout', :id => @dashboard.id, :layout => "70%-30%"}, :method => :post %>
-      </div>
-
-      <div class="select-layout <%= 'selected' if @dashboard.layout=="33%-33%-33%" -%>" style="text-align:center;width: 19%;">
-        <%= link_to image_tag('layout333333.png'), {:action => 'set_layout', :id => @dashboard.id, :layout => "33%-33%-33%"}, :method => :post %>
-      </div>
-      <div style="clear:both;"></div>
+    <div style="clear:both;"></div>
   </div>
 </div>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/detached/no_dashboard.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/detached/no_dashboard.html.erb
new file mode 100644 (file)
index 0000000..4043a26
--- /dev/null
@@ -0,0 +1,28 @@
+<%= render :partial => 'gwt/base', :locals => {:resource => nil, :popup => false, :metric => nil} -%>
+<%= render :partial => 'gwt/resource_viewers' -%>
+
+<img id="page_loading" src="<%= ApplicationController.root_context -%>/images/loading.gif">
+<div id="resource_container"></div>
+
+<script type="text/javascript">
+  // see if an anchor has been passed
+  var anchor;
+  var stripped_url = document.location.toString().split("#");
+  if (stripped_url.length > 1) {
+    anchor = stripped_url[1];
+  }
+  
+  // and call the resource page
+  new Ajax.Updater('resource_container', '<%= url_for params.merge({:controller => 'resource', :action => 'index', :id => @file.id}) -%>',
+    {
+      asynchronous:true,
+      evalScripts:true,
+      onComplete:function (transport) {
+        $('page_loading').hide();
+        if (anchor!=null) {
+          window.location.hash = anchor;
+        }
+      }
+    });
+
+</script>
\ No newline at end of file