refine-rails 2.9.1 → 2.9.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -50
- data/app/assets/stylesheets/index.tailwind.css +5 -1
- data/app/controllers/refine/inline/criteria_controller.rb +6 -0
- data/app/models/refine/filter.rb +7 -2
- 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 +24 -19
- data/app/views/refine/inline/criteria/_form_fields.html.erb +88 -17
- 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/lib/refine/rails/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c511b1d652c0c97df24249a54ff96afcf0857129194e6babd19207cf6418dec
|
4
|
+
data.tar.gz: 3ffebe81b88605d56aec0bcea24b79b1b3c181228bec5d06bea8c33a16a445c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53db67c1486011495f1efbe6cccd3a8508697d23eea902c738277a5b55f3cc1ef460bf54960bff7dc40b6db7d75daa4b6a895430c81a6034daf80a1bfd13393b
|
7
|
+
data.tar.gz: 7dc1a7a8d51967bdb15f33b074a4564690b80be1902ab35bd67526dc9fbf2f492f34db3d6513987f9a620eeb16cf839ea4931f052e299ca8bf3a048ef39dc638
|
data/README.md
CHANGED
@@ -42,41 +42,6 @@ This is a helper method you can inspect in `Hammerstone::FilterApplicationContro
|
|
42
42
|
@pagy, @contacts = pagy(@refine_filter.get_query)
|
43
43
|
```
|
44
44
|
|
45
|
-
# TODO: Everything below this header was not covered in the installation guide. Not sure if it is deprecated
|
46
|
-
|
47
|
-
12. Add the `reveal` controller to your application if using the `filter_builder_dropdown` partial
|
48
|
-
|
49
|
-
`yarn add stimulus-reveal`
|
50
|
-
|
51
|
-
```javascript
|
52
|
-
//index.js
|
53
|
-
import RevealController from 'stimulus-reveal'
|
54
|
-
|
55
|
-
application.register('reveal', RevealController)
|
56
|
-
```
|
57
|
-
|
58
|
-
~13. If the gems tailwind styles are being purged with JIT you can add the gem to `tmp/gems` and add this to your tailwing config.~
|
59
|
-
|
60
|
-
``` tailwind.config.js
|
61
|
-
'./tmp/gems/*/app/views/**/*.html.erb',
|
62
|
-
'./tmp/gems/*/app/helpers/**/*.rb',
|
63
|
-
'./tmp/gems/*/app/assets/stylesheets/**/*.css',
|
64
|
-
'./tmp/gems/*/app/javascript/**/*.js',
|
65
|
-
```
|
66
|
-
|
67
|
-
~Run the following rake task:~
|
68
|
-
```
|
69
|
-
task :add_temp_gems do
|
70
|
-
target = `bundle show refine-rails`.chomp
|
71
|
-
if target.present?
|
72
|
-
puts "Linking refine-rails to '#{target}'."
|
73
|
-
`ln -s #{target} tmp/gems/refine-rails`
|
74
|
-
end
|
75
|
-
end
|
76
|
-
```
|
77
|
-
|
78
|
-
Don't forget to restart the server!
|
79
|
-
|
80
45
|
14. Add external styles - currently themify icons (can be overriden - the trash can icon is located in `_criterion.html.erb`) and `daterangepicker`
|
81
46
|
A quick way to load them is in the `head` section. Also available as an npm package.
|
82
47
|
|
@@ -374,25 +339,11 @@ import { controllerDefinitions as refineControllers } from "@hammerstone/refine-
|
|
374
339
|
application.load(refineControllers)
|
375
340
|
```
|
376
341
|
|
377
|
-
## Readme Installation Goals (what we're working towards - does not work yet)
|
378
|
-
|
379
|
-
1. Run the generator
|
380
|
-
`rails generate refine:install`
|
381
|
-
|
382
|
-
2. Define your filters, subclassing from `Hammerstone::Refine::Filter`
|
383
|
-
|
384
|
-
3. Call `apply_filter` in your controller (or even better, instantiate the filter in your controller `@contacts = ContactFilter.new(blueprint, initial_query` -> might not be possible, how can we do this with validations?)
|
385
|
-
|
386
|
-
4. If you want to customize the views you can override our stylesheet with you own.
|
387
|
-
If you need even more customization you can override the views with `rails generate refine:views` will extract the views
|
388
|
-
|
389
|
-
5. Add custom datepicker if desired and scope stored filters.
|
390
|
-
|
391
342
|
## Releasing New Versions
|
392
343
|
|
393
344
|
- Every release should update the gem and NPM package so version numbers stay in sync.
|
394
345
|
- Make sure to update the CHANGELOG with a note explaining what the new version does
|
395
|
-
- Make sure you have the [bump](https://rubygems.org/gems/bump)
|
346
|
+
- Make sure you have the [bump](https://rubygems.org/gems/bump) gems installed locally
|
396
347
|
|
397
348
|
### Releasing the Ruby Gem
|
398
349
|
|
@@ -224,7 +224,7 @@
|
|
224
224
|
}
|
225
225
|
|
226
226
|
.refine-criterion-refinement-container {
|
227
|
-
@apply w-full
|
227
|
+
@apply w-full sm:w-auto sm:flex-shrink-0;
|
228
228
|
}
|
229
229
|
|
230
230
|
/* _delete_criterion.html.erb */
|
@@ -601,6 +601,10 @@
|
|
601
601
|
padding: 0.5rem 0;
|
602
602
|
}
|
603
603
|
|
604
|
+
.refine--refinement-input-container {
|
605
|
+
margin: 0.5rem 0;
|
606
|
+
}
|
607
|
+
|
604
608
|
|
605
609
|
/* _date_condition.html.erb */
|
606
610
|
.refine--date-condition-days-text {
|
data/app/models/refine/filter.rb
CHANGED
@@ -50,7 +50,6 @@ module Refine
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
-
# DEPRECATED use Refine::Filters::Criterion#human_readable instead
|
54
53
|
def human_readable_criterions
|
55
54
|
output = []
|
56
55
|
if blueprint.present?
|
@@ -58,7 +57,13 @@ module Refine
|
|
58
57
|
if criterion[:type] == "conjunction"
|
59
58
|
output << criterion[:word]
|
60
59
|
else
|
61
|
-
|
60
|
+
condition = get_condition_for_criterion(criterion)
|
61
|
+
text = condition.human_readable(criterion[:input])
|
62
|
+
if condition.has_date_refinement?
|
63
|
+
date_refinement_condition = condition.has_date_refinement?.call
|
64
|
+
text += date_refinement_condition.human_readable(criterion[:input][:date_refinement])
|
65
|
+
end
|
66
|
+
output << text
|
62
67
|
end
|
63
68
|
end
|
64
69
|
end
|
@@ -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
|
@@ -5,33 +5,38 @@
|
|
5
5
|
refine__update_criterion_id_value: criterion_id,
|
6
6
|
position: criterion.position}) do %>
|
7
7
|
|
8
|
+
<div class="refine-criterion-line">
|
8
9
|
<!-- Select Condition -->
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
<div class="refine-criterion-condition-container">
|
11
|
+
<%= render partial: 'refine/blueprints/condition_select', locals: {
|
12
|
+
selected_condition_id: criterion.condition_id } %>
|
13
|
+
</div>
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
<!-- Select Clause -->
|
16
|
+
<div class="refine-criterion-clause-container">
|
17
|
+
<%= render partial: 'refine/blueprints/clause_select', locals: {
|
18
|
+
meta: criterion.meta, selected_clause: criterion.input[:clause]} %>
|
19
|
+
</div>
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
<!-- Render correct type of condition -->
|
22
|
+
<%= render partial: "refine/blueprints/clauses/#{criterion.component}", locals: {
|
23
|
+
criterion: criterion,
|
24
|
+
condition: criterion.condition, input: criterion.input, criterion_id: criterion_id, meta: criterion.meta, meta_clause: criterion.selected_clause_meta, input_id: nil } %>
|
25
|
+
</div>
|
24
26
|
|
25
27
|
<!-- Refinements -->
|
26
28
|
<% criterion.refinements.each do |refinement|%>
|
27
29
|
|
28
|
-
<div class="refine-criterion-refinement-
|
29
|
-
|
30
|
-
|
31
|
-
|
30
|
+
<div class="refine-criterion-refinement-line">
|
31
|
+
<i class="fa-thin fa-l"></i>
|
32
|
+
<div class="refine-criterion-refinement-container">
|
33
|
+
<%= render partial: 'refine/blueprints/clause_select', locals: {
|
34
|
+
meta: refinement[:meta], input_id: "input, #{refinement[:id]}", selected_clause: criterion.input.dig(refinement[:id].to_sym, :clause) || {} } %>
|
35
|
+
</div>
|
32
36
|
|
33
|
-
|
34
|
-
|
37
|
+
<%= render partial: "refine/blueprints/clauses/#{refinement[:component].underscore}", locals: {
|
38
|
+
condition: refinement, input: criterion.input[refinement[:id].to_sym] || {}, criterion_id: criterion_id, meta: refinement[:meta], input_id: "input, #{refinement[:id]}", meta_clause: criterion.meta_for_refinement_clause(refinement), criterion: criterion} %>
|
39
|
+
</div>
|
35
40
|
<% end %>
|
36
41
|
<!-- End Refinements -->
|
37
42
|
|
@@ -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", type: "submit", form: form_id %>
|
53
|
-
</div>
|
124
|
+
|
54
125
|
|
55
126
|
|
56
127
|
<% end %>
|
@@ -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
|
%>
|
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.3
|
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-02-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -101,6 +101,7 @@ files:
|
|
101
101
|
- app/models/refine/filters/builder.rb
|
102
102
|
- app/models/refine/filters/criterion.rb
|
103
103
|
- app/models/refine/filters/query.rb
|
104
|
+
- app/models/refine/inline/criteria/date_refinement.rb
|
104
105
|
- app/models/refine/inline/criteria/input.rb
|
105
106
|
- app/models/refine/inline/criteria/numeric_refinement.rb
|
106
107
|
- app/models/refine/inline/criteria/option.rb
|
@@ -177,7 +178,7 @@ files:
|
|
177
178
|
- lib/tasks/refine/rails_tasks.rake
|
178
179
|
homepage: https://rubygems.org/gems/refine-rails
|
179
180
|
licenses:
|
180
|
-
-
|
181
|
+
- MIT
|
181
182
|
metadata:
|
182
183
|
homepage_uri: https://rubygems.org/gems/refine-rails
|
183
184
|
source_code_uri: https://github.com/clickfunnels2/refine-rails
|
@@ -197,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
197
198
|
- !ruby/object:Gem::Version
|
198
199
|
version: '0'
|
199
200
|
requirements: []
|
200
|
-
rubygems_version: 3.
|
201
|
+
rubygems_version: 3.3.26
|
201
202
|
signing_key:
|
202
203
|
specification_version: 4
|
203
204
|
summary: Visual query builder for Rails
|