button -> chip
This commit is contained in:
@@ -5,7 +5,7 @@ module FiltersHelper
|
||||
|
||||
def filter_chips(filter, **)
|
||||
filter.to_h.map do |kind, object|
|
||||
filter_button_from kind, object, **
|
||||
filter_chip_from kind, object, **
|
||||
end.join.html_safe
|
||||
end
|
||||
|
||||
@@ -19,24 +19,24 @@ module FiltersHelper
|
||||
end
|
||||
end
|
||||
|
||||
def button_to_filter(text, kind:, object:, data: {})
|
||||
def button_to_chip(text, kind:, object:, data: {})
|
||||
if object
|
||||
button_to text, filter_chips_path, method: :post, class: "btn btn--plain filter__button", params: filter_attrs(kind, object), data: data
|
||||
button_to text, filter_chips_path, method: :post, class: "btn btn--plain filter__button", params: chip_attrs(kind, object), data: data
|
||||
else
|
||||
button_tag text, type: :button, class: "btn btn--plain filter__button", data: data
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def filter_button_from(kind, object, **)
|
||||
def filter_chip_from(kind, object, **)
|
||||
if object.respond_to? :map
|
||||
safe_join object.map { |o| filter_chip_tag(**filter_attrs(kind, o), **) }
|
||||
safe_join object.map { |o| filter_chip_tag(**chip_attrs(kind, o), **) }
|
||||
else
|
||||
filter_chip_tag(**filter_attrs(kind, object), **)
|
||||
filter_chip_tag(**chip_attrs(kind, object), **)
|
||||
end
|
||||
end
|
||||
|
||||
def filter_attrs(kind, object)
|
||||
def chip_attrs(kind, object)
|
||||
case kind&.to_sym
|
||||
when :tags
|
||||
[ object.hashtag, object.id, "tag_ids[]" ]
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
<menu class="filter__menu list-style-none unpad margin-none">
|
||||
<li><strong class="filter__label">Sort by</strong></li>
|
||||
<% Filter::INDEXES.each do |index| %>
|
||||
<li><%= button_to_filter index.humanize, kind: :indexed_by, object: index, data: { action: "filter-form#clearCategory", filter_form_name_param: "indexed_by" } %></li>
|
||||
<li><%= button_to_chip index.humanize, kind: :indexed_by, object: index, data: { action: "filter-form#clearCategory", filter_form_name_param: "indexed_by" } %></li>
|
||||
<% end %>
|
||||
</menu>
|
||||
</div>
|
||||
@@ -67,9 +67,9 @@
|
||||
<div class="flex gap flex-item-grow">
|
||||
<menu class="filter__menu list-style-none unpad margin-none">
|
||||
<li><strong class="filter__label">In Project</strong></li>
|
||||
<li><%= button_to_filter "All projects", kind: :buckets, object: nil, data: { action: "filter-form#clearCategory", filter_form_name_param: "bucket_ids[]" } %></li>
|
||||
<li><%= button_to_chip "All projects", kind: :buckets, object: nil, data: { action: "filter-form#clearCategory", filter_form_name_param: "bucket_ids[]" } %></li>
|
||||
<% Current.user.buckets.order(:name).each do |bucket| %>
|
||||
<li><%= button_to_filter bucket.name, kind: :buckets, object: bucket %></li>
|
||||
<li><%= button_to_chip bucket.name, kind: :buckets, object: bucket %></li>
|
||||
<% end %>
|
||||
</menu>
|
||||
</div>
|
||||
@@ -79,7 +79,7 @@
|
||||
<menu class="filter__menu list-style-none unpad margin-none">
|
||||
<li><strong class="filter__label">Tagged</strong></li>
|
||||
<% Current.account.tags.order(:title).each do |tag| %>
|
||||
<li><%= button_to_filter tag.title, kind: :tags, object: tag %></li>
|
||||
<li><%= button_to_chip tag.title, kind: :tags, object: tag %></li>
|
||||
<% end %>
|
||||
</menu>
|
||||
</div>
|
||||
@@ -88,10 +88,10 @@
|
||||
<div class="flex gap flex-item-grow">
|
||||
<menu class="filter__menu list-style-none unpad margin-none">
|
||||
<li><strong class="filter__label">Assigned to…</strong></li>
|
||||
<li><%= button_to_filter "No one", kind: :assignments, object: "unassigned", data: { action: "filter-form#clearCategory", filter_form_name_param: "assignee_ids[]" } %></li>
|
||||
<li><%= button_to_filter "Me", kind: :assignees, object: Current.user, data: { action: "filter-form#clearCategory", filter_form_name_param: "assignments" } %></li>
|
||||
<li><%= button_to_chip "No one", kind: :assignments, object: "unassigned", data: { action: "filter-form#clearCategory", filter_form_name_param: "assignee_ids[]" } %></li>
|
||||
<li><%= button_to_chip "Me", kind: :assignees, object: Current.user, data: { action: "filter-form#clearCategory", filter_form_name_param: "assignments" } %></li>
|
||||
<% Current.account.users.active.without(Current.user).order(:name).each do |user| %>
|
||||
<li><%= button_to_filter user.name, kind: :assignees, object: user, data: { action: "filter-form#clearCategory", filter_form_name_param: "assignments" } %></li>
|
||||
<li><%= button_to_chip user.name, kind: :assignees, object: user, data: { action: "filter-form#clearCategory", filter_form_name_param: "assignments" } %></li>
|
||||
<% end %>
|
||||
</menu>
|
||||
</div>
|
||||
@@ -100,9 +100,9 @@
|
||||
<div class="flex gap flex-item-grow">
|
||||
<menu class="filter__menu list-style-none unpad margin-none">
|
||||
<li><strong class="filter__label">Assigned by…</strong></li>
|
||||
<li><%= button_to_filter "Me", kind: :assigners, object: Current.user %></li>
|
||||
<li><%= button_to_chip "Me", kind: :assigners, object: Current.user %></li>
|
||||
<% Current.account.users.active.without(Current.user).order(:name).each do |user| %>
|
||||
<li><%= button_to_filter user.name, kind: :assigners, object: user %></li>
|
||||
<li><%= button_to_chip user.name, kind: :assigners, object: user %></li>
|
||||
<% end %>
|
||||
</menu>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user