ui_bibz 2.0.0.alpha26 → 2.0.0.alpha27

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6e201b34591106705046a782c99ff13790c3ba97
4
- data.tar.gz: 33322f78ac7cabfacc2f9bc6e2962b693985e19f
3
+ metadata.gz: 0a49b595e3b3bbb119b817a614eba6b4c598e0f7
4
+ data.tar.gz: 8f16ce2ac1f0f6a1af2f0f8d722d9de9257c15a5
5
5
  SHA512:
6
- metadata.gz: 88e4bbd1372e35d65da74020f3c25ab6d30d8f81f0cf2e6b84437befc083c2e4b76bb23d4d5aacaea39671f5a121c8a4f1c151d6d01f20353687e798f177d438
7
- data.tar.gz: 28dffc8d28d507a6bbf21223b6509b8bb4d28076a1309e81c7f27e397ec1cf7c32f8e266d2fac995b36211f8fd5138ce0d75e4367452a191e423c3df1220aed7
6
+ metadata.gz: da948b0bd0354030fb60b60ab33340d1d9d798459d3eaab79d0bec3b086bf3ae31db20b1f35c0e67f2cfe754eedaf1c14e8f08cde511759f5dff1b42d145a9c3
7
+ data.tar.gz: 9e4ed4f4f4cfd18cd2018ee394d07541b76bc620e5a7db82b557dbb426125425e22fc84ae38b3e486717863f9297596e34fd57964bace828f821187f0dda5b7e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ui_bibz (2.0.0.alpha26)
4
+ ui_bibz (2.0.0.alpha27)
5
5
  bootstrap (= 4.0.0.alpha5)
6
6
  font-awesome-sass
7
7
  haml
@@ -53,14 +53,14 @@ GEM
53
53
  minitest (~> 5.1)
54
54
  tzinfo (~> 1.1)
55
55
  arel (7.1.4)
56
- autoprefixer-rails (6.6.0)
56
+ autoprefixer-rails (6.7.5)
57
57
  execjs
58
58
  awesome_print (1.7.0)
59
59
  bootstrap (4.0.0.alpha5)
60
60
  autoprefixer-rails (>= 6.0.3)
61
61
  sass (>= 3.4.19)
62
- builder (3.2.2)
63
- codeclimate-test-reporter (1.0.4)
62
+ builder (3.2.3)
63
+ codeclimate-test-reporter (1.0.6)
64
64
  simplecov
65
65
  concurrent-ruby (1.0.4)
66
66
  docile (1.1.5)
@@ -83,13 +83,13 @@ GEM
83
83
  haml (>= 4.0.6, < 5.0)
84
84
  html2haml (>= 1.0.1)
85
85
  railties (>= 4.0.1)
86
- html2haml (2.0.0)
86
+ html2haml (2.1.0)
87
87
  erubis (~> 2.7.0)
88
- haml (~> 4.0.0)
89
- nokogiri (~> 1.6.0)
88
+ haml (~> 4.0)
89
+ nokogiri (>= 1.6.0)
90
90
  ruby_parser (~> 3.5)
91
- i18n (0.7.0)
92
- json (2.0.2)
91
+ i18n (0.8.1)
92
+ json (2.0.3)
93
93
  loofah (2.0.3)
94
94
  nokogiri (>= 1.5.9)
95
95
  mail (2.6.4)
@@ -101,7 +101,7 @@ GEM
101
101
  mini_portile2 (2.1.0)
102
102
  minitest (5.10.1)
103
103
  nio4r (1.2.1)
104
- nokogiri (1.6.8.1)
104
+ nokogiri (1.7.0.1)
105
105
  mini_portile2 (~> 2.1.0)
106
106
  rack (2.0.1)
107
107
  rack-test (0.6.3)
@@ -130,7 +130,7 @@ GEM
130
130
  rake (>= 0.8.7)
131
131
  thor (>= 0.18.1, < 2.0)
132
132
  rake (12.0.0)
133
- ruby_parser (3.8.3)
133
+ ruby_parser (3.8.4)
134
134
  sexp_processor (~> 4.1)
