SECTION=Navigation::SECTION_CONFIGURATION
verify :method => :post, :only => [:create, :delete, :up, :down, :activate, :deactivate, :up_column, :down_column, :add_column, :delete_column, :set_sorted_column, :set_view, :set_columns, :set_page_size], :redirect_to => {:action => :index}
- before_filter :login_required, :except => %w(index treemap list)
+ before_filter :login_required, :except => %w(index treemap)
def manage
if is_admin?
@filters.sort! { |a,b| a.name.downcase <=> b.name.downcase }
end
- def list
- @widget=Widget.find(params[:widget])
- @filter=::Filter.find(params[:id])
- @filter_context=Filters.execute(@filter, self, params)
-
- render :partial => 'list', :locals => {:edit_mode => params[:edit_mode], :widget => @widget}
- end
-
def new
@filter=::Filter.new()
@filter.criteria<<Criterion.new_for_qualifiers(%w(TRK))
#
module FiltersHelper
- def goto_page(msg, filter, override={})
- link_to_remote msg, {:update => "filter-#{@widget.id}", :url => params.merge({:controller => :filters, :action => :list, :id => filter.id, :edit_mode => @edit_mode, :widget => @widget.id}.merge(override))}
- end
-
def column_title(column, filter)
- if column.sortable?
- html=goto_page(h(column.display_name), filter, {:asc => (!(column.ascending?)).to_s, :sort => column.id})
- else
- html=h(column.display_name)
- end
- if column.variation
- html="<img src='#{ApplicationController.root_context}/images/trend-up.png'></img> #{html}"
- end
+ if column.sortable?
+ html=link_to h(column.display_name), url_for(:overwrite_params => {:asc => (!(column.ascending?)).to_s, :sort => column.id})
+ else
+ html=h(column.display_name)
+ end
+ if column.variation
+ html="<img src='#{ApplicationController.root_context}/images/trend-up.png'></img> #{html}"
+ end
- if filter.sorted_column==column
- html << (column.ascending? ? image_tag("asc12.png") : image_tag("desc12.png"))
- end
- html
+ if filter.sorted_column==column
+ html << (column.ascending? ? image_tag("asc12.png") : image_tag("desc12.png"))
+ end
+ html
end
def column_align(column)
- (column.on_name? || column.on_key?) ? 'left' : 'right'
+ (column.on_name? || column.on_key?) ? 'left' : 'right'
end
def treemap_metrics(filter)
- metrics=filter.measure_columns.map { |col| col.metric }
- size_metric=(metrics.size>=1 ? metrics[0] : Metric.by_key('ncloc'))
- color_metric=nil
- if metrics.size>=2
- color_metric=metrics[1]
- end
- if color_metric.nil? || !color_metric.treemap_color?
- color_metric=Metric.by_key('violations_density')
- end
- [size_metric, color_metric]
+ metrics=filter.measure_columns.map{|col| col.metric}
+ size_metric=(metrics.size>=1 ? metrics[0] : Metric.by_key('ncloc'))
+ color_metric=nil
+ if metrics.size>=2
+ color_metric=metrics[1]
+ end
+ if color_metric.nil? || !color_metric.treemap_color?
+ color_metric=Metric.by_key('violations_density')
+ end
+ [size_metric, color_metric]
end
def period_names
- p1=Property.value('sonar.timemachine.period1', nil, 'previous_analysis')
- p2=Property.value('sonar.timemachine.period2', nil, '5')
- p3=Property.value('sonar.timemachine.period3', nil, '30')
- [period_name(p1), period_name(p2), period_name(p3)]
+ p1=Property.value('sonar.timemachine.period1', nil, 'previous_analysis')
+ p2=Property.value('sonar.timemachine.period2', nil, '5')
+ p3=Property.value('sonar.timemachine.period3', nil, '30')
+ [period_name(p1), period_name(p2), period_name(p3)]
end
private
def period_name(property)
- if property=='previous_analysis'
- message('delta_since_previous_analysis')
- elsif property =~ /^[\d]+(\.[\d]+){0,1}$/
- # is integer
- message('delta_over_x_days', :params => property)
- elsif property =~ /\d{4}-\d{2}-\d{2}/
- message('delta_since', :params => property)
- elsif !property.blank?
- message('delta_since_version', :params => property)
- else
- nil
- end
+ if property=='previous_analysis'
+ message('delta_since_previous_analysis')
+ elsif property =~ /^[\d]+(\.[\d]+){0,1}$/
+ # is integer
+ message('delta_over_x_days', :params => property)
+ elsif property =~ /\d{4}-\d{2}-\d{2}/
+ message('delta_since', :params => property)
+ elsif !property.blank?
+ message('delta_since_version', :params => property)
+ else
+ nil
+ end
end
-
end
<% filter=@filter_context.filter %>
-<% @edit_mode=edit_mode %>
-<% @widget=widget if widget %>
-
-<div id="filter-<%= @widget.id -%>">
+<div>
<table class="data nowrap width100" id="results">
<thead id="results-head">
<tr>
%>
|
<% if max_pages > 20 && start_page > 1 %>
- <%= goto_page message('paging_previous'), filter, :page_id => 1 %>
- <% end %>
-
- <% if current_page>start_page %>
- <%= goto_page message('paging_previous'), filter, :page_id => current_page-1 %>
- <% else %>
- <%= message('paging_previous') -%>
+ <%= link_to message('paging_first'), {:overwrite_params => {:page_id => 1}} -%>
<% end %>
-
+ <%= link_to_if current_page>start_page, message('paging_previous'), {:overwrite_params => {:page_id => current_page-1}} %>
<% for index in start_page..end_page %>
- <% unless index==current_page %>
- <%= goto_page index.to_s, filter, :page_id => index %>
- <% else %>
- <%= index.to_s -%>
- <% end %>
+ <%= link_to_unless index==current_page, index.to_s, {:overwrite_params => {:page_id => index}} %>
<% end %>
-
- <% if current_page<end_page %>
- <%= goto_page message('paging_next'), filter, :page_id => current_page+1 %>
- <% else %>
- <%= message('paging_next') -%>
- <% end %>
-
+ <%= link_to_if current_page<end_page, message('paging_next'), {:overwrite_params => {:page_id => 1+current_page}} %>
<% if max_pages > 20 && end_page < max_pages %>
- <%= goto_page message('paging_last'), filter, :page_id => max_pages %>
+ <%= link_to message('paging_last'), {:overwrite_params => {:page_id => max_pages}} -%>
<% end %>
<% end %>