mirror of
https://github.com/rickbarrette/stopwatch.git
synced 2026-04-02 09:51:57 -04:00
Redmine 5
This commit is contained in:
15
init.rb
15
init.rb
@@ -1,14 +1,11 @@
|
|||||||
require_dependency 'stopwatch'
|
|
||||||
require 'stopwatch/hooks'
|
|
||||||
|
|
||||||
Redmine::Plugin.register :stopwatch do
|
Redmine::Plugin.register :stopwatch do
|
||||||
name 'Redmine Stopwatch Plugin'
|
name 'Redmine Stopwatch Plugin'
|
||||||
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 '0.2.0'
|
version '1.0.0'
|
||||||
|
|
||||||
requires_redmine version_or_higher: '3.4.0'
|
requires_redmine version_or_higher: '5.0.0'
|
||||||
settings default: {
|
settings default: {
|
||||||
'default_activity' => 'always_ask',
|
'default_activity' => 'always_ask',
|
||||||
}, partial: 'stopwatch/settings'
|
}, partial: 'stopwatch/settings'
|
||||||
@@ -21,10 +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.configuration.to_prepare do
|
Stopwatch.setup
|
||||||
Stopwatch::ContextMenusControllerPatch.apply
|
|
||||||
Stopwatch::IssuesControllerPatch.apply
|
|
||||||
Stopwatch::TimeEntryPatch.apply
|
|
||||||
Stopwatch::UserPatch.apply
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,15 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Stopwatch
|
module Stopwatch
|
||||||
|
def self.setup
|
||||||
|
Stopwatch::ContextMenusControllerPatch.apply
|
||||||
|
Stopwatch::IssuesControllerPatch.apply
|
||||||
|
::TimeEntry.prepend Stopwatch::TimeEntryPatch
|
||||||
|
::User.prepend Stopwatch::UserPatch
|
||||||
|
Stopwatch::Hooks # just load it
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
def self.settings
|
def self.settings
|
||||||
Setting.plugin_stopwatch
|
Setting.plugin_stopwatch
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,13 +1,9 @@
|
|||||||
module Stopwatch
|
module Stopwatch
|
||||||
module TimeEntryPatch
|
module TimeEntryPatch
|
||||||
def self.apply
|
extend ActiveSupport::Concern
|
||||||
TimeEntry.prepend self unless TimeEntry < self
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.prepended(base)
|
prepended do
|
||||||
base.class_eval do
|
before_destroy :stop_timer
|
||||||
before_destroy :stop_timer
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def stop_timer
|
def stop_timer
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
module Stopwatch
|
module Stopwatch
|
||||||
module UserPatch
|
module UserPatch
|
||||||
def self.apply
|
extend ActiveSupport::Concern
|
||||||
User.prepend self unless User < self
|
|
||||||
end
|
|
||||||
|
|
||||||
def timer_running?
|
def timer_running?
|
||||||
Stopwatch::Timer.new(self).running?
|
Stopwatch::Timer.new(self).running?
|
||||||
|
|||||||
Reference in New Issue
Block a user