mirror of
https://github.com/rickbarrette/stopwatch.git
synced 2026-11-18 03:50:36 -05:00
Readable Start/Stop colours, exact selectors, fork notes
- Colour-coded Start/Stop links use #2e7d32 / #c62828, which meet the 4.5:1 text contrast ratio on white and on the mobile backgrounds (limegreen was ~2:1, red ~4:1) - Selectors match the end of the link address (/timer/start, /timer/stop), exactly what stopwatch.js rewrites, instead of any address containing "start"/"stop" - highlighted_links setting uses a string key like default_activity, has a default, and the form sends 0 when unticked - Context-menu hook uses the calling view (hook_caller) instead of building a new view context - README: "Changes in this fork" section (GPLv3 modification notice) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BiwYMjhoQvL7XsKKfRz4pM
This commit is contained in:
6 files changed
+34
-15
No files matched your search
@@ -18,6 +18,17 @@ Minimal plugin that aims to make tracking your time with Redmine much easier.
|
||||
|
||||

|
||||
|
||||
## Changes in this fork
|
||||
|
||||
This is a fork of [jkraemer/stopwatch](https://github.com/jkraemer/stopwatch), modified by
|
||||
Rick Barrette (2026):
|
||||
|
||||
- **Redmine 7:** requires Redmine 7.0+. The issue context-menu Start/Stop entry now uses Redmine 7's
|
||||
`view_issues_context_menu_start` hook instead of patching `ContextMenusController` (July 2026).
|
||||
- **Colour-coded Start/Stop:** an optional setting ("Color-code Start/Stop") shows the issue Start
|
||||
link in green and Stop in red, with tinted buttons on mobile (March 2026; colours adjusted for
|
||||
readable contrast in October 2026).
|
||||
|
||||
## Installation
|
||||
|
||||
Add the plugin to your Redmine installation's `plugins` folder, run `bundle
|
||||
|
||||
@@ -5,5 +5,6 @@
|
||||
|
||||
<p>
|
||||
<label for="settings_highlighted_links"><%= t '.label_highlighted_links' %> </label>
|
||||
<%= check_box_tag 'settings[highlighted_links]', 1, Setting.plugin_stopwatch[:highlighted_links] %>
|
||||
<%= hidden_field_tag 'settings[highlighted_links]', '0', id: nil %>
|
||||
<%= check_box_tag 'settings[highlighted_links]', '1', Stopwatch.highlighted_links, id: 'settings_highlighted_links' %>
|
||||
</p>
|
||||
@@ -1,22 +1,27 @@
|
||||
a.stopwatch_issue_timer[href*="stop"] {
|
||||
color: red;
|
||||
/* Colour-codes the issue Start/Stop tracking links (enabled in the plugin settings).
|
||||
Matches the end of the link address, which stopwatch.js rewrites between ".../timer/start" and
|
||||
".../timer/stop" when a timer starts or stops, so the colour always follows the link.
|
||||
Colours meet the 4.5:1 contrast ratio for readable text, on white and on the mobile backgrounds. */
|
||||
|
||||
a.stopwatch_issue_timer[href$="/timer/stop"] {
|
||||
color: #c62828;
|
||||
}
|
||||
|
||||
a.stopwatch_issue_timer[href*="start"] {
|
||||
color: limegreen;
|
||||
a.stopwatch_issue_timer[href$="/timer/start"] {
|
||||
color: #2e7d32;
|
||||
}
|
||||
|
||||
/* Mobile only */
|
||||
@media (max-width: 899px) {
|
||||
a.stopwatch_issue_timer[href*="stop"] {
|
||||
color: red;
|
||||
a.stopwatch_issue_timer[href$="/timer/stop"] {
|
||||
color: #c62828;
|
||||
background-color: #ffe5e5;
|
||||
border: 1px solid red;
|
||||
border: 1px solid #c62828;
|
||||
}
|
||||
|
||||
a.stopwatch_issue_timer[href*="start"] {
|
||||
color: limegreen;
|
||||
a.stopwatch_issue_timer[href$="/timer/start"] {
|
||||
color: #2e7d32;
|
||||
background-color: #eaffea;
|
||||
border: 1px solid limegreen;
|
||||
border: 1px solid #2e7d32;
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ Redmine::Plugin.register :stopwatch do
|
||||
requires_redmine version_or_higher: '7.0.0'
|
||||
settings default: {
|
||||
'default_activity' => 'always_ask',
|
||||
'highlighted_links' => '0',
|
||||
}, partial: 'stopwatch/settings'
|
||||
|
||||
menu :account_menu, :stopwatch,
|
||||
|
||||
+2
-1
@@ -41,7 +41,8 @@ module Stopwatch
|
||||
end
|
||||
end
|
||||
|
||||
# Colour-code the issue Start/Stop links (green to start, red to stop)
|
||||
def self.highlighted_links
|
||||
settings[:highlighted_links]
|
||||
settings['highlighted_links'].to_s == '1'
|
||||
end
|
||||
end
|
||||
@@ -17,8 +17,8 @@ module Stopwatch
|
||||
issue = issues.first
|
||||
return '' unless User.current.allowed_to?(:log_time, issue.project)
|
||||
|
||||
# 'controller' in this context gives access to view helper context
|
||||
view = context[:controller].view_context
|
||||
# hook_caller is the view rendering the context menu
|
||||
view = context[:hook_caller]
|
||||
timer = Stopwatch::IssueTimer.new(issue: issue)
|
||||
|
||||
link = if timer.running?
|
||||
@@ -27,7 +27,7 @@ module Stopwatch
|
||||
IssueLinks.new(issue, view).start_timer
|
||||
end
|
||||
|
||||
view.content_tag(:li, link.html_safe)
|
||||
view.content_tag(:li, link)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user