135
135
  sass (3.4.23)
136
136
  sass-rails (5.0.6)
@@ -139,11 +139,11 @@ GEM
139
139
  sprockets (>= 2.8, < 4.0)
140
140
  sprockets-rails (>= 2.0, < 4.0)
141
141
  tilt (>= 1.1, < 3)
142
- sexp_processor (4.7.0)
143
- simple_form (3.3.1)
142
+ sexp_processor (4.8.0)
143
+ simple_form (3.4.0)
144
144
  actionpack (> 4, < 5.1)
145
145
  activemodel (> 4, < 5.1)
146
- simplecov (0.12.0)
146
+ simplecov (0.13.0)
147
147
  docile (~> 1.1.0)
148
148
  json (>= 1.8, < 3)
149
149
  simplecov-html (~> 0.10.0)
@@ -155,13 +155,13 @@ GEM
155
155
  actionpack (>= 4.0)
156
156
  activesupport (>= 4.0)
157
157
  sprockets (>= 3.0.0)
158
- sqlite3 (1.3.12)
158
+ sqlite3 (1.3.13)
159
159
  thor (0.19.4)
160
- thread_safe (0.3.5)
161
- tilt (2.0.5)
160
+ thread_safe (0.3.6)
161
+ tilt (2.0.6)
162
162
  tzinfo (1.2.2)
163
163
  thread_safe (~> 0.1)
164
- websocket-driver (0.6.4)
164
+ websocket-driver (0.6.5)
165
165
  websocket-extensions (>= 0.1.0)
166
166
  websocket-extensions (0.1.2)
167
167
  will-paginate-i18n (0.1.15)
@@ -2,11 +2,15 @@
2
2
 
3
3
  constructor: ->
4
4
  @switch() if $('input.switch').length > 0
5
+ @inputConnected()
5
6
  @selectPicker() if $('select.selectpicker').length > 0
6
7
  @multiSelect() if $('.multi-select').length > 0
7
8
  @multiColumn() if $('.multi-column').length > 0
8
9
  @formula() if $('.formula_field_input').length > 0
9
10
 
11
+ inputConnected: ->
12
+ $('.ui-bibz-connect').inputConnected()
13
+
10
14
  selectPicker: ->
11
15
  $('select.selectpicker').selectpicker
12
16
  iconBase: 'fa'
@@ -62,42 +66,43 @@
62
66
  formulaInputField.removeClass('fix-border-right')
63
67
 
64
68
  multiColumn: ->
65
- $('.multi-column').each ->
66
- data = $(this).data()
67
- delete data["multiselect"]
68
- if data["searchable"]
69
- $(this).multiSelect
70
- selectableOptgroup: if data["selectableOptgroup"] then true else false
71
- selectableHeader: "<input type='text' class='search-input form-control' autocomplete='off' placeholder='Search in selectable items'><br/>"
72
- selectionHeader: "<input type='text' class='search-input form-control' autocomplete='off' placeholder='Search in selected items'><br/>"
73
- afterInit: (ms) ->
74
- that = this
75
- $selectableSearch = that.$selectableUl.siblings('input')
76
- $selectionSearch = that.$selectionUl.siblings('input')
77
- $selectionSearch = that.$selectionUl.siblings('input')
78
- selectableSearchString = "#" + that.$container.attr("id") + " .ms-elem-selectable:not(.ms-selected)"
79
- selectionSearchString = "#" + that.$container.attr("id") + " .ms-elem-selection.ms-selected"
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"
80
85
 
81
- that.qs1 = $selectableSearch.quicksearch(selectableSearchString).on("keydown", (e) ->
82
- if e.which is 40
83
- that.$selectableUl.focus()
84
- false
85
- )
86
- that.qs2 = $selectionSearch.quicksearch(selectionSearchString).on("keydown", (e) ->
87
- if e.which is 40
88
- that.$selectionUl.focus()
89
- false
90
- )
91
- return
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
92
97
 
