Class: FiltrosPersonalizados::FieldsPadroes::Field

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

Constant Summary collapse

TODOS =
"Prenchidos"
NENHUM =
"Não preenchidos"
IGUAL =
"Igual a"
DIFERENTE =
"Diferente de"
ENTRE =
"Entre"
MAIOR_QUE =
"Maior que"
MENOR_QUE =
"Menor que"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(relation, field_name, args = {}) ⇒ Field

Returns a new instance of Field.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/filtros_personalizados/fields_padroes/field.rb', line 17

def initialize(relation, field_name, args={})
  self.relation         = relation
  self.field_name       = field_name
  self.tipo_selecionado = args[:tipo_selecionado]
  self.values           = args[:values]
  self.collection       = args[:collection]
  self.collection_id    = args[:collection_id]
  self.collection_name  = args[:collection_name]
  self.partial_name     = args[:partial_name]
  self.autocomplete_path= args[:autocomplete_path]
  self.options          = args[:options]
  self.noactions        = args[:noactions] || []
  if args[:association_relation].present? && args[:association_name].present? && args[:association_search].present?
    self.association      = FiltrosPersonalizados::Association.new(
      args[:association_relation],
      args[:association_name],
      args[:association_search]
    )
  end
end

Instance Attribute Details

#associationObject

Returns the value of attribute association.



5
6
7
# File 'lib/filtros_personalizados/fields_padroes/field.rb', line 5

def association
  @association
end

#autocomplete_pathObject

Returns the value of attribute autocomplete_path.



5
6
7
# File 'lib/filtros_personalizados/fields_padroes/field.rb', line 5

def autocomplete_path
  @autocomplete_path
end

#collectionObject

Returns the value of attribute collection.



5
6
7
# File 'lib/filtros_personalizados/fields_padroes/field.rb', line 5

def collection
  @collection
end

#collection_idObject

Returns the value of attribute collection_id.



5
6
7
# File 'lib/filtros_personalizados/fields_padroes/field.rb', line 5

def collection_id
  @collection_id
end

#collection_nameObject

Returns the value of attribute collection_name.



5
6
7
# File 'lib/filtros_personalizados/fields_padroes/field.rb', line 5

def collection_name
  @collection_name
end

#field_nameObject

Returns the value of attribute field_name.



5
6
7
# File 'lib/filtros_personalizados/fields_padroes/field.rb', line 5

def field_name
  @field_name
end

#field_typeObject

Returns the value of attribute field_type.



5
6
7
# File 'lib/filtros_personalizados/fields_padroes/field.rb', line 5

def field_type
  @field_type
end

#is_openObject

Returns the value of attribute is_open.



5
6
7
# File 'lib/filtros_personalizados/fields_padroes/field.rb', line 5

def is_open
  @is_open
end

#noactionsObject

Returns the value of attribute noactions.



5
6
7
# File 'lib/filtros_personalizados/fields_padroes/field.rb', line 5

def noactions
  @noactions
end

#optionsObject

Returns the value of attribute options.



5
6
7
# File 'lib/filtros_personalizados/fields_padroes/field.rb', line 5

def options
  @options
end

#partial_nameObject

Returns the value of attribute partial_name.



5
6
7
# File 'lib/filtros_personalizados/fields_padroes/field.rb', line 5

def partial_name
  @partial_name
end

#relationObject

Returns the value of attribute relation.



5
6
7
# File 'lib/filtros_personalizados/fields_padroes/field.rb', line 5

def relation
  @relation
end

#tipo_selecionadoObject

Returns the value of attribute tipo_selecionado.



5
6
7
# File 'lib/filtros_personalizados/fields_padroes/field.rb', line 5

def tipo_selecionado
  @tipo_selecionado
end

#valuesObject

Returns the value of attribute values.



5
6
7
# File 'lib/filtros_personalizados/fields_padroes/field.rb', line 5

def values
  @values
end

Instance Method Details

#captionObject



38
39
40
41
# File 'lib/filtros_personalizados/fields_padroes/field.rb', line 38

def caption
  I18n.t("activerecord.attributes.#{self.relation.singularize}.#{self.field_name}",
          default: I18n.t(self.field_name)) rescue  self.field_name
end