From 776c0cd823384fe514e6b4da47f19ce547bdc524 Mon Sep 17 00:00:00 2001 From: Jens Kraemer Date: Sat, 7 Jun 2025 11:41:49 +0800 Subject: [PATCH] switch to svg icons --- .../_time_entries_context_menu_start.html.erb | 4 +-- .../stopwatch_timers/_entries_list.html.erb | 6 ++-- .../context_menus_controller_patch.rb | 5 ++- lib/stopwatch/issue_links.rb | 35 +++++++++---------- lib/stopwatch/issues_controller_patch.rb | 4 +-- 5 files changed, 26 insertions(+), 28 deletions(-) diff --git a/app/views/stopwatch/hooks/_time_entries_context_menu_start.html.erb b/app/views/stopwatch/hooks/_time_entries_context_menu_start.html.erb index 9d972bb..8868d84 100644 --- a/app/views/stopwatch/hooks/_time_entries_context_menu_start.html.erb +++ b/app/views/stopwatch/hooks/_time_entries_context_menu_start.html.erb @@ -2,9 +2,9 @@ <% time_entry = @time_entries.first %>
  • <% if User.current.is_running_timer? time_entry %> - <%= context_menu_link l(:label_stopwatch_stop), stop_stopwatch_timer_path(time_entry, context: '1'), class: 'icon icon-time', remote: true, method: :put %> + <%= context_menu_link sprite_icon(:time, l(:label_stopwatch_stop)), stop_stopwatch_timer_path(time_entry, context: '1'), class: 'icon', remote: true, method: :put %> <% else %> - <%= context_menu_link l(:label_stopwatch_start), start_stopwatch_timer_path(time_entry, context: '1'), class: 'icon icon-time', remote: true, method: :put %> + <%= context_menu_link sprite_icon(:time, l(:label_stopwatch_start)), start_stopwatch_timer_path(time_entry, context: '1'), class: 'icon', remote: true, method: :put %> <% end %>
  • <% end %> diff --git a/app/views/stopwatch_timers/_entries_list.html.erb b/app/views/stopwatch_timers/_entries_list.html.erb index 26481bf..4d5eb19 100644 --- a/app/views/stopwatch_timers/_entries_list.html.erb +++ b/app/views/stopwatch_timers/_entries_list.html.erb @@ -17,11 +17,11 @@ <%= html_hours(format_hours(entry.hours)) %> <% if running %> - <%= link_to t(:label_stopwatch_stop), stop_stopwatch_timer_path(entry), remote: true, class: "icon-only icon-time", method: :put %> + <%= link_to sprite_icon(:time, t(:label_stopwatch_stop)), stop_stopwatch_timer_path(entry), remote: true, class: "icon-only", method: :put %> <% else %> - <%= link_to t(:label_stopwatch_start), start_stopwatch_timer_path(entry), remote: true, class: "icon-only icon-time", method: :put %> + <%= link_to sprite_icon(:time, t(:label_stopwatch_start)), start_stopwatch_timer_path(entry), remote: true, class: "icon-only", method: :put %> <% end %> - <%= link_to l(:button_edit), edit_stopwatch_timer_path(entry), remote: true, class: "icon-only icon-edit" if entry.editable_by? User.current %> + <%= link_to sprite_icon(:edit, l(:button_edit)), edit_stopwatch_timer_path(entry), remote: true, class: "icon-only" if entry.editable_by? User.current %> <% end -%> diff --git a/lib/stopwatch/context_menus_controller_patch.rb b/lib/stopwatch/context_menus_controller_patch.rb index 575e6c7..49327b1 100644 --- a/lib/stopwatch/context_menus_controller_patch.rb +++ b/lib/stopwatch/context_menus_controller_patch.rb @@ -10,9 +10,9 @@ module Stopwatch User.current.allowed_to?(:log_time, issue.project) t = Stopwatch::IssueTimer.new(issue: issue) if t.running? - link << IssueLinks.new(issue).stop_timer + link << IssueLinks.new(issue, self).stop_timer else - link << IssueLinks.new(issue).start_timer + link << IssueLinks.new(issue, self).start_timer end end super + content_tag(:li, link.html_safe) @@ -26,4 +26,3 @@ module Stopwatch end end end - diff --git a/lib/stopwatch/issue_links.rb b/lib/stopwatch/issue_links.rb index 4d6a834..88b0fde 100644 --- a/lib/stopwatch/issue_links.rb +++ b/lib/stopwatch/issue_links.rb @@ -1,26 +1,25 @@ module Stopwatch - class IssueLinks < Struct.new(:issue) - include ActionView::Helpers::UrlHelper - include Rails.application.routes.url_helpers - - + class IssueLinks < Struct.new(:issue, :context) def start_timer - link_to(I18n.t(:label_stopwatch_start), - start_issue_timer_path(issue), - class: 'icon icon-time stopwatch_issue_timer', - data: { issue_id: issue.id }, - remote: true, - method: 'post') + context.link_to( + context.sprite_icon(:time, I18n.t(:label_stopwatch_start)), + context.start_issue_timer_path(issue), + class: 'stopwatch_issue_timer', + data: { issue_id: issue.id }, + remote: true, + method: 'post' + ) end def stop_timer - link_to(I18n.t(:label_stopwatch_stop), - stop_issue_timer_path(issue), - class: 'icon icon-time stopwatch_issue_timer', - data: { issue_id: issue.id }, - remote: true, - method: 'post') - + context.link_to( + context.sprite_icon(:time, I18n.t(:label_stopwatch_stop)), + context.stop_issue_timer_path(issue), + class: 'stopwatch_issue_timer', + data: { issue_id: issue.id }, + remote: true, + method: 'post' + ) end # to make route helpers happy diff --git a/lib/stopwatch/issues_controller_patch.rb b/lib/stopwatch/issues_controller_patch.rb index 1f404ff..02d9fb4 100644 --- a/lib/stopwatch/issues_controller_patch.rb +++ b/lib/stopwatch/issues_controller_patch.rb @@ -8,9 +8,9 @@ module Stopwatch if User.current.allowed_to?(:log_time, issue.project) t = Stopwatch::IssueTimer.new(issue: issue) if t.running? - link << IssueLinks.new(issue).stop_timer + link << IssueLinks.new(issue, self).stop_timer else - link << IssueLinks.new(issue).start_timer + link << IssueLinks.new(issue, self).start_timer end end link.html_safe + super