93
- afterSelect: ->
94
- @qs1.cache()
95
- @qs2.cache()
96
- return
98
+ # afterSelect: ->
99
+ # @qs1.cache()
100
+ # @qs2.cache()
101
+ # return
97
102
 
98
- afterDeselect: ->
99
- @qs1.cache()
100
- @qs2.cache()
101
- return
102
- else
103
- $(this).multiSelect(data)
103
+ # afterDeselect: ->
104
+ # @qs1.cache()
105
+ # @qs2.cache()
106
+ # return
107
+ # else
108
+ # $(this).multiSelect(data)
@@ -0,0 +1,65 @@
1
+ (($) ->
2
+
3
+ updateOptionsHtml = (data, componentTarget) ->
4
+ componentTarget.children('option').remove()
5
+ data.forEach (opt) ->
6
+ componentTarget.append($("<option></option>").attr("value", opt.value).text(opt.text))
7
+
8
+ updateTargetComponent = (data, componentTarget) ->
9
+ updateOptionsHtml(data, componentTarget)
10
+ componentTarget.multiSelect('refresh') if componentTarget.hasClass('multi-column')
11
+ componentTarget.selectpicker('refresh') if componentTarget.hasClass('selectpicker')
12
+ componentTarget.multiselect('rebuild') if componentTarget.hasClass('multi-select')
13
+
14
+ $.fn.inputConnected = (options) ->
15
+
16
+ defaults =
17
+ mode: "remote"
18
+ events: "change" # change, click, ...
19
+ target:
20
+ url: null # url for remote connection
21
+ selector: null # component target id
22
+ data: [] # data for local connection
23
+ # Add a proxy
24
+ # Proxy:
25
+ # url: null
26
+ # method: 'GET'
27
+ # data: null
28
+
29
+ settings = $.extend({}, defaults, options)
30
+
31
+ self = this
32
+ return this.each ->
33
+ component = $(this)
34
+ connect = component.data().connect
35
+ connect.target = connect.target || {}
36
+ return unless connect?
37
+
38
+ mode = connect.mode || settings.mode
39
+ events = connect.events || settings.events
40
+ target =
41
+ url: connect.target.url || settings.target.url
42
+ data: connect.target.data || settings.target.data
43
+ selector: connect.target.selector || settings.target.selector
44
+
45
+ componentTarget = $("#{ target.selector }")
46
+
47
+ component.on events, (e) ->
48
+ e.preventDefault()
49
+ componentTarget.empty()
50
+ values = component.val()
51
+
52
+ if mode == "remote"
53
+ params = if Array.isArray(values) then { ids: values } else { id: values }
54
+ $.ajax({ url: target.url, data: params }).done (data) ->
55
+ updateTargetComponent(data, componentTarget)
56
+
57
+ if mode == "local"
58
+ data = target.data || settings.target.data
59
+ data = data.filter (value) ->
60
+ values = [].concat.apply([], [values]) # flatten
61
+ return values.includes(String(value.connect_option_id))
62
+
63
+ updateTargetComponent(data, componentTarget)
64
+
65
+ )(jQuery)
@@ -0,0 +1,38 @@
1
+ $.fn.multiSelect.defaults =
2
+ qs1: null
3
+ qs2: null
4
+ selectableOptgroup: false
5
+ selectableHeader: "<input type='text' class='search-input form-control' autocomplete='off' placeholder='Search in selectable items'><br/>"
6
+ selectionHeader: "<input type='text' class='search-input form-control' autocomplete='off' placeholder='Search in selected items'><br/>"
7
+ afterInit: (ms) ->
8
+ that = this
9
+ that.options.selectableOptgroup = if $(this)[0].$element.data('selectableOptgroup') then true else false
10
+
11
+ if $(this)[0].$element.data('searchable')
12
+ $selectableSearch = that.$selectableUl.siblings('input')
13
+ $selectionSearch = that.$selectionUl.siblings('input')
14
+ $selectionSearch = that.$selectionUl.siblings('input')
15
+ selectableSearchString = "#" + that.$container.attr("id") + " .ms-elem-selectable:not(.ms-selected)"
16
+ selectionSearchString = "#" + that.$container.attr("id") + " .ms-elem-selection.ms-selected"
17
+
18
+ that.qs1 = $selectableSearch.quicksearch(selectableSearchString).on("keydown", (e) ->
19
+ if e.which is 40
20
+ that.$selectableUl.focus()
21
+ false
22
+ )
23
+ that.qs2 = $selectionSearch.quicksearch(selectionSearchString).on("keydown", (e) ->
24
+ if e.which is 40
25
+ that.$selectionUl.focus()
26
+ false
27
+ )
28
+ else
29
+ that.$selectableContainer.children('.search-input').remove()
30
+ that.$selectionContainer.children('.search-input').remove()
31
+
32
+ afterSelect: ->
33
+ @qs1.cache() if @qs1?
34
+ @qs2.cache() if @qs2?
35
+
36
+ afterDeselect: ->
37
+ @qs1.cache() if @qs1?
38
+ @qs2.cache() if @qs2?
@@ -4,6 +4,7 @@
4
4
  # multi_column_field component
