mirror of
https://github.com/rickbarrette/stopwatch.git
synced 2026-04-02 01:41:58 -04:00
start/stop tracking: issue context menu entry
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<% if @started_time_entry %>
|
||||
contextMenuHide();
|
||||
window.stopwatch.timerStarted(
|
||||
<%= raw Stopwatch::Timer.new(User.current).to_json %>
|
||||
);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
contextMenuHide();
|
||||
window.stopwatch.updateStartStopLink(
|
||||
'#stopwatch_stop_timer_<%= @issue.id %>',
|
||||
'<%= j Stopwatch::IssueLinks.new(@issue).start_timer %>'
|
||||
|
||||
5
init.rb
5
init.rb
@@ -22,8 +22,9 @@ Redmine::Plugin.register :stopwatch do
|
||||
end
|
||||
|
||||
Rails.configuration.to_prepare do
|
||||
Stopwatch::UserPatch.apply
|
||||
Stopwatch::TimeEntryPatch.apply
|
||||
Stopwatch::ContextMenusControllerPatch.apply
|
||||
Stopwatch::IssuesControllerPatch.apply
|
||||
Stopwatch::TimeEntryPatch.apply
|
||||
Stopwatch::UserPatch.apply
|
||||
end
|
||||
|
||||
|
||||
29
lib/stopwatch/context_menus_controller_patch.rb
Normal file
29
lib/stopwatch/context_menus_controller_patch.rb
Normal file
@@ -0,0 +1,29 @@
|
||||
# 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).stop_timer
|
||||
else
|
||||
link << IssueLinks.new(issue).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
|
||||
|
||||
Reference in New Issue
Block a user