Registering hooks for the issues. #1147

This commit is contained in:
Eric Davis
2008-05-27 16:47:00 -07:00
parent 5af52d5c15
commit 6835ec59dc
2 changed files with 45 additions and 2 deletions

35
lib/budget_issue_hook.rb Normal file
View File

@@ -0,0 +1,35 @@
class BudgetIssueHook
# http://snippets.dzone.com/posts/show/1799
def self.help
Helper.instance
end
class Helper
include Singleton
include ActionView::Helpers::TagHelper
include ActionView::Helpers::FormHelper
include ActionView::Helpers::FormTagHelper
include ActionView::Helpers::FormOptionsHelper
end
def self.issue_show(context = { })
# TODO: Escape
data = "<td><b>Deliverable :</b></td><td>#{context[:issue].deliverable.subject unless context[:issue].deliverable.nil?}</td>"
return "<tr>#{data}<td></td></tr>"
end
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
def self.issue_bulk_edit(context = { })
select = help.select_tag('deliverable_id',
help.content_tag('option', GLoc.l(:label_no_change_option), :value => '') +
help.content_tag('option', GLoc.l(:label_none), :value => 'none') +
help.options_from_collection_for_select(Deliverable.find_all_by_project_id(context[:project].id, :id, :subject), :id, :subject))
return help.content_tag(:p, "<label>#{GLoc.l(:field_deliverable)}: " + select + "</label>")
end
end