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