aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2011-12-08 14:54:27 +0100
committerSimon Brandhof <simon.brandhof@gmail.com>2011-12-08 14:57:16 +0100
commitbe65e3865c2d34e43cc791503da8c815dff73278 (patch)
tree5b9abaee529b67cd19e23a8ee27e8e3d22652005 /sonar-server
parent1caf2de1184017100a2f53e962c39b9ae06299de (diff)
downloadsonarqube-be65e3865c2d34e43cc791503da8c815dff73278.tar.gz
sonarqube-be65e3865c2d34e43cc791503da8c815dff73278.zip
SONAR-1974 do not reload the page when the violation is created
Diffstat (limited to 'sonar-server')
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb21
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/measures.html.erb136
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/violations.html.erb329
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/resource/_create_violation_form.html.erb82
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/resource/_javascript.html.erb20
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/resource/index.html.erb25
6 files changed, 320 insertions, 293 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb
index b891e9ab304..b71b4df4962 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb
@@ -70,8 +70,6 @@ class ResourceController < ApplicationController
# Ajax request to display a form to create a review anywhere in source code
def show_create_violation_form
@line = params[:line].to_i
- @colspan = params[:colspan].to_i
- @from = params[:from]
@rules = Rule.manual_rules
@html_id="#{params[:resource]}_#{@line}"
render :partial => 'resource/create_violation_form'
@@ -87,23 +85,18 @@ class ResourceController < ApplicationController
bad_request(message('code_viewer.create_violation.missing_message')) if params[:message].blank?
bad_request(message('code_viewer.create_violation.missing_severity')) if params[:severity].blank?
+ violation = nil
Review.transaction do
rule = Rule.find_or_create_manual_rule(rule_id_or_name)
violation = rule.create_violation!(resource, params)
violation.create_review!(
- :assignee => current_user,
- :user => current_user,
- :status => Review::STATUS_OPEN,
- :manual_violation => true)
+ :assignee => current_user,
+ :user => current_user,
+ :status => Review::STATUS_OPEN,
+ :manual_violation => true)
end
- if params[:from]=='drilldown'
- render :js => "d(#{resource.id})"
- else
- render :update do |page|
- page.redirect_to :controller => 'resource', :action => 'index', :id => resource.key, :tab => 'violations'
- end
- end
+ render :partial => 'resource/violation', :locals => {:violation => violation}
end
private
@@ -126,7 +119,7 @@ class ResourceController < ApplicationController
if params[:tab].present?
@extension=@extensions.find { |extension| extension.getId()==params[:tab] }
- elsif !params[:metric].blank?
+ elsif !params[:metric].blank?
metric=Metric.by_key(params[:metric])
@extension=@extensions.find { |extension| extension.getDefaultTabForMetrics().include?(metric.key) }
end
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/measures.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/measures.html.erb
index f127d6e7801..b68fdbdf113 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/measures.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/measures.html.erb
@@ -1,31 +1,33 @@
-<%= render :partial => 'resource/javascript', :locals => {:from => 'drilldown'} -%>
+<%= render :partial => 'resource/javascript' -%>
<%= render :partial => 'header' -%>
<% if params[:period] && @snapshot.project_snapshot.periods? %>
-<div id="snapshot_title" class="page_title">
- <h4>
- <form method="GET" action="<%= url_for :action => 'measures' -%>" style="display: inline">
- <input type="hidden" name="metric" value="<%= params[:metric] -%>" />
+ <div id="snapshot_title" class="page_title">
+ <h4>
+ <form method="GET" action="<%= url_for :action => 'measures' -%>" style="display: inline">
+ <input type="hidden" name="metric" value="<%= params[:metric] -%>"/>
- <select id="select-comparison" name="period" onchange="submit()" class="small">
- <% if @drilldown.display_value? %>
- <option value=""><%= message('time_changes') -%>...</option>
- <% end %>
- <% for period_index in 1..5 do %>
- <%= period_select_options(@snapshot, period_index) if @drilldown.display_period?(period_index) -%>
- <% end %>
- </select>
- </form>
- </h4>
-</div>
+ <select id="select-comparison" name="period" onchange="submit()" class="small">
+ <% if @drilldown.display_value? %>
+ <option value=""><%= message('time_changes') -%>...</option>
+ <% end %>
+ <% for period_index in 1..5 do %>
+ <%= period_select_options(@snapshot, period_index) if @drilldown.display_period?(period_index) -%>
+ <% end %>
+ </select>
+ </form>
+ </h4>
+ </div>
<% end %>
<div class="dashbox">
<% if @characteristic %>
<h3><%= @highlighted_metric.short_name -%> / <%= h(@characteristic.name(true)) -%></h3>
+
<p class="big"><%= format_measure(@snapshot.characteristic_measure(@highlighted_metric, @characteristic)) %></p>
<% else %>
<h3><%= @highlighted_metric.short_name -%></h3>
+
<p class="big">
<%= format_measure(@snapshot.measure(@highlighted_metric.key), :period => @period) %>
</p>
@@ -33,60 +35,62 @@
</div>
&nbsp;<!-- keep &nbsp; for IE6 ! -->
<table id="drilldown" class="width100" style="clear:left">
-<% if @highlighted_metric!=@metric %>
-<tr>
-<td colspan="<%= @drilldown.columns.size -%>"><%= message('drilldown.drilldown_on') -%> <b><%= format_measure(@metric.key, :period => @period) -%> <%= @metric.short_name -%></b></td>
-</tr>
-<tr>
-<% end
+ <% if @highlighted_metric!=@metric %>
+ <tr>
+ <td colspan="<%= @drilldown.columns.size -%>"><%= message('drilldown.drilldown_on') -%> <b><%= format_measure(@metric.key, :period => @period) -%> <%= @metric.short_name -%></b></td>
+ </tr>
+ <tr>
+ <% end
- rids=[]
- @drilldown.columns.each_with_index do |column, index|
-%>
-<td class="column <%= 'first' if index==0 -%>" nowrap>
- <div class="scrollable" id="col_<%= column.scope -%>">
- <table class="spaced">
- <% column.measures.each do |measure|
- resource=column.resource(measure)
- selected = column.selected_snapshot && column.selected_snapshot.project_id==resource.id
- clazz = cycle("even", "odd", :name => "col_#{column.scope}")
- clazz = clazz + ' selected' if selected
- %>
- <tr class="<%= clazz -%>">
- <td nowrap>
- <%
- if resource.entity?
- if resource.copy_resource_id %>
- <%= qualifier_icon(resource) -%>
- <%= link_to(resource.name, {:only_path => true, :overwrite_params => {:rids => nil, :id => resource.copy_resource_id}}) -%>
- <% else %>
- <%= qualifier_icon(resource) -%>
- <a href="#" onclick="d(<%= resource.id -%>)" alt="<%= resource.name(true) -%>" title="<%= resource.name(true) -%>"><%= resource.name(false) -%></a>
- <% end
- else %>
- <%= link_to(image_tag('zoom.png'), {:id => resource.id, :metric => @metric.id}, {:class => 'nolink'}) -%>
- <%= qualifier_icon(resource) -%>
- <%= link_to(resource.name, {:only_path => true, :overwrite_params => {:rids => (selected ? rids-[resource.id] : rids+[resource.id])}}) -%>
+ rids=[]
+ @drilldown.columns.each_with_index do |column, index|
+ %>
+ <td class="column <%= 'first' if index==0 -%>" nowrap>
+ <div class="scrollable" id="col_<%= column.scope -%>">
+ <table class="spaced">
+ <% column.measures.each do |measure|
+ resource=column.resource(measure)
+ selected = column.selected_snapshot && column.selected_snapshot.project_id==resource.id
+ clazz = cycle("even", "odd", :name => "col_#{column.scope}")
+ clazz = clazz + ' selected' if selected
+ %>
+ <tr class="<%= clazz -%>">
+ <td nowrap>
+ <%
+ if resource.entity?
+ if resource.copy_resource_id %>
+ <%= qualifier_icon(resource) -%>
+ <%= link_to(resource.name, {:only_path => true, :overwrite_params => {:rids => nil, :id => resource.copy_resource_id}}) -%>
+ <% else %>
+ <%= qualifier_icon(resource) -%>
+ <a href="#" onclick="d(<%= resource.id -%>)" alt="<%= resource.name(true) -%>" title="<%= resource.name(true) -%>"><%= resource.name(false) -%></a>
+ <% end
+ else %>
+ <%= link_to(image_tag('zoom.png'), {:id => resource.id, :metric => @metric.id}, {:class => 'nolink'}) -%>
+ <%= qualifier_icon(resource) -%>
+ <%= link_to(resource.name, {:only_path => true, :overwrite_params => {:rids => (selected ? rids-[resource.id] : rids+[resource.id])}}) -%>
+ <% end %>
+ </td>
+ <td class="right last">
+ <%= format_measure(measure, :skip_span_id => true, :period => @period) -%>
+ </td>
+ </tr>
<% end %>
- </td>
- <td class="right last" >
- <%= format_measure(measure, :skip_span_id => true, :period => @period) -%>
- </td>
- </tr>
- <% end %>
- </table>
- </div>
-</td>
-<%
- rids<<column.selected_snapshot.project_id if column.selected_snapshot
- end
-%>
-</tr>
+ </table>
+ </div>
+ </td>
+ <%
+ rids<<column.selected_snapshot.project_id if column.selected_snapshot
+ end
+ %>
+ </tr>
</table>
<script>
-<% @drilldown.columns.each do |column| %>
-$$('#col_<%= column.scope -%> tr.selected').each(function(item) {item.scrollIntoView(true);});
-<% end %>
+ <% @drilldown.columns.each do |column| %>
+ $$('#col_<%= column.scope -%> tr.selected').each(function (item) {
+ item.scrollIntoView(true);
+ });
+ <% end %>
</script>
<%= render :partial => 'footer' -%>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/violations.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/violations.html.erb
index cfb793ce4a0..e6523a83ffa 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/violations.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/violations.html.erb
@@ -1,179 +1,188 @@
-<%= render :partial => 'resource/javascript', :locals => {:from => 'drilldown'} -%>
+<%= render :partial => 'resource/javascript' -%>
<%= render :partial => 'header' -%>
<div id="snapshot_title" class="page_title">
-<h4>
-<%
- profile_measure=@snapshot.measure(Metric::PROFILE)
- %>
-<% if profile_measure %>Profile <%= link_to profile_measure.data, :controller => '/rules_configuration', :action => 'index', :id => profile_measure.value.to_i %> - <% end %>
-<% if @snapshot.project_snapshot.periods? %>
-<form method="GET" action="<%= url_for :only_path=>true, :overwrite_params => {:period => nil} -%>" style="display: inline">
- <select id="select-comparison" name="period" onchange="submit()" class="small">
- <option value=""><%= message('time_changes') -%>...</option>
- <%= violation_period_select_options(@snapshot, 1) -%>
- <%= violation_period_select_options(@snapshot, 2) -%>
- <%= violation_period_select_options(@snapshot, 3) -%>
- <%= violation_period_select_options(@snapshot, 4) -%>
- <%= violation_period_select_options(@snapshot, 5) -%>
- </select>
- </form>
-<% end %>
-</h4>
+ <h4>
+ <%
+ profile_measure=@snapshot.measure(Metric::PROFILE)
+ %>
+ <% if profile_measure %>Profile <%= link_to profile_measure.data, :controller => '/rules_configuration', :action => 'index', :id => profile_measure.value.to_i %> -
+ <% end %>
+ <% if @snapshot.project_snapshot.periods? %>
+ <form method="GET" action="<%= url_for :only_path=>true, :overwrite_params => {:period => nil} -%>" style="display: inline">
+ <select id="select-comparison" name="period" onchange="submit()" class="small">
+ <option value=""><%= message('time_changes') -%>...</option>
+ <%= violation_period_select_options(@snapshot, 1) -%>
+ <%= violation_period_select_options(@snapshot, 2) -%>
+ <%= violation_period_select_options(@snapshot, 3) -%>
+ <%= violation_period_select_options(@snapshot, 4) -%>
+ <%= violation_period_select_options(@snapshot, 5) -%>
+ </select>
+ </form>
+ <% end %>
+ </h4>
</div>
<table width="100%" cellpadding="0" cellspacing="0" id="columns">
-<tr>
- <td align="left" width="1%" nowrap class="column first">
+ <tr>
+ <td align="left" width="1%" nowrap class="column first">
- <%
- value_column = (@period ? "variation_value_#{@period}" : 'value')
- max = 0
- if @period
- blocker_violations=@snapshot.measure('new_blocker_violations')
- critical_violations=@snapshot.measure('new_critical_violations')
- major_violations=@snapshot.measure('new_major_violations')
- minor_violations=@snapshot.measure('new_minor_violations')
- info_violations=@snapshot.measure('new_info_violations')
- else
- blocker_violations=@snapshot.measure('blocker_violations')
- critical_violations=@snapshot.measure('critical_violations')
- major_violations=@snapshot.measure('major_violations')
- minor_violations=@snapshot.measure('minor_violations')
- info_violations=@snapshot.measure('info_violations')
- end
+ <%
+ value_column = (@period ? "variation_value_#{@period}" : 'value')
+ max = 0
+ if @period
+ blocker_violations=@snapshot.measure('new_blocker_violations')
+ critical_violations=@snapshot.measure('new_critical_violations')
+ major_violations=@snapshot.measure('new_major_violations')
+ minor_violations=@snapshot.measure('new_minor_violations')
+ info_violations=@snapshot.measure('new_info_violations')
+ else
+ blocker_violations=@snapshot.measure('blocker_violations')
+ critical_violations=@snapshot.measure('critical_violations')
+ major_violations=@snapshot.measure('major_violations')
+ minor_violations=@snapshot.measure('minor_violations')
+ info_violations=@snapshot.measure('info_violations')
+ end
- [blocker_violations, critical_violations, major_violations, minor_violations, info_violations].each do |m|
- value = measure_or_variation_value(m)
- max = value if value && value>max
- end
- %>
- <h3><%= message('violations_drilldown.col.severity') -%></h3>
- <table class="spacedicon" style="border: 1px solid #ccc;">
- <%= render :partial => 'severity', :locals => {:css => 'even', :severity => 'BLOCKER', :max => max, :measure => blocker_violations }%>
- <%= render :partial => 'severity', :locals => {:css => 'odd', :severity => 'CRITICAL', :max => max, :measure => critical_violations }%>
- <%= render :partial => 'severity', :locals => {:css => 'even', :severity => 'MAJOR', :max => max, :measure => major_violations }%>
- <%= render :partial => 'severity', :locals => {:css => 'odd', :severity => 'MINOR', :max => max, :measure => minor_violations }%>
- <%= render :partial => 'severity', :locals => {:css => 'even', :severity => 'INFO', :max => max, :measure => info_violations }%>
- </table>
- </td>
- <td class="column" align="left" style="white-space: normal;">
- <h3><%= message('violations_drilldown.col.rule') -%></h3>
- <div class="scrollable">
- <table class="spacedicon" width="100%" id="col_rules">
- <%
- max=0
- rule_index=0
- already_selected=false
- @rule_measures.each do |m|
- value = m.send(value_column) if m
- max=value if value && value>max
- end
- @rule_measures.sort do|x,y|
- val=y.rule_priority<=>x.rule_priority
- if val==0
- x_value=x.send(value_column)
- y_value=y.send(value_column)
- y_value <=> x_value
- else
- val
- end
- end.each do |rule_measure|
- value = rule_measure.send(value_column)
- next if value.nil? || value==0
- rule=rule_measure.rule
- clazz = cycle('even', 'odd', :name => 'rules')
- selected = !already_selected && @rule && @rule.id==rule_measure.rule_id && (@rule_severity.nil? || @rule_severity==rule_measure.severity)
- already_selected = true if selected
- clazz = clazz + ' selected' if selected
- rule_index+=1
- %>
- <tr class="<%= clazz -%>">
- <td width="1%" nowrap>
- <a id="<%= "rule#{rule_index}" -%>" title="<%= message('violations_drilldown.click_for_more_on_x', :params => [rule.plugin_name, rule.plugin_rule_key]) -%>" onclick="window.open(this.href,'rule','height=800,width=900,scrollbars=1,resizable=1');return false;" href="<%= url_for :controller => 'rules', :action => 'show', :id => rule.key, :layout => 'false' -%>"><img src="<%= ApplicationController.root_context -%>/images/priority/<%= rule_measure.rule_priority -%>.png" /></a>
- </td>
- <td>
- <%= link_to(rule.name, {:rule => (selected ? nil : rule.key), :rule_sev => (selected ? nil : rule_measure.severity), :sid => nil, :severity => @severity, :period => @period, :rids => (selected ? nil : @selected_rids)}, :title => "#{rule.plugin_name}: #{rule.plugin_rule_key}") -%>
- </td>
- <td class="right" nowrap="nowrap">
- <span><%= @period ? format_variation(rule_measure, :period => @period, :style => 'light') : rule_measure.formatted_value -%></span>
- </td>
- <td class="left last">
- <%= barchart(:width => 70, :percent => (100 * value / max).to_i, :color => (@period ? '#cc0000' : '#777')) if max>0 %>
- </td>
- </tr>
- <% end %>
+ [blocker_violations, critical_violations, major_violations, minor_violations, info_violations].each do |m|
+ value = measure_or_variation_value(m)
+ max = value if value && value>max
+ end
+ %>
+ <h3><%= message('violations_drilldown.col.severity') -%></h3>
+ <table class="spacedicon" style="border: 1px solid #ccc;">
+ <%= render :partial => 'severity', :locals => {:css => 'even', :severity => 'BLOCKER', :max => max, :measure => blocker_violations} %>
+ <%= render :partial => 'severity', :locals => {:css => 'odd', :severity => 'CRITICAL', :max => max, :measure => critical_violations} %>
+ <%= render :partial => 'severity', :locals => {:css => 'even', :severity => 'MAJOR', :max => max, :measure => major_violations} %>
+ <%= render :partial => 'severity', :locals => {:css => 'odd', :severity => 'MINOR', :max => max, :measure => minor_violations} %>
+ <%= render :partial => 'severity', :locals => {:css => 'even', :severity => 'INFO', :max => max, :measure => info_violations} %>
+ </table>
+ </td>
+ <td class="column" align="left" style="white-space: normal;">
+ <h3><%= message('violations_drilldown.col.rule') -%></h3>
- <% if rule_index==0 %>
- <tr class="even"><td><%= message('violations_drilldown.no_violations') -%></td></tr>
- <% end %>
- </table>
- </div>
-</td>
-</tr>
+ <div class="scrollable">
+ <table class="spacedicon" width="100%" id="col_rules">
+ <%
+ max=0
+ rule_index=0
+ already_selected=false
+ @rule_measures.each do |m|
+ value = m.send(value_column) if m
+ max=value if value && value>max
+ end
+ @rule_measures.sort do |x, y|
+ val=y.rule_priority<=>x.rule_priority
+ if val==0
+ x_value=x.send(value_column)
+ y_value=y.send(value_column)
+ y_value <=> x_value
+ else
+ val
+ end
+ end.each do |rule_measure|
+ value = rule_measure.send(value_column)
+ next if value.nil? || value==0
+ rule=rule_measure.rule
+ clazz = cycle('even', 'odd', :name => 'rules')
+ selected = !already_selected && @rule && @rule.id==rule_measure.rule_id && (@rule_severity.nil? || @rule_severity==rule_measure.severity)
+ already_selected = true if selected
+ clazz = clazz + ' selected' if selected
+ rule_index+=1
+ %>
+ <tr class="<%= clazz -%>">
+ <td width="1%" nowrap>
+ <a id="<%= "rule#{rule_index}" -%>" title="<%= message('violations_drilldown.click_for_more_on_x', :params => [rule.plugin_name, rule.plugin_rule_key]) -%>" onclick="window.open(this.href,'rule','height=800,width=900,scrollbars=1,resizable=1');return false;" href="<%= url_for :controller => 'rules', :action => 'show', :id => rule.key, :layout => 'false' -%>"><img src="<%= ApplicationController.root_context -%>/images/priority/<%= rule_measure.rule_priority -%>.png"/></a>
+ </td>
+ <td>
+ <%= link_to(rule.name, {:rule => (selected ? nil : rule.key), :rule_sev => (selected ? nil : rule_measure.severity), :sid => nil, :severity => @severity, :period => @period, :rids => (selected ? nil : @selected_rids)}, :title => "#{rule.plugin_name}: #{rule.plugin_rule_key}") -%>
+ </td>
+ <td class="right" nowrap="nowrap">
+ <span><%= @period ? format_variation(rule_measure, :period => @period, :style => 'light') : rule_measure.formatted_value -%></span>
+ </td>
+ <td class="left last">
+ <%= barchart(:width => 70, :percent => (100 * value / max).to_i, :color => (@period ? '#cc0000' : '#777')) if max>0 %>
+ </td>
+ </tr>
+ <% end %>
+
+ <% if rule_index==0 %>
+ <tr class="even">
+ <td><%= message('violations_drilldown.no_violations') -%></td>
+ </tr>
+ <% end %>
+ </table>
+ </div>
+ </td>
+ </tr>
</table>
<br/>
<table width="100%">
-<tr>
-<%
- paths=[]
- rids=[]
- column_width=(100/@drilldown.columns.size).to_i if @drilldown.columns.size>0
- @drilldown.columns.each_with_index do |column, index|
-%><td class="column <%= 'first' if index==0 -%>" nowrap width="<%= column_width -%>%">
-<div class="scrollable" id="col_<%= column.scope -%>">
-<table class="spaced">
- <%
- column.measures.each do |measure|
- resource=column.resource(measure)
- clazz = cycle('even', 'odd', :name => "col_#{column.scope}")
- selected = column.selected_snapshot && column.selected_snapshot.project_id==resource.id
- if selected
- clazz += ' selected'
- paths << [h(resource.name), @selected_rids-[resource.id]]
- end
- %>
- <tr class="<%= clazz -%>">
- <td nowrap>
- <%
- if resource.entity?
- if resource.copy_resource_id %>
- <%= qualifier_icon(resource) -%>
- <%= link_to(h(resource.name), {:only_path => true, :overwrite_params => {:rids => nil, :id => resource.copy_resource_id}}) -%>
- <% else %>
- <%= qualifier_icon(resource) -%>
- <a href="#" onclick="d(<%= resource.id -%>, '<%= @period_index -%>', '<%= @rule ? @rule.key : @severity -%>');" alt="<%= resource.name(true) -%>" title="<%= resource.name(true) -%>"><%= resource.name(false) %></a>
- <%
- end
- else %>
- <%= link_to(image_tag('zoom.png'), {:id => resource.id}, {:class => 'nolink'}) %>
- <%= qualifier_icon(resource) %>
- <%= link_to(h(resource.name), {:only_path => true, :overwrite_params => {:rids => (selected ? rids-[resource.id] : rids+[resource.id])}}) -%>
- <% end %>
- </td>
- <td class="right last" nowrap>
- <%= @period ? format_variation(measure, :period => @period, :style => 'light') : measure.formatted_value -%>
- </td>
-</tr>
-<% end %>
-</table>
-</div>
-</td>
-<%
- rids<<column.selected_snapshot.project_id if column.selected_snapshot
- end %>
-</tr>
+ <tr>
+ <%
+ paths=[]
+ rids=[]
+ column_width=(100/@drilldown.columns.size).to_i if @drilldown.columns.size>0
+ @drilldown.columns.each_with_index do |column, index|
+ %>
+ <td class="column <%= 'first' if index==0 -%>" nowrap width="<%= column_width -%>%">
+ <div class="scrollable" id="col_<%= column.scope -%>">
+ <table class="spaced">
+ <%
+ column.measures.each do |measure|
+ resource=column.resource(measure)
+ clazz = cycle('even', 'odd', :name => "col_#{column.scope}")
+ selected = column.selected_snapshot && column.selected_snapshot.project_id==resource.id
+ if selected
+ clazz += ' selected'
+ paths << [h(resource.name), @selected_rids-[resource.id]]
+ end
+ %>
+ <tr class="<%= clazz -%>">
+ <td nowrap>
+ <%
+ if resource.entity?
+ if resource.copy_resource_id %>
+ <%= qualifier_icon(resource) -%>
+ <%= link_to(h(resource.name), {:only_path => true, :overwrite_params => {:rids => nil, :id => resource.copy_resource_id}}) -%>
+ <% else %>
+ <%= qualifier_icon(resource) -%>
+ <a href="#" onclick="d(<%= resource.id -%>, '<%= @period_index -%>', '<%= @rule ? @rule.key : @severity -%>');" alt="<%= resource.name(true) -%>" title="<%= resource.name(true) -%>"><%= resource.name(false) %></a>
+ <%
+ end
+ else %>
+ <%= link_to(image_tag('zoom.png'), {:id => resource.id}, {:class => 'nolink'}) %>
+ <%= qualifier_icon(resource) %>
+ <%= link_to(h(resource.name), {:only_path => true, :overwrite_params => {:rids => (selected ? rids-[resource.id] : rids+[resource.id])}}) -%>
+ <% end %>
+ </td>
+ <td class="right last" nowrap>
+ <%= @period ? format_variation(measure, :period => @period, :style => 'light') : measure.formatted_value -%>
+ </td>
+ </tr>
+ <% end %>
+ </table>
+ </div>
+ </td>
+ <%
+ rids<<column.selected_snapshot.project_id if column.selected_snapshot
+ end %>
+ </tr>
</table>
<script>
-$$('#col_rules tr.selected').each(function(item) {item.scrollIntoView(true);});
-<% @drilldown.columns.each do |column| %>
-$$('#col_<%= column.scope -%> tr.selected').each(function(item) {item.scrollIntoView(true);});
-<% end %>
+ $$('#col_rules tr.selected').each(function (item) {
+ item.scrollIntoView(true);
+ });
+ <% @drilldown.columns.each do |column| %>
+ $$('#col_<%= column.scope -%> tr.selected').each(function (item) {
+ item.scrollIntoView(true);
+ });
+ <% end %>
-<% if @drilldown.highlighted_resource %>
- d(<%= @drilldown.highlighted_resource.id -%>);
-<% end %>
+ <% if @drilldown.highlighted_resource %>
+ d(<%= @drilldown.highlighted_resource.id -%>);
+ <% end %>
</script>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_create_violation_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_create_violation_form.html.erb
index 80003e74fcb..614c515bd81 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_create_violation_form.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_create_violation_form.html.erb
@@ -1,45 +1,55 @@
-<tr id="createViolationForm<%= @line -%>">
- <% for index in 0...@colspan %>
- <td class="nothing"></td>
+<tr id="createViolationRow<%= @line -%>">
+ <% for index in 0...(params['gray_colspan'].to_i) %>
+ <td class="gray"></td>
+ <% end %>
+ <% for index in 0...(params['white_colspan'].to_i) %>
+ <td class="white"></td>
<% end %>
<td class="violations">
- <% form_remote_tag :url => "#{ApplicationController.root_context}/resource/create_violation", :failure => "$('errorViolationForm#{@line}').update(request.responseText);$('errorViolationForm#{@line}').show()" do -%>
- <input type="hidden" name="resource" value="<%= params[:resource] -%>">
- <input type="hidden" name="line" value="<%= @line -%>">
- <input type="hidden" name="from" value="<%= @from -%>">
+ <div id="createViolationCell<%= @line -%>">
+ <% form_remote_tag :url => "#{ApplicationController.root_context}/resource/create_violation",
+ :update => {:success => "createViolationCell#{@line}"},
+ :html => {:id => "createViolationForm#{@line}"},
+ :failure => "$('errorViolationForm#{@line}').update(request.responseText);$('errorViolationForm#{@line}').show()" do -%>
+ <input type="hidden" name="resource" value="<%= params[:resource] -%>">
+ <input type="hidden" name="line" value="<%= @line -%>">
+ <input type="hidden" name="gray_colspan" value="<%= params[:gray_colspan] -%>">
+ <input type="hidden" name="white_colspan" value="<%= params[:white_colspan] -%>">
- <div class="violation">
- <div class="vtitle">
- <select name="severity" class="withIcons">
- <% Severity::SEVERITIES.each do |severity| %>
- <option class="sev_<%= severity -%>" value="<%= severity -%>" <%= 'selected' if severity==Severity::MAJOR -%>><%= message("severity.#{severity}") -%></option>
- <% end %>
- </select>
- &nbsp;
- <img src="<%= ApplicationController.root_context -%>/images/sep12.png">
- &nbsp;
- <select id="select-rule-<%= @html_id -%>" name="rule" onkeyup="this.blur();this.focus();" onchange="if ($F(this)=='') {$('new_rule_<%= @html_id -%>').show()} else {$('new_rule_<%= @html_id -%>').hide()}">
- <option value=""><%= message('code_viewer.create_violation.new_rule') -%></option>
- <% unless @rules.empty? %>
- <optgroup label="<%= message('code_viewer.create_violation.rules') -%>">
- <% @rules.each do |rule| %>
- <option value="<%= rule.id -%>"><%= h rule.name -%></option>
- <% end %>
- </optgroup>
- <% end %>
- </select>
+ <div class="violation">
+ <div class="vtitle">
+ <select name="severity" class="withIcons">
+ <% Severity::SEVERITIES.each do |severity| %>
+ <option class="sev_<%= severity -%>" value="<%= severity -%>" <%= 'selected' if severity==Severity::MAJOR -%>><%= message("severity.#{severity}") -%></option>
+ <% end %>
+ </select>
+ &nbsp;
+ <img src="<%= ApplicationController.root_context -%>/images/sep12.png">
+ &nbsp;
+ <select id="select-rule-<%= @html_id -%>" name="rule" onkeyup="this.blur();this.focus();" onchange="if ($F(this)=='') {$('new_rule_<%= @html_id -%>').show()} else {$('new_rule_<%= @html_id -%>').hide()}">
+ <option value=""><%= message('code_viewer.create_violation.new_rule') -%></option>
+ <% unless @rules.empty? %>
+ <optgroup label="<%= message('code_viewer.create_violation.rules') -%>">
+ <% @rules.each do |rule| %>
+ <option value="<%= rule.id -%>"><%= h rule.name -%></option>
+ <% end %>
+ </optgroup>
+ <% end %>
+ </select>
- <input type="text" name="new_rule" size="50" id="new_rule_<%= @html_id -%>">
- </div>
+ <input type="text" name="new_rule" size="50" id="new_rule_<%= @html_id -%>">
+ </div>
+
+ <div class="discussionComment first">
+ <textarea rows="5" name="message" style="width: 100%"></textarea>
- <div class="discussionComment first">
- <textarea rows="5" name="message" style="width: 100%"></textarea>
- <div class="error" id="errorViolationForm<%= @line -%>" style="display: none"></div>
- <input type="submit" value="<%= message('code_viewer.create_violation.submit') -%>">
- <a href="#" onclick="return hVF(<%= @line -%>)"><%= message('cancel') -%></a>
+ <div class="error" id="errorViolationForm<%= @line -%>" style="display: none"></div>
+ <input type="submit" value="<%= message('code_viewer.create_violation.submit') -%>">
+ <a href="#" onclick="return hVF(<%= @line -%>)"><%= message('cancel') -%></a>
+ </div>
</div>
- </div>
- <% end %>
+ <% end %>
+ </div>
</td>
</tr>
<script type="text/javascript">
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_javascript.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_javascript.html.erb
index bc1d9cfca3e..b9ccbb6c82d 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_javascript.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_javascript.html.erb
@@ -1,24 +1,24 @@
<script type="text/javascript">
// show form to create violations
- function sVF(resource, line, colspan) {
+ function sVF(resource, line, gray_colspan, white_colspan) {
row = $('createViolationForm' + line);
if (row == null) {
new Ajax.Updater(
- 'pos' + line,
- '<%= ApplicationController.root_context -%>/resource/show_create_violation_form',
- {
- parameters: {resource: resource, line: line, colspan: colspan, from: '<%= from -%>'},
- asynchronous:true,
- evalScripts: true,
- insertion: 'after'
- });
+ 'pos' + line,
+ '<%= ApplicationController.root_context -%>/resource/show_create_violation_form',
+ {
+ parameters:{resource:resource, line:line, gray_colspan:gray_colspan, white_colspan:white_colspan},
+ asynchronous:true,
+ evalScripts:true,
+ insertion:'after'
+ });
}
return false;
}
// hide review form
function hVF(line) {
- row = $('createViolationForm' + line);
+ row = $('createViolationRow' + line);
if (row != null) {
row.remove();
}
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/index.html.erb
index c42ce265a9c..103503bbbc7 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/index.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/index.html.erb
@@ -1,5 +1,5 @@
<%= render :partial => 'tabs' -%>
-<%= render :partial => 'resource/javascript', :locals => {:from => 'resource'} -%>
+<%= render :partial => 'resource/javascript' -%>
<%= render :partial => "resource/header_#{@extension.getId()}" -%>
<% if @display_violations && @global_violations && @global_violations.size>0 -%>
@@ -17,10 +17,21 @@
<table id="sources" class="sources2 code" cellpadding="0" cellspacing="0" border="0">
<%
colspan=2
- colspan+=1 if @display_manual_violation_form
- colspan+=1 if @scm_available
- colspan+=2 if @display_coverage
- violation_form_colspan=(@scm_available ? 3 : 2)
+ gray_colspan=1
+ white_colspan=0
+ if @display_manual_violation_form
+ colspan+=1
+ gray_colspan+=1
+ end
+ if @scm_available
+ colspan+=1
+ gray_colspan+=1
+ end
+ if @display_coverage
+ colspan+=2
+ white_colspan+=2
+ end
+
current_revision=nil
previous_hidden=false
first_section=true
@@ -68,7 +79,7 @@
%>
<tr class="row" id="pos<%= index+1 -%>">
<% if @display_manual_violation_form %>
- <td class="plus"><a onclick="return sVF(<%= @resource.id -%>,<%= index + 1 -%>,<%= violation_form_colspan -%>)"></a></td>
+ <td class="plus"><a onclick="return sVF(<%= @resource.id -%>,<%= index + 1 -%>,<%= gray_colspan -%>,<%= white_colspan -%>)"></a></td>
<%
end
if @scm_available
@@ -109,7 +120,7 @@
<% if @display_violations && line.violations? %>
<tr>
<% if @display_manual_violation_form %>
- <td class="nothing"></td>
+ <td class="gray"></td>
<% end
if @scm_available %>
<td class="scm"></td>