From 228028b1180ef24f2680990de9d80003a2c923e5 Mon Sep 17 00:00:00 2001 From: hjust Date: Tue, 23 Feb 2010 14:14:50 +0000 Subject: [PATCH] Reverted part on r520 git-svn-id: https://dev.finn.de/svn/cockpit/trunk@525 7926756e-e54e-46e6-9721-ed318f58905e --- app/models/cost_query.rb | 32 +++----------------------------- 1 file changed, 3 insertions(+), 29 deletions(-) diff --git a/app/models/cost_query.rb b/app/models/cost_query.rb index 70719abcd0..b5a20b0970 100644 --- a/app/models/cost_query.rb +++ b/app/models/cost_query.rb @@ -103,28 +103,6 @@ class CostQuery < ActiveRecord::Base self.group_by ||= {} end - def display_time_entries -# read_attribute("display_time_entries") && ( - !self.filters || !self.filters.any? do |f| - f["enabled"] == "1" && f["scope"] == "costs" && f["column_name"] == "cost_type_id" && ( - (f["operator"] == "!" && f["values"].include?("")) || - (f["operator"] == "=" && !f["values"].include?("")) - ) - end -# ) - end - - def display_cost_entries -# read_attribute("display_cost_entries") && ( - !self.filters || !self.filters.any? do |f| - f["enabled"] == "1" && f["scope"] == "costs" && f["column_name"] == "cost_type_id" && ( - (f["operator"] == "=" && f["values"].all? {|v| v == ""}) - ) - end -# ) - end - - def self.operators # These are the operators used by filter types. @@ -179,7 +157,7 @@ class CostQuery < ActiveRecord::Base @available_filters = { :costs => { - "cost_type_id" => { :type => :list, :order => 2, :applies => [:cost_entries], :flags => [], :db_table => CostType.table_name, :db_field => "id", :values => [[l(:field_labor_costs), ""]] + CostType.find(:all, :order => 'name').collect{|s| [s.name, s.id.to_s] }}, + "cost_type_id" => { :type => :list_optional, :order => 2, :applies => [:cost_entries], :flags => [], :db_table => CostType.table_name, :db_field => "id", :values => CostType.find(:all, :order => 'name').collect{|s| [s.name, s.id.to_s] }}, "activity_id" => { :type => :list_optional, :order => 3, :applies => [:time_entries], :flags => [], :db_table => TimeEntryActivity.table_name, :db_field => "id", :values => TimeEntryActivity.find(:all, :order => 'position').collect{|s| [s.name, s.id.to_s] }}, "created_on" => { :type => :date_exact, :applies => [:time_entries, :cost_entries], :flags => [], :order => 4 }, "updated_on" => { :type => :date_exact, :applies => [:time_entries, :cost_entries], :flags => [], :order => 5 }, @@ -253,10 +231,6 @@ class CostQuery < ActiveRecord::Base return match.blank? ? nil : match[0] end - def clean_filters - - end - MAGIC_GROUP_KEYS = [:block, :time, :display, :db_field, :other_group] def self.grouping_column(*names, &block) @@ -671,9 +645,9 @@ private sql = '' case operator when "=" - sql = "#{db_table}.#{db_field} IN (" + value.collect{|val| val.present? ? "'#{connection.quote_string(val)}'" : "NULL"}.join(",") + ")" unless value.blank? + sql = "#{db_table}.#{db_field} IN (" + value.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + ")" unless value.blank? when "!" - sql = "(#{db_table}.#{db_field} IS NULL OR #{db_table}.#{db_field} NOT IN (" + value.collect{|val| val.present? ? "'#{connection.quote_string(val)}'" : "NULL"}.join(",") + "))" + sql = "(#{db_table}.#{db_field} IS NULL OR #{db_table}.#{db_field} NOT IN (" + value.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + "))" when "!*" sql = "#{db_table}.#{db_field} IS NULL" sql << " OR #{db_table}.#{db_field} = ''" if is_custom_filter