diff --git a/app/helpers/accounts_helper.rb b/app/helpers/accounts_helper.rb index 99ef891ce..302902f39 100644 --- a/app/helpers/accounts_helper.rb +++ b/app/helpers/accounts_helper.rb @@ -1,4 +1,6 @@ module AccountsHelper + ACTIVITY_HIGHLIGHT_MARKUP = '\1'.freeze + def summary_card(title:, &block) content = capture(&block) render "accounts/summary_card", title: title, content: content @@ -8,4 +10,12 @@ module AccountsHelper # Always use the account sync path, which handles syncing all providers sync_account_path(account) end + + def highlight_activity_entry_name(name, query = params.dig(:q, :search)) + search = query.to_s.strip + return name if search.blank? + + escaped_name = ERB::Util.html_escape(name.to_s) + highlight(escaped_name, search, highlighter: ACTIVITY_HIGHLIGHT_MARKUP, sanitize: false) + end end diff --git a/app/views/trades/_trade.html.erb b/app/views/trades/_trade.html.erb index 04b67e645..a614b0251 100644 --- a/app/views/trades/_trade.html.erb +++ b/app/views/trades/_trade.html.erb @@ -32,10 +32,10 @@
- <%= link_to entry.name, + <%= link_to(highlight_activity_entry_name(entry.name), entry_path(entry), data: { turbo_frame: "drawer", turbo_prefetch: false }, - class: "hover:underline" %> + class: "hover:underline") %>
<% end %> diff --git a/app/views/transactions/_split_parent_row.html.erb b/app/views/transactions/_split_parent_row.html.erb index 99bf6a086..df864569b 100644 --- a/app/views/transactions/_split_parent_row.html.erb +++ b/app/views/transactions/_split_parent_row.html.erb @@ -29,10 +29,10 @@
- <%= link_to entry.name, + <%= link_to(highlight_activity_entry_name(entry.name), entry_path(entry), data: { turbo_frame: "drawer", turbo_prefetch: false }, - class: "hover:underline" %> + class: "hover:underline") %>
diff --git a/app/views/transactions/_transaction.html.erb b/app/views/transactions/_transaction.html.erb index 551c56138..61a584982 100644 --- a/app/views/transactions/_transaction.html.erb +++ b/app/views/transactions/_transaction.html.erb @@ -59,7 +59,7 @@
<% if transaction.transfer? %> <%= link_to( - entry.name, + highlight_activity_entry_name(entry.name), transaction.transfer.present? ? transfer_path(transaction.transfer) : entry_path(entry), data: { turbo_frame: "drawer", @@ -69,7 +69,7 @@ ) %> <% else %> <%= link_to( - entry.name, + highlight_activity_entry_name(entry.name), entry_path(entry), data: { turbo_frame: "drawer", diff --git a/app/views/valuations/_valuation.html.erb b/app/views/valuations/_valuation.html.erb index e377eda0f..d19a78f5d 100644 --- a/app/views/valuations/_valuation.html.erb +++ b/app/views/valuations/_valuation.html.erb @@ -17,10 +17,10 @@ <%= render DS::FilledIcon.new(icon: icon, size: "md", hex_color: color, rounded: true) %>
- <%= link_to entry.name, + <%= link_to(highlight_activity_entry_name(entry.name), entry_path(entry), data: { turbo_frame: "drawer", turbo_prefetch: false }, - class: "hover:underline" %> + class: "hover:underline") %>