Class: LatoView::Input::Cell
- Defined in:
- app/concepts/lato_view/input/cell.rb
Overview
Cella Input
Constant Summary collapse
- @@types =
Lista di tipologie di input accettate
VIEW_INPUTTYPES- @@widths =
Lista dei parametri accettati per l’attributo width
VIEW_INPUTWIDTH
Instance Attribute Summary collapse
-
#custom_class ⇒ Object
Classi custom da inserire nel codice dell’input * default: nil.
-
#disabled ⇒ Object
Valore che indica se disattivare o meno l’input * default: false.
-
#label ⇒ Object
Testo da inserire nella label dell’input * default: nil.
-
#multiple_files ⇒ Object
Valore che indica (nel caso di input file) se accettare piu’ file o uno singolarmente * default: false.
-
#name ⇒ Object
Nome da assegnare all’input * default: ‘input’.
-
#option_blank ⇒ Object
Valore booleano che indica (nel caso di input select) se mostrare o meno la prima opzione del select vuota * default: false.
-
#options ⇒ Object
Lista di opzioni da mostrare (nel caso di input select o radio buttons e checkbox).
-
#password_visible ⇒ Object
Valore booleano che indica (nel caso di input password) se mostrare il pulsante per vedere la password * default: true.
-
#placeholder ⇒ Object
Valore da inserire come placeholder all’input * default: nil.
-
#required ⇒ Object
Valore booleano usato per indicare se l’input e’ obbligatorio nel form in cui si trova * default: false.
-
#type ⇒ Object
Tipologia di input da inizializzare (text, number, select, password, email, multiple-select, date, checkbox, radio, textarea, file) * default: ‘text’.
-
#value ⇒ Object
Valore gia’ impostato nell’input * default: nil.
-
#width ⇒ Object
Dimensione dell’input (half, third, fourth, two-third) * default: nil (‘large’).
Class Method Summary collapse
-
.generate_options_from_activerecords(activerecords, value, name) ⇒ Object
Funzione che prende in input un activerecords, il nome dell’attributo da usare come valore e il nome dell’attributo da usare come nome e ritorna un array da usare come options per un input select o un radio buttons.
Instance Method Summary collapse
-
#initialize(type: 'text', name: 'input', placeholder: '', value: '', label: '', width: 'large', required: false, password_visible: true, custom_class: '', options: [], option_blank: false, disabled: false, multiple_files: false) ⇒ Cell
constructor
A new instance of Cell.
- #show ⇒ Object
Constructor Details
#initialize(type: 'text', name: 'input', placeholder: '', value: '', label: '', width: 'large', required: false, password_visible: true, custom_class: '', options: [], option_blank: false, disabled: false, multiple_files: false) ⇒ Cell
Returns a new instance of Cell.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'app/concepts/lato_view/input/cell.rb', line 71 def initialize(type: 'text', name: 'input', placeholder: '', value: '', label: '', width: 'large', required: false, password_visible: true, custom_class: '', options: [], option_blank: false, disabled: false, multiple_files: false) # eseguo brevi controlli sull'input raise 'Input Concept: type has not a correct value' unless @@types.include? type raise 'Input Concept: width has not a correct value' unless @@widths.include? width raise 'Input Concept: options must be an array' if && !.is_a?(Array) # assegno i valori alle variabili di istanza @type = type @name = name @placeholder = placeholder @value = value @label = label @width = width @required = required @password_visible = password_visible = @custom_class = custom_class @option_blank = option_blank @disabled = disabled @multiple_files = multiple_files end |
Instance Attribute Details
#custom_class ⇒ Object
Classi custom da inserire nel codice dell’input
-
default: nil
49 50 51 |
# File 'app/concepts/lato_view/input/cell.rb', line 49 def custom_class @custom_class end |
#disabled ⇒ Object
Valore che indica se disattivare o meno l’input
-
default: false
64 65 66 |
# File 'app/concepts/lato_view/input/cell.rb', line 64 def disabled @disabled end |
#label ⇒ Object
Testo da inserire nella label dell’input
-
default: nil
31 32 33 |
# File 'app/concepts/lato_view/input/cell.rb', line 31 def label @label end |
#multiple_files ⇒ Object
Valore che indica (nel caso di input file) se accettare piu’ file o uno singolarmente
-
default: false
69 70 71 |
# File 'app/concepts/lato_view/input/cell.rb', line 69 def multiple_files @multiple_files end |
#name ⇒ Object
Nome da assegnare all’input
-
default: ‘input’
19 20 21 |
# File 'app/concepts/lato_view/input/cell.rb', line 19 def name @name end |
#option_blank ⇒ Object
Valore booleano che indica (nel caso di input select) se mostrare o meno la prima opzione del select vuota
-
default: false
60 61 62 |
# File 'app/concepts/lato_view/input/cell.rb', line 60 def option_blank @option_blank end |
#options ⇒ Object
Lista di opzioni da mostrare (nel caso di input select o radio buttons e checkbox). La struttura deve essere [[‘value1’, ‘Name 1’], [‘value2’, ‘Name 2’]]
-
default: []
55 56 57 |
# File 'app/concepts/lato_view/input/cell.rb', line 55 def end |
#password_visible ⇒ Object
Valore booleano che indica (nel caso di input password) se mostrare il pulsante per vedere la password
-
default: true
45 46 47 |
# File 'app/concepts/lato_view/input/cell.rb', line 45 def password_visible @password_visible end |
#placeholder ⇒ Object
Valore da inserire come placeholder all’input
-
default: nil
23 24 25 |
# File 'app/concepts/lato_view/input/cell.rb', line 23 def placeholder @placeholder end |
#required ⇒ Object
Valore booleano usato per indicare se l’input e’ obbligatorio nel form in cui si trova
-
default: false
40 41 42 |
# File 'app/concepts/lato_view/input/cell.rb', line 40 def required @required end |
#type ⇒ Object
Tipologia di input da inizializzare (text, number, select, password, email, multiple-select, date, checkbox, radio, textarea, file)
-
default: ‘text’
15 16 17 |
# File 'app/concepts/lato_view/input/cell.rb', line 15 def type @type end |
#value ⇒ Object
Valore gia’ impostato nell’input
-
default: nil
27 28 29 |
# File 'app/concepts/lato_view/input/cell.rb', line 27 def value @value end |
#width ⇒ Object
Dimensione dell’input (half, third, fourth, two-third)
-
default: nil (‘large’)
35 36 37 |
# File 'app/concepts/lato_view/input/cell.rb', line 35 def width @width end |
Class Method Details
.generate_options_from_activerecords(activerecords, value, name) ⇒ Object
Funzione che prende in input un activerecords, il nome dell’attributo da usare come valore e il nome dell’attributo da usare come nome e ritorna un array da usare come options per un input select o un radio buttons
137 138 139 140 141 142 143 |
# File 'app/concepts/lato_view/input/cell.rb', line 137 def self.(activerecords, value, name) rows = [] activerecords.each do |row| rows.push([row.send(value), row.send(name)]) end rows end |
Instance Method Details
#show ⇒ Object
96 97 98 |
# File 'app/concepts/lato_view/input/cell.rb', line 96 def show render "#{@type.downcase}.html" if @type end |