22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/custom_form_generator/helpers/template_render.rb', line 22
def filter_and_sort_template(_config)
<<-SLIM
div
button onclick='showFilterPanel()' Filter
select name='sort'
- config['sort'].each do |sort_option|
option value=sort_option['key'] = sort_option['label']
select name='order_by'
- config['order_by'].each do |order_option|
option value=order_option['key'] = order_option['label']
div id='filterPanel' style='display:none;'
- config['filter'].each do |filter_option|
label = filter_option['label']
- if filter_option['type'] == 'radio'
fieldset
legend= filter_option['label']
- filter_option['options'].each do |option|
input type='radio' name=filter_option['key'] value=option['value']
label= option['label']
- if filter_option['default']
input type='radio' name=filter_option['key'] value=filter_option['default'] checked
- else
- filter_option['options'].each do |option|
input type='checkbox' name=filter_option['key'] value=option['value']
label= option['label']
button type='submit' Apply
SLIM
end
|