Sha256: 1d113bac1767e5e7fd5356460e21d3a620b233747a09b7a6771f445b93a82817
Contents?: true
Size: 1.47 KB
Versions: 6
Compression:
Stored size: 1.47 KB
Contents
class <%= model_name %>Query < EasyQuery self.queried_class = <%= model_name %> def initialize_available_filters <%- db_columns.each do |column_name, column_options| -%> <%- if project? && column_name == 'project_id' -%> if project.nil? add_available_filter '<%= column_name %>', name: ::<%= model_name %>.human_attribute_name(:<%= column_name %>), type: :<%= column_options[:query_type] %>, values: all_projects_values end <%- else -%> add_available_filter '<%= column_name %>', name: ::<%= model_name %>.human_attribute_name(:<%= column_name %>), type: :<%= column_options[:query_type] -%> <%- end -%> <%- end -%> <%- if acts_as_customizable? -%> add_custom_fields_filters(<%= model_name %>CustomField) <%- end -%> end def available_columns return @available_columns if @available_columns <%- db_columns.each do |column_name, column_options| -%> add_available_column '<%= column_options[:query_column_name] || column_name %>', caption: ::<%= model_name %>.human_attribute_name(:<%= column_name %>) <%- end -%> <%- if acts_as_customizable? -%> @available_columns += <%= model_name %>CustomField.visible.collect {|cf| QueryCustomFieldColumn.new(cf) } <%- end -%> @available_columns end def default_columns_names super.presence || <%= db_columns.collect{|column_name, column_options| (column_options[:query_column_name] || column_name).to_sym}[0..3].to_s %>.flat_map{|c| [c.to_s, c.to_sym]} end end
Version data entries
6 entries across 6 versions & 1 rubygems