5
5
  #= require jquery.quicksearch.min
6
6
  #= require jquery.multi-select.min
7
+ #= require jquery.multi-select-extend
7
8
 
8
9
  # Bootstrap
9
10
  #= require tether.min
@@ -21,6 +22,9 @@
21
22
  # multi_select_field component
22
23
  #= require bootstrap-multiselect.min
23
24
 
25
+ # input_connected
26
+ #= require input-connected
27
+
24
28
  # mardown-editor
25
29
  #= require marked
26
30
  #= require bootstrap-markdown
@@ -91,3 +91,7 @@ select.form-control
91
91
  background-color: white
92
92
  .formula_field_alert, .formula_field_result, .formula_field_sign
93
93
  display: none
94
+
95
+ .select-field-refresh
96
+ .btn
97
+ padding: 10px 16px
@@ -0,0 +1,15 @@
1
+ module CustomInputs
2
+ class SelectInput < SimpleForm::Inputs::CollectionInput
3
+ include UiBibz::Ui::Core::Forms::Selects
4
+
5
+ def input(wrapper_options)
6
+ label_method, value_method = detect_collection_methods
7
+ i = UiBibz::Ui::Core::Forms::Selects::SelectField.new(attribute_name, options, input_html_options)
8
+
9
+ @builder.collection_select(
10
+ attribute_name, collection, value_method, label_method,
11
+ input_options, i.html_options
12
+ )
13
+ end
14
+ end
15
+ end
data/lib/ui_bibz.rb CHANGED
@@ -43,6 +43,7 @@ module UiBibz
43
43
 
44
44
  module Selects
45
45
  autoload :DropdownSelectField, "ui_bibz/ui/core/forms/selects/dropdown_select_field"
46
+ autoload :SelectField, "ui_bibz/ui/core/forms/selects/select_field"
46
47
  autoload :MultiColumnField, "ui_bibz/ui/core/forms/selects/multi_column_field"
47
48
  autoload :MultiSelectField, "ui_bibz/ui/core/forms/selects/multi_select_field"
48
49
  end
@@ -8,7 +8,7 @@ module UiBibz::Concerns::Models::Searchable
8
8
  @session = session
9
9
  @arguments = args
10
10
 
11
- initialize_params unless @arguments[:store_id].nil?
11
+ initialize_params
12
12
  OpenStruct.new(generate_parameters)
13
13
  end
14
14
 
@@ -37,12 +37,15 @@ module UiBibz::Concerns::Models::Searchable
37
37
 
38
38
  # If there is more one table in html page
39
39
  def self.initialize_params
40
- unless self.is_good_store_id?
41
- @params[:search] = nil
42
- @params[:per_page] = nil
43
- @params[:page] = nil
44
- @params[:sort] = nil
45
- @params[:direction] = nil
40
+ @tmp_params = {}
41
+ if self.is_good_store_id?
42
+ @tmp_params = {
43
+ search: @params[:search],
44
+ per_page: @params[:per_page],
45
+ page: @params[:page],
46
+ sort: @params[:sort],
47
+ direction: @params[:direction]
48
+ }
46
49
  end
