Changed position of cost entry filter select and issue filter select (closes #13114)

Added default filter costs__spent_on with operator "w" (this week) (closes 13113)
removed some debug statements

git-svn-id: https://dev.finn.de/svn/cockpit/trunk@228 7926756e-e54e-46e6-9721-ed318f58905e
pull/6827/head
hjust 15 years ago
parent 8e97877945
commit c108931c6b
  1. 17
      app/controllers/cost_reports_controller.rb
  2. 17
      app/models/cost_query.rb
  3. 9
      app/views/cost_reports/_filters.rhtml
  4. 2
      app/views/cost_reports/index.rhtml

@ -76,7 +76,18 @@ private
# Give it a name, required to be valid
@query = CostQuery.new(:name => "_")
@query.project = @project
@query.filters = params[:filters].collect {|f| f[1]}.select{|f| f[:enabled] != "0"} if params[:filters]
if params[:filters].blank?
# we create a default filter
@query.filters = [{
:column_name => "spent_on",
:scope => "costs",
:operator => "w",
:enabled => "1",
:values => [""]
}]
else
@query.filters = params[:filters].collect {|f| f[1]}.select{|f| f[:enabled] != "0"}
end
@query.group_by = params[:group_by] || {}
if params[:cost_query]
@ -100,6 +111,10 @@ private
@query.project = @project
end
end
p @query
end

@ -193,7 +193,8 @@ class CostQuery < ActiveRecord::Base
end
def create_filter(scope, column_name)
Filter.new(scope, column_name, available_filters[scope][column_name])
column = available_filters[scope][column_name]
column ? Filter.new(scope, column_name, column) : nil
end
def create_filter_from_hash(filter_hash = {})
@ -238,8 +239,7 @@ class CostQuery < ActiveRecord::Base
end
grouping_scope(:issues) do
# TODO: subproject_id
grouping_column(:tracker_id, :fixed_version_id)
grouping_column(:tracker_id, :fixed_version_id, :subproject_id)
end
grouping_scope(:costs) do
@ -283,16 +283,9 @@ class CostQuery < ActiveRecord::Base
def group_by_columns_for_select
self.class.group_by_columns.inject([["", ""]]) do |list, (column_name, values)|
#column = available_filters[values[:scope]][column_name.to_s]
#label = column[:name] || l(("field_"+column_name.to_s.gsub(/\_id$/, "")).to_sym)
#a = available_filters[values[:scope]]
#label = "blub"
#list << [label, "#{values[:scope]}__#{column_name}"]
filter = create_filter(values[:scope], column_name.to_s)
list << [filter.label, "#{values[:scope]}__#{column_name}"]
list << [filter.label, "#{values[:scope]}__#{column_name}"] if filter
list
end
end

@ -134,14 +134,13 @@
<% end if @query.filters %>
</table></td>
<td class="add-filter">
<%= l(:label_issue_filter_add) %>: <%= select_tag 'add_issue_filter_select', options_for_select(add_issue_filter_select),
:onchange => "add_filter(this, 'issues');",
<%= l(:label_cost_filter_add) %>: <%= select_tag 'add_cost_filter_select', options_for_select(add_cost_filter_select),
:onchange => "add_filter(this, 'costs');",
:class => "select-small",
:name => nil %><br />
<%= l(:label_cost_filter_add) %>: <%= select_tag 'add_cost_filter_select', options_for_select(add_cost_filter_select),
:onchange => "add_filter(this, 'costs');",
<%= l(:label_issue_filter_add) %>: <%= select_tag 'add_issue_filter_select', options_for_select(add_issue_filter_select),
:onchange => "add_filter(this, 'issues');",
:class => "select-small",
:name => nil %>
</td>

@ -32,7 +32,7 @@
<div id="query_from_content">
<fieldset id="filters" class="collapsible <%= "collapsed" unless @query.new_record? %>">
<legend onclick="toggleFieldset(this);"><%= l(:label_filter_plural) %></legend>
<div <%= 'style="display:none;"' unless @query.new_record? %>><%#= render :partial => 'filters', :locals => {:query_form => query_form} %></div>
<div <%= 'style="display:none;"' unless @query.new_record? %>><%= render :partial => 'filters', :locals => {:query_form => query_form} %></div>
</fieldset>
<fieldset id="group-by" class="collapsible">

Loading…
Cancel
Save