refine-rails 2.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +413 -0
- data/Rakefile +8 -0
- data/app/assets/config/refine_rails_manifest.js +0 -0
- data/app/assets/javascripts/refine-stimulus.esm.js +2 -0
- data/app/assets/javascripts/refine-stimulus.esm.js.map +1 -0
- data/app/assets/javascripts/refine-stimulus.js +2 -0
- data/app/assets/javascripts/refine-stimulus.js.map +1 -0
- data/app/assets/javascripts/refine-stimulus.modern.js +2 -0
- data/app/assets/javascripts/refine-stimulus.modern.js.map +1 -0
- data/app/assets/javascripts/refine-stimulus.umd.js +2 -0
- data/app/assets/javascripts/refine-stimulus.umd.js.map +1 -0
- data/app/assets/stylesheets/index.css +1873 -0
- data/app/assets/stylesheets/index.tailwind.css +1035 -0
- data/app/controllers/refine/blueprints_controller.rb +80 -0
- data/app/controllers/refine/filter_application_controller.rb +29 -0
- data/app/controllers/refine/inline/criteria_controller.rb +161 -0
- data/app/controllers/refine/inline/stored_filters_controller.rb +84 -0
- data/app/controllers/refine/stored_filters_controller.rb +69 -0
- data/app/javascript/controllers/index.js +66 -0
- data/app/javascript/controllers/refine/add-controller.js +42 -0
- data/app/javascript/controllers/refine/criterion-form-controller.js +31 -0
- data/app/javascript/controllers/refine/date-controller.js +113 -0
- data/app/javascript/controllers/refine/defaults-controller.js +32 -0
- data/app/javascript/controllers/refine/delete-controller.js +13 -0
- data/app/javascript/controllers/refine/filter-pills-controller.js +63 -0
- data/app/javascript/controllers/refine/form-controller.js +51 -0
- data/app/javascript/controllers/refine/inline-conditions-controller.js +33 -0
- data/app/javascript/controllers/refine/popup-controller.js +46 -0
- data/app/javascript/controllers/refine/search-filter-controller.js +50 -0
- data/app/javascript/controllers/refine/server-refresh-controller.js +43 -0
- data/app/javascript/controllers/refine/state-controller.js +220 -0
- data/app/javascript/controllers/refine/stored-filter-controller.js +23 -0
- data/app/javascript/controllers/refine/submit-form-controller.js +8 -0
- data/app/javascript/controllers/refine/toggle-controller.js +12 -0
- data/app/javascript/controllers/refine/turbo-stream-form-controller.js +24 -0
- data/app/javascript/controllers/refine/turbo-stream-link-controller.js +24 -0
- data/app/javascript/controllers/refine/update-controller.js +86 -0
- data/app/javascript/index.js +1 -0
- data/app/javascript/refine/helpers/index.js +77 -0
- data/app/models/refine/blueprints/blueprint.rb +58 -0
- data/app/models/refine/blueprints/blueprint_example.json +25 -0
- data/app/models/refine/conditions/boolean_condition.rb +112 -0
- data/app/models/refine/conditions/clause.rb +38 -0
- data/app/models/refine/conditions/clauses.rb +38 -0
- data/app/models/refine/conditions/condition.rb +285 -0
- data/app/models/refine/conditions/condition_error.rb +1 -0
- data/app/models/refine/conditions/date_condition.rb +464 -0
- data/app/models/refine/conditions/date_with_time_condition.rb +8 -0
- data/app/models/refine/conditions/errors/condition_clause_error.rb +7 -0
- data/app/models/refine/conditions/errors/criteria_limit_exceeded_error.rb +2 -0
- data/app/models/refine/conditions/errors/option_error.rb +2 -0
- data/app/models/refine/conditions/errors/relationship_error.rb +1 -0
- data/app/models/refine/conditions/filter_condition.rb +93 -0
- data/app/models/refine/conditions/has_clauses.rb +117 -0
- data/app/models/refine/conditions/has_meta.rb +10 -0
- data/app/models/refine/conditions/has_refinements.rb +156 -0
- data/app/models/refine/conditions/numeric_condition.rb +224 -0
- data/app/models/refine/conditions/option_condition.rb +260 -0
- data/app/models/refine/conditions/text_condition.rb +152 -0
- data/app/models/refine/conditions/uses_attributes.rb +168 -0
- data/app/models/refine/filter.rb +302 -0
- data/app/models/refine/filters/blueprint_editor.rb +102 -0
- data/app/models/refine/filters/builder.rb +59 -0
- data/app/models/refine/filters/criterion.rb +87 -0
- data/app/models/refine/filters/query.rb +82 -0
- data/app/models/refine/inline/criteria/input.rb +50 -0
- data/app/models/refine/inline/criteria/numeric_refinement.rb +13 -0
- data/app/models/refine/inline/criteria/option.rb +2 -0
- data/app/models/refine/inline/criterion.rb +141 -0
- data/app/models/refine/invalid_filter_error.rb +8 -0
- data/app/models/refine/stabilize.rb +29 -0
- data/app/models/refine/stabilizers/database_stabilizer.rb +21 -0
- data/app/models/refine/stabilizers/errors/url_stabilizer_error.rb +2 -0
- data/app/models/refine/stabilizers/url_encoded_stabilizer.rb +21 -0
- data/app/models/refine/stored_filter.rb +14 -0
- data/app/models/refine/tracks_pending_relationship_subqueries.rb +196 -0
- data/app/views/_filter_builder_dropdown.html.erb +63 -0
- data/app/views/_filter_pills.html.erb +40 -0
- data/app/views/_loading.html.erb +32 -0
- data/app/views/refine/blueprints/_add_and.html.erb +25 -0
- data/app/views/refine/blueprints/_add_group.html.erb +24 -0
- data/app/views/refine/blueprints/_clause_select.html.erb +24 -0
- data/app/views/refine/blueprints/_condition_select.html.erb +53 -0
- data/app/views/refine/blueprints/_criterion.html.erb +41 -0
- data/app/views/refine/blueprints/_criterion_errors.html.erb +7 -0
- data/app/views/refine/blueprints/_delete_criterion.html.erb +11 -0
- data/app/views/refine/blueprints/_group.html.erb +13 -0
- data/app/views/refine/blueprints/_query.html.erb +34 -0
- data/app/views/refine/blueprints/_stored_filters.html.erb +23 -0
- data/app/views/refine/blueprints/clauses/_date_condition.html.erb +80 -0
- data/app/views/refine/blueprints/clauses/_date_picker.html.erb +26 -0
- data/app/views/refine/blueprints/clauses/_filter_condition.html.erb +36 -0
- data/app/views/refine/blueprints/clauses/_numeric_condition.html.erb +35 -0
- data/app/views/refine/blueprints/clauses/_option_condition.html.erb +37 -0
- data/app/views/refine/blueprints/clauses/_text_condition.html.erb +13 -0
- data/app/views/refine/blueprints/create.turbo_stream.erb +22 -0
- data/app/views/refine/blueprints/new.html.erb +7 -0
- data/app/views/refine/blueprints/show.html.erb +4 -0
- data/app/views/refine/blueprints/show.turbo_stream.erb +22 -0
- data/app/views/refine/inline/criteria/_form_fields.html.erb +62 -0
- data/app/views/refine/inline/criteria/create.turbo_stream.erb +19 -0
- data/app/views/refine/inline/criteria/edit.turbo_stream.erb +26 -0
- data/app/views/refine/inline/criteria/index.html.erb +64 -0
- data/app/views/refine/inline/criteria/new.turbo_stream.erb +24 -0
- data/app/views/refine/inline/filters/_add_first_condition_button.html.erb +19 -0
- data/app/views/refine/inline/filters/_and_button.html.erb +26 -0
- data/app/views/refine/inline/filters/_criterion.html.erb +23 -0
- data/app/views/refine/inline/filters/_group.html.erb +13 -0
- data/app/views/refine/inline/filters/_load_button.html.erb +15 -0
- data/app/views/refine/inline/filters/_or_button.html.erb +26 -0
- data/app/views/refine/inline/filters/_popup.html.erb +26 -0
- data/app/views/refine/inline/filters/_save_button.html.erb +15 -0
- data/app/views/refine/inline/filters/_show.html.erb +40 -0
- data/app/views/refine/inline/inputs/_date_condition.html.erb +7 -0
- data/app/views/refine/inline/inputs/_date_condition_days.html.erb +18 -0
- data/app/views/refine/inline/inputs/_date_condition_range.html.erb +22 -0
- data/app/views/refine/inline/inputs/_date_condition_single.html.erb +9 -0
- data/app/views/refine/inline/inputs/_date_picker.html.erb +20 -0
- data/app/views/refine/inline/inputs/_numeric_condition.html.erb +23 -0
- data/app/views/refine/inline/inputs/_option_condition.html.erb +14 -0
- data/app/views/refine/inline/inputs/_text_condition.html.erb +8 -0
- data/app/views/refine/inline/stored_filters/find.turbo_stream.erb +19 -0
- data/app/views/refine/inline/stored_filters/index.html.erb +28 -0
- data/app/views/refine/inline/stored_filters/new.turbo_stream.erb +47 -0
- data/app/views/refine/stored_filters/create.turbo_stream.erb +2 -0
- data/app/views/refine/stored_filters/find.turbo_stream.erb +5 -0
- data/app/views/refine/stored_filters/index.html.erb +39 -0
- data/app/views/refine/stored_filters/new.html.erb +29 -0
- data/app/views/refine/stored_filters/show.html.erb +1 -0
- data/config/locales/en/dates.en.yml +29 -0
- data/config/locales/en/en.yml +20 -0
- data/config/locales/en/refine.en.yml +187 -0
- data/config/routes.rb +17 -0
- data/lib/generators/filter/filter_generator.rb +27 -0
- data/lib/generators/filter/templates/filter.rb.erb +20 -0
- data/lib/refine/rails/engine.rb +15 -0
- data/lib/refine/rails/version.rb +5 -0
- data/lib/refine/rails.rb +38 -0
- data/lib/tasks/refine/rails_tasks.rake +13 -0
- metadata +202 -0
@@ -0,0 +1,80 @@
|
|
1
|
+
<% condition_id = condition.try(:id) || condition[:id] %>
|
2
|
+
<%# If the condition is not a refinements, it comes from the criterion form object, if it is
|
3
|
+
a refinement it's still a hash %>
|
4
|
+
|
5
|
+
<% if ['st', 'nst'].include? input[:clause] %>
|
6
|
+
<!-- render nothing -->
|
7
|
+
<% elsif ['exct', 'gt', 'lt'].include? input[:clause] %>
|
8
|
+
<div class="refine-date-condition-days-container">
|
9
|
+
<label for="<%= condition_id %>" class="sr-only"><%= t("refine.refine_blueprints.clauses.date_condition.number_of") %></label>
|
10
|
+
<input
|
11
|
+
class="refine-date-condition-days-input"
|
12
|
+
type="text"
|
13
|
+
value="<%= input[:days] %>"
|
14
|
+
placeholder="<%= t("refine.refine_blueprints.clauses.date_condition.date_number_of_placeholder") %>"
|
15
|
+
data-input-key="days"
|
16
|
+
data-action="input->refine--update#value blur->refine--update#refreshFromServer"
|
17
|
+
data-input-id='<%= input_id if defined? input_id %>'
|
18
|
+
/>
|
19
|
+
</div>
|
20
|
+
<div class="refine-date-condition-days-text">
|
21
|
+
<span><%= t("refine.refine_blueprints.clauses.date_condition.days") %></span>
|
22
|
+
</div>
|
23
|
+
<div class="refine-date-condition-days-modifier-container">
|
24
|
+
<select
|
25
|
+
class="refine-date-condition-days-modifier-select"
|
26
|
+
name="modifer"
|
27
|
+
<% if input[:modifier].blank? %>
|
28
|
+
data-controller="refine--defaults"
|
29
|
+
data-refine--defaults-input-value="{ "modifier": "ago" }"
|
30
|
+
data-refine--defaults-criterion-id-value="<%= criterion_id %>"
|
31
|
+
data-refine--defaults-input-key-value="<%= input_key_value if defined? input_key_value %>"
|
32
|
+
<% end %>
|
33
|
+
data-input-id='<%= input_id if defined? input_id %>'
|
34
|
+
data-input-key="modifier"
|
35
|
+
data-action="change->refine--update#value"
|
36
|
+
>
|
37
|
+
<option
|
38
|
+
<% if input[:modifier] == 'ago' %>selected<% end %>
|
39
|
+
value="ago"
|
40
|
+
>
|
41
|
+
<%= t("refine.refine_blueprints.clauses.date_condition.ago") %>
|
42
|
+
</option>
|
43
|
+
<option
|
44
|
+
<% if input[:modifier] == 'from_now' %>selected<% end %>
|
45
|
+
value="from_now"
|
46
|
+
>
|
47
|
+
<%= t("refine.refine_blueprints.clauses.date_condition.from_now") %>
|
48
|
+
</option>
|
49
|
+
</select>
|
50
|
+
<%= render partial: 'refine/blueprints/criterion_errors', locals: { criterion: criterion } %>
|
51
|
+
</div>
|
52
|
+
<% else %>
|
53
|
+
<div
|
54
|
+
class="<%= (input[:clause] == 'btwn' || input[:clause] == 'nbtwn') ? 'refine-date-condition-first-date-container-btwn' : 'refine-date-condition-first-date-container' %>"
|
55
|
+
>
|
56
|
+
<%= render partial: "refine/blueprints/clauses/date_picker", locals: {
|
57
|
+
criterion: criterion,
|
58
|
+
label: t("refine.refine_blueprints.clauses.date_condition.first_date"),
|
59
|
+
condition_id: condition_id,
|
60
|
+
date: input[:date1],
|
61
|
+
input_key: 'date1',
|
62
|
+
input_id: defined?(input_id) && input_id,
|
63
|
+
} %>
|
64
|
+
<%= render partial: 'refine/blueprints/criterion_errors', locals: { criterion: criterion } %>
|
65
|
+
</div>
|
66
|
+
<% if (input[:clause] == 'btwn' || input[:clause] == 'nbtwn') %>
|
67
|
+
<span class="refine-date-condition-and"><%= t("refine.refine_blueprints.clauses.date_condition.and") %></span>
|
68
|
+
<div class="refine-date-condition-second-date-container">
|
69
|
+
<%= render partial: "refine/blueprints/clauses/date_picker", locals: {
|
70
|
+
criterion: criterion,
|
71
|
+
label: t("refine.refine_blueprints.clauses.date_condition.second_date"),
|
72
|
+
condition_id: condition_id,
|
73
|
+
date: input[:date2],
|
74
|
+
input_key: 'date2',
|
75
|
+
input_id: defined?(input_id) && input_id,
|
76
|
+
} %>
|
77
|
+
</div>
|
78
|
+
<% end %>
|
79
|
+
<% end %>
|
80
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<div
|
2
|
+
data-controller="refine--date"
|
3
|
+
class="refine-date-picker-container"
|
4
|
+
data-refine--date-locale-value="<%= I18n.locale %>"
|
5
|
+
data-refine--date-date-format-value="<%= I18n.t("refine.date.formats.moment") %>"
|
6
|
+
data-refine--date-datetime-format-value="<%= I18n.t("refine.time.formats.moment") %>"
|
7
|
+
data-refine--date-picker-locale-value="<%= I18n.t("refine.daterangepicker").deep_transform_keys { |k| k.to_s.camelize(:lower) }.to_json %>",
|
8
|
+
>
|
9
|
+
<label for="<%= condition_id %>" class="sr-only"><%= label %></label>
|
10
|
+
|
11
|
+
<input
|
12
|
+
class="refine--date-picker-input"
|
13
|
+
type="text"
|
14
|
+
value="<%= date&.to_date && I18n.l(date&.to_date, format: I18n.t("refine.date.formats.ruby")) %>"
|
15
|
+
data-refine--date-target="field"
|
16
|
+
/>
|
17
|
+
<input
|
18
|
+
type="hidden"
|
19
|
+
name="<%= condition_id %>"
|
20
|
+
value="<%= date&.to_date&.strftime('%Y-%m-%d') %>"
|
21
|
+
data-refine--date-target="hiddenField"
|
22
|
+
data-input-key="<%= input_key %>"
|
23
|
+
data-input-id="<%= defined?(input_id) && input_id %>"
|
24
|
+
data-action="change->refine--update#value"
|
25
|
+
>
|
26
|
+
</div>
|
@@ -0,0 +1,36 @@
|
|
1
|
+
<% selected = input.has_key?(:selected) ? input[:selected] : [] %>
|
2
|
+
|
3
|
+
<% if ['st', 'nst'].include? input[:clause] %>
|
4
|
+
<!-- Render nothing -->
|
5
|
+
<% elsif %>
|
6
|
+
<%= tag.div class: 'refine-filter-condition-container' do %>
|
7
|
+
<%= tag.div data: {
|
8
|
+
action: "$change->refine--update#selected blur->refine--update#refreshFromServer",
|
9
|
+
controller: 'fields--super-select',
|
10
|
+
fields__super_select_enable_search_value: 'true',
|
11
|
+
fields__super_select_container_width_value: 'resolve',
|
12
|
+
} do %>
|
13
|
+
<select
|
14
|
+
class="refine-filter-condition-select"
|
15
|
+
data-fields--super-select-target="select"
|
16
|
+
name="values"
|
17
|
+
data-input-id='<%= input_id if input_id%>'
|
18
|
+
>
|
19
|
+
<% condition.meta[:options].each do |option| %>
|
20
|
+
<option
|
21
|
+
value="<%= option[:id] %>"
|
22
|
+
<% if selected.find { |id| id == option[:id] } %>selected<% end %>
|
23
|
+
>
|
24
|
+
<%= option[:display] %>
|
25
|
+
</option>
|
26
|
+
<% end %>
|
27
|
+
|
28
|
+
</select>
|
29
|
+
<% end %>
|
30
|
+
<% if meta[:postfix] %>
|
31
|
+
<span class="refine-filter-condition-postfix"><%= meta[:postfix] %></span>
|
32
|
+
<% end %>
|
33
|
+
<% end %>
|
34
|
+
<% end %>
|
35
|
+
|
36
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
<% condition_id = condition.try(:id) || condition[:id] %>
|
2
|
+
<% if ['st', 'nst'].include? input[:clause] %>
|
3
|
+
<!-- render nothing -->
|
4
|
+
<% else %>
|
5
|
+
<div class="<%= input[:clause] != 'btwn' ? 'refine-numeric-condition-container' : 'refine-numeric-condition-container-btwn' %>">
|
6
|
+
|
7
|
+
<input
|
8
|
+
class="refine-numeric-condition-input <%="has-error" if criterion.errors.any? %> "
|
9
|
+
name="<%= condition_id %>"
|
10
|
+
type="text"
|
11
|
+
value="<%= input[:value1] %>"
|
12
|
+
data-input-key="value1"
|
13
|
+
data-action="input->refine--update#value blur->refine--update#refreshFromServer"
|
14
|
+
data-input-id="<%= defined?(input_id) && input_id %>"
|
15
|
+
/>
|
16
|
+
<%= render partial: 'refine/blueprints/criterion_errors', locals: { criterion: criterion } %>
|
17
|
+
</div>
|
18
|
+
|
19
|
+
<% if ['btwn', 'nbtwn'].include? input[:clause] %>
|
20
|
+
<!-- Add second input for value2 if clause is between or not between -->
|
21
|
+
<span class="refine-numeric-condition-and"><%= t("refine.refine_blueprints.clauses.numeric_condition.and") %></span>
|
22
|
+
<div class="refine-numeric-condition-second-container">
|
23
|
+
<input
|
24
|
+
class="refine-numeric-condition-second-input"
|
25
|
+
name="<%= condition_id %>"
|
26
|
+
type="text"
|
27
|
+
value="<%= input[:value2] %>"
|
28
|
+
data-input-key="value2"
|
29
|
+
data-action="input->refine--update#value blur->refine--update#refreshFromServer"
|
30
|
+
data-input-id="<%= defined?(input_id) && input_id %>"
|
31
|
+
/>
|
32
|
+
<%= render partial: 'refine/blueprints/criterion_errors', locals: { criterion: criterion } %>
|
33
|
+
</div>
|
34
|
+
<% end %>
|
35
|
+
<% end %>
|
@@ -0,0 +1,37 @@
|
|
1
|
+
<% selected = input.has_key?(:selected) ? input[:selected] : [] %>
|
2
|
+
<% multiple = meta_clause[:multiple] ? "multiple" : "" %>
|
3
|
+
<% if ['st', 'nst'].include? input[:clause] %>
|
4
|
+
<!-- Render nothing -->
|
5
|
+
<% elsif %>
|
6
|
+
<div class="refine-option-condition-container <%= "has-error" if criterion.errors.any? %> ">
|
7
|
+
<%= tag.div data: {
|
8
|
+
action: "$change->refine--update#selected blur->refine--update#refreshFromServer",
|
9
|
+
controller: 'fields--super-select',
|
10
|
+
fields__super_select_enable_search_value: 'true',
|
11
|
+
fields__super_select_container_width_value: 'resolve',
|
12
|
+
} do %>
|
13
|
+
<select <%=multiple%>
|
14
|
+
class="refine-option-condition-select"
|
15
|
+
data-fields--super-select-target="select"
|
16
|
+
name="values"
|
17
|
+
data-input-id='<%= input_id if input_id%>'
|
18
|
+
>
|
19
|
+
<% condition.meta[:options].each do |option| %>
|
20
|
+
<option
|
21
|
+
value="<%= option[:id] %>"
|
22
|
+
<% if selected.find { |id| id == option[:id] } %>selected<% end %>
|
23
|
+
>
|
24
|
+
<%= option[:display].truncate(64) %>
|
25
|
+
</option>
|
26
|
+
<% end %>
|
27
|
+
|
28
|
+
</select>
|
29
|
+
<% end %>
|
30
|
+
<% if meta[:postfix] %>
|
31
|
+
<span class="refine-option-condition-postfix"><%= meta[:postfix] %></span>
|
32
|
+
<% end %>
|
33
|
+
<%= render partial: 'refine/blueprints/criterion_errors', locals: { criterion: criterion } %>
|
34
|
+
</div>
|
35
|
+
<% end %>
|
36
|
+
|
37
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<% unless ['st', 'nst'].include? input[:clause] %>
|
2
|
+
<div class="refine-text-condition-container">
|
3
|
+
<label for="<%= condition.id %>" class="sr-only"><%= condition.display %></label>
|
4
|
+
<input
|
5
|
+
class="refine-text-condition-input <%="has-error" if criterion.errors.any? %> "
|
6
|
+
name="<%= condition.id %>"
|
7
|
+
type="text"
|
8
|
+
value="<%= input[:value] %>"
|
9
|
+
data-action="input->refine--update#updateBlueprint keydown->refine--update#cancelEnter"
|
10
|
+
/>
|
11
|
+
<%= render partial: 'refine/blueprints/criterion_errors', locals: { criterion: criterion } %>
|
12
|
+
</div>
|
13
|
+
<% end %>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<% if @filter_submit_success %>
|
2
|
+
<%= turbo_stream.append_all "body" do %>
|
3
|
+
<script>
|
4
|
+
(function() {
|
5
|
+
const formId = <%= @refine_filter_builder.client_id.to_json.html_safe %>
|
6
|
+
const event = new CustomEvent("filter-submit-success", {
|
7
|
+
bubbles: true,
|
8
|
+
detail: {
|
9
|
+
stableId: <%= @stable_id.to_json.html_safe %>,
|
10
|
+
url: <%= @url_for_redirect.to_json.html_safe %>,
|
11
|
+
formId: formId
|
12
|
+
}
|
13
|
+
})
|
14
|
+
document
|
15
|
+
.getElementById(<%= dom_id(@refine_filter_builder, "query").to_json.html_safe %>)
|
16
|
+
.dispatchEvent(event)
|
17
|
+
})()
|
18
|
+
</script>
|
19
|
+
<% end %>
|
20
|
+
<% else %>
|
21
|
+
<%= turbo_stream.replace(dom_id(@refine_filter_builder, "query"), partial: "refine/blueprints/query") %>
|
22
|
+
<% end %>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<%= turbo_stream.replace(dom_id(@refine_filter_builder, "query"), partial: "refine/blueprints/query") %>
|
2
|
+
<% if @stable_id %>
|
3
|
+
<%= turbo_stream.append_all "body" do %>
|
4
|
+
<script>
|
5
|
+
(function() {
|
6
|
+
const formId = <%= @refine_filter_builder.client_id.to_json.html_safe %>
|
7
|
+
const event = new CustomEvent("filter-stabilized", {
|
8
|
+
bubbles: true,
|
9
|
+
detail: {
|
10
|
+
stableId: <%= @stable_id.to_json.html_safe %>,
|
11
|
+
formId: formId
|
12
|
+
}
|
13
|
+
})
|
14
|
+
document
|
15
|
+
.getElementById(<%= dom_id(@refine_filter_builder, "query").to_json.html_safe %>)
|
16
|
+
?.dispatchEvent(event)
|
17
|
+
})()
|
18
|
+
</script>
|
19
|
+
<% end %>
|
20
|
+
<% end %>
|
21
|
+
|
22
|
+
<%= turbo_stream.replace(dom_id(@refine_filter_builder, "query"), partial: "refine/blueprints/query") %>
|
@@ -0,0 +1,62 @@
|
|
1
|
+
<%= form.hidden_field :stable_id, form: form_id %>
|
2
|
+
<%= form.hidden_field :client_id, form: form_id %>
|
3
|
+
<%= form.hidden_field :condition_id, form: form_id %>
|
4
|
+
<%= form.hidden_field :conjunction, form: form_id %>
|
5
|
+
<%= form.hidden_field :position, form: form_id %>
|
6
|
+
|
7
|
+
<%= form.fields :input_attributes, model: @criterion.input do |input_fields| %>
|
8
|
+
|
9
|
+
|
10
|
+
<%# Input Value %>
|
11
|
+
<% unless ['st', 'nst'].include? @criterion.input.clause %>
|
12
|
+
<%= render @criterion.input_partial, criterion: @criterion, form: form, input_fields: input_fields, form_id: form_id %>
|
13
|
+
<div class="refine--separator"></div>
|
14
|
+
<% end %>
|
15
|
+
|
16
|
+
<%# Count Refinement %>
|
17
|
+
<% if @criterion.condition.has_count_refinement? %>
|
18
|
+
<label style="color: black;"><%= @criterion.condition.get_count_refinement_condition.display %></label>
|
19
|
+
<%= input_fields.fields :count_refinement_attributes, model: @criterion.input.count_refinement do |count_fields| %>
|
20
|
+
<div class="refine--criterion-clause-container">
|
21
|
+
<%= count_fields.collection_select :clause,
|
22
|
+
@criterion.condition.get_count_refinement_condition.clauses,
|
23
|
+
:id,
|
24
|
+
:display,
|
25
|
+
{},
|
26
|
+
class: "refine--clause-select",
|
27
|
+
data: {action: "change->refine--criterion-form#refresh"}
|
28
|
+
%>
|
29
|
+
</div>
|
30
|
+
|
31
|
+
<% unless ['st', 'nst'].include? @criterion.input.count_refinement.clause %>
|
32
|
+
<%= render "refine/inline/inputs/numeric_condition", input_fields: count_fields, form_id: form_id %>
|
33
|
+
<% end %>
|
34
|
+
<% end %>
|
35
|
+
|
36
|
+
<% end %>
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
<%# Clause Select %>
|
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>
|
54
|
+
|
55
|
+
|
56
|
+
<% end %>
|
57
|
+
|
58
|
+
<% @error_messages&.each do |msg| %>
|
59
|
+
<p class="refine-criterion-error">
|
60
|
+
<%= msg %>
|
61
|
+
</p>
|
62
|
+
<% end %>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<%= turbo_stream.append_all "body" do %>
|
2
|
+
<script>
|
3
|
+
(function() {
|
4
|
+
const event = new CustomEvent("filter-submit-success", {
|
5
|
+
bubbles: true,
|
6
|
+
detail: {
|
7
|
+
stableId: <%= @refine_stable_id.to_json.html_safe %>,
|
8
|
+
url: <%= @url_for_redirect.to_json.html_safe %>,
|
9
|
+
formId: <%= @refine_client_id.to_json.html_safe %>
|
10
|
+
}
|
11
|
+
})
|
12
|
+
document
|
13
|
+
.getElementById(<%= "refine-inline-filter-#{@refine_client_id}".to_json.html_safe %>)
|
14
|
+
.dispatchEvent(event)
|
15
|
+
})()
|
16
|
+
</script>
|
17
|
+
<% end %>
|
18
|
+
|
19
|
+
<%= turbo_stream.replace "refine-inline-filter-#{@refine_client_id}", partial: "refine/inline/filters/show" %>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<% form_id = dom_id(@criterion, :form) %>
|
2
|
+
|
3
|
+
<%= turbo_stream.update dom_id(@criterion) do %>
|
4
|
+
<div class="refine--criterion-fields">
|
5
|
+
<%= fields model: @criterion,
|
6
|
+
data: {
|
7
|
+
controller: "refine--criterion-form",
|
8
|
+
refine__criterion_form_url_value: edit_refine_inline_criterion_url(
|
9
|
+
@criterion.position, @criterion.to_params
|
10
|
+
),
|
11
|
+
refine__criterion_form_turbo_frame_value: dom_id(@criterion)
|
12
|
+
} do |form|
|
13
|
+
%>
|
14
|
+
<%= render "form_fields", form: form, form_id: form_id %>
|
15
|
+
<% end %>
|
16
|
+
</div>
|
17
|
+
<% end %>
|
18
|
+
|
19
|
+
|
20
|
+
<%= turbo_stream.append_all "body" do %>
|
21
|
+
<%= form_with url: refine_inline_criterion_path(@criterion.position),
|
22
|
+
method: :put,
|
23
|
+
id: form_id,
|
24
|
+
data: {controller: "refine--turbo-stream-form", action: "submit->refine--turbo-stream-form#submit"}
|
25
|
+
%>
|
26
|
+
<% end %>
|
@@ -0,0 +1,64 @@
|
|
1
|
+
<%
|
2
|
+
# a hash mapping Category => [array, of, conditions], sorted by category
|
3
|
+
categorized_conditions = @conditions
|
4
|
+
.group_by {|c| c.meta[:category].presence}
|
5
|
+
.sort_by {|(category, _conditions)| category.to_s.downcase }
|
6
|
+
.to_h
|
7
|
+
|
8
|
+
# an array of uncategorized conditions
|
9
|
+
uncategorized_conditions = categorized_conditions.delete(nil)
|
10
|
+
%>
|
11
|
+
|
12
|
+
<%= turbo_frame_tag @criterion do %>
|
13
|
+
<div data-controller="refine--inline-conditions">
|
14
|
+
|
15
|
+
<div class="refine--search-box">
|
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--inline-conditions#filterConditions">
|
18
|
+
</div>
|
19
|
+
|
20
|
+
<div class="refine--separator-m0"></div>
|
21
|
+
|
22
|
+
<div class="refine--condition-list">
|
23
|
+
<% uncategorized_conditions.each do |condition| %>
|
24
|
+
<%= link_to condition.display,
|
25
|
+
new_refine_inline_criterion_url(@criterion.to_params.deep_merge(refine_inline_criterion: {condition_id: condition.id})),
|
26
|
+
class: "refine--condition-list-item",
|
27
|
+
data: {
|
28
|
+
controller: "refine--turbo-stream-link",
|
29
|
+
action: "refine--turbo-stream-link#visit",
|
30
|
+
refine__inline_conditions_target: "condition"
|
31
|
+
}
|
32
|
+
%>
|
33
|
+
<% end %>
|
34
|
+
|
35
|
+
<% categorized_conditions.each do |(category, conditions)| %>
|
36
|
+
<b data-refine--inline-conditions-target="category"><%= category %></b>
|
37
|
+
<% conditions.each do |condition| %>
|
38
|
+
<%= link_to condition.display,
|
39
|
+
new_refine_inline_criterion_url(@criterion.to_params.deep_merge(refine_inline_criterion: {condition_id: condition.id})),
|
40
|
+
class: "refine--condition-list-item",
|
41
|
+
data: {
|
42
|
+
controller: "refine--turbo-stream-link",
|
43
|
+
action: "refine--turbo-stream-link#visit",
|
44
|
+
refine__inline_conditions_target: "condition",
|
45
|
+
category: category
|
46
|
+
}
|
47
|
+
%>
|
48
|
+
<% end %>
|
49
|
+
<% end %>
|
50
|
+
</div>
|
51
|
+
|
52
|
+
</div>
|
53
|
+
<div class="refine--separator"></div>
|
54
|
+
<%= render "refine/inline/filters/popup",
|
55
|
+
frame_id: dom_id(@criterion, :load),
|
56
|
+
src: refine_inline_stored_filters_path(@criterion.to_params),
|
57
|
+
frame_class: "refine--stored-filter-list-popup" do
|
58
|
+
%>
|
59
|
+
<%= link_to "#", class: "refine--stored-filters-link", data: {action: "click->refine--popup#show"} do %>
|
60
|
+
<div class="material-icons-outlined refine--list-icon">save</div>
|
61
|
+
<%= t('.saved_filters') %>
|
62
|
+
<% end %>
|
63
|
+
<% end %>
|
64
|
+
<% end %>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<% form_id = dom_id(@criterion, :form) %>
|
2
|
+
|
3
|
+
<%= turbo_stream.update dom_id(@criterion) do %>
|
4
|
+
<div class="refine--criterion-fields">
|
5
|
+
<%= fields model: @criterion,
|
6
|
+
class: "refine--criterion-form",
|
7
|
+
data: {
|
8
|
+
controller: "refine--criterion-form",
|
9
|
+
refine__criterion_form_url_value: new_refine_inline_criterion_url(
|
10
|
+
@criterion.to_params),
|
11
|
+
refine__criterion_form_turbo_frame_value: dom_id(@criterion),
|
12
|
+
} do |form|
|
13
|
+
%>
|
14
|
+
<%= render "form_fields", form: form, conjunction: @conjunction, position: @position, form_id: form_id %>
|
15
|
+
<% end %>
|
16
|
+
</div>
|
17
|
+
<% end %>
|
18
|
+
|
19
|
+
<%# 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. %>
|
20
|
+
<%= turbo_stream.append_all "body" do %>
|
21
|
+
<%= form_with url: refine_inline_criteria_path,
|
22
|
+
method: :post, id: form_id, data: {controller: "refine--turbo-stream-form", action: "submit->refine--turbo-stream-form#submit"} %>
|
23
|
+
<% end %>
|
24
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<%
|
2
|
+
criterion = Refine::Inline::Criterion.new(
|
3
|
+
stable_id: @refine_filter.to_stable_id,
|
4
|
+
refine_filter: @refine_filter,
|
5
|
+
client_id: @refine_client_id,
|
6
|
+
conjunction: "and",
|
7
|
+
position: position
|
8
|
+
)
|
9
|
+
%>
|
10
|
+
|
11
|
+
<%= render "refine/inline/filters/popup",
|
12
|
+
frame_id: dom_id(criterion),
|
13
|
+
src: refine_inline_criteria_path(criterion.to_params) do
|
14
|
+
%>
|
15
|
+
<button class="refine--add-condition-button refine--add-first-condition-button" href="#" data-action="click->refine--popup#show" type="button">
|
16
|
+
<span class="icon material-icons-outlined refine--icon-sm">add</span>
|
17
|
+
<span><%= t(".filter") %></span>
|
18
|
+
</button>
|
19
|
+
<% end %>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<%
|
2
|
+
criterion = Refine::Inline::Criterion.new(
|
3
|
+
stable_id: @refine_filter.to_stable_id,
|
4
|
+
refine_filter: @refine_filter,
|
5
|
+
client_id: @refine_client_id,
|
6
|
+
conjunction: "and",
|
7
|
+
position: position
|
8
|
+
)
|
9
|
+
%>
|
10
|
+
|
11
|
+
<% if @refine_filter.criteria_limit_reached? %>
|
12
|
+
<button disabled class="refine--add-condition-button" type="button" title="<%= t(".criteria_limit", criteria_limit: @refine_filter.criteria_limit) %>">
|
13
|
+
<span class="icon material-icons-outlined refine--icon-sm">add</span>
|
14
|
+
<span class="refine--add-button-label"><%= t("refine.inline.filters.and_button.condition") %></span>
|
15
|
+
</button>
|
16
|
+
<% else %>
|
17
|
+
<%= render "refine/inline/filters/popup",
|
18
|
+
frame_id: dom_id(criterion),
|
19
|
+
src: refine_inline_criteria_path(criterion.to_params) do
|
20
|
+
%>
|
21
|
+
<button class="refine--add-condition-button" type="button" data-action="click->refine--popup#show">
|
22
|
+
<span class="icon material-icons-outlined refine--icon-sm">add</span>
|
23
|
+
<span class="refine--add-button-label"><%= t("refine.inline.filters.and_button.condition") %></span>
|
24
|
+
</button>
|
25
|
+
<% end %>
|
26
|
+
<% end %>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<%# Filter Pill partial %>
|
2
|
+
|
3
|
+
<%= render "refine/inline/filters/popup",
|
4
|
+
frame_id: dom_id(criterion) do
|
5
|
+
%>
|
6
|
+
|
7
|
+
<div class="refine--condition-pill-wrapper">
|
8
|
+
<div class="refine--condition-pill">
|
9
|
+
<%= link_to criterion.condition_display, edit_refine_inline_criterion_path(criterion.position, criterion.to_params), class: "refine--condition-pill-name", data: {controller: "refine--turbo-stream-link", action: "refine--turbo-stream-link#visit"} %>
|
10
|
+
<div class="refine--remove-condition"></div>
|
11
|
+
<%= link_to refine_inline_criterion_path(criterion.position, criterion.to_params), class: "refine--remove-condition", data: {turbo_method: :delete, controller: "refine--turbo-stream-link", action: "refine--turbo-stream-link#visit"} do %>
|
12
|
+
<% end %>
|
13
|
+
<div class="refine--condition-value-wrapper">
|
14
|
+
<div class="refine--condition-value-clause"><%= criterion.clause_display %></div>
|
15
|
+
<div class="refine--condition-value-self">
|
16
|
+
<div><%= criterion.human_readable_value.truncate(64) %></div>
|
17
|
+
</div>
|
18
|
+
</div>
|
19
|
+
</div>
|
20
|
+
|
21
|
+
</div>
|
22
|
+
|
23
|
+
<% end %>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<div class="refine--group">
|
2
|
+
<div class="refine--group-conditions-wrapper">
|
3
|
+
<div class="refine--group-conditions">
|
4
|
+
<% group.each.with_index do |criterion, i| %>
|
5
|
+
<% unless i == 0 %>
|
6
|
+
<div class="refine--condition-join"><%= t(".and") %></div>
|
7
|
+
<% end %>
|
8
|
+
<%= render "refine/inline/filters/criterion", criterion: criterion %>
|
9
|
+
<% end %>
|
10
|
+
</div>
|
11
|
+
<%= render "refine/inline/filters/and_button", position: group.last.position + 1 %>
|
12
|
+
</div>
|
13
|
+
</div>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<%
|
2
|
+
criterion = Refine::Inline::Criterion.new(
|
3
|
+
stable_id: @refine_filter.to_stable_id,
|
4
|
+
client_id: @refine_client_id,
|
5
|
+
)
|
6
|
+
%>
|
7
|
+
|
8
|
+
<%= render "refine/inline/filters/popup",
|
9
|
+
frame_id: dom_id(criterion, :load),
|
10
|
+
src: refine_inline_stored_filters_path(criterion.to_params) do
|
11
|
+
%>
|
12
|
+
<button class="refine--inline-btn" type="button" data-action="click->refine--popup#show">
|
13
|
+
<%= t(".load_filter") %>
|
14
|
+
</button>
|
15
|
+
<% end %>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<%
|
2
|
+
criterion = Refine::Inline::Criterion.new(
|
3
|
+
stable_id: @refine_filter.to_stable_id,
|
4
|
+
refine_filter: @refine_filter,
|
5
|
+
client_id: @refine_client_id,
|
6
|
+
conjunction: "or",
|
7
|
+
position: position
|
8
|
+
)
|
9
|
+
%>
|
10
|
+
|
11
|
+
<% if @refine_filter.criteria_limit_reached? %>
|
12
|
+
<button disabled class="refine--add-group-button" type="button" title="<%= t(".criteria_limit", criteria_limit: @refine_filter.criteria_limit) %>">
|
13
|
+
<span class="icon material-icons-outlined refine--icon-sm">add</span>
|
14
|
+
<span class="refine--add-group-button-label"><%= t(".group") %></span>
|
15
|
+
</button>
|
16
|
+
<% else %>
|
17
|
+
<%= render "refine/inline/filters/popup",
|
18
|
+
frame_id: dom_id(criterion),
|
19
|
+
src: refine_inline_criteria_path(criterion.to_params) do
|
20
|
+
%>
|
21
|
+
<button class="refine--add-group-button" type="button" data-action="click->refine--popup#show">
|
22
|
+
<span class="icon material-icons-outlined refine--icon-sm">add</span>
|
23
|
+
<span class="refine--add-group-button-label"><%= t(".group") %></span>
|
24
|
+
</button>
|
25
|
+
<% end %>
|
26
|
+
<% end %>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<%#
|
2
|
+
Generic partial for placing a button that will load popup content via hotwire.
|
3
|
+
Required params:
|
4
|
+
- frame_id (the DOM ID of the turbo frame)
|
5
|
+
|
6
|
+
Optional class:
|
7
|
+
- src (the URL to load popup content from)
|
8
|
+
- container_class (class attribute of the wrapper div. Defaults to "refine--inline-popup-container")
|
9
|
+
- frame_class (class attribute of the turbo frame. Defaults to "refine--inline-popup")
|
10
|
+
|
11
|
+
somewhere in your yield be sure to include a `data-action="click->refine--popup#show"` to trigger the the popup
|
12
|
+
|
13
|
+
Popup can be hidden with `data-action="click->refine--popup#hide"`
|
14
|
+
%>
|
15
|
+
|
16
|
+
<%
|
17
|
+
src ||= ""
|
18
|
+
container_class ||= "refine--inline-popup-container"
|
19
|
+
frame_class ||= "refine--inline-popup"
|
20
|
+
is_open ||= false
|
21
|
+
%>
|
22
|
+
|
23
|
+
<%= tag.div class: container_class, data: {controller: "refine--popup", refine__popup_src_value: src, refine__is_open_value: is_open } do %>
|
24
|
+
<%= yield %>
|
25
|
+
<%= turbo_frame_tag frame_id, class: frame_class, data: {refine__popup_target: "frame"} %>
|
26
|
+
<% end %>
|