Forward filter error messages to query

pull/693/head
Till Breuer 11 years ago committed by Christian Ratz
parent 5d4a5d3fcd
commit edb0170ee8
  1. 8
      app/models/query.rb

@ -83,7 +83,7 @@ class Query < ActiveRecord::Base
def validate_work_package_filters
self.filters.each do |filter|
errors.add :base, errors.full_message(WorkPackage.human_attribute_name(filter.field), I18n.t('activerecord.errors.messages.invalid')) unless filter.valid?
errors.add :base, errors.full_message(WorkPackage.human_attribute_name(filter.field), filter.errors.messages.values.flatten.join) unless filter.valid?
end
end
@ -97,11 +97,9 @@ class Query < ActiveRecord::Base
def add_filter(field, operator, values)
# values must be an array
return unless values and values.is_a? Array # and !values.first.empty?
# check if field is defined as an available filter
return unless values and values.is_a? Array
if work_package_filter_available? field
filter_options = available_work_package_filters[field]
self.filters << Queries::WorkPackages::Filter.new(field, operator: operator, values: values)
end
end

Loading…
Cancel
Save