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?
|
||||
|
||||
Reference in New Issue
Block a user