mirror of
https://github.com/rickbarrette/redmine_qbo_vehicles.git
synced 2026-04-02 07:01:59 -04:00
Updated patches and hooks
This commit is contained in:
8
init.rb
8
init.rb
@@ -41,10 +41,4 @@ Redmine::Plugin.register :redmine_qbo_vehicles do
|
||||
|
||||
end
|
||||
|
||||
# Dynamically load all Hooks & Patches recursively
|
||||
base_dir = File.join(File.dirname(__FILE__), 'lib')
|
||||
|
||||
# '**' looks inside subdirectories, '*.rb' matches Ruby files
|
||||
Dir.glob(File.join(base_dir, '**', '*.rb')).sort.each do |file|
|
||||
require file
|
||||
end
|
||||
RedmineQboVehicles.setup
|
||||
23
lib/redmine_qbo_vehicles.rb
Normal file
23
lib/redmine_qbo_vehicles.rb
Normal file
@@ -0,0 +1,23 @@
|
||||
#The MIT License (MIT)
|
||||
#
|
||||
#Copyright (c) 2026 rick barrette
|
||||
#
|
||||
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
#
|
||||
#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
#
|
||||
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
module RedmineQboVehicles
|
||||
def self.setup
|
||||
Issue.prepend Vehicles::Patches::IssuePatch
|
||||
Customer.prepend Vehicles::Patches::CustomerPatch
|
||||
|
||||
Vehicles::Hooks::CustomerShowHookListener
|
||||
Vehicles::Hooks::InvoiceHookListener
|
||||
Vehicles::Hooks::IssuesFormHookListener
|
||||
Vehicles::Hooks::IssuesShowHookListener
|
||||
Vehicles::Hooks::PdfHookListener
|
||||
Vehicles::Hooks::ViewHookListener
|
||||
end
|
||||
end
|
||||
@@ -14,16 +14,12 @@ module Vehicles
|
||||
# Patches Redmine QBO Customer dynamically.
|
||||
# Adds a relationship for vehicle ownership by customers
|
||||
module CustomerPatch
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
ActiveSupport.on_load(:active_record) do
|
||||
|
||||
Customer.class_eval do
|
||||
has_many :vehicles
|
||||
end
|
||||
|
||||
prepended do
|
||||
has_many :vehicles
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
@@ -8,23 +8,18 @@
|
||||
#
|
||||
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
require_dependency 'issue'
|
||||
|
||||
module Vehicles
|
||||
module Patches
|
||||
|
||||
# Patches Redmine's Issues dynamically.
|
||||
# Adds a relationship for attahcing a vehilce to an issue
|
||||
module IssuePatch
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
ActiveSupport.on_load(:active_record) do
|
||||
|
||||
Issue.class_eval do
|
||||
belongs_to :vehicle
|
||||
end
|
||||
|
||||
prepended do
|
||||
belongs_to :vehicle
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user