ransack_ui 1.4.0 → 2.0.0

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
  SHA256:
3
- metadata.gz: ac84bded42933bf2a64def821e3698e5182047397d2e8bb6f0321d6b38051d21
4
- data.tar.gz: abdc1d7d87b36deb0648b320b7e65e4511a046e35455b0f7887bb22c60a75b19
3
+ metadata.gz: c76bc56f01efed6de571cb9a79a094095af122c6a35f46abb9bf6567de74b275
4
+ data.tar.gz: 26367f813d7dd0851ede9a027aea951ff307fd9e2f7d1380abe72eb5afc762f0
5
5
  SHA512:
6
- metadata.gz: 70fa91e7584802f51d68c0990e4a27acbfc928954cc48d6833258507287826b9b71a9c066f11c06c5b44449a72025367d61cf69f572f57d105ab4f55e86778b8
7
- data.tar.gz: 7356459d70de3031278ec4ef61b1197d7c533b221ec1d2966e3e1e32072778f260f06e50970525fef732e6e6b0d8be8aa0a880af5e0472cc3e64bbce1bca5d00
6
+ metadata.gz: 06223a0eee0aa80c48b987aea5271aae10d4d2921265cd70725b9731615fbae62270684d23069502df922618e0f6d65e7b163291fb4fa8f9a0c63b3695fb5cce
7
+ data.tar.gz: 664bb6c97c1a9fd16b4bc461de11cb466e5236297551ad3932816c1122b5e65f5442730bbee135f4f19fd07cadbb1fe752779916794d533af2cd33b6572ec4d8
data/CHANGELOG.md ADDED
@@ -0,0 +1,20 @@
1
+ # Change Log
2
+
3
+ ## v2.0.0
4
+
5
+ ### 💥 Breaking Changes
6
+
7
+ * Bumped minimum supported version of Select2 from V3 to V4 (Note: Select2 usage is entirely optional.)
8
+ * Changed Ransack dependency requirement from ~> 2.0 to Ransack < 4
9
+
10
+ ### 🚀 Features
11
+
12
+ * Moved project ownership from github.com:ndbroadbent/ransack_ui.git to github.com:fatfreecrm/ransack_ui.git
13
+
14
+ ### 🐛 Bug Fixes
15
+
16
+ * Fixed html issue with "Add a filter" rendering
17
+
18
+ ### 📝 Documentation
19
+
20
+ * Added CHANGELOG.md
data/README.md CHANGED
@@ -3,8 +3,6 @@
3
3
  Provides HTML templates and JavaScript to build a fully functional
4
4
  advanced search form using Ransack.
5
5
 
6
- Please note: this project is still in *alpha* and the following instructions are not yet complete/fully working.
7
-
8
6
  ## Installation
9
7
 
10
8
  Add this line to your application's Gemfile:
@@ -37,5 +37,5 @@ Ransack.predicate_inputs = {}
37
37
  Ransack.option_predicates = ['eq', 'eq_any', 'not_eq', 'not_eq_all', 'null', 'not_null']
38
38
 
39
39
  # Use a tags input for 'in' if Select2 is available
40
- if Select2?
40
+ if $.fn.select2?
41
41
  Ransack.predicate_inputs.in = 'tags'
@@ -12,7 +12,7 @@
12
12
 
13
13
  # Store initial predicates and set up Select2 on select lists in .filters
14
14
  containers = el.find('.filters')
15
- if Select2?
15
+ if $.fn.select2?
16
16
  @init_select2(containers)
17
17
  @store_initial_predicates(containers)
18
18
 
@@ -59,17 +59,17 @@
59
59
  @destroy_multi_input(multi_input, selected_attribute.val())
60
60
 
61
61
  # Handle association columns with AJAX autocomplete
62
- if selected_attribute.data('ajax-url') and Select2?
62
+ if selected_attribute.data('ajax--url') and $.fn.select2?
63
63
  @set_option_predicates(base_id, available, column_type)
64
64
 
65
65
  # Handle columns with options detected from validates :inclusion
66
- else if selected_attribute.data('select-options') and Select2?
66
+ else if selected_attribute.data('select-options') and $.fn.select2?
67
67
  @set_option_predicates(base_id, available, column_type, true)