47
50
  end
48
51
 
@@ -60,7 +63,7 @@ module UiBibz::Concerns::Models::Searchable
60
63
  sql = generate_parent_sort_query sql if @params[:parent]
61
64
 
62
65
  # Main query with argument or not
63
- sql = search_by_query sql unless @params[:search].blank?
66
+ sql = search_by_query sql unless @tmp_params[:search].blank?
64
67
 
65
68
  generate_sql sql, column_args
66
69
  end
@@ -71,15 +74,15 @@ module UiBibz::Concerns::Models::Searchable
71
74
 
72
75
  def self.generate_default_sql sql
73
76
  if is_sorting?
74
- sql.paginate(:page => @params[:page], per_page: @session[:per_page])
77
+ sql.paginate(:page => @tmp_params[:page], per_page: @session[:per_page])
75
78
  else
76
- sql.reorder(order_sql).paginate(:page => @params[:page], per_page: @session[:per_page])
79
+ sql.reorder(order_sql).paginate(:page => @tmp_params[:page], per_page: @session[:per_page])
77
80
  end
78
81
  end
79
82
 
80
83
  def self.generate_count_sql sql
81
- sq = "SELECT * FROM (#{ sql.group(table_name + '.id').to_sql }) countable ORDER BY countable.count #{ @params[:direction] || asc }"
82
- self.paginate_by_sql(sq, :page => @params[:page], per_page: @session[:per_page])
84
+ sq = "SELECT * FROM (#{ sql.group(table_name + '.id').to_sql }) countable ORDER BY countable.count #{ @tmp_params[:direction] || asc }"
85
+ self.paginate_by_sql(sq, :page => @tmp_params[:page], per_page: @session[:per_page])
83
86
  end
84
87
 
85
88
  def self.generate_select_count_sort_query sql, column_args
@@ -87,7 +90,7 @@ module UiBibz::Concerns::Models::Searchable
87
90
  end
88
91
 
89
92
  def self.generate_parent_sort_query sql
90
- sql.select("#{ table_name }2.*, #{ @params[:sort] } AS parent_name").from("#{ table_name } #{ table_name }2").joins("LEFT OUTER JOIN #{ table_name } ON #{ table_name }2.parent_id = #{ table_name }.id")
93
+ sql.select("#{ table_name }2.*, #{ @tmp_params[:sort] } AS parent_name").from("#{ table_name } #{ table_name }2").joins("LEFT OUTER JOIN #{ table_name } ON #{ table_name }2.parent_id = #{ table_name }.id")
91
94
  end
92
95
 
93
96
  def self.get_column_args
@@ -99,14 +102,14 @@ module UiBibz::Concerns::Models::Searchable
99
102
  end
100
103
 
101
104
  def self.is_sorting?
102
- @params[:sort].nil? || @params[:direction].nil?
105
+ @tmp_params[:sort].nil? || @tmp_params[:direction].nil?
103
106
  end
104
107
 
105
108
  def self.search_by_query sql
106
109
  raise 'Add searchable_attributes method in Model' if @searchable_attributes.nil?
107
110
  sql_query = []
108
111
  sql_attributes = {}
109
- search_patterns = @params[:search].strip.gsub(/(?<=[\\s])\\s*|^\\s+|\\s+$/, '').downcase
112
+ search_patterns = @tmp_params[:search].strip.gsub(/(?<=[\\s])\\s*|^\\s+|\\s+$/, '').downcase
110
113
 
111
114
  search_patterns_tmp = search_patterns.scan(/"(.*?)"/).flatten
112
115
  search_patterns = search_patterns.gsub(/"(.*?)"/, '').split(' ')
@@ -131,11 +134,11 @@ module UiBibz::Concerns::Models::Searchable
131
134
  end
132
135
 
133
136
  def self.order_sql
