@query.is_public = false unless User.current.allowed_to?(:manage_public_queries, @project) || User.current.admin?
@query.column_names = nil if params[:default_columns]
- params[:fields].each do |field|
- @query.add_filter(field, params[:operators][field], params[:values][field])
- end if params[:fields]
+ @query.add_filters(params[:fields], params[:operators], params[:values]) if params[:fields]
@query.group_by ||= params[:group_by]
if request.post? && params[:confirm] && @query.save
def edit
if request.post?
@query.filters = {}
- params[:fields].each do |field|
- @query.add_filter(field, params[:operators][field], params[:values][field])
- end if params[:fields]
+ @query.add_filters(params[:fields], params[:operators], params[:values]) if params[:fields]
@query.attributes = params[:query]
@query.project = nil if params[:query_is_for_all]
@query.is_public = false unless User.current.allowed_to?(:manage_public_queries, @project) || User.current.admin?
parms = expression.scan(/^(o|c|!\*|!|\*)?(.*)$/).first
add_filter field, (parms[0] || "="), [parms[1] || ""]
end
+
+ # Add multiple filters using +add_filter+
+ def add_filters(fields, operators, values)
+ fields.each do |field|
+ add_filter(field, operators[field], values[field])
+ end
+ end
def has_filter?(field)
filters and filters[field]