mirror of
https://github.com/rickbarrette/stopwatch.git
synced 2026-08-19 06:40:43 -04:00
Compare commits
4
Commits
e4846bf4ac
...
ec38414f06
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ec38414f06 | ||
|
|
06b7050d07 | ||
|
|
1425758a53 | ||
|
|
a2fff4a5cf |
@@ -3,9 +3,9 @@ Redmine::Plugin.register :stopwatch do
|
||||
author 'Jens Krämer'
|
||||
author_url 'https://jkraemer.net/'
|
||||
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: {
|
||||
'default_activity' => 'always_ask',
|
||||
}, 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) }
|
||||
end
|
||||
|
||||
Rails.application.config.to_prepare do
|
||||
Stopwatch.setup
|
||||
end
|
||||
Stopwatch.setup
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
module Stopwatch
|
||||
def self.setup
|
||||
Stopwatch::ContextMenusControllerPatch.apply
|
||||
Stopwatch::IssuesControllerPatch.apply
|
||||
::TimeEntry.prepend Stopwatch::TimeEntryPatch
|
||||
::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
|
||||
@@ -6,5 +6,28 @@ module Stopwatch
|
||||
partial: 'stopwatch/hooks/layouts_base_body_bottom'
|
||||
render_on :view_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
|
||||
|
||||
Reference in New Issue
Block a user