Added rdoc comments and using the Base class now
This commit is contained in:
+43
-17
@@ -1,29 +1,33 @@
|
||||
class BudgetIssueHook
|
||||
|
||||
# http://snippets.dzone.com/posts/show/1799
|
||||
def self.help
|
||||
Helper.instance
|
||||
end
|
||||
# Hooks to attach to the Redmine Issues. They are attached in init.rb by the
|
||||
# +add_hook+ method
|
||||
class BudgetIssueHook < Redmine::Plugin::Hook::Base
|
||||
|
||||
class Helper
|
||||
include Singleton
|
||||
include ERB::Util
|
||||
include ActionView::Helpers::TagHelper
|
||||
include ActionView::Helpers::FormHelper
|
||||
include ActionView::Helpers::FormTagHelper
|
||||
include ActionView::Helpers::FormOptionsHelper
|
||||
end
|
||||
|
||||
# Renders the Deliverable subject
|
||||
#
|
||||
# Context:
|
||||
# * :issue => Issue being rendered
|
||||
#
|
||||
def self.issue_show(context = { })
|
||||
data = "<td><b>Deliverable :</b></td><td>#{help.html_escape context[:issue].deliverable.subject unless context[:issue].deliverable.nil?}</td>"
|
||||
return "<tr>#{data}<td></td></tr>"
|
||||
end
|
||||
|
||||
# Renders a select tag with all the Deliverables
|
||||
#
|
||||
# Context:
|
||||
# * :form => Edit form
|
||||
# * :project => Current project
|
||||
#
|
||||
def self.issue_edit(context = { })
|
||||
select = context[:form].select :deliverable_id, Deliverable.find_all_by_project_id(context[:project]).collect { |d| [d.subject, d.id] }, :include_blank => true
|
||||
return "<p>#{select}</p>"
|
||||
end
|
||||
|
||||
# Renders a select tag with all the Deliverables for the bulk edit page
|
||||
#
|
||||
# Context:
|
||||
# * :project => Current project
|
||||
#
|
||||
def self.issue_bulk_edit(context = { })
|
||||
select = help.select_tag('deliverable_id',
|
||||
help.content_tag('option', GLoc.l(:label_no_change_option), :value => '') +
|
||||
@@ -33,13 +37,35 @@ class BudgetIssueHook
|
||||
return help.content_tag(:p, "<label>#{GLoc.l(:field_deliverable)}: " + select + "</label>")
|
||||
end
|
||||
|
||||
# Saves the Deliverable assignment to the issue
|
||||
#
|
||||
# Context:
|
||||
# * :issue => Issue being saved
|
||||
# * :params => HTML parameters
|
||||
#
|
||||
def self.issue_bulk_edit_save(context = { })
|
||||
context[:issue].deliverable = Deliverable.find(context[:params][:deliverable_id]) unless context[:params][:deliverable_id].blank?
|
||||
case true
|
||||
|
||||
when context[:params][:deliverable_id].blank?
|
||||
# Do nothing
|
||||
when context[:params][:deliverable_id] == 'none'
|
||||
# Unassign deliverable
|
||||
context[:issue].deliverable = nil
|
||||
else
|
||||
context[:issue].deliverable = Deliverable.find(context[:params][:deliverable_id])
|
||||
end
|
||||
|
||||
return ''
|
||||
end
|
||||
|
||||
# TODO Later: Overwritting the caller is bad juju
|
||||
# Deliverable changes for the journal use the Deliverable subject
|
||||
# instead of the id
|
||||
#
|
||||
# Context:
|
||||
# * :detail => Detail about the journal change
|
||||
#
|
||||
def self.issue_helper_show_details(context = { })
|
||||
# TODO Later: Overwritting the caller is bad juju
|
||||
if context[:detail].prop_key == 'deliverable_id'
|
||||
d = Deliverable.find_by_id(context[:detail].value)
|
||||
context[:detail].value = d.subject unless d.nil? || d.subject.nil?
|
||||
|
||||
+11
-23
@@ -1,31 +1,19 @@
|
||||
class BudgetProjectHook
|
||||
|
||||
# http://snippets.dzone.com/posts/show/1799
|
||||
def self.help
|
||||
Helper.instance
|
||||
end
|
||||
|
||||
class Helper
|
||||
include Singleton
|
||||
include ActionView::Helpers::TagHelper
|
||||
include ActionView::Helpers::UrlHelper
|
||||
include ActionView::Helpers::FormHelper
|
||||
include ActionView::Helpers::FormTagHelper
|
||||
include ActionView::Helpers::FormOptionsHelper
|
||||
include ActionView::Helpers::JavaScriptHelper
|
||||
include ActionView::Helpers::PrototypeHelper
|
||||
|
||||
include ActionController::UrlWriter
|
||||
|
||||
def protect_against_forgery?
|
||||
false
|
||||
end
|
||||
end
|
||||
# Hooks to attach to the Redmine Projects. They are attached in init.rb by the
|
||||
# +add_hook+ method
|
||||
class BudgetProjectHook < Redmine::Plugin::Hook::Base
|
||||
|
||||
# Renders an additional table header to the membership setting
|
||||
#
|
||||
# Context: none
|
||||
def self.member_list_header(context ={ })
|
||||
return "<th>#{GLoc.l(:label_member_rate) }</th>"
|
||||
end
|
||||
|
||||
# Renders an AJAX from to update the member's billing rate
|
||||
#
|
||||
# Context:
|
||||
# * :member => Current Member record
|
||||
#
|
||||
def self.member_list_column_three(context = { })
|
||||
|
||||
# Build a form_remote_tag by hand since this isn't in the scope of a controller
|
||||
|
||||
+5
-1
@@ -1,7 +1,9 @@
|
||||
require_dependency 'issue'
|
||||
|
||||
# Patches Redmine's Issues dynamically. Adds a relationship
|
||||
# Issue +belongs_to+ to Deliverable
|
||||
module IssuePatch
|
||||
def self.included(base)
|
||||
def self.included(base) # :nodoc:
|
||||
base.extend(ClassMethods)
|
||||
|
||||
base.send(:include, InstanceMethods)
|
||||
@@ -36,6 +38,8 @@ module IssuePatch
|
||||
end
|
||||
|
||||
module InstanceMethods
|
||||
# Wraps the association to get the Deliverable subject. Needed for the
|
||||
# Query and filtering
|
||||
def deliverable_subject
|
||||
unless self.deliverable.nil?
|
||||
return self.deliverable.subject
|
||||
|
||||
+8
-5
@@ -1,7 +1,9 @@
|
||||
require_dependency 'query'
|
||||
|
||||
# Patches Redmine's Queries dynamically, adding the Deliverable
|
||||
# to the available query columns
|
||||
module QueryPatch
|
||||
def self.included(base)
|
||||
def self.included(base) # :nodoc:
|
||||
base.extend(ClassMethods)
|
||||
|
||||
base.send(:include, InstanceMethods)
|
||||
@@ -18,20 +20,21 @@ module QueryPatch
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
def hello
|
||||
puts 'hello'
|
||||
end
|
||||
|
||||
|
||||
# Setter for +available_columns+ that isn't provided by the core.
|
||||
def available_columns=(v)
|
||||
self.available_columns = (v)
|
||||
end
|
||||
|
||||
# Method to add a column to the +available_columns+ that isn't provided by the core.
|
||||
def add_available_column(column)
|
||||
self.available_columns << (column)
|
||||
end
|
||||
end
|
||||
|
||||
module InstanceMethods
|
||||
|
||||
# Wrapper around the +available_filters+ to add a new Deliverable filter
|
||||
def budget_available_filters
|
||||
@available_filters = redmine_available_filters
|
||||
|
||||
|
||||
Reference in New Issue
Block a user