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

@@ -2,9 +2,9 @@
<% time_entry = @time_entries.first %> <% time_entry = @time_entries.first %>
<li> <li>
<% if User.current.is_running_timer? time_entry %> <% 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 %> <% 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 %>
</li> </li>
<% end %> <% end %>

View File

@@ -17,11 +17,11 @@
<td class="hours"><%= html_hours(format_hours(entry.hours)) %></td> <td class="hours"><%= html_hours(format_hours(entry.hours)) %></td>
<td class="buttons"> <td class="buttons">
<% if running %> <% 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 %> <% 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 %> <% 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 %>
</td> </td>
</tr> </tr>
<% end -%> <% end -%>

View File

@@ -10,9 +10,9 @@ module Stopwatch
User.current.allowed_to?(:log_time, issue.project) User.current.allowed_to?(:log_time, issue.project)
t = Stopwatch::IssueTimer.new(issue: issue) t = Stopwatch::IssueTimer.new(issue: issue)
if t.running? if t.running?
link << IssueLinks.new(issue).stop_timer link << IssueLinks.new(issue, self).stop_timer
else else
link << IssueLinks.new(issue).start_timer link << IssueLinks.new(issue, self).start_timer
end end
end end
super + content_tag(:li, link.html_safe) super + content_tag(:li, link.html_safe)
@@ -26,4 +26,3 @@ module Stopwatch
end end
end end
end end

View File

@@ -1,26 +1,25 @@
module Stopwatch module Stopwatch
class IssueLinks < Struct.new(:issue) class IssueLinks < Struct.new(:issue, :context)
include ActionView::Helpers::UrlHelper
include Rails.application.routes.url_helpers
def start_timer def start_timer
link_to(I18n.t(:label_stopwatch_start), context.link_to(
start_issue_timer_path(issue), context.sprite_icon(:time, I18n.t(:label_stopwatch_start)),
class: 'icon icon-time stopwatch_issue_timer', context.start_issue_timer_path(issue),
class: 'stopwatch_issue_timer',
data: { issue_id: issue.id }, data: { issue_id: issue.id },
remote: true, remote: true,
method: 'post') method: 'post'
)
end end
def stop_timer def stop_timer
link_to(I18n.t(:label_stopwatch_stop), context.link_to(
stop_issue_timer_path(issue), context.sprite_icon(:time, I18n.t(:label_stopwatch_stop)),
class: 'icon icon-time stopwatch_issue_timer', context.stop_issue_timer_path(issue),
class: 'stopwatch_issue_timer',
data: { issue_id: issue.id }, data: { issue_id: issue.id },
remote: true, remote: true,
method: 'post') method: 'post'
)
end end
# to make route helpers happy # to make route helpers happy

View File

@@ -8,9 +8,9 @@ module Stopwatch
if User.current.allowed_to?(:log_time, issue.project) if User.current.allowed_to?(:log_time, issue.project)
t = Stopwatch::IssueTimer.new(issue: issue) t = Stopwatch::IssueTimer.new(issue: issue)
if t.running? if t.running?
link << IssueLinks.new(issue).stop_timer link << IssueLinks.new(issue, self).stop_timer
else else
link << IssueLinks.new(issue).start_timer link << IssueLinks.new(issue, self).start_timer
end end
end end
link.html_safe + super link.html_safe + super