134
- self.is_sorting? ? "#{ self.table_name }.id asc" : "#{ @params[:sort]} #{ @params[:direction] }"
137
+ self.is_sorting? ? "#{ self.table_name }.id asc" : "#{ @tmp_params[:sort]} #{ @tmp_params[:direction] }"
135
138
  end
136
139
 
137
140
  def self.search_sort_paginate
138
- @session[:per_page] = @params[:per_page] unless @params[:per_page].nil?
141
+ @session[:per_page] = @tmp_params[:per_page] unless @tmp_params[:per_page].nil?
139
142
  self.search
140
143
  end
141
144
 
@@ -154,6 +154,14 @@ module UiBibz::Helpers::UiCoreHelper
154
154
  UiBibz::Ui::Core::Forms::Choices::RadioField.new(content, options, html_options, &block).render
155
155
  end
156
156
 
157
+ # Select Field Component
158
+ #
159
+ # +options+ (Hash)
160
+ # +html_options+ (Hash)
161
+ def select_field content = nil, options = nil, html_options = nil, &block
162
+ UiBibz::Ui::Core::Forms::Selects::SelectField.new(content, options, html_options, &block).render
163
+ end
164
+
157
165
  # Dropdown Select Field Component
158
166
  #
159
167
  # +options+ (Hash)
@@ -90,6 +90,7 @@ module UiBibz::Ui::Core
90
90
 
91
91
  # Override this method to add html data
92
92
  def component_html_data
93
+ add_html_data('connect', options[:connect]) if options[:connect]
93
94
  end
94
95
 
95
96
  # Override this method to add html Options
@@ -18,6 +18,7 @@ module KlassExtension
18
18
  status,
19
19
  effect,
20
20
  options_classes,
21
+ connect,
21
22
  component_html_classes
22
23
  ]
23
24
  html_options[:class] = join_classes(cls)
@@ -35,4 +36,8 @@ module KlassExtension
35
36
  options[:state] unless options[:state].nil?
36
37
  end
37
38
 
39
+ def connect
40
+ "ui-bibz-connect" unless options[:connect].nil?
41
+ end
42
+
38
43
  end
@@ -69,6 +69,7 @@ module UiBibz::Ui::Core::Forms::Buttons
69
69
  end
70
70
 
71
71
  def component_html_data
72
+ super
72
73
  add_html_data "toggle", "buttons"
73
74
  end
74
75
 
@@ -69,6 +69,7 @@ module UiBibz::Ui::Core::Forms::Choices
69
69
  end
70
70
 
71
71
  def component_html_data
72
+ super
72
73
  size
73
74
  state
74
75
  animate
@@ -75,6 +75,7 @@ module UiBibz::Ui::Core::Forms::Dates
75
75
  end
76
76
 
77
77
  def component_html_data
78
+ super
78
79
  date_locale
79
80
  provide
80
81
  format
@@ -74,6 +74,7 @@ module UiBibz::Ui::Core::Forms::Selects
74
74
  style
75
75
  header
76
76
  actions_box
77
+ connect_options
77
78
  end
78
79
 
79
80
  def component_html_options
@@ -82,6 +83,10 @@ module UiBibz::Ui::Core::Forms::Selects
82
83
 
83
84
  ############################ Data html options
84
85
 
86
+ def connect_options
87
+ add_html_data('connect', options[:connect]) if options[:connect]
88
+ end
89
+
85
90
  def max_options
86
91
  add_html_data('max_options', options[:max_options]) if options[:max_options]
87
92
  end
@@ -53,6 +53,7 @@ module UiBibz::Ui::Core::Forms::Selects
53
53
  private
54
54
 
55
55
  def component_html_data
56
+ super
56
57
  searchable
57
58
  selectable_opt_group
58
59
  end
@@ -64,6 +64,7 @@ module UiBibz::Ui::Core::Forms::Selects
64
64
  end
65
65
 
66
66
  def component_html_data
67
+ super
67
68
  clickable_opt_group
68
69
  collapsible_opt_group
69
70
  searchable
