4 Commits
Author SHA1 Message Date
ricky ec38414f06 Version Bump 2026-07-29 12:21:42 -04:00
ricky 06b7050d07 Fixed Issues Context Menu 2026-07-29 11:53:41 -04:00
ricky 1425758a53 removed log 2026-07-29 11:37:12 -04:00
ricky a2fff4a5cf Disabled contex menu patch & bumped required version 2026-07-29 11:29:07 -04:00
4 changed files with 26 additions and 34 deletions
+3 -5
View File
@@ -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,6 +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
Rails.application.config.to_prepare do Stopwatch.setup
Stopwatch.setup
end
-1
View File
@@ -2,7 +2,6 @@
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
@@ -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
+23
View File
@@ -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