ransack_ui 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
@@ -27,9 +27,9 @@
|
|
27
27
|
column_type = selected.data('type')
|
28
28
|
|
29
29
|
base_id = target.attr('id').slice(0, -8)
|
30
|
-
predicate_select = @element.find(
|
31
|
-
predicate_select2 = @element.find(
|
32
|
-
query_input = $(
|
30
|
+
predicate_select = @element.find("select##{base_id}p")
|
31
|
+
predicate_select2 = @element.find("#s2id_#{base_id}p")
|
32
|
+
query_input = $("input##{base_id}v_0_value")
|
33
33
|
|
34
34
|
# Initialize datepicker if column is date/datetime/time
|
35
35
|
$.proxy(@init_datetimepicker, this)(base_id)
|
@@ -65,7 +65,7 @@
|
|
65
65
|
else
|
66
66
|
predicate_select2.show()
|
67
67
|
# If Select2 is on query input, remove and set defaults
|
68
|
-
if query_select2 = @element.find(
|
68
|
+
if query_select2 = @element.find("#s2id_#{base_id}v_0_value")
|
69
69
|
query_input.select2('destroy')
|
70
70
|
query_input.val('')
|
71
71
|
previous_val = ''
|
@@ -81,17 +81,19 @@
|
|
81
81
|
predicate_select.find('option').each (i, o) -> $(o).remove()
|
82
82
|
|
83
83
|
$.each available, (i, p) =>
|
84
|
-
[
|
84
|
+
[predicate, label] = [p[0], p[1]]
|
85
85
|
|
86
86
|
# Also allow compound predicates, unless column
|
87
87
|
# is a date type. (No support for any/all on dates yet.)
|
88
|
-
|
89
|
-
|
88
|
+
if !column_type?.match(/date|time/)
|
89
|
+
p_key = predicate.replace(/_(any|all)$/, '')
|
90
|
+
else
|
91
|
+
p_key = predicate
|
90
92
|
|
91
|
-
if
|
93
|
+
if p_key in predicates
|
92
94
|
# Get alternative predicate label depending on column type
|
93
|
-
label = @alt_predicate_label_or_default(
|
94
|
-
predicate_select.append $(
|
95
|
+
label = @alt_predicate_label_or_default(predicate, column_type, label)
|
96
|
+
predicate_select.append $("<option value=#{predicate}>#{label}</option>")
|
95
97
|
|
96
98
|
# Select first predicate if current selection is invalid
|
97
99
|
predicate_select.select2('val', previous_val)
|
@@ -105,11 +107,11 @@
|
|
105
107
|
target = $(e.currentTarget)
|
106
108
|
p = target.val() || ""
|
107
109
|
base_id = target.attr('id').slice(0, -1)
|
108
|
-
query_input = $(
|
110
|
+
query_input = $("input##{base_id}v_0_value")
|
109
111
|
|
110
112
|
# We need to use a dummy input to handle multiple terms
|
111
113
|
multi_id = query_input.attr('id') + '_multi'
|
112
|
-
multi_input = @element.find(
|
114
|
+
multi_input = @element.find("##{multi_id}")
|
113
115
|
|
114
116
|
if Select2?
|
115
117
|
# Turn query input into Select2 tag list when query accepts multiple values
|
@@ -160,7 +162,7 @@
|
|
160
162
|
|
161
163
|
# Fetch all query inputs for condition
|
162
164
|
base_name = target.data('base-name')
|
163
|
-
inputs = @element.find(
|
165
|
+
inputs = @element.find("input[name^=\"#{base_name}\"]")
|
164
166
|
|
165
167
|
# Set the original query input to the first value before shifting inputs and values
|
166
168
|
$(inputs[0]).val(e.val[0])
|
@@ -263,8 +265,8 @@
|
|
263
265
|
|
264
266
|
init_datetimepicker: (base_id) ->
|
265
267
|
if $.ui?.timepicker?
|
266
|
-
query_input = @element.find(
|
267
|
-
selected_attr = @element.find(
|
268
|
+
query_input = @element.find("input##{base_id}v_0_value")
|
269
|
+
selected_attr = @element.find("select##{base_id}a_0_name option:selected")
|
268
270
|
|
269
271
|
# Clear any datepicker from query input first
|
270
272
|
query_input.datepicker('destroy')
|
data/lib/ransack_ui/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ransack_ui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -76,7 +76,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
76
76
|
version: '0'
|
77
77
|
segments:
|
78
78
|
- 0
|
79
|
-
hash:
|
79
|
+
hash: 4299301087477081386
|
80
80
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
81
|
none: false
|
82
82
|
requirements:
|
@@ -85,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
85
|
version: '0'
|
86
86
|
segments:
|
87
87
|
- 0
|
88
|
-
hash:
|
88
|
+
hash: 4299301087477081386
|
89
89
|
requirements: []
|
90
90
|
rubyforge_project:
|
91
91
|
rubygems_version: 1.8.24
|