-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
159 additions
and
144 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# frozen_string_literal: true | ||
|
||
class Facet | ||
#### | ||
#### accessors | ||
#### | ||
|
||
attr_accessor :attribute, :value, :position, :count, :url_params, :type | ||
|
||
#### | ||
#### constants | ||
#### | ||
|
||
#### | ||
#### extensions | ||
#### | ||
|
||
include ActiveModel::Model | ||
|
||
#### | ||
#### | ||
#### | ||
|
||
def active?(params) | ||
'checked' if params[attribute].eql?(value) | ||
end | ||
|
||
def current_param = { attribute => value } | ||
|
||
def public_attribute = attribute.titleize | ||
|
||
def public_value = value.titleize | ||
|
||
def presentation = "#{public_value.truncate(20)} (#{count})" | ||
|
||
def url(params) | ||
remove_filter_url = params.tap { |hs| hs.delete(attribute) } | ||
apply_filter_url = params.merge(current_param) | ||
active?(params) ? remove_filter_url : apply_filter_url | ||
end | ||
|
||
#### | ||
#### self | ||
#### | ||
|
||
def self.set_attributes = @facets.map(&:attribute).uniq | ||
|
||
# private | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
app/views/shared/template/layout/_navigation_checkbox_item.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<li class="relative" data-side-nav-target="link"> | ||
<div class="flex items-center"> | ||
<input id="<%= facet.value %>" name="<%= facet.attribute %>" type="checkbox" <%= facet.active?(request.params) %> class="h-4 w-4 rounded border-gray-300 text-indigo-600 focus:ring-indigo-600"> | ||
<%= link_to facet.url(request.params), class: 'flex justify-between gap-2 py-1 pr-3 text-sm transition pl-4 text-zinc-600 hover:text-zinc-900 dark:text-zinc-400 dark:hover:text-white ' do %> | ||
<span class="truncate"><%= facet.presentation %></span> | ||
<% end %> | ||
</div> | ||
<ul role="list" class="hidden"></ul> | ||
</li> |
9 changes: 0 additions & 9 deletions
9
app/views/shared/template/layout/_navigation_group_item.html.erb
This file was deleted.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
app/views/shared/template/layout/_navigation_radio_item.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<li class="relative" data-side-nav-target="link"> | ||
<div class="flex items-center"> | ||
<input id="<%= facet.value %>" name="<%= facet.attribute %>" type="radio" <%= facet.active?(request.params) %> class="h-4 w-4 border-gray-300 text-indigo-600 focus:ring-indigo-600""> | ||
<%= link_to facet.url(request.params), class: 'flex justify-between gap-2 py-1 pr-3 text-sm transition pl-4 text-zinc-600 hover:text-zinc-900 dark:text-zinc-400 dark:hover:text-white ' do %> | ||
<span class="truncate"><%= facet.presentation %></span> | ||
<% end %> | ||
</div> | ||
<ul role="list" class="hidden"></ul> | ||
</li> |