switch to svg icons

This commit is contained in:
Jens Kraemer
2025-06-07 11:41:49 +08:00
parent e40840b974
commit 776c0cd823
5 changed files with 26 additions and 28 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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