Class: FiltrosPersonalizados::FieldsPadroes::StringOptions

Inherits:
Field
  • Object
show all
Defined in:
lib/filtros_personalizados/fields_padroes/string_options.rb

Constant Summary

Constants inherited from Field

Field::DIFERENTE, Field::ENTRE, Field::IGUAL, Field::MAIOR_QUE, Field::MENOR_QUE, Field::NENHUM, Field::TODOS

Instance Attribute Summary

Attributes inherited from Field

#association, #autocomplete_path, #collection, #collection_id, #collection_name, #field_name, #field_type, #is_open, #noactions, #options, #partial_name, #relation, #tipo_selecionado, #values

Instance Method Summary collapse

Methods inherited from Field

#caption, #initialize

Constructor Details

This class inherits a constructor from FiltrosPersonalizados::FieldsPadroes::Field

Instance Method Details

#acoes_disponiveisObject



6
7
8
# File 'lib/filtros_personalizados/fields_padroes/string_options.rb', line 6

def acoes_disponiveis
  [IGUAL, DIFERENTE, TODOS] - self.noactions
end

#fileObject



19
20
21
# File 'lib/filtros_personalizados/fields_padroes/string_options.rb', line 19

def file
  "personalizaveis/stringoptions.html.erb"
end

#selecaoObject



23
24
25
26
27
28
29
30
# File 'lib/filtros_personalizados/fields_padroes/string_options.rb', line 23

def selecao
  aux = case self.tipo_selecionado
  when IGUAL       then self.values.present? ? " #{IGUAL.downcase} #{values.join(',')}" : ""
  when DIFERENTE   then self.values.present? ? " #{DIFERENTE.downcase} #{values.join(',')}" : ""
  else ""
  end
  aux.present? ? "#{self.caption}: #{aux}" : ""
end

#whereObject



10
11
12
13
14
15
16
17
# File 'lib/filtros_personalizados/fields_padroes/string_options.rb', line 10

def where
  return "" if values.blank?
  case self.tipo_selecionado
  when IGUAL       then self.values.present? ? "#{self.relation}.#{self.field_name}     in ('#{values.join('\',\'')}')" : ""
  when DIFERENTE   then self.values.present? ? "#{self.relation}.#{self.field_name} not in ('#{values.join('\',\'')}')" : ""
  else ""
  end
end