68
68
 
69
69
  # Handle regular columns
70
70
  else
71
- if Select2?
72
- predicate_select2.select2("enable")
71
+ if $.fn.select2?
72
+ predicate_select2.prop('disabled', false)
73
73
 
74
74
  # If Select2 is on query input, remove and set defaults
75
75
  if query_select2.length > 0
@@ -102,11 +102,11 @@
102
102
  predicate_select.append $("<option value=#{predicate}>#{label}</option>")
103
103
 
104
104
  # Select first predicate if current selection is invalid
105
- if Select2?
106
- predicate_select.select2('val', previous_val)
105
+ if $.fn.select2?
106
+ predicate_select.val(previous_val)
107
107
 
108
108
  # Run predicate_changed callback
109
- predicate_select.change()
109
+ predicate_select.trigger('change')
110
110
 
111
111
  return true
112
112
 
@@ -138,14 +138,14 @@
138
138
  # Hide query input when not needed
139
139
  if p in no_query_predicates
140
140
  # If Select2 is on query input, remove and set defaults
141
- if Select2? && query_select2.length
141
+ if $.fn.select2? && query_select2.length
142
142
  query_input.select2('destroy')
143
143
 
144
144
  query_input.val("true")
145
145
  query_input.hide()
146
146
  query_input.parent().find('.ui-datepicker-trigger').hide()
147
147
 
148
- if Select2?
148
+ if $.fn.select2?
149
149
  # Turn query input into Select2 tag list when query accepts multiple values
150
150
  if p in ["in", "not_in"] || p.match(/_(all|any)$/)
151
151
  # Add dummy 'multi' input for select2 if not already added
@@ -175,7 +175,7 @@
175
175
  query_input.css('display', '')
176
176
 
177
177
  # Handle association columns with AJAX autocomplete
178
- if selected_attribute.data('ajax-url')
178
+ if selected_attribute.data('ajax--url')
179
179
  if query_select2.length
180
180
  query_input.hide()
181
181
  else
@@ -193,7 +193,7 @@
193
193
  return if selected_attribute.data('select-options')
194
194
 
195
195
  # Don't show query input if ajax auto complete is present on selected attribute
196
- unless p in ['eq', 'not_eq'] and selected_attribute.data('ajax-url')
196
+ unless p in ['eq', 'not_eq'] and selected_attribute.data('ajax--url')
197
197
  unless query_input.is(":visible")
198
198
  query_input.val('')
199
199
  #query_input.show()
@@ -226,7 +226,7 @@
226
226
  predicate_select.append $("<option value=#{predicate}>#{label}</option>")
227
227
 
228
228
  # Select first predicate if current selection is invalid
229
- predicate_select.select2('val', previous_val)
229
+ predicate_select.val(previous_val)
230
230
 
231
231
  # Attempts to find a predicate translation for the specific column type,
232
232
  # or returns the default label.
@@ -288,12 +288,12 @@
288
288
  # Hide all query inputs
289
289
  inputs.hide()
290
290
 
291
- if Select2?
291
+ if $.fn.select2?
292
292
  # Find newly created input and setup Select2
293
293
  multi_query = @element.find('#' + multi_id)
294
294
 
295
295
  # Handle association columns with AJAX autocomplete
296
- if selected_attribute.data('ajax-url')
296
+ if selected_attribute.data('ajax--url')
297
297
  # Set label to single association label, if anything was selected
298
298
  if query_select2.length && query_input.select2('data')
299
299
  query_input_data = query_input.select2('data')
@@ -310,30 +310,31 @@
310
310
  else
311
311
  # Setup Select2 with tagging support (can create options)
312
312
  multi_query.select2
313
- tags: []
313
+ data: [], tags: true
314
314
  tokenSeparators: [',']
315
- formatNoMatches: (t) ->
316
- "Add a search term"
315
+ language:
316
+ noMatches: (t) ->
317
+ "Add a search term"
317
318
 
318
- multi_query.select2('val', values)
319
+ multi_query.val(values)
319
320
 
320
321
  setup_select2_association: (query_input, selected_attribute, multiple = false) ->
