Sha256: af41e06754a7562cd3c7021627d775eb8277433b375a21a559400b0e69b35295

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_list_columns
    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

Version Path
redmine_extensions-0.0.39 lib/generators/redmine_extensions/entity/templates/query.rb.erb
redmine_extensions-0.0.38 lib/generators/redmine_extensions/entity/templates/query.rb.erb
redmine_extensions-0.0.37 lib/generators/redmine_extensions/entity/templates/query.rb.erb
redmine_extensions-0.0.36 lib/generators/redmine_extensions/entity/templates/query.rb.erb
redmine_extensions-0.0.34 lib/generators/redmine_extensions/entity/templates/query.rb.erb
redmine_extensions-0.0.33 lib/generators/redmine_extensions/entity/templates/query.rb.erb