From 2fe9ea44f63d1ec9970283c00e6ece73b4de4d82 Mon Sep 17 00:00:00 2001 From: Andy Smith Date: Thu, 21 Aug 2025 15:00:17 -0500 Subject: [PATCH] Make hotkey link helper --- app/helpers/filters_helper.rb | 8 +++++ app/views/events/filter/_header.html.erb | 41 ++++-------------------- 2 files changed, 14 insertions(+), 35 deletions(-) diff --git a/app/helpers/filters_helper.rb b/app/helpers/filters_helper.rb index 08fb73b16..fe67602d8 100644 --- a/app/helpers/filters_helper.rb +++ b/app/helpers/filters_helper.rb @@ -44,4 +44,12 @@ module FiltersHelper filter.stages.any? || filter.terms.any? || filter.card_ids&.any? || filter.assignment_status.unassigned? || !filter.indexed_by.latest? end + + def hotkey_link(title, path, key, icon) + link_to path, class: "popup__group btn borderless", id: "filter-hotkey-#{key}", role: "listitem", data: { filter_target: "item", navigable_list_target: "item", controller: "hotkey", action: "keydown.#{key}@document->hotkey#click keydown.shift+#{key}@document->hotkey#click"} do + concat icon_tag(icon) + concat tag.span(title.html_safe) + concat tag.kbd(key) + end + end end diff --git a/app/views/events/filter/_header.html.erb b/app/views/events/filter/_header.html.erb index e0d6c9b7f..3c85aaa72 100644 --- a/app/views/events/filter/_header.html.erb +++ b/app/views/events/filter/_header.html.erb @@ -1,37 +1,8 @@
- <%= link_to root_path, class: "popup__group btn borderless", id: "filter-hotkey-home", data: { filter_target: "item", navigable_list_target: "item", controller: "hotkey", action: "keydown.1@document->hotkey#click keydown.shift+1@document->hotkey#click" } do %> - <%= icon_tag "home" %> - Home - 1 - <% end %> - - <%= link_to cards_path(assignee_ids: [Current.user.id]), class: "popup__group btn borderless", id: "filter-hotkey-assigned-to-me", data: { filter_target: "item", navigable_list_target: "item", controller: "hotkey", action: "keydown.2@document->hotkey#click keydown.shift+2@document->hotkey#click" } do %> - <%= icon_tag "clipboard" %> - Assigned to me - 2 - <% end %> - - <%= link_to cards_path(creator_ids: [Current.user.id]), class: "popup__group btn borderless", id: "filter-hotkey-added-by-me", data: { filter_target: "item", navigable_list_target: "item", controller: "hotkey", action: "keydown.3@document->hotkey#click keydown.shift+3@document->hotkey#click" } do %> - <%= icon_tag "person-add" %> - Added by me - 3 - <% end %> - - <%= link_to new_collection_path, class: "popup__group btn borderless", id: "filter-hotkey-new-collection", data: { filter_target: "item", navigable_list_target: "item", controller: "hotkey", action: "keydown.4@document->hotkey#click keydown.shift+4@document->hotkey#click" } do %> - <%= icon_tag "collection-add" %> - New Collection - 4 - <% end %> - - <%= link_to notifications_path, class: "popup__group btn borderless", id: "filter-hotkey-notifications", data: { filter_target: "item", navigable_list_target: "item", controller: "hotkey", action: "keydown.5@document->hotkey#click keydown.shift+5@document->hotkey#click" } do %> - <%= icon_tag "bell" %> - Notifications - 5 - <% end %> - - <%= link_to account_settings_path, class: "popup__group btn borderless", id: "filter-hotkey-account-settings", data: { filter_target: "item", navigable_list_target: "item", controller: "hotkey", action: "keydown.6@document->hotkey#click keydown.shift+6@document->hotkey#click" } do %> - <%= icon_tag "settings" %> - Account Settings - 6 - <% end %> + <%= hotkey_link "Home", root_path, 1, "home" %> + <%= hotkey_link "Assigned to me", cards_path(assignee_ids: [Current.user.id]), 2, "clipboard" %> + <%= hotkey_link "Added by me", cards_path(creator_ids: [Current.user.id]), 3, "person-add" %> + <%= hotkey_link "New Collection", new_collection_path, 4, "collection-add" %> + <%= hotkey_link "Notifications", notifications_path, 5, "bell" %> + <%= hotkey_link "Account #{tag.span("Settings", class: "visually-hidden")}", account_settings_path, 6, "settings" %>