From d77eafe012758ae425b9c79bdc0dfed137a7a29b Mon Sep 17 00:00:00 2001 From: Jose Farias Date: Tue, 12 Nov 2024 19:26:21 -0600 Subject: [PATCH] button -> chip --- app/helpers/filters_helper.rb | 14 +++++++------- app/views/bubbles/_filters.html.erb | 18 +++++++++--------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/app/helpers/filters_helper.rb b/app/helpers/filters_helper.rb index 3e66f5f5c..a6689350c 100644 --- a/app/helpers/filters_helper.rb +++ b/app/helpers/filters_helper.rb @@ -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[]" ] diff --git a/app/views/bubbles/_filters.html.erb b/app/views/bubbles/_filters.html.erb index abf39c727..be34a65a6 100644 --- a/app/views/bubbles/_filters.html.erb +++ b/app/views/bubbles/_filters.html.erb @@ -58,7 +58,7 @@
  • Sort by
  • <% Filter::INDEXES.each do |index| %> -
  • <%= button_to_filter index.humanize, kind: :indexed_by, object: index, data: { action: "filter-form#clearCategory", filter_form_name_param: "indexed_by" } %>
  • +
  • <%= button_to_chip index.humanize, kind: :indexed_by, object: index, data: { action: "filter-form#clearCategory", filter_form_name_param: "indexed_by" } %>
  • <% end %>
    @@ -67,9 +67,9 @@
  • In Project
  • -
  • <%= button_to_filter "All projects", kind: :buckets, object: nil, data: { action: "filter-form#clearCategory", filter_form_name_param: "bucket_ids[]" } %>
  • +
  • <%= button_to_chip "All projects", kind: :buckets, object: nil, data: { action: "filter-form#clearCategory", filter_form_name_param: "bucket_ids[]" } %>
  • <% Current.user.buckets.order(:name).each do |bucket| %> -
  • <%= button_to_filter bucket.name, kind: :buckets, object: bucket %>
  • +
  • <%= button_to_chip bucket.name, kind: :buckets, object: bucket %>
  • <% end %>
    @@ -79,7 +79,7 @@
  • Tagged
  • <% Current.account.tags.order(:title).each do |tag| %> -
  • <%= button_to_filter tag.title, kind: :tags, object: tag %>
  • +
  • <%= button_to_chip tag.title, kind: :tags, object: tag %>
  • <% end %>
    @@ -88,10 +88,10 @@
  • Assigned to…
  • -
  • <%= button_to_filter "No one", kind: :assignments, object: "unassigned", data: { action: "filter-form#clearCategory", filter_form_name_param: "assignee_ids[]" } %>
  • -
  • <%= button_to_filter "Me", kind: :assignees, object: Current.user, data: { action: "filter-form#clearCategory", filter_form_name_param: "assignments" } %>
  • +
  • <%= button_to_chip "No one", kind: :assignments, object: "unassigned", data: { action: "filter-form#clearCategory", filter_form_name_param: "assignee_ids[]" } %>
  • +
  • <%= button_to_chip "Me", kind: :assignees, object: Current.user, data: { action: "filter-form#clearCategory", filter_form_name_param: "assignments" } %>
  • <% Current.account.users.active.without(Current.user).order(:name).each do |user| %> -
  • <%= button_to_filter user.name, kind: :assignees, object: user, data: { action: "filter-form#clearCategory", filter_form_name_param: "assignments" } %>
  • +
  • <%= button_to_chip user.name, kind: :assignees, object: user, data: { action: "filter-form#clearCategory", filter_form_name_param: "assignments" } %>
  • <% end %>
    @@ -100,9 +100,9 @@
  • Assigned by…
  • -
  • <%= button_to_filter "Me", kind: :assigners, object: Current.user %>
  • +
  • <%= button_to_chip "Me", kind: :assigners, object: Current.user %>
  • <% Current.account.users.active.without(Current.user).order(:name).each do |user| %> -
  • <%= button_to_filter user.name, kind: :assigners, object: user %>
  • +
  • <%= button_to_chip user.name, kind: :assigners, object: user %>
  • <% end %>