321
322
  selected_attribute_val = selected_attribute.val()
322
323
  # Set up Select2 for query input
323
324
  query_input.select2
324
- placeholder: "Search #{selected_attribute.data('ajax-entity')}"
325
+ placeholder: "Search #{selected_attribute.data('ajax--entity')}"
325
326
  minimumInputLength: 1
326
327
  allowClear: true
327
328
  multiple: multiple
328
329
  ajax:
329
- url: selected_attribute.data('ajax-url')
330
+ url: selected_attribute.data('ajax--url')
330
331
  dataType: 'json'
331
- type: selected_attribute.data('ajax-type')
332
- data: (query, page) ->
332
+ type: selected_attribute.data('ajax--type')
333
+ data: (params) ->
333
334
  obj = {}
334
- obj[selected_attribute.data('ajax-key')] = query
335
+ obj[selected_attribute.data('ajax--key')] = params
335
336
  obj
336
- results: (data, page) ->
337
+ processResults: (data) ->
337
338
  {results: $.map(data, (text, id) -> {id: id, text: text}) }
338
339
  initSelection: (element, callback) ->
339
340
  data = []
@@ -348,7 +349,7 @@
348
349
  callback(multiple and data or data[0])
349
350
  else
350
351
  # If no label could be found, clear value
351
- element.select2('val', '')
352
+ element.val('')
352
353
 
353
354
  setup_select2_options: (query_input, selected_attribute, multiple = false) ->
354
355
  query_input.select2
@@ -374,7 +375,7 @@
374
375
  if data.length
375
376
  callback(multiple and data or data[0])
376
377
  else
377
- element.select2('val', '')
378
+ element.val('')
378
379
 
379
380
  add_query_input: (base_input, base_name, id, value) ->
