refine-rails 2.9.13 → 2.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5836b6a4e038da50667759f2797771d2c58cd85b55bdf675c566ed3378da2867
4
- data.tar.gz: 2be921931819b0c9174e359078312ee2cf7061df037024786638f1110d7ab1a0
3
+ metadata.gz: b10da95439ebbfb430380582aeb607bbc56e065fdd85168d755fd1165a665e81
4
+ data.tar.gz: a67a503d0142ffcd6b6400661407749f13a205e2640df94f294b9597cabc6cd6
5
5
  SHA512:
6
- metadata.gz: c3b75ad55aa0c839691eec7694b91028e4d1e22db4b8aab45ada04f9a5989c1ffb1d986a1f33a6a8b1eedd2718cacb981442db1bcc59fa10ca0de1b9c1039cae
7
- data.tar.gz: 6fab69ea67b35e8925638a6ce16ff99d2d590331867ca126403460639e708ccca8f9caa6b17e9d579fda9329e9d26008c77698cfca62884182ead9c2d71d85aa
6
+ metadata.gz: e777469805d700bf202f4bef49870725e20c08f8ab7486b00d2395801c843caf62b35fbfd786f78364a5b4523c3b6d542cb93a2a7743ce756bcc87be0ac77dde
7
+ data.tar.gz: d6299c4843f0b56f3b6b3221106759960b39447cf07e293b89ce99fec79fd36f40ec6546252ce9d9c45a139b6ea49ec3384ff52332c55648aaf9f3d6ab0dec31
@@ -1670,7 +1670,12 @@ input.refine--text-condition-input:focus {
1670
1670
  padding: 5px;
1671
1671
  align-items: center;
1672
1672
  background-color: #fff;
1673
- &:hover {
1673
+ &:disabled {
1674
+ color: #111;
1675
+ background-color: #f8f8f8;
1676
+ cursor: not-allowed;
1677
+ }
1678
+ &:not([disabled]):hover {
1674
1679
  color: #111;
1675
1680
  background-color: #f8f8f8;
1676
1681
  }
@@ -840,7 +840,12 @@ input.refine--text-condition-input:focus {
840
840
  padding: 5px;
841
841
  align-items: center;
842
842
  background-color: #fff;
843
- &:hover {
843
+ &:disabled {
844
+ color: #111;
845
+ background-color: #f8f8f8;
846
+ cursor: not-allowed;
847
+ }
848
+ &:not([disabled]):hover {
844
849
  color: #111;
845
850
  background-color: #f8f8f8;
846
851
  }
@@ -312,5 +312,9 @@ module Refine
312
312
  def criteria_limit_set?
313
313
  criteria_limit.to_i.positive?
314
314
  end
315
+
316
+ def has_category_ordering?
317
+ respond_to?(:category_order) && category_order.is_a?(Array) && category_order.any?
318
+ end
315
319
  end
316
320
  end
@@ -5,7 +5,10 @@
5
5
  conditions.filter { |c| c[:meta][:category] == category}
6
6
  end
7
7
 
8
- categories = conditions.map { |c| c[:meta][:category] }.uniq.compact
8
+ # If an ordering has been defined for categories, use that, otherwise use the order in which they appear in the sorted conditions
9
+ categories = (@refine_filter.has_category_ordering?) ? @refine_filter.category_order : conditions.map { |c| c[:meta][:category] }.uniq.compact
10
+
11
+ recommended_conditions = conditions.select { |c| c[:meta][:recommended] }
9
12
 
10
13
  # Note that the stimulus controllers set default condition id for new conditions
11
14
  # so this is only for rare cases where it gets unset
@@ -40,6 +43,19 @@
40
43
  ><%= condition_option[:display] %></option>
41
44
  <% end %>
42
45
  </optgroup>
46
+
47
+ <% if recommended_conditions&.any? %>
48
+ <optgroup class="divider" label="<%= t(".recommended") %>">
49
+ <% recommended_conditions.each do |condition_option| %>
50
+ <option
51
+ value="<%= condition_option[:id] %>"
52
+ <% if selected_condition_id == condition_option[:id] %>selected<% end %>
53
+ title="<%= condition_option[:display] %>"
54
+ ><%= condition_option[:display] %></option>
55
+ <% end %>
56
+ </optgroup>
57
+ <% end %>
58
+
43
59
  <% categories.each do |category| %>
44
60
  <optgroup class="divider" label="<%= category %>">
45
61
  <% conditions_for_category.call(category).each do |condition_option| %>
@@ -2,9 +2,19 @@
2
2
  # a hash mapping Category => [array, of, conditions], sorted by category
3
3
  categorized_conditions = @conditions
4
4
  .group_by {|c| c.meta[:category].presence}
5
- .sort_by {|(category, _conditions)| category.to_s.downcase }
5
+ .sort_by do |(category, _conditions)|
6
+ if @refine_filter.has_category_ordering?
7
+ @refine_filter.category_order.index(category) || Float::INFINITY
8
+ else
9
+ category.to_s.downcase
10
+ end
11
+ end
6
12
  .to_h
7
13
 
14
+ recommended_conditions = @conditions
15
+ .select { |c| c.meta[:recommended] }
16
+ .sort_by {|recommended| recommended.to_s.downcase }
17
+
8
18
  # an array of uncategorized conditions
9
19
  uncategorized_conditions = categorized_conditions.delete(nil)
10
20
  %>
@@ -31,17 +41,34 @@
31
41
  <div class="refine--separator-m0"></div>
32
42
 
33
43
  <div class="refine--condition-list">
34
- <% uncategorized_conditions.each do |condition| %>
35
- <%= link_to condition.display,
36
- new_refine_inline_criterion_url(@criterion.to_params.deep_merge(refine_inline_criterion: {condition_id: condition.id})),
37
- class: "refine--condition-list-item",
38
- data: {
39
- controller: "refine--turbo-stream-link",
40
- action: "refine--turbo-stream-link#visit",
41
- refine__typeahead_list_target: "listItem",
42
- list_item_value: condition.display
43
- }
44
- %>
44
+ <% if uncategorized_conditions&.any? %>
45
+ <% uncategorized_conditions.each do |condition| %>
46
+ <%= link_to condition.display,
47
+ new_refine_inline_criterion_url(@criterion.to_params.deep_merge(refine_inline_criterion: {condition_id: condition.id})),
48
+ class: "refine--condition-list-item",
49
+ data: {
50
+ controller: "refine--turbo-stream-link",
51
+ action: "refine--turbo-stream-link#visit",
52
+ refine__typeahead_list_target: "listItem",
53
+ list_item_value: condition.display
54
+ }
55
+ %>
56
+ <% end %>
57
+ <% end %>
58
+
59
+ <% if recommended_conditions.any? %>
60
+ <b data-refine--typeahead-list-target="recommended"><%= t('.recommended') %></b>
61
+ <% recommended_conditions.each do |condition| %>
62
+ <%= link_to condition.display,
63
+ new_refine_inline_criterion_url(@criterion.to_params.deep_merge(refine_inline_criterion: {condition_id: condition.id})),
64
+ class: "refine--condition-list-item",
65
+ data: {
66
+ controller: "refine--turbo-stream-link",
67
+ action: "refine--turbo-stream-link#visit",
68
+ refine__typeahead_list_target: "listItem",
69
+ }
70
+ %>
71
+ <% end %>
45
72
  <% end %>
46
73
 
47
74
  <% categorized_conditions.each do |(category, conditions)| %>
@@ -66,6 +66,10 @@ en:
66
66
  days: "days"
67
67
  and: "and"
68
68
 
69
+ blueprints:
70
+ condition_select:
71
+ recommended: "Recommended"
72
+
69
73
  refine_blueprints:
70
74
  add_and:
71
75
  add_and: "AND"
@@ -184,5 +188,8 @@ en:
184
188
  filters:
185
189
  add_first_condition_button:
186
190
  filter: "Filter"
191
+ criteria:
192
+ index:
193
+ recommended: "Recommended"
187
194
  load_button:
188
195
  load_filter: "Load Filter"
@@ -1,5 +1,5 @@
1
1
  module Refine
2
2
  module Rails
3
- VERSION = "2.9.13"
3
+ VERSION = "2.10.0"
4
4
  end
5
5
  end
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.13
4
+ version: 2.10.0
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: 2024-06-18 00:00:00.000000000 Z
12
+ date: 2024-08-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails