-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature - inline ui can now merge OR groupings #193
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
PATH | ||
remote: . | ||
specs: | ||
refine-rails (2.11.4) | ||
refine-rails (2.11.5) | ||
rails (>= 6.0) | ||
|
||
GEM | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,12 +93,17 @@ def clear | |
handle_filter_update() | ||
end | ||
|
||
private | ||
def merge_groups | ||
@criterion = Refine::Inline::Criterion.new(criterion_params.merge(refine_filter: @refine_filter)) | ||
Refine::Filters::BlueprintEditor | ||
.new(@refine_filter.blueprint) | ||
.change_conjunction(criterion_params[:position].to_i - 1, "and") | ||
|
||
def set_blank_filter | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This wasn't being used anywhere and was leftover from my work on the clear button. So removed |
||
@refine_filter = Refine::Rails.configuration.stabilizer_classes[:url].new | ||
handle_filter_update(@refine_filter.to_stable_id) | ||
end | ||
|
||
private | ||
|
||
def set_refine_filter | ||
@refine_filter ||= Refine::Rails.configuration.stabilizer_classes[:url] | ||
.new | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,14 @@ def update(index, criterion:) | |
blueprint[index][:input] = input | ||
end | ||
|
||
def change_conjunction(index, conjunction_word) | ||
if conjunction_word == "and" | ||
blueprint[index][:word] = "and" | ||
elsif conjunction_word == "or" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No real use case for this behavior but I went ahead and added it since it was easy |
||
blueprint[index][:word] = "or" | ||
end | ||
end | ||
|
||
def delete(index) | ||
# To support 'groups' there is some complicated logic for deleting criterion. | ||
# | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<% group_position ||= 0 %> | ||
|
||
<% unless group_position == 0 %> | ||
<% if render_stack %> | ||
<div class="refine--group-join-stack"> | ||
<% end %> | ||
<div class="refine--group-join"> | ||
<%= t("refine.inline.filters.or") %> | ||
<%= link_to merge_groups_refine_inline_criteria_path(group.first.to_params), class: "refine--remove-group", data: {turbo_method: :post, controller: "refine--turbo-stream-link", action: "refine--turbo-stream-link#visit"} do %> | ||
<span class="material-icons-outlined refine--icon-sm">clear</span> | ||
<% end %> | ||
</div> | ||
<% if render_stack %> | ||
</div> | ||
<% end %> | ||
<% end %> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,15 +15,7 @@ | |
<% else %> | ||
<div class="refine--groups-wrapper"> | ||
<% groups.each.with_index do |group, i| %> | ||
<% unless i == 0 %> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. most of this got moved into the or_separator partial |
||
<% if render_stack %> | ||
<div class="refine--group-join-stack"> | ||
<% end %> | ||
<div class="refine--group-join"><%= t("refine.inline.filters.or") %></div> | ||
<% if render_stack %> | ||
</div> | ||
<% end %> | ||
<% end %> | ||
<%= render "refine/inline/filters/or_separator", group: group, group_position: i, render_stack: render_stack %> | ||
<%= render "refine/inline/filters/group", group: group, group_count: groups.count, condition_count: group.count, render_stack: render_stack %> | ||
<% if i == groups.length - 1 %> | ||
<%= render "refine/inline/filters/or_button", position: @refine_filter.blueprint.length %> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
module Refine | ||
module Rails | ||
VERSION = "2.11.4" | ||
VERSION = "2.11.5" | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically we don't need a criterion object to perform the operation required here, but the controller expects a criterion so the action just passes in the first element of the group being acted on. Its not ideal and arguably we should have a conjunction controller or a rethink of how criteria are managed. Today criterion are also acting on their surrounding conjunctions and it can be confusing but I didn't want to mess with this paradigm in this work