@@ -0,0 +1,95 @@
1
+ module UiBibz::Ui::Core::Forms::Selects
2
+
3
+ # Create a SelectField
4
+ #
5
+ # This element is an extend of UiBibz::Ui::Core::Component.
6
+ # source : http://silviomoreto.github.io/bootstrap-select/examples/
7
+ #
8
+ # ==== Attributes
9
+ #
10
+ # * +content+ - Content of element
11
+ # * +options+ - Options of element
12
+ # * +html_options+ - Html Options of element
13
+ #
14
+ # ==== Options
15
+ #
16
+ # You can add HTML attributes using the +html_options+.
17
+ # You can pass arguments in options attribute:
18
+ # * +status+ - status of élement with symbol value:
19
+ # (+:primary+, +:secondary+, +:info+, +:warning+, +:danger+, +:link+)
20
+ # * option_tags - Array, Object [required]
21
+ # * searchable - Boolean
22
+ # * max_options - Integer
23
+ # * selected_text_format - String
24
+ # * menu_size - Integer
25
+ # * header - String
26
+ # * actions_box - Boolean
27
+ # * show_tick - Boolean
28
+ # * show_menu_arrow - Boolean
29
+ # * dropup - Boolean
30
+ #
31
+ # ==== Signatures
32
+ #
33
+ # UiBibz::Ui::Core::Forms::Selects::SelectField.new(content, options = {}, html_options = {}).render
34
+ #
35
+ # UiBibz::Ui::Core::Forms::Selects::SelectField.new(options = {}, html_options = {}) do
36
+ # content
37
+ # end.render
38
+ #
39
+ # ==== Examples
40
+ #
41
+ # UiBibz::Ui::Core::Forms::Selects::SelectField.new('fruits', { option_tags: list_of_fruits, searchable: true }, { class: 'test' })
42
+ #
43
+ # UiBibz::Ui::Core::Forms::Selects::SelectField.new({ option_tags: list_of_fruits, actions_box: true }, { class: 'test' }) do
44
+ # 'fruits'
45
+ # end
46
+ #
47
+ # ==== Helper
48
+ #
49
+ # dropdown_select_field(content, options = {}, html_options = {})
50
+ #
51
+ class SelectField < UiBibz::Ui::Core::Component
52
+
53
+ # See UiBibz::Ui::Core::Component.initialize
54
+ def initialize content = nil, options = nil, html_options = nil, &block
55
+ super
56
+ end
57
+
58
+ # Render html tag
59
+ def render
60
+ if options[:refresh]
61
+ content_tag :div, class: 'input-group select-field-refresh' do
62
+ concat select_tag content, options[:option_tags], html_options
63
+ concat btn_refresh_html
64
+ end
65
+ else
66
+ select_tag content, options[:option_tags], html_options
67
+ end
68
+ end
69
+
70
+ private
71
+
72
+ def component_html_classes
73
+ ['select-field', 'form-control']
74
+ end
75
+
76
+ def btn_refresh_html
77
+ content_tag :span, UiBibz::Ui::Core::Forms::Buttons::Button.new('', { glyph: 'refresh', status: options[:status], connect: connect_options }, { class: 'input-refresh-button' }).render, class: 'input-group-btn'
78
+
79
+ end
80
+
81
+ def connect_options
82
+ connect = options[:refresh] || {}
83
+ {
84
+ events: connect.try(:[], :events) || "click",
85
+ mode: connect.try(:[], :type) || "remote",
86
+ target: {
87
+ selector: connect.try(:[], :target).try(:[], :selector) || "##{ content.parameterize.underscore }",
88
+ url: connect.try(:[], :target).try(:[], :url) || "",
89
+ data: connect.try(:[], :target).try(:[], :data) || []
90
+ }
91
+ }
92
+ end
93
+
94
+ end
95
+ end
@@ -63,6 +63,7 @@ module UiBibz::Ui::Core::Forms::Textareas
63
63
  private
64
64
 
65
65
  def component_html_data
66
+ super
66
67
  provide
67
68
  autofocus
68
69
  savable
