refine-rails 2.9.0 → 2.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -6
- data/app/assets/javascripts/refine-stimulus.esm.js +1 -1
- data/app/assets/javascripts/refine-stimulus.esm.js.map +1 -1
- data/app/assets/javascripts/refine-stimulus.js +1 -1
- data/app/assets/javascripts/refine-stimulus.js.map +1 -1
- data/app/assets/javascripts/refine-stimulus.modern.js +1 -1
- data/app/assets/javascripts/refine-stimulus.modern.js.map +1 -1
- data/app/assets/javascripts/refine-stimulus.umd.js +1 -1
- data/app/assets/javascripts/refine-stimulus.umd.js.map +1 -1
- data/app/assets/stylesheets/index.css +16 -17
- data/app/assets/stylesheets/index.tailwind.css +16 -15
- data/app/controllers/refine/inline/criteria_controller.rb +6 -0
- data/app/javascript/controllers/index.js +3 -3
- data/app/javascript/controllers/refine/criterion-form-controller.js +13 -12
- data/app/javascript/controllers/refine/typeahead-list-controller.js +33 -0
- data/app/models/refine/conditions/date_condition.rb +1 -1
- data/app/models/refine/filter/internationalized.rb +28 -0
- data/app/models/refine/filter.rb +17 -3
- data/app/models/refine/inline/criteria/date_refinement.rb +14 -0
- data/app/models/refine/inline/criteria/input.rb +16 -2
- data/app/models/refine/inline/criterion.rb +2 -2
- data/app/views/refine/blueprints/_criterion.html.erb +1 -1
- data/app/views/refine/inline/criteria/_form_fields.html.erb +88 -17
- data/app/views/refine/inline/criteria/edit.turbo_stream.erb +11 -11
- data/app/views/refine/inline/criteria/index.html.erb +6 -5
- data/app/views/refine/inline/criteria/new.turbo_stream.erb +10 -11
- data/app/views/refine/inline/filters/_criterion.html.erb +0 -1
- data/app/views/refine/inline/inputs/_date_condition.html.erb +2 -2
- data/app/views/refine/inline/inputs/_date_condition_range.html.erb +2 -2
- data/app/views/refine/inline/inputs/_date_condition_single.html.erb +1 -1
- data/app/views/refine/inline/inputs/_option_condition.html.erb +21 -10
- data/lib/refine/rails/version.rb +1 -1
- metadata +5 -2
@@ -15,7 +15,8 @@ class Refine::Inline::Criteria::Input
|
|
15
15
|
:value,
|
16
16
|
:value1,
|
17
17
|
:value2,
|
18
|
-
:count_refinement
|
18
|
+
:count_refinement,
|
19
|
+
:date_refinement
|
19
20
|
|
20
21
|
def attributes
|
21
22
|
{
|
@@ -28,7 +29,8 @@ class Refine::Inline::Criteria::Input
|
|
28
29
|
value: value,
|
29
30
|
value1: value1,
|
30
31
|
value2: value2,
|
31
|
-
count_refinement_attributes: count_refinement_attributes.presence
|
32
|
+
count_refinement_attributes: count_refinement_attributes.presence,
|
33
|
+
date_refinement_attributes: date_refinement_attributes.presence
|
32
34
|
}.compact
|
33
35
|
end
|
34
36
|
|
@@ -44,6 +46,18 @@ class Refine::Inline::Criteria::Input
|
|
44
46
|
count_refinement.attributes = attrs.to_h
|
45
47
|
end
|
46
48
|
|
49
|
+
def date_refinement
|
50
|
+
@date_refinement ||= Refine::Inline::Criteria::DateRefinement.new
|
51
|
+
end
|
52
|
+
|
53
|
+
def date_refinement_attributes
|
54
|
+
date_refinement.attributes
|
55
|
+
end
|
56
|
+
|
57
|
+
def date_refinement_attributes=(attrs = {})
|
58
|
+
date_refinement.attributes = attrs.to_h
|
59
|
+
end
|
60
|
+
|
47
61
|
def selected=(value)
|
48
62
|
@selected = Array.wrap(value)
|
49
63
|
end
|
@@ -21,6 +21,7 @@ class Refine::Inline::Criterion
|
|
21
21
|
attrs[:input_attributes] = attrs.delete(:input)
|
22
22
|
if input_attrs = attrs[:input_attributes]
|
23
23
|
input_attrs[:count_refinement_attributes] = input_attrs.delete(:count_refinement)
|
24
|
+
input_attrs[:date_refinement_attributes] = input_attrs.delete(:date_refinement)
|
24
25
|
end
|
25
26
|
new(attrs)
|
26
27
|
end
|
@@ -93,6 +94,7 @@ class Refine::Inline::Criterion
|
|
93
94
|
result[:input] = result.delete(:input_attributes)
|
94
95
|
if input_attrs = result[:input]
|
95
96
|
input_attrs[:count_refinement] = input_attrs.delete(:count_refinement_attributes)
|
97
|
+
input_attrs[:date_refinement] = input_attrs.delete(:date_refinement_attributes)
|
96
98
|
end
|
97
99
|
result
|
98
100
|
end
|
@@ -121,8 +123,6 @@ class Refine::Inline::Criterion
|
|
121
123
|
end
|
122
124
|
|
123
125
|
def validate!
|
124
|
-
# TODO figure out how to validate inputs with count refinements
|
125
|
-
return if input.count_refinement.attributes.present?
|
126
126
|
errors.clear
|
127
127
|
begin
|
128
128
|
query_for_validate = refine_filter.initial_query || refine_filter.model.all
|
@@ -27,7 +27,7 @@
|
|
27
27
|
|
28
28
|
<div class="refine-criterion-refinement-container">
|
29
29
|
<%= render partial: 'refine/blueprints/clause_select', locals: {
|
30
|
-
meta: refinement[:meta], input_id: "input, #{refinement[:id]}", selected_clause: criterion.input.dig(
|
30
|
+
meta: refinement[:meta], input_id: "input, #{refinement[:id]}", selected_clause: criterion.input.dig(refinement[:id].to_sym, :clause) || {} } %>
|
31
31
|
</div>
|
32
32
|
|
33
33
|
<%= render partial: "refine/blueprints/clauses/#{refinement[:component].underscore}", locals: {
|
@@ -1,3 +1,18 @@
|
|
1
|
+
<%
|
2
|
+
condition = @criterion.condition
|
3
|
+
date_refinement_condition = condition.has_date_refinement? && condition.get_date_refinement_condition
|
4
|
+
count_refinement_condition = condition.has_count_refinement? && condition.get_count_refinement_condition
|
5
|
+
|
6
|
+
last_clause_select = if count_refinement_condition
|
7
|
+
:count
|
8
|
+
elsif date_refinement_condition
|
9
|
+
:date
|
10
|
+
else
|
11
|
+
:criterion
|
12
|
+
end
|
13
|
+
%>
|
14
|
+
|
15
|
+
|
1
16
|
<%= form.hidden_field :stable_id, form: form_id %>
|
2
17
|
<%= form.hidden_field :client_id, form: form_id %>
|
3
18
|
<%= form.hidden_field :condition_id, form: form_id %>
|
@@ -10,16 +25,66 @@
|
|
10
25
|
<%# Input Value %>
|
11
26
|
<% unless ['st', 'nst'].include? @criterion.input.clause %>
|
12
27
|
<%= render @criterion.input_partial, criterion: @criterion, form: form, input_fields: input_fields, form_id: form_id %>
|
28
|
+
<% if last_clause_select == :criterion %>
|
29
|
+
<div class="refine--separator"></div>
|
30
|
+
<% end %>
|
31
|
+
<% end %>
|
32
|
+
|
33
|
+
<%# Clause Select %>
|
34
|
+
<div class="refine--criterion-clause-container">
|
35
|
+
<%= input_fields.label :clause, t('.rule') %>
|
36
|
+
<%= input_fields.collection_select :clause,
|
37
|
+
@criterion.condition.approved_clauses,
|
38
|
+
:id,
|
39
|
+
:display,
|
40
|
+
{},
|
41
|
+
class: "refine--select refine--clause-select",
|
42
|
+
data: {action: "change->refine--criterion-form#refresh"},
|
43
|
+
form: form_id
|
44
|
+
%>
|
45
|
+
<% if last_clause_select == :criterion %>
|
46
|
+
<%= form.button t('global.buttons.apply'), class: "refine--apply-button", type: "submit", form: form_id %>
|
47
|
+
<% end %>
|
48
|
+
</div>
|
49
|
+
|
50
|
+
<%# Date Refinement %>
|
51
|
+
<% if @criterion.condition.has_date_refinement? %>
|
13
52
|
<div class="refine--separator"></div>
|
53
|
+
<label style="color: black;"><%= date_refinement_condition.display %></label>
|
54
|
+
<%= input_fields.fields :date_refinement_attributes, model: @criterion.input.date_refinement do |date_fields| %>
|
55
|
+
<div class="refine--refinement-input-container">
|
56
|
+
<% unless ['st', 'nst'].include? @criterion.input.date_refinement.clause %>
|
57
|
+
<%= render "refine/inline/inputs/date_condition", criterion: @criterion, form: form, input_fields: date_fields, form_id: form_id %>
|
58
|
+
<% end %>
|
59
|
+
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<div class="refine--criterion-clause-container">
|
63
|
+
<%= date_fields.label :clause, t('.rule') %>
|
64
|
+
<%= date_fields.collection_select :clause,
|
65
|
+
date_refinement_condition.approved_clauses,
|
66
|
+
:id,
|
67
|
+
:display,
|
68
|
+
{},
|
69
|
+
class: "refine--select refine--clause-select",
|
70
|
+
data: {action: "change->refine--criterion-form#refresh"},
|
71
|
+
form: form_id
|
72
|
+
%>
|
73
|
+
<% if last_clause_select == :date %>
|
74
|
+
<%= form.button t('global.buttons.apply'), class: "refine--apply-button", type: "submit", form: form_id %>
|
75
|
+
<% end %>
|
76
|
+
</div>
|
77
|
+
<% end %>
|
78
|
+
|
14
79
|
<% end %>
|
15
80
|
|
16
81
|
<%# Count Refinement %>
|
17
|
-
<% if
|
82
|
+
<% if count_refinement_condition %>
|
18
83
|
<label style="color: black;"><%= @criterion.condition.get_count_refinement_condition.display %></label>
|
19
84
|
<%= input_fields.fields :count_refinement_attributes, model: @criterion.input.count_refinement do |count_fields| %>
|
20
85
|
<div class="refine--criterion-clause-container">
|
21
86
|
<%= count_fields.collection_select :clause,
|
22
|
-
|
87
|
+
count_refinement_condition.approved_clauses,
|
23
88
|
:id,
|
24
89
|
:display,
|
25
90
|
{},
|
@@ -29,28 +94,34 @@
|
|
29
94
|
</div>
|
30
95
|
|
31
96
|
<% unless ['st', 'nst'].include? @criterion.input.count_refinement.clause %>
|
32
|
-
<%= render "refine/inline/inputs/numeric_condition", input_fields: count_fields, form_id: form_id %>
|
97
|
+
<%= render "refine/inline/inputs/numeric_condition", criterion: @criterion, form: form, input_fields: count_fields, form_id: form_id %>
|
33
98
|
<% end %>
|
99
|
+
|
100
|
+
<div class="refine--criterion-clause-container">
|
101
|
+
<%= count.label :clause, t('.rule') %>
|
102
|
+
<%= count.collection_select :clause,
|
103
|
+
@criterion.condition.approved_clauses,
|
104
|
+
:id,
|
105
|
+
:display,
|
106
|
+
{},
|
107
|
+
class: "refine--select refine--clause-select",
|
108
|
+
data: {action: "change->refine--criterion-form#refresh"},
|
109
|
+
form: form_id
|
110
|
+
%>
|
111
|
+
<% if last_clause_select == :count %>
|
112
|
+
<%= form.button t('global.buttons.apply'), class: "refine--apply-button", type: "submit", form: form_id %>
|
113
|
+
<% end %>
|
114
|
+
</div>
|
115
|
+
|
116
|
+
|
117
|
+
|
34
118
|
<% end %>
|
35
119
|
|
36
120
|
<% end %>
|
37
121
|
|
38
122
|
|
39
123
|
|
40
|
-
|
41
|
-
<div class="refine--criterion-clause-container">
|
42
|
-
<%= input_fields.label :clause, t('.rule') %>
|
43
|
-
<%= input_fields.collection_select :clause,
|
44
|
-
@criterion.condition.approved_clauses,
|
45
|
-
:id,
|
46
|
-
:display,
|
47
|
-
{},
|
48
|
-
class: "refine--select refine--clause-select",
|
49
|
-
data: {action: "change->refine--criterion-form#refresh"},
|
50
|
-
form: form_id
|
51
|
-
%>
|
52
|
-
<%= form.button t('global.buttons.apply'), class: "refine--apply-button", data: {action: "refine--criterion-form#submit"}, type: "submit", form: form_id %>
|
53
|
-
</div>
|
124
|
+
|
54
125
|
|
55
126
|
|
56
127
|
<% end %>
|
@@ -1,19 +1,19 @@
|
|
1
1
|
<% form_id = dom_id(@criterion, :form) %>
|
2
2
|
|
3
3
|
<%= turbo_stream.update dom_id(@criterion) do %>
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
%>
|
4
|
+
<%= tag.div class: "refine--criterion-fields",
|
5
|
+
data: {
|
6
|
+
controller: "refine--criterion-form",
|
7
|
+
refine__criterion_form_url_value: edit_refine_inline_criterion_url(
|
8
|
+
@criterion.position, @criterion.to_params
|
9
|
+
),
|
10
|
+
refine__criterion_form_form_id_value: form_id
|
11
|
+
} do
|
12
|
+
%>
|
13
|
+
<%= fields model: @criterion do |form| %>
|
14
14
|
<%= render "form_fields", form: form, form_id: form_id %>
|
15
15
|
<% end %>
|
16
|
-
|
16
|
+
<% end %>
|
17
17
|
<% end %>
|
18
18
|
|
19
19
|
|
@@ -10,11 +10,11 @@
|
|
10
10
|
%>
|
11
11
|
|
12
12
|
<%= turbo_frame_tag @criterion do %>
|
13
|
-
<div data-controller="refine--
|
13
|
+
<div data-controller="refine--typeahead-list">
|
14
14
|
|
15
15
|
<div class="refine--search-box">
|
16
16
|
<span class="material-icons refine--icon-search">search</span>
|
17
|
-
<input class="refine--search-trigger" data-search-target="filterProperties" placeholder="<%= t('.type_to_search') %>..." type="text" data-action="refine--
|
17
|
+
<input class="refine--search-trigger" data-search-target="filterProperties" placeholder="<%= t('.type_to_search') %>..." type="text" data-action="refine--typeahead-list#filter" autofocus>
|
18
18
|
</div>
|
19
19
|
|
20
20
|
<div class="refine--separator-m0"></div>
|
@@ -27,13 +27,14 @@
|
|
27
27
|
data: {
|
28
28
|
controller: "refine--turbo-stream-link",
|
29
29
|
action: "refine--turbo-stream-link#visit",
|
30
|
-
|
30
|
+
refine__typeahead_list_target: "listItem",
|
31
|
+
list_item_value: condition.display
|
31
32
|
}
|
32
33
|
%>
|
33
34
|
<% end %>
|
34
35
|
|
35
36
|
<% categorized_conditions.each do |(category, conditions)| %>
|
36
|
-
<b data-refine--
|
37
|
+
<b data-refine--typeahead-list-target="category"><%= category %></b>
|
37
38
|
<% conditions.each do |condition| %>
|
38
39
|
<%= link_to condition.display,
|
39
40
|
new_refine_inline_criterion_url(@criterion.to_params.deep_merge(refine_inline_criterion: {condition_id: condition.id})),
|
@@ -41,7 +42,7 @@
|
|
41
42
|
data: {
|
42
43
|
controller: "refine--turbo-stream-link",
|
43
44
|
action: "refine--turbo-stream-link#visit",
|
44
|
-
|
45
|
+
refine__typeahead_list_target: "listItem",
|
45
46
|
category: category
|
46
47
|
}
|
47
48
|
%>
|
@@ -1,19 +1,18 @@
|
|
1
1
|
<% form_id = dom_id(@criterion, :form) %>
|
2
2
|
|
3
3
|
<%= turbo_stream.update dom_id(@criterion) do %>
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
%>
|
4
|
+
<%= tag.div class: "refine--criterion-fields",
|
5
|
+
data: {
|
6
|
+
controller: "refine--criterion-form",
|
7
|
+
refine__criterion_form_url_value: new_refine_inline_criterion_url(
|
8
|
+
@criterion.to_params),
|
9
|
+
refine__criterion_form_form_id_value: form_id
|
10
|
+
} do
|
11
|
+
%>
|
12
|
+
<%= fields model: @criterion do |form| %>
|
14
13
|
<%= render "form_fields", form: form, conjunction: @conjunction, position: @position, form_id: form_id %>
|
15
14
|
<% end %>
|
16
|
-
|
15
|
+
<% end %>
|
17
16
|
<% end %>
|
18
17
|
|
19
18
|
<%# The actual form tag is appended to the end of the body html. Inputs are attached using the `form` attribute. This allows the query builder to be placed inside an outer form on the page. %>
|
@@ -1,6 +1,6 @@
|
|
1
|
-
<% if
|
1
|
+
<% if input_fields.object.clause.in? ["exct", "gt", "lt"] %>
|
2
2
|
<%= render "refine/inline/inputs/date_condition_days", input_fields: input_fields, criterion: criterion, form_id: form_id %>
|
3
|
-
<% elsif
|
3
|
+
<% elsif input_fields.object.clause == "btwn" %>
|
4
4
|
<%= render "refine/inline/inputs/date_condition_range", input_fields: input_fields, criterion: criterion, form_id: form_id %>
|
5
5
|
<% else %>
|
6
6
|
<%= render "refine/inline/inputs/date_condition_single", input_fields: input_fields, criterion: criterion, form_id: form_id %>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<%= render "refine/inline/inputs/date_picker",
|
3
3
|
input_fields: input_fields,
|
4
4
|
attribute: :date1,
|
5
|
-
value:
|
5
|
+
value: input_fields.object.date1,
|
6
6
|
label: "#{criterion.condition.display.downcase} (#{t('.min')})",
|
7
7
|
form_id: form_id
|
8
8
|
%>
|
@@ -13,7 +13,7 @@
|
|
13
13
|
<%= render "refine/inline/inputs/date_picker",
|
14
14
|
input_fields: input_fields,
|
15
15
|
attribute: :date2,
|
16
|
-
value:
|
16
|
+
value: input_fields.object.date2,
|
17
17
|
label: "#{criterion.condition.display.downcase} (#{t('.max')})",
|
18
18
|
form_id: form_id
|
19
19
|
%>
|
@@ -1,13 +1,24 @@
|
|
1
|
-
<div class="refine-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
1
|
+
<div class="refine--option-condition-container" data-controller="refine--typeahead-list">
|
2
|
+
<div class="refine--search-box">
|
3
|
+
<span class="material-icons refine--icon-search">search</span>
|
4
|
+
<input class="refine--search-trigger" data-search-target="filterProperties" placeholder="<%= t('.type_to_search') %>..." type="text" data-action="refine--typeahead-list#filter" autofocus>
|
5
|
+
</div>
|
6
|
+
|
7
|
+
<% criterion.options.each do |option| %>
|
8
|
+
<%= tag.label class: "refine--option-label",
|
9
|
+
data: {
|
10
|
+
refine__typeahead_list_target: "listItem",
|
11
|
+
list_item_value: option.display
|
12
|
+
} do
|
13
|
+
%>
|
14
|
+
<% if criterion.multiple? %>
|
15
|
+
<%= check_box_tag input_fields.field_name("selected", multiple: true), option.id, criterion.input.selected.to_a.include?(option.id), class: "refine--option-input", form: form_id %>
|
16
|
+
<% else %>
|
17
|
+
<%= radio_button_tag input_fields.field_name("selected"), option.id, (criterion.input.selected == [option.id]), class: "refine--option-input", form: form_id %>
|
18
|
+
<% end %>
|
19
|
+
<span class="refine--option-text"><%= option.display.truncate(64) %></span>
|
20
|
+
<% end %>
|
21
|
+
<% end %>
|
11
22
|
<% if criterion.condition.meta[:postfix] %>
|
12
23
|
<span class="refine-option--condition-postfix"><%= meta[:postfix] %></span>
|
13
24
|
<% end %>
|
data/lib/refine/rails/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: refine-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.9.
|
4
|
+
version: 2.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Colleen Schnettler
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2024-01-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -70,6 +70,7 @@ files:
|
|
70
70
|
- app/javascript/controllers/refine/toggle-controller.js
|
71
71
|
- app/javascript/controllers/refine/turbo-stream-form-controller.js
|
72
72
|
- app/javascript/controllers/refine/turbo-stream-link-controller.js
|
73
|
+
- app/javascript/controllers/refine/typeahead-list-controller.js
|
73
74
|
- app/javascript/controllers/refine/update-controller.js
|
74
75
|
- app/javascript/index.js
|
75
76
|
- app/javascript/refine/helpers/index.js
|
@@ -95,10 +96,12 @@ files:
|
|
95
96
|
- app/models/refine/conditions/text_condition.rb
|
96
97
|
- app/models/refine/conditions/uses_attributes.rb
|
97
98
|
- app/models/refine/filter.rb
|
99
|
+
- app/models/refine/filter/internationalized.rb
|
98
100
|
- app/models/refine/filters/blueprint_editor.rb
|
99
101
|
- app/models/refine/filters/builder.rb
|
100
102
|
- app/models/refine/filters/criterion.rb
|
101
103
|
- app/models/refine/filters/query.rb
|
104
|
+
- app/models/refine/inline/criteria/date_refinement.rb
|
102
105
|
- app/models/refine/inline/criteria/input.rb
|
103
106
|
- app/models/refine/inline/criteria/numeric_refinement.rb
|
104
107
|
- app/models/refine/inline/criteria/option.rb
|