380
381
  base_input.after $('<input name="'+base_name+'['+id+'][value]" '+
@@ -401,7 +402,7 @@
401
402
  target.before content.replace(regexp, new_id)
402
403
  prev_container = target.prev()
403
404
 
404
- if Select2?
405
+ if $.fn.select2?
405
406
  @init_select2(prev_container)
406
407
 
407
408
  if $.ransack.button_group_select?
@@ -409,7 +410,7 @@
409
410
 
410
411
  @store_initial_predicates(prev_container)
411
412
  # Fire change event on any new selects.
412
- prev_container.find("select").change()
413
+ prev_container.find("select").trigger('change')
413
414
  false
414
415
 
415
416
  remove_fields: (e) ->
@@ -441,11 +442,11 @@
441
442
  width: '230px'
442
443
  placeholder: "Select a Field"
443
444
  allowClear: true
444
- formatSelection: (object, container) ->
445
+ templateSelection: (object) ->
445
446
  # If initializing and element is not present,
446
447
  # search for option element in original select tag
447
448
  if !object.element
448
- this.element.find('option').each (i, option) ->
449
+ container.find('select option').each (i, option) ->
449
450
  if option.value == object.id
450
451
  object.element = option
451
452
  return false
@@ -3,13 +3,13 @@
3
3
 
4
4
  <%= f.attribute_fields do |a| %>
5
5
  <span class="fields" data-object-name="<%= f.object_name %>">
6
- <%= a.attribute_select({}, :class => 'ransack_attribute') %>
6
+ <%= a.attribute_select({}, class: 'ransack_attribute') %>
7
7
  <% end %>
8
8
 
9
- <%= f.predicate_select({}, :class => 'ransack_predicate') %>
9
+ <%= f.predicate_select({}, class: 'ransack_predicate') %>
10
10
 
11
11
  <%= f.value_fields do |v| %>
12
12
  <span class="fields value" data-object-name="<%= f.object_name %>">
13
- <%= v.text_field :value, :style => "width: 200px;", :class => "ransack_query" %>
13
+ <%= v.text_field :value, style: "width: 200px;", class: "ransack_query" %>
14
14
  <% end %>
15
15
  </div>
@@ -180,16 +180,16 @@ module Ransack
180
180
  foreign_klass = attribute_data[:foreign_klass]
181
181
 
182
182
  if foreign_klass
183
- # If field is a foreign key, set up 'data-ajax-*' attributes for auto-complete
183
+ # If field is a foreign key, set up 'data-ajax--*' attributes for auto-complete
184
184
  controller = ActiveSupport::Inflector.tableize(foreign_klass.to_s)
185
- html_options[:'data-ajax-entity'] = I18n.translate(controller, default: controller)
185
+ html_options[:'data-ajax--entity'] = I18n.translate(controller, default: controller)
186
186
  if ajax_options[:url]
187
- html_options[:'data-ajax-url'] = ajax_options[:url].sub(':controller', controller)
187
+ html_options[:'data-ajax--url'] = ajax_options[:url].sub(':controller', controller)
188
188
  else
189
- html_options[:'data-ajax-url'] = "/#{controller}.json"
189
+ html_options[:'data-ajax--url'] = "/#{controller}.json"
190
190
  end
191
- html_options[:'data-ajax-type'] = ajax_options[:type] || 'GET'
192
- html_options[:'data-ajax-key'] = ajax_options[:key] || 'query'
191
+ html_options[:'data-ajax--type'] = ajax_options[:type] || 'GET'
192
+ html_options[:'data-ajax--key'] = ajax_options[:key] || 'query'
193
193
  end
194
194
 
195
195
  [
@@ -1,3 +1,3 @@
1
1
  module RansackUI
2
- VERSION = '1.4.0'.freeze
2
+ VERSION = '2.0.0'.freeze
3
3
  end
@@ -11,11 +11,11 @@ module RansackUI
11
11
  end
12
12
 
13
13
  if options[:theme].to_s == 'bootstrap'
14
- link_to nil, :class => 'add_fields btn btn-small btn-primary', 'data-field-type' => type, 'data-content' => fields.to_s do
14
+ link_to nil, :class => 'add_fields btn btn-small btn-primary', 'data-field-type' => type, 'data-content' => "#{fields}" do
15
15
  "<i class=\"icon-plus icon-white\"></i><span>#{name}</span>".html_safe
16
16
  end
17
17
  else
18
- link_to name, nil, :class => 'add_fields', 'data-field-type' => type, 'data-content' => fields.to_s
18
+ link_to name, nil, :class => 'add_fields', 'data-field-type' => type, 'data-content' => "#{fields}"
19
19
  end
20
20
  end
21
21
 
data/ransack_ui.gemspec CHANGED
@@ -18,5 +18,5 @@ Gem::Specification.new do |gem|
18
18
  gem.require_paths = ['lib']
19
19
 
20
20
  gem.add_dependency 'ransack_chronic', '>= 1.1.0'
21
- gem.add_dependency 'ransack', '~> 2.0'
21
+ gem.add_dependency 'ransack', '< 4'
22
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ransack_ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Broadbent
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-28 00:00:00.000000000 Z
11
+ date: 2024-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ransack_chronic
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: ransack
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - "<"
32
32
  - !ruby/object:Gem::Version
33
- version: '2.0'
33
+ version: '4'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - "<"
39
39
  - !ruby/object:Gem::Version
40
- version: '2.0'
40
+ version: '4'
41
41
  description: Framework for building a search UI with Ransack
42
42
  email:
43
43
  - nathan.f77@gmail.com
@@ -47,6 +47,7 @@ extra_rdoc_files: []
47
47
  files:
48
48
  - ".gitignore"
49
49
  - ".rubocop_todo.yml"
50
+ - CHANGELOG.md
50
51
  - Gemfile
51
52
  - LICENSE.txt
52
53
  - README.md
@@ -84,7 +85,7 @@ homepage: https://github.com/ndbroadbent/ransack_ui
84
85
  licenses:
85
86
  - MIT
86
87
  metadata: {}
87
- post_install_message:
88
+ post_install_message:
88
89
  rdoc_options: []
89
90
  require_paths:
90
91
  - lib
@@ -99,8 +100,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
100
  - !ruby/object:Gem::Version
100
101
  version: '0'
101
102
  requirements: []
102
- rubygems_version: 3.1.2
103
- signing_key:
103
+ rubygems_version: 3.5.9
104
+ signing_key:
104
105
  specification_version: 4
105
106
  summary: UI Builder for Ransack
106
107
  test_files: []