diff --git a/lib/budget_issue_hook.rb b/lib/budget_issue_hook.rb index 1caed72..198903c 100644 --- a/lib/budget_issue_hook.rb +++ b/lib/budget_issue_hook.rb @@ -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 = "
#{select}
" 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, "") 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? diff --git a/lib/budget_project_hook.rb b/lib/budget_project_hook.rb index 02f8d63..7507f48 100644 --- a/lib/budget_project_hook.rb +++ b/lib/budget_project_hook.rb @@ -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 "