refine-rails 2.10.1 → 2.11.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: 9368004666e1ce85b95a59bacbbc3108bbf4c031501ebcb02d6be4762981c9ec
4
- data.tar.gz: 4012a923ccf3c31f0940026e7f5f6a53d750becc3b1d399545947ddd6c6013c0
3
+ metadata.gz: a6d08917ff81795522878aecd04801d73264e3fd0e1b9ad1e2a1f80a65ec63ec
4
+ data.tar.gz: 4733498d5eaa05caf9a1761139b5682a0bfac934ad9000c6b3229887bcb40170
5
5
  SHA512:
6
- metadata.gz: 06f22e0514e0dcbcac454ccbf925fd82a781272ab878c6340a3eda4a99670bfc84f5ee7028a963d1943d844855bcc07f112149e7b87133598f52defb40d33031
7
- data.tar.gz: 590cf17e85b249c95513dc5ac14c98e1cd725001f2a2cfb93dba995a4144c4fb6d6a9c4997b234fa9839c04a436c57ff0b4a8279dba04aef3e906afa7e10505c
6
+ metadata.gz: 7befd7713b999794b8cd59c4f65a11912bf3de30f3a28dd2da8479d6338fa3d4228f97d4df98b9f4779b7ce6d66720f5f1838b842a8cbc0305389ed666a8f2b0
7
+ data.tar.gz: caba22b5b9eb31c5e175fe3a08a524a5bff4d6ec94d25bc13e8901af3d5750ef7e62dd0041aa11dc442beddcf17acfa14fdfe980669e15ccb869b85c79191d70
@@ -10,6 +10,7 @@ module Refine::Conditions
10
10
  include HasMeta
11
11
  include UsesAttributes
12
12
  include HasRefinements
13
+ include HasIcon
13
14
 
14
15
  attr_reader :ensurances, :before_validations, :clause, :filter
15
16
  attr_accessor :display, :id, :is_refinement, :attribute
@@ -0,0 +1,24 @@
1
+ module Refine::Conditions::HasIcon
2
+ def icon_class
3
+ @icon_class ||= nil
4
+ end
5
+
6
+ def icon_template
7
+ @icon_template ||= {}
8
+ end
9
+
10
+ def with_icon_class(icon_class)
11
+ @icon_class = icon_class
12
+ self
13
+ end
14
+
15
+ def with_icon_template(template_path:, locals: {})
16
+ @icon_template = { template_path: template_path, locals: locals }
17
+ self
18
+ end
19
+
20
+ def has_icon?
21
+ icon_class.present? || !icon_template.empty?
22
+ end
23
+
24
+ end
@@ -65,7 +65,9 @@
65
65
  value="<%= condition_option[:id] %>"
66
66
  <% if selected_condition_id == condition_option[:id] %>selected<% end %>
67
67
  title="<%= condition_option[:display] %>"
68
- ><%= condition_option[:display] %></option>
68
+ >
69
+ <%= condition_option[:display] %>
70
+ </option>
69
71
  <% end %>
70
72
  </optgroup>
71
73
  <% end %>
@@ -0,0 +1,27 @@
1
+ <%
2
+ category ||= nil
3
+
4
+ data = {
5
+ controller: "refine--turbo-stream-link",
6
+ action: "refine--turbo-stream-link#visit",
7
+ refine__typeahead_list_target: "listItem",
8
+ list_item_value: condition.display,
9
+ }
10
+ if category && category.present?
11
+ data[:category] = category
12
+ end
13
+ %>
14
+ <%= link_to(
15
+ new_refine_inline_criterion_url(@criterion.to_params.deep_merge(refine_inline_criterion: {condition_id: condition.id})),
16
+ {
17
+ class: "refine--condition-list-item",
18
+ }.merge(data: data)) do %>
19
+ <% if condition.has_icon? %>
20
+ <% if condition.icon_class.present? %>
21
+ <i class="<%= condition.icon_class %>"></i>
22
+ <% else %>
23
+ <%= render partial: condition.icon_template[:template_path], locals: condition.icon_template[:locals] %>
24
+ <% end %>
25
+ <% end %>
26
+ <%= condition.display %>
27
+ <% end %>
@@ -43,49 +43,21 @@
43
43
  <div class="refine--condition-list">
44
44
  <% if uncategorized_conditions&.any? %>
45
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 %>
46
+ <%= render partial: "condition_list_item", locals: {condition: condition } %>
47
+ <% end %>
57
48
  <% end %>
58
49
 
59
50
  <% if recommended_conditions.any? %>
60
51
  <b data-refine--typeahead-list-target="recommended"><%= t('.recommended') %></b>
61
52
  <% 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
- list_item_value: condition.display
70
- }
71
- %>
53
+ <%= render partial: "condition_list_item", locals: {condition: condition } %>
72
54
  <% end %>
73
55
  <% end %>
74
56
 
75
57
  <% categorized_conditions.each do |(category, conditions)| %>
76
58
  <b data-refine--typeahead-list-target="category"><%= category %></b>
77
59
  <% conditions.each do |condition| %>
78
- <%= link_to condition.display,
79
- new_refine_inline_criterion_url(@criterion.to_params.deep_merge(refine_inline_criterion: {condition_id: condition.id})),
80
- class: "refine--condition-list-item",
81
- data: {
82
- controller: "refine--turbo-stream-link",
83
- action: "refine--turbo-stream-link#visit",
84
- refine__typeahead_list_target: "listItem",
85
- list_item_value: condition.display,
86
- category: category
87
- }
88
- %>
60
+ <%= render partial: "condition_list_item", locals: {condition: condition, category: category } %>
89
61
  <% end %>
90
62
  <% end %>
91
63
  </div>
@@ -1,5 +1,5 @@
1
1
  module Refine
2
2
  module Rails
3
- VERSION = "2.10.1"
3
+ VERSION = "2.11.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.10.1
4
+ version: 2.11.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-08-15 00:00:00.000000000 Z
12
+ date: 2024-08-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -89,6 +89,7 @@ files:
89
89
  - app/models/refine/conditions/errors/relationship_error.rb
90
90
  - app/models/refine/conditions/filter_condition.rb
91
91
  - app/models/refine/conditions/has_clauses.rb
92
+ - app/models/refine/conditions/has_icon.rb
92
93
  - app/models/refine/conditions/has_meta.rb
93
94
  - app/models/refine/conditions/has_refinements.rb
94
95
  - app/models/refine/conditions/numeric_condition.rb
@@ -136,6 +137,7 @@ files:
136
137
  - app/views/refine/blueprints/new.html.erb
137
138
  - app/views/refine/blueprints/show.html.erb
138
139
  - app/views/refine/blueprints/show.turbo_stream.erb
140
+ - app/views/refine/inline/criteria/_condition_list_item.html.erb
139
141
  - app/views/refine/inline/criteria/_form_fields.html.erb
140
142
  - app/views/refine/inline/criteria/create.turbo_stream.erb
141
143
  - app/views/refine/inline/criteria/edit.turbo_stream.erb