@@ -44,7 +44,7 @@ module UiBibz::Ui::Ux::Tables
44
44
  # add surround_field maybe ?
45
45
  content_tag :div, html_options do
46
46
  concat content_tag(:span, UiBibz::Ui::Core::Glyph.new('search').render, class: 'input-group-addon')
47
- concat tag(:input, type: 'search', value: store.search, name: 'search', class: 'form-control', placeholder: search_placeholder_field)
47
+ concat tag(:input, type: 'search', value: search_content, name: 'search', class: 'form-control', placeholder: search_placeholder_field)
48
48
  concat content_tag(:span, UiBibz::Ui::Core::Glyph.new('times-circle').render, class: 'clear-search-btn input-group-addon')
49
49
  end
50
50
  end
@@ -56,11 +56,19 @@ module UiBibz::Ui::Ux::Tables
56
56
  concat tag(:input, type: 'hidden', name: k, value: v) unless default_parameters?(k)
57
57
  end
58
58
  concat tag(:input, type: 'hidden', name: 'store_id', value: store.id) unless store.id.nil? # if there is more one table in html page
59
- concat tag(:input, type: 'search', value: store.search, name: 'search', class: 'form-control', placeholder: search_placeholder_field)
59
+ concat tag(:input, type: 'search', value: search_content, name: 'search', class: 'form-control', placeholder: search_placeholder_field)
60
60
  concat content_tag(:span, clear_button, class: 'input-group-btn')
61
61
  end
62
62
  end
63
63
 
64
+ def search_content
65
+ if store.id.nil?
66
+ store.search
67
+ else
68
+ store.id == store.params[:store_id] ? store.search : ''
69
+ end
70
+ end
71
+
64
72
  def clear_button
65
73
  content_tag :button, UiBibz::Ui::Core::Glyph.new('times-circle').render, type: :button, class: 'btn btn-secondary'
66
74
  end
@@ -1,3 +1,3 @@
1
1
  module UiBibz
2
- VERSION = "2.0.0.alpha26"
2
+ VERSION = "2.0.0.alpha27"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ui_bibz
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.alpha26
4
+ version: 2.0.0.alpha27
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thooams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-02 00:00:00.000000000 Z
11
+ date: 2017-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -223,7 +223,9 @@ files:
223
223
  - app/assets/javascripts/fix_bootstrap.coffee
224
224
  - app/assets/javascripts/form.coffee
225
225
  - app/assets/javascripts/formula.coffee
226
+ - app/assets/javascripts/input-connected.coffee
226
227
  - app/assets/javascripts/interface.coffee
228
+ - app/assets/javascripts/jquery.multi-select-extend.coffee
227
229
  - app/assets/javascripts/table.coffee
228
230
  - app/assets/javascripts/ui_bibz.coffee
229
231
  - app/assets/stylesheets/bootstrap-switch.sass
@@ -239,6 +241,7 @@ files:
239
241
  - app/inputs/custom_inputs/multi_column_input.rb
240
242
  - app/inputs/custom_inputs/multi_select_input.rb
241
243
  - app/inputs/custom_inputs/radios_input.rb
244
+ - app/inputs/custom_inputs/select_input.rb
242
245
  - app/inputs/custom_inputs/surround_input.rb
243
246
  - app/inputs/custom_inputs/switch_input.rb
244
247
  - config/initializers/will_paginate.rb
@@ -286,6 +289,7 @@ files:
286
289
  - lib/ui_bibz/ui/core/forms/selects/dropdown_select_field.rb
287
290
  - lib/ui_bibz/ui/core/forms/selects/multi_column_field.rb
288
291
  - lib/ui_bibz/ui/core/forms/selects/multi_select_field.rb
292
+ - lib/ui_bibz/ui/core/forms/selects/select_field.rb
289
293
  - lib/ui_bibz/ui/core/forms/textareas/markdown_editor_field.rb
290
294
  - lib/ui_bibz/ui/core/forms/texts/autocomplete_field.rb
291
295
  - lib/ui_bibz/ui/core/forms/texts/surround_field.rb