Class: Input::Select::Cell

Inherits:
Cell
  • Object
show all
Defined in:
app/cells/lato_view/input/select/cell.rb

Constant Summary collapse

@@widths =
VIEW_INPUTWIDTH

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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 = options
  @option_blank = option_blank
  @multiple = multiple
  # check params
  check_params
end

Instance Attribute Details

#createObject

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_classObject

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

#disabledObject

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

#labelObject

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

#multipleObject

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

#nameObject

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_blankObject

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

#optionsObject

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
  @options
end

#placeholderObject

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

#requiredObject

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

#valueObject

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

#widthObject

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.generate_options_from_activerecords(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.generate_options_from_array(array)
  rows = []
  array.each do |row|
    rows.push({name: row, value: row})
  end
  return rows
end

Instance Method Details

#showObject



31
32
33
# File 'app/cells/lato_view/input/select/cell.rb', line 31

def show
  render "show.html"
end