Class: Input::Select::Cell
- Inherits:
-
Cell
- Object
- Cell
- Input::Select::Cell
- Defined in:
- app/cells/lato_view/input/select/cell.rb
Constant Summary collapse
- @@widths =
VIEW_INPUTWIDTH
Instance Attribute Summary collapse
-
#create ⇒ Object
NB: options must be an array of hash ‘name’, value: ‘value’.
-
#custom_class ⇒ Object
NB: options must be an array of hash ‘name’, value: ‘value’.
-
#disabled ⇒ Object
NB: options must be an array of hash ‘name’, value: ‘value’.
-
#label ⇒ Object
NB: options must be an array of hash ‘name’, value: ‘value’.
-
#multiple ⇒ Object
NB: options must be an array of hash ‘name’, value: ‘value’.
-
#name ⇒ Object
NB: options must be an array of hash ‘name’, value: ‘value’.
-
#option_blank ⇒ Object
NB: options must be an array of hash ‘name’, value: ‘value’.
-
#options ⇒ Object
NB: options must be an array of hash ‘name’, value: ‘value’.
-
#placeholder ⇒ Object
NB: options must be an array of hash ‘name’, value: ‘value’.
-
#required ⇒ Object
NB: options must be an array of hash ‘name’, value: ‘value’.
-
#value ⇒ Object
NB: options must be an array of hash ‘name’, value: ‘value’.
-
#width ⇒ Object
NB: options must be an array of hash ‘name’, value: ‘value’.
Class Method Summary collapse
-
.generate_options_from_activerecords(activerecords, value, name) ⇒ Object
take in input an activerecords list, a value string and a name string, return an array that can be used with select.
-
.generate_options_from_array(array) ⇒ Object
take in input an array list, return an array that can be used with select.
Instance Method Summary collapse
-
#initialize(name: 'input', placeholder: '', value: '', label: '', width: 'large', required: false, disabled: false, custom_class: '', options: [], option_blank: true, multiple: false, create: false) ⇒ Cell
constructor
A new instance of Cell.
- #show ⇒ Object
Constructor Details
#initialize(name: 'input', placeholder: '', value: '', label: '', width: 'large', required: false, disabled: false, custom_class: '', options: [], option_blank: true, multiple: false, create: false) ⇒ Cell
Returns a new instance of Cell.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/cells/lato_view/input/select/cell.rb', line 10 def initialize(name: 'input', placeholder: '', value: '', label: '', width: 'large', required: false, disabled: false, custom_class: '', options: [], option_blank: true, multiple: false, create: false) # save params @name = name @placeholder = placeholder @value = value @label = label @width = width @required = required @disabled = disabled @custom_class = custom_class @select_class = (create ? 'select-create' : 'select') @options = @option_blank = option_blank @multiple = multiple # check params check_params end |
Instance Attribute Details
#create ⇒ Object
NB: options must be an array of hash ‘name’, value: ‘value’
7 8 9 |
# File 'app/cells/lato_view/input/select/cell.rb', line 7 def create @create end |
#custom_class ⇒ Object
NB: options must be an array of hash ‘name’, value: ‘value’
7 8 9 |
# File 'app/cells/lato_view/input/select/cell.rb', line 7 def custom_class @custom_class end |
#disabled ⇒ Object
NB: options must be an array of hash ‘name’, value: ‘value’
7 8 9 |
# File 'app/cells/lato_view/input/select/cell.rb', line 7 def disabled @disabled end |
#label ⇒ Object
NB: options must be an array of hash ‘name’, value: ‘value’
7 8 9 |
# File 'app/cells/lato_view/input/select/cell.rb', line 7 def label @label end |
#multiple ⇒ Object
NB: options must be an array of hash ‘name’, value: ‘value’
7 8 9 |
# File 'app/cells/lato_view/input/select/cell.rb', line 7 def multiple @multiple end |
#name ⇒ Object
NB: options must be an array of hash ‘name’, value: ‘value’
7 8 9 |
# File 'app/cells/lato_view/input/select/cell.rb', line 7 def name @name end |
#option_blank ⇒ Object
NB: options must be an array of hash ‘name’, value: ‘value’
7 8 9 |
# File 'app/cells/lato_view/input/select/cell.rb', line 7 def option_blank @option_blank end |
#options ⇒ Object
NB: options must be an array of hash ‘name’, value: ‘value’
7 8 9 |
# File 'app/cells/lato_view/input/select/cell.rb', line 7 def @options end |
#placeholder ⇒ Object
NB: options must be an array of hash ‘name’, value: ‘value’
7 8 9 |
# File 'app/cells/lato_view/input/select/cell.rb', line 7 def placeholder @placeholder end |
#required ⇒ Object
NB: options must be an array of hash ‘name’, value: ‘value’
7 8 9 |
# File 'app/cells/lato_view/input/select/cell.rb', line 7 def required @required end |
#value ⇒ Object
NB: options must be an array of hash ‘name’, value: ‘value’
7 8 9 |
# File 'app/cells/lato_view/input/select/cell.rb', line 7 def value @value end |
#width ⇒ Object
NB: options must be an array of hash ‘name’, value: ‘value’
7 8 9 |
# File 'app/cells/lato_view/input/select/cell.rb', line 7 def width @width end |
Class Method Details
.generate_options_from_activerecords(activerecords, value, name) ⇒ Object
take in input an activerecords list, a value string and a name string, return an array that can be used with select
69 70 71 72 73 74 75 |
# File 'app/cells/lato_view/input/select/cell.rb', line 69 def self.(activerecords, value, name) rows = [] activerecords.each do |row| rows.push({name: row.send(name), value: row.send(value)}) end return rows end |
.generate_options_from_array(array) ⇒ Object
take in input an array list, return an array that can be used with select
79 80 81 82 83 84 85 |
# File 'app/cells/lato_view/input/select/cell.rb', line 79 def self.(array) rows = [] array.each do |row| rows.push({name: row, value: row}) end return rows end |
Instance Method Details
#show ⇒ Object
31 32 33 |
# File 'app/cells/lato_view/input/select/cell.rb', line 31 def show render "show.html" end |