ui_bibz 2.0.0.alpha28 → 2.0.0.alpha29
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -1
- data/Gemfile.lock +5 -3
- data/app/assets/javascripts/form.coffee +16 -54
- data/app/assets/javascripts/input-connected.coffee +39 -15
- data/app/assets/javascripts/table.coffee +3 -2
- data/app/assets/stylesheets/fix-dropdown-select.sass +6 -0
- data/app/assets/stylesheets/ui_bibz.sass +3 -3
- data/app/inputs/custom_inputs/{autocomplete_input.rb → auto_complete_field_input.rb} +2 -2
- data/app/inputs/custom_inputs/{dropdown_select_input.rb → collection_input.rb} +19 -12
- data/app/inputs/custom_inputs/{date_picker_input.rb → date_picker_field_input.rb} +1 -1
- data/app/inputs/custom_inputs/dropdown_select_field_input.rb +9 -0
- data/app/inputs/custom_inputs/{formula_input.rb → formula_field_input.rb} +1 -1
- data/app/inputs/custom_inputs/{markdown_editor_input.rb → markdown_editor_field_input.rb} +1 -1
- data/app/inputs/custom_inputs/{multi_column_input.rb → multi_column_field_input.rb} +1 -1
- data/app/inputs/custom_inputs/multi_select_field_input.rb +9 -0
- data/app/inputs/custom_inputs/{radios_input.rb → radio_field_input.rb} +1 -1
- data/app/inputs/custom_inputs/select_field_input.rb +8 -0
- data/app/inputs/custom_inputs/{surround_input.rb → surround_field_input.rb} +1 -1
- data/app/inputs/custom_inputs/{switch_input.rb → switch_field_input.rb} +1 -1
- data/lib/ui_bibz/concerns/models/searchable.rb +6 -1
- data/lib/ui_bibz/helpers/ui_core_helper.rb +2 -2
- data/lib/ui_bibz/ui/core/component.rb +0 -1
- data/lib/ui_bibz/ui/core/connected_component.rb +80 -0
- data/lib/ui_bibz/ui/core/forms/buttons/button.rb +1 -1
- data/lib/ui_bibz/ui/core/forms/buttons/button_refresh.rb +3 -3
- data/lib/ui_bibz/ui/core/forms/choices/switch_field.rb +1 -1
- data/lib/ui_bibz/ui/core/forms/numbers/formula_field.rb +5 -5
- data/lib/ui_bibz/ui/core/forms/selects/dropdown_select_field.rb +12 -21
- data/lib/ui_bibz/ui/core/forms/selects/multi_column_field.rb +8 -3
- data/lib/ui_bibz/ui/core/forms/selects/multi_select_field.rb +7 -12
- data/lib/ui_bibz/ui/core/forms/selects/select_field.rb +11 -10
- data/lib/ui_bibz/ui/core/forms/texts/{autocomplete_field.rb → auto_complete_field.rb} +30 -8
- data/lib/ui_bibz/ui/ux/tables/extensions/paginable.rb +2 -2
- data/lib/ui_bibz/ui/ux/tables/extensions/searchable.rb +1 -1
- data/lib/ui_bibz/ui/ux/tables/extensions/sortable.rb +4 -2
- data/lib/ui_bibz/ui/ux/tables/table_card.rb +3 -3
- data/lib/ui_bibz/ui/ux/tables/table_pagination.rb +5 -1
- data/lib/ui_bibz/ui/ux/tables/table_pagination_per_page.rb +3 -3
- data/lib/ui_bibz/ui/ux/tables/table_search_field.rb +6 -4
- data/lib/ui_bibz/version.rb +1 -1
- data/lib/ui_bibz.rb +2 -1
- data/test/dummy/app/models/continent.rb +3 -0
- data/test/dummy/app/models/country.rb +3 -0
- data/test/dummy/db/migrate/20170309084406_continents.rb +9 -0
- data/test/dummy/db/migrate/20170309084453_countries.rb +10 -0
- data/test/dummy/db/schema.rb +15 -3
- data/test/simple_form_test.rb +98 -36
- data/test/ui/core/forms/choices/switch_field_test.rb +10 -10
- data/test/ui/core/forms/numbers/formula_field_test.rb +1 -1
- data/test/ui/core/forms/selects/dropdown_select_field_test.rb +10 -10
- data/test/ui/core/forms/selects/multi_column_field_test.rb +2 -2
- data/test/ui/core/forms/selects/multi_select_field_test.rb +3 -3
- data/test/ui/core/forms/selects/select_field_test.rb +1 -1
- data/test/ui/core/forms/texts/auto_complete_field_test.rb +23 -0
- data/test/ui/ux/tables/table_test.rb +5 -5
- metadata +26 -16
- data/app/inputs/custom_inputs/multi_select_input.rb +0 -15
- data/app/inputs/custom_inputs/select_input.rb +0 -15
- data/test/ui/core/forms/texts/autocomplete_field_test.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eba8735c72e14ff037beabdc38c39cdca776757f
|
4
|
+
data.tar.gz: a1fa0ddb5be8b7056ab83e32258249ccf49bed1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd839687955389dd26fe3a3e355ff4d7803ecff01982d2f83fd0eaf99bcb8517ea3facc18bdd88c716656f010dc2cdbe5508102162f7b5780cb88fcbe157e84b
|
7
|
+
data.tar.gz: 4710b15b4581678be50bb53b0efb12db286676b1b15baafb5c39eff30161d0989105712ae83650529bf0e258f506ae9c6a660a513140c8fc0ad32be06a230554
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ui_bibz (2.0.0.
|
4
|
+
ui_bibz (2.0.0.alpha29)
|
5
5
|
bootstrap (= 4.0.0.alpha5)
|
6
6
|
font-awesome-sass
|
7
7
|
haml
|
@@ -53,13 +53,14 @@ GEM
|
|
53
53
|
minitest (~> 5.1)
|
54
54
|
tzinfo (~> 1.1)
|
55
55
|
arel (7.1.4)
|
56
|
-
autoprefixer-rails (6.7.
|
56
|
+
autoprefixer-rails (6.7.7)
|
57
57
|
execjs
|
58
|
+
awesome_print (1.7.0)
|
58
59
|
bootstrap (4.0.0.alpha5)
|
59
60
|
autoprefixer-rails (>= 6.0.3)
|
60
61
|
sass (>= 3.4.19)
|
61
62
|
builder (3.2.3)
|
62
|
-
codeclimate-test-reporter (1.0.
|
63
|
+
codeclimate-test-reporter (1.0.7)
|
63
64
|
simplecov
|
64
65
|
concurrent-ruby (1.0.5)
|
65
66
|
docile (1.1.5)
|
@@ -172,6 +173,7 @@ PLATFORMS
|
|
172
173
|
ruby
|
173
174
|
|
174
175
|
DEPENDENCIES
|
176
|
+
awesome_print
|
175
177
|
codeclimate-test-reporter
|
176
178
|
factory_girl_rails (~> 4.0)
|
177
179
|
minitest
|
@@ -1,36 +1,37 @@
|
|
1
1
|
@UiBibzForm = class Form
|
2
2
|
|
3
3
|
constructor: ->
|
4
|
-
@switch()
|
5
|
-
@inputConnected()
|
6
|
-
@selectPicker()
|
7
|
-
@multiSelect()
|
8
|
-
@multiColumn()
|
9
|
-
@formula()
|
4
|
+
@switch() if $('input.switch-field').length > 0
|
5
|
+
@inputConnected() if $('.ui-bibz-connect').length > 0
|
6
|
+
@selectPicker() if $('.dropdown-select-field').length > 0
|
7
|
+
@multiSelect() if $('.multi-select-field').length > 0
|
8
|
+
@multiColumn() if $('.multi-column-field').length > 0
|
9
|
+
@formula() if $('.formula-field').length > 0
|
10
10
|
|
11
11
|
inputConnected: ->
|
12
12
|
$('.ui-bibz-connect').inputConnected()
|
13
13
|
|
14
14
|
selectPicker: ->
|
15
|
-
$('select.
|
15
|
+
$('select.dropdown-select-field').selectpicker
|
16
16
|
iconBase: 'fa'
|
17
17
|
tickIcon: 'fa-check'
|
18
18
|
style: 'btn-secondary'
|
19
|
+
showTick: false
|
19
20
|
|
20
21
|
switch: ->
|
21
|
-
$('input.switch').bootstrapSwitch({ size: 'large' })
|
22
|
+
$('input.switch-field').bootstrapSwitch({ size: 'large' })
|
22
23
|
|
23
24
|
multiSelect: ->
|
24
25
|
# http://loudev.com/
|
25
|
-
$('.multi-select').each ->
|
26
|
+
$('.multi-select-field').each ->
|
26
27
|
data = $(this).data()
|
27
28
|
delete data["multiselect"]
|
28
|
-
data = Object.assign({ inheritClass: true }, data)
|
29
|
+
data = Object.assign({ buttonClass: 'btn btn-secondary', inheritClass: true }, data)
|
29
30
|
$(this).multiselect(data)
|
30
31
|
|
31
32
|
formula: ->
|
32
33
|
me = this
|
33
|
-
formula_input_field = $('.
|
34
|
+
formula_input_field = $('.formula-field')
|
34
35
|
me.updateFormulaField(formula_input_field)
|
35
36
|
|
36
37
|
formula_input_field.on 'keyup', ->
|
@@ -38,9 +39,9 @@
|
|
38
39
|
|
39
40
|
updateFormulaField: (field) ->
|
40
41
|
formulaInputField = field
|
41
|
-
formulaSignField = formulaInputField.siblings('.
|
42
|
-
formulaResultField = formulaInputField.siblings('.
|
43
|
-
formulaAlert = formulaInputField.siblings('.
|
42
|
+
formulaSignField = formulaInputField.siblings('.formula-field-sign')
|
43
|
+
formulaResultField = formulaInputField.siblings('.formula-field-result')
|
44
|
+
formulaAlert = formulaInputField.siblings('.formula-field-alert')
|
44
45
|
|
45
46
|
f = new window.UiBibzFormula()
|
46
47
|
result = f.go(formulaInputField.val())
|
@@ -66,43 +67,4 @@
|
|
66
67
|
formulaInputField.removeClass('fix-border-right')
|
67
68
|
|
68
69
|
multiColumn: ->
|
69
|
-
$(".multi-column").multiSelect()
|
70
|
-
# $('.multi-column').each ->
|
71
|
-
# data = $(this).data()
|
72
|
-
# delete data["multiselect"]
|
73
|
-
# if data["searchable"]
|
74
|
-
# $(this).multiSelect
|
75
|
-
# selectableOptgroup: if data["selectableOptgroup"] then true else false
|
76
|
-
# selectableHeader: "<input type='text' class='search-input form-control' autocomplete='off' placeholder='Search in selectable items'><br/>"
|
77
|
-
# selectionHeader: "<input type='text' class='search-input form-control' autocomplete='off' placeholder='Search in selected items'><br/>"
|
78
|
-
# afterInit: (ms) ->
|
79
|
-
# that = this
|
80
|
-
# $selectableSearch = that.$selectableUl.siblings('input')
|
81
|
-
# $selectionSearch = that.$selectionUl.siblings('input')
|
82
|
-
# $selectionSearch = that.$selectionUl.siblings('input')
|
83
|
-
# selectableSearchString = "#" + that.$container.attr("id") + " .ms-elem-selectable:not(.ms-selected)"
|
84
|
-
# selectionSearchString = "#" + that.$container.attr("id") + " .ms-elem-selection.ms-selected"
|
85
|
-
|
86
|
-
# that.qs1 = $selectableSearch.quicksearch(selectableSearchString).on("keydown", (e) ->
|
87
|
-
# if e.which is 40
|
88
|
-
# that.$selectableUl.focus()
|
89
|
-
# false
|
90
|
-
# )
|
91
|
-
# that.qs2 = $selectionSearch.quicksearch(selectionSearchString).on("keydown", (e) ->
|
92
|
-
# if e.which is 40
|
93
|
-
# that.$selectionUl.focus()
|
94
|
-
# false
|
95
|
-
# )
|
96
|
-
# return
|
97
|
-
|
98
|
-
# afterSelect: ->
|
99
|
-
# @qs1.cache()
|
100
|
-
# @qs2.cache()
|
101
|
-
# return
|
102
|
-
|
103
|
-
# afterDeselect: ->
|
104
|
-
# @qs1.cache()
|
105
|
-
# @qs2.cache()
|
106
|
-
# return
|
107
|
-
# else
|
108
|
-
# $(this).multiSelect(data)
|
70
|
+
$(".multi-column-field").multiSelect()
|
@@ -1,25 +1,46 @@
|
|
1
1
|
(($) ->
|
2
2
|
|
3
3
|
updateOptionsHtml = (data, componentTarget) ->
|
4
|
-
componentTarget.children('option').remove()
|
4
|
+
componentTarget.children('option:not([value=""])').remove()
|
5
|
+
|
6
|
+
if Array.isArray(data)
|
7
|
+
appendToElement(data, componentTarget)
|
8
|
+
else
|
9
|
+
$.each data, (k,v) ->
|
10
|
+
updateOptionsHtml(data, componentTarget)
|
11
|
+
optgroup = $("<optgroup></optgroup>").attr("label", k)
|
12
|
+
appendToElement(v, optgroup)
|
13
|
+
componentTarget.append(optgroup)
|
14
|
+
|
15
|
+
appendToElement = (data, element) ->
|
5
16
|
data.forEach (opt) ->
|
6
|
-
|
17
|
+
element.append($("<option></option>").attr("value", opt.value).text(opt.text))
|
7
18
|
|
8
|
-
updateTargetComponent = (data, componentTarget) ->
|
19
|
+
updateTargetComponent = (data, componentTarget, component) ->
|
9
20
|
updateOptionsHtml(data, componentTarget)
|
10
|
-
componentTarget
|
11
|
-
componentTarget.
|
12
|
-
componentTarget.
|
21
|
+
updateTargetRefreshButton(componentTarget, component)
|
22
|
+
componentTarget.multiSelect('refresh') if componentTarget.hasClass('multi-column-field')
|
23
|
+
componentTarget.selectpicker('refresh') if componentTarget.hasClass('dropdown-select-field')
|
24
|
+
componentTarget.multiselect('rebuild') if componentTarget.hasClass('multi-select-field')
|
25
|
+
componentTarget.change()
|
26
|
+
|
27
|
+
updateTargetRefreshButton = (componentTarget, component) ->
|
28
|
+
if hasRefreshButton(componentTarget)
|
29
|
+
refreshBtn = componentTarget.parents('.input-group').find('.input-refresh-button')
|
30
|
+
refreshBtn.attr('value', component.val()).attr('name', component.attr('name'))
|
31
|
+
|
32
|
+
hasRefreshButton = (component) ->
|
33
|
+
component.parents('.input-group').hasClass('field-refresh')
|
13
34
|
|
14
35
|
$.fn.inputConnected = (options) ->
|
15
36
|
|
16
37
|
defaults =
|
17
|
-
mode: "remote"
|
18
|
-
events: "change" # change, click, ...
|
38
|
+
mode: "remote" # String: remote || local
|
39
|
+
events: "change" # String: change, click, ...
|
19
40
|
target:
|
20
|
-
url: null # url for remote connection
|
21
|
-
selector: null # component target id
|
22
|
-
data: [] # data for local connection
|
41
|
+
url: null # String: url for remote connection
|
42
|
+
selector: null # String: component target id or class
|
43
|
+
data: [] # Array : data for local connection
|
23
44
|
# Add a proxy
|
24
45
|
# Proxy:
|
25
46
|
# url: null
|
@@ -46,13 +67,16 @@
|
|
46
67
|
|
47
68
|
component.on events, (e) ->
|
48
69
|
e.preventDefault()
|
49
|
-
componentTarget.empty()
|
50
70
|
values = component.val()
|
51
71
|
|
72
|
+
name = component.attr('name')
|
73
|
+
name = if name? then name.replace(' ', '_').split('[')[0] else "id"
|
74
|
+
name = if Array.isArray(values) then "#{ name }s" else name
|
75
|
+
|
52
76
|
if mode == "remote"
|
53
|
-
params =
|
77
|
+
params = { "#{ name }": values }
|
54
78
|
$.ajax({ url: target.url, data: params }).done (data) ->
|
55
|
-
updateTargetComponent(data, componentTarget)
|
79
|
+
updateTargetComponent(data, componentTarget, component)
|
56
80
|
|
57
81
|
if mode == "local"
|
58
82
|
data = target.data || settings.target.data
|
@@ -60,6 +84,6 @@
|
|
60
84
|
values = [].concat.apply([], [values]) # flatten
|
61
85
|
return values.includes(String(value.connect_option_id))
|
62
86
|
|
63
|
-
updateTargetComponent(data, componentTarget)
|
87
|
+
updateTargetComponent(data, componentTarget, component)
|
64
88
|
|
65
89
|
)(jQuery)
|
@@ -10,12 +10,13 @@
|
|
10
10
|
# Submit form when per_page select changing
|
11
11
|
submitPerPageSelect: ->
|
12
12
|
$('.table-pagination-per-page select').change () ->
|
13
|
+
$(this).parents('form').find('input[name=link_type]').val('per_page')
|
13
14
|
$(this).parents('form').submit()
|
14
15
|
|
15
16
|
# Clear search
|
16
17
|
clearSearch: ->
|
17
|
-
$('.
|
18
|
-
$(this).
|
18
|
+
$('.clear-search-btn').click () ->
|
19
|
+
$(this).parents('form').find('input[type=search]').val('')
|
19
20
|
$(this).parents('form').submit()
|
20
21
|
|
21
22
|
# Resize search field
|
@@ -71,10 +71,9 @@ select.form-control
|
|
71
71
|
border-bottom-right-radius: 0 !important
|
72
72
|
border-top-right-radius: 0 !important
|
73
73
|
width: 100%
|
74
|
-
.
|
74
|
+
.formula-field-sign
|
75
75
|
width: auto
|
76
76
|
min-width: 16px
|
77
|
-
padding: 4px 5px
|
78
77
|
font-weight: 400
|
79
78
|
line-height: 1.42857143
|
80
79
|
text-align: center
|
@@ -83,13 +82,14 @@ select.form-control
|
|
83
82
|
background-color: #eee
|
84
83
|
border: solid #ccc
|
85
84
|
border-width: 1px 0
|
85
|
+
padding: 0.5rem 0.75rem
|
86
86
|
margin-left: -5px
|
87
87
|
margin-right: -5px
|
88
88
|
border-left: none
|
89
89
|
border-right: none
|
90
90
|
.form-control[readonly]
|
91
91
|
background-color: white
|
92
|
-
.
|
92
|
+
.formula-field_alert, .formula-field-result, .formula-field-sign
|
93
93
|
display: none
|
94
94
|
|
95
95
|
.select-field-refresh
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module CustomInputs
|
2
|
-
class
|
2
|
+
class AutoCompleteFieldInput < SimpleForm::Inputs::CollectionInput
|
3
3
|
include UiBibz::Ui::Core::Forms::Texts
|
4
4
|
include ActionView::Helpers::FormOptionsHelper
|
5
5
|
|
@@ -9,7 +9,7 @@ module CustomInputs
|
|
9
9
|
options = options.merge({ builder: @builder })
|
10
10
|
options = options.merge(option_tags: options_from_collection_for_select(collection, label_method, label_method))
|
11
11
|
|
12
|
-
UiBibz::Ui::Core::Forms::Texts::
|
12
|
+
UiBibz::Ui::Core::Forms::Texts::AutoCompleteField.new(attribute_name, options, input_html_options).render
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -1,23 +1,30 @@
|
|
1
1
|
module CustomInputs
|
2
|
-
class
|
2
|
+
class CollectionInput < SimpleForm::Inputs::CollectionInput
|
3
3
|
include UiBibz::Ui::Core::Forms::Selects
|
4
|
+
include ActionView::Helpers::FormOptionsHelper
|
5
|
+
|
6
|
+
def input_html_options
|
7
|
+
opts = super
|
8
|
+
opts = opts.merge({ prompt: options[:prompt] }) unless options[:prompt].blank?
|
9
|
+
opts = opts.merge({ disabled: options[:disabled] }) unless options[:disabled].blank?
|
10
|
+
opts = opts.merge({ include_blank: options[:include_blank] }) unless options[:include_blank].blank?
|
11
|
+
opts = opts.merge({ multiple: options[:multiple] }) unless options[:multiple].blank?
|
12
|
+
opts
|
13
|
+
end
|
4
14
|
|
5
|
-
def
|
15
|
+
def new_options
|
6
16
|
label_method, value_method = detect_collection_methods
|
7
|
-
i = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new(attribute_name, options, input_html_options)
|
8
|
-
|
9
17
|
if options[:grouped] == true
|
10
|
-
|
11
|
-
|
18
|
+
options.merge({ option_tags: option_groups_from_collection_for_select(
|
19
|
+
grouped_collection,
|
12
20
|
group_method, group_label_method,
|
13
21
|
value_method, label_method,
|
14
|
-
input_options
|
15
|
-
)
|
22
|
+
input_options
|
23
|
+
)})
|
16
24
|
else
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
)
|
25
|
+
options.merge({ option_tags: options_from_collection_for_select(
|
26
|
+
collection, value_method, label_method, input_options
|
27
|
+
)})
|
21
28
|
end
|
22
29
|
end
|
23
30
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module CustomInputs
|
2
2
|
# multi_column_input manages collection and grouped_collection
|
3
|
-
class
|
3
|
+
class MultiColumnFieldInput < SimpleForm::Inputs::CollectionInput
|
4
4
|
include UiBibz::Ui::Core::Forms::Selects
|
5
5
|
|
6
6
|
def input(wrapper_options)
|
@@ -42,13 +42,14 @@ module UiBibz::Concerns::Models::Searchable
|
|
42
42
|
@tmp_params = {
|
43
43
|
search: @params[:search],
|
44
44
|
per_page: @params[:per_page],
|
45
|
-
page: @params[:page],
|
45
|
+
page: self.new_search? ? nil : @params[:page],
|
46
46
|
sort: @params[:sort],
|
47
47
|
direction: @params[:direction]
|
48
48
|
}
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
+
|
52
53
|
def self.search
|
53
54
|
sql = all
|
54
55
|
column_args = get_column_args
|
@@ -146,6 +147,10 @@ module UiBibz::Concerns::Models::Searchable
|
|
146
147
|
def self.is_good_store_id?
|
147
148
|
@arguments[:store_id] == @params[:store_id]
|
148
149
|
end
|
150
|
+
|
151
|
+
def self.new_search?
|
152
|
+
@params[:link_type] == 'search'
|
153
|
+
end
|
149
154
|
end
|
150
155
|
|
151
156
|
module ClassMethods
|
@@ -174,8 +174,8 @@ module UiBibz::Helpers::UiCoreHelper
|
|
174
174
|
#
|
175
175
|
# +options+ (Hash)
|
176
176
|
# +html_options+ (Hash)
|
177
|
-
def
|
178
|
-
UiBibz::Ui::Core::Forms::Texts::
|
177
|
+
def auto_complete_field content = nil, options = nil, html_options = nil, &block
|
178
|
+
UiBibz::Ui::Core::Forms::Texts::AutoCompleteField.new(content, options, html_options, &block).render
|
179
179
|
end
|
180
180
|
|
181
181
|
# Input section end ----------------------------------------------------
|
@@ -0,0 +1,80 @@
|
|
1
|
+
module UiBibz::Ui::Core
|
2
|
+
|
3
|
+
# Creates a connected component of the given +name+ using options created by the set of +options+.
|
4
|
+
#
|
5
|
+
# ==== Attributes
|
6
|
+
#
|
7
|
+
# * +content+ - Content of element
|
8
|
+
# * +options+ - Options of element
|
9
|
+
# * +html_options+ - Html Options of element
|
10
|
+
#
|
11
|
+
# ==== Options
|
12
|
+
#
|
13
|
+
# You can add HTML attributes using the +html_options+.
|
14
|
+
# You can pass arguments in options attribute:
|
15
|
+
# * +status+ - status of élement with symbol value:
|
16
|
+
# (+:default+, +:primary+, +:info+, +:warning+, +:danger+)
|
17
|
+
# * +glyph+ - Add glyph with name or hash options
|
18
|
+
# * +name+ - String
|
19
|
+
# * +size+ - Integer
|
20
|
+
# * +type+ - Symbol
|
21
|
+
#
|
22
|
+
# ==== Signatures
|
23
|
+
#
|
24
|
+
# UiBibz::Ui::Core::Component.new(content, options = nil, html_options = nil)
|
25
|
+
#
|
26
|
+
# UiBibz::Ui::Core::Component.new(options = nil, html_options = nil) do
|
27
|
+
# content
|
28
|
+
# end
|
29
|
+
#
|
30
|
+
# ==== Examples
|
31
|
+
#
|
32
|
+
# UiBibz::Ui::Core::Component.new(content, { type: :success, glyph: 'eye' }, { class: 'test' })
|
33
|
+
# # or
|
34
|
+
# UiBibz::Ui::Core::Component.new({glyph: { name: 'eye', size: 3}, { class: 'test' }) do
|
35
|
+
# content
|
36
|
+
# end
|
37
|
+
#
|
38
|
+
class ConnectedComponent < Component
|
39
|
+
|
40
|
+
# See UiBibz::Ui::Core::Component.initialize
|
41
|
+
def initialize content = nil, options = nil, html_options = nil, &block
|
42
|
+
super
|
43
|
+
end
|
44
|
+
|
45
|
+
# Render html tag
|
46
|
+
def render
|
47
|
+
super
|
48
|
+
end
|
49
|
+
|
50
|
+
protected
|
51
|
+
|
52
|
+
def refresh_render
|
53
|
+
content_tag :div, class: 'input-group field-refresh' do
|
54
|
+
concat select_tag content, options[:option_tags], html_options
|
55
|
+
concat refresh_btn_html
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def component_html_data
|
60
|
+
connect_options
|
61
|
+
end
|
62
|
+
|
63
|
+
private
|
64
|
+
|
65
|
+
def connect_opts
|
66
|
+
selector = options[:refresh][:target][:selector]
|
67
|
+
options[:refresh][:target][:selector] = selector.blank? ? "##{ content.to_s.parameterize.underscore }" : selector
|
68
|
+
options[:refresh]
|
69
|
+
end
|
70
|
+
|
71
|
+
def refresh_btn_html
|
72
|
+
content_tag(:span, UiBibz::Ui::Core::Forms::Buttons::ButtonRefresh.new('', connect: connect_opts).render, class: 'input-group-btn')
|
73
|
+
end
|
74
|
+
|
75
|
+
def connect_options
|
76
|
+
add_html_data('connect', options[:connect]) if options[:connect]
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
end
|
@@ -49,7 +49,7 @@ module UiBibz::Ui::Core::Forms::Buttons
|
|
49
49
|
# button(options = {}, html_options = {}) do
|
50
50
|
# content
|
51
51
|
# end
|
52
|
-
class Button < UiBibz::Ui::Core::
|
52
|
+
class Button < UiBibz::Ui::Core::ConnectedComponent
|
53
53
|
|
54
54
|
# See UiBibz::Ui::Core::Component.initialize
|
55
55
|
def initialize content = nil, options = nil, html_options = nil, &block
|
@@ -57,7 +57,7 @@ module UiBibz::Ui::Core::Forms::Buttons
|
|
57
57
|
private
|
58
58
|
|
59
59
|
def component_options
|
60
|
-
options[:connect] =
|
60
|
+
options[:connect] = cnt_opts
|
61
61
|
{ glyph: 'refresh', status: options[:status] }
|
62
62
|
end
|
63
63
|
|
@@ -65,10 +65,10 @@ module UiBibz::Ui::Core::Forms::Buttons
|
|
65
65
|
['input-refresh-button', 'btn']
|
66
66
|
end
|
67
67
|
|
68
|
-
def
|
68
|
+
def cnt_opts
|
69
69
|
{
|
70
70
|
events: options[:connect].try(:[], :events) || "click",
|
71
|
-
mode: options[:connect].try(:[], :
|
71
|
+
mode: options[:connect].try(:[], :mode) || "remote",
|
72
72
|
target: {
|
73
73
|
selector: options[:connect].try(:[], :target).try(:[], :selector) || "",
|
74
74
|
url: options[:connect].try(:[], :target).try(:[], :url) || "",
|