mirror of
https://github.com/rickbarrette/stopwatch.git
synced 2026-08-18 22:30:44 -04:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ec38414f06 | ||
|
|
06b7050d07 | ||
|
|
1425758a53 | ||
|
|
a2fff4a5cf | ||
|
|
e4846bf4ac | ||
|
|
60dfa7ae4a | ||
|
|
490fbd476d | ||
|
|
527f72f93b |
@@ -14,11 +14,10 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
redmine:
|
redmine:
|
||||||
- '5.0'
|
- '6.0'
|
||||||
- '5.1'
|
- '6.1'
|
||||||
ruby:
|
ruby:
|
||||||
- '3.0'
|
- '3.3'
|
||||||
- '3.1'
|
|
||||||
database:
|
database:
|
||||||
- postgresql
|
- postgresql
|
||||||
- mysql
|
- mysql
|
||||||
|
|||||||
@@ -2,3 +2,8 @@
|
|||||||
<label for="settings_default_activity"><%= t '.label_default_activity' %> </label>
|
<label for="settings_default_activity"><%= t '.label_default_activity' %> </label>
|
||||||
<%= select_tag 'settings[default_activity]', options_from_collection_for_select( [['always_ask', t('.label_always_ask')], ['system', t('.label_system')]] + TimeEntryActivity.system.active.to_a.pluck(:id, :name), :first, :last, Stopwatch.settings['default_activity'] ) %>
|
<%= select_tag 'settings[default_activity]', options_from_collection_for_select( [['always_ask', t('.label_always_ask')], ['system', t('.label_system')]] + TimeEntryActivity.system.active.to_a.pluck(:id, :name), :first, :last, Stopwatch.settings['default_activity'] ) %>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<label for="settings_highlighted_links"><%= t '.label_highlighted_links' %> </label>
|
||||||
|
<%= check_box_tag 'settings[highlighted_links]', 1, Setting.plugin_stopwatch[:highlighted_links] %>
|
||||||
|
</p>
|
||||||
@@ -1,2 +1,3 @@
|
|||||||
<%= javascript_include_tag "stopwatch", plugin: "stopwatch" %>
|
<%= javascript_include_tag "stopwatch", plugin: "stopwatch" %>
|
||||||
<%= stylesheet_link_tag "stopwatch", plugin: "stopwatch" %>
|
<%= stylesheet_link_tag "stopwatch", plugin: "stopwatch" %>
|
||||||
|
<%= stylesheet_link_tag "highlighted_links", plugin: "stopwatch" if Stopwatch.highlighted_links %>
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
a.stopwatch_issue_timer[href*="stop"] {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
a.stopwatch_issue_timer[href*="start"] {
|
||||||
|
color: limegreen;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Mobile only */
|
||||||
|
@media (max-width: 899px) {
|
||||||
|
a.stopwatch_issue_timer[href*="stop"] {
|
||||||
|
color: red;
|
||||||
|
background-color: #ffe5e5;
|
||||||
|
border: 1px solid red;
|
||||||
|
}
|
||||||
|
|
||||||
|
a.stopwatch_issue_timer[href*="start"] {
|
||||||
|
color: limegreen;
|
||||||
|
background-color: #eaffea;
|
||||||
|
border: 1px solid limegreen;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
tr.time-entry.running td.hours {
|
tr.time-entry.running td.hours {
|
||||||
color: red;
|
color: red;
|
||||||
}
|
}
|
||||||
@@ -5,6 +5,7 @@ en:
|
|||||||
settings:
|
settings:
|
||||||
label_always_ask: 'Always ask'
|
label_always_ask: 'Always ask'
|
||||||
label_default_activity: 'Default activity for "Start tracking"'
|
label_default_activity: 'Default activity for "Start tracking"'
|
||||||
|
label_highlighted_links: "Color-code Start/Stop"
|
||||||
label_system: 'Use system default'
|
label_system: 'Use system default'
|
||||||
stopwatch_timers:
|
stopwatch_timers:
|
||||||
entries_list:
|
entries_list:
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ Redmine::Plugin.register :stopwatch do
|
|||||||
author 'Jens Krämer'
|
author 'Jens Krämer'
|
||||||
author_url 'https://jkraemer.net/'
|
author_url 'https://jkraemer.net/'
|
||||||
description "Start/stop timer and quick access to today's time bookings for Redmine"
|
description "Start/stop timer and quick access to today's time bookings for Redmine"
|
||||||
version '1.1.0'
|
version '2026.7.0'
|
||||||
|
|
||||||
requires_redmine version_or_higher: '6.0.0'
|
requires_redmine version_or_higher: '7.0.0'
|
||||||
settings default: {
|
settings default: {
|
||||||
'default_activity' => 'always_ask',
|
'default_activity' => 'always_ask',
|
||||||
}, partial: 'stopwatch/settings'
|
}, partial: 'stopwatch/settings'
|
||||||
@@ -18,4 +18,4 @@ Redmine::Plugin.register :stopwatch do
|
|||||||
if: ->(*_){ User.current.logged? and User.current.allowed_to?(:log_time, nil, global: true) }
|
if: ->(*_){ User.current.logged? and User.current.allowed_to?(:log_time, nil, global: true) }
|
||||||
end
|
end
|
||||||
|
|
||||||
Stopwatch.setup
|
Stopwatch.setup
|
||||||
+4
-2
@@ -2,14 +2,12 @@
|
|||||||
|
|
||||||
module Stopwatch
|
module Stopwatch
|
||||||
def self.setup
|
def self.setup
|
||||||
Stopwatch::ContextMenusControllerPatch.apply
|
|
||||||
Stopwatch::IssuesControllerPatch.apply
|
Stopwatch::IssuesControllerPatch.apply
|
||||||
::TimeEntry.prepend Stopwatch::TimeEntryPatch
|
::TimeEntry.prepend Stopwatch::TimeEntryPatch
|
||||||
::User.prepend Stopwatch::UserPatch
|
::User.prepend Stopwatch::UserPatch
|
||||||
Stopwatch::Hooks # just load it
|
Stopwatch::Hooks # just load it
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def self.settings
|
def self.settings
|
||||||
Setting.plugin_stopwatch
|
Setting.plugin_stopwatch
|
||||||
end
|
end
|
||||||
@@ -42,4 +40,8 @@ module Stopwatch
|
|||||||
return activities.detect{ |a| a == default || a.parent == default }
|
return activities.detect{ |a| a == default || a.parent == default }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.highlighted_links
|
||||||
|
settings[:highlighted_links]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
module Stopwatch
|
|
||||||
module ContextMenusControllerPatch
|
|
||||||
module Helper
|
|
||||||
def watcher_link(objects, user)
|
|
||||||
link = +''
|
|
||||||
if params[:action] == 'issues' and
|
|
||||||
objects.one? and (issue = objects[0]).is_a?(Issue) and
|
|
||||||
User.current.allowed_to?(:log_time, issue.project)
|
|
||||||
t = Stopwatch::IssueTimer.new(issue: issue)
|
|
||||||
if t.running?
|
|
||||||
link << IssueLinks.new(issue, self).stop_timer
|
|
||||||
else
|
|
||||||
link << IssueLinks.new(issue, self).start_timer
|
|
||||||
end
|
|
||||||
end
|
|
||||||
super + content_tag(:li, link.html_safe)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.apply
|
|
||||||
ContextMenusController.class_eval do
|
|
||||||
helper Helper
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -6,5 +6,28 @@ module Stopwatch
|
|||||||
partial: 'stopwatch/hooks/layouts_base_body_bottom'
|
partial: 'stopwatch/hooks/layouts_base_body_bottom'
|
||||||
render_on :view_time_entries_context_menu_start,
|
render_on :view_time_entries_context_menu_start,
|
||||||
partial: 'stopwatch/hooks/time_entries_context_menu_start'
|
partial: 'stopwatch/hooks/time_entries_context_menu_start'
|
||||||
|
|
||||||
|
# This hook is natively provided by Redmine 7's issues context menu view
|
||||||
|
def view_issues_context_menu_start(context = {})
|
||||||
|
issues = context[:issues]
|
||||||
|
|
||||||
|
# We only append our element if exactly one issue is highlighted
|
||||||
|
return '' unless issues&.one?
|
||||||
|
|
||||||
|
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
|
||||||
|
timer = Stopwatch::IssueTimer.new(issue: issue)
|
||||||
|
|
||||||
|
link = if timer.running?
|
||||||
|
IssueLinks.new(issue, view).stop_timer
|
||||||
|
else
|
||||||
|
IssueLinks.new(issue, view).start_timer
|
||||||
|
end
|
||||||
|
|
||||||
|
view.content_tag(:li, link.html_safe)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user