Don't use hooks if the project doesn't have the module enabled. #1300
This commit is contained in:
1 parent
8295b737a1
commit
ab67d20fcf
2 files changed
+46
-28
No files matched your search
@@ -8,8 +8,12 @@ class BudgetIssueHook < Redmine::Plugin::Hook::Base
|
|||||||
# * :issue => Issue being rendered
|
# * :issue => Issue being rendered
|
||||||
#
|
#
|
||||||
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>"
|
if context[:project].module_enabled?('budget_module')
|
||||||
return "<tr>#{data}<td></td></tr>"
|
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>"
|
||||||
|
else
|
||||||
|
return ''
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Renders a select tag with all the Deliverables
|
# Renders a select tag with all the Deliverables
|
||||||
@@ -19,8 +23,12 @@ class BudgetIssueHook < Redmine::Plugin::Hook::Base
|
|||||||
# * :project => Current project
|
# * :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
|
if context[:project].module_enabled?('budget_module')
|
||||||
return "<p>#{select}</p>"
|
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>"
|
||||||
|
else
|
||||||
|
return ''
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Renders a select tag with all the Deliverables for the bulk edit page
|
# Renders a select tag with all the Deliverables for the bulk edit page
|
||||||
@@ -29,12 +37,16 @@ class BudgetIssueHook < Redmine::Plugin::Hook::Base
|
|||||||
# * :project => Current project
|
# * :project => Current project
|
||||||
#
|
#
|
||||||
def self.issue_bulk_edit(context = { })
|
def self.issue_bulk_edit(context = { })
|
||||||
select = help.select_tag('deliverable_id',
|
if context[:project].module_enabled?('budget_module')
|
||||||
help.content_tag('option', GLoc.l(:label_no_change_option), :value => '') +
|
select = help.select_tag('deliverable_id',
|
||||||
help.content_tag('option', GLoc.l(:label_none), :value => 'none') +
|
help.content_tag('option', GLoc.l(:label_no_change_option), :value => '') +
|
||||||
help.options_from_collection_for_select(Deliverable.find_all_by_project_id(context[:project].id, :id, :subject), :id, :subject))
|
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>")
|
return help.content_tag(:p, "<label>#{GLoc.l(:field_deliverable)}: " + select + "</label>")
|
||||||
|
else
|
||||||
|
return ''
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Saves the Deliverable assignment to the issue
|
# Saves the Deliverable assignment to the issue
|
||||||
|
|||||||
+25
-19
@@ -6,7 +6,11 @@ class BudgetProjectHook < Redmine::Plugin::Hook::Base
|
|||||||
#
|
#
|
||||||
# Context: none
|
# Context: none
|
||||||
def self.member_list_header(context ={ })
|
def self.member_list_header(context ={ })
|
||||||
return "<th>#{GLoc.l(:label_member_rate) }</th>"
|
if context[:project].module_enabled?('budget_module')
|
||||||
|
return "<th>#{GLoc.l(:label_member_rate) }</th>"
|
||||||
|
else
|
||||||
|
return ''
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Renders an AJAX from to update the member's billing rate
|
# Renders an AJAX from to update the member's billing rate
|
||||||
@@ -15,23 +19,25 @@ class BudgetProjectHook < Redmine::Plugin::Hook::Base
|
|||||||
# * :member => Current Member record
|
# * :member => Current Member record
|
||||||
#
|
#
|
||||||
def self.member_list_column_three(context = { })
|
def self.member_list_column_three(context = { })
|
||||||
|
if context[:project].module_enabled?('budget_module')
|
||||||
# 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
|
||||||
form = help.form_tag({:controller => 'members', :action => 'edit', :id => context[:member].id, :host => Setting.host_name},
|
form = help.form_tag({:controller => 'members', :action => 'edit', :id => context[:member].id, :host => Setting.host_name},
|
||||||
:onsubmit => help.remote_function(:url => {
|
:onsubmit => help.remote_function(:url => {
|
||||||
:controller => 'members',
|
:controller => 'members',
|
||||||
:action => 'edit',
|
:action => 'edit',
|
||||||
:id => context[:member].id,
|
:id => context[:member].id,
|
||||||
:host => Setting.host_name
|
:host => Setting.host_name
|
||||||
},
|
},
|
||||||
:host => Setting.host_name,
|
:host => Setting.host_name,
|
||||||
:form => true,
|
:form => true,
|
||||||
:method => 'post',
|
:method => 'post',
|
||||||
:return => 'false' )+ '; return false;') +
|
:return => 'false' )+ '; return false;') +
|
||||||
help.text_field_tag('member[rate]', help.number_with_precision(context[:member].rate, 0), :class => "small") +
|
help.text_field_tag('member[rate]', help.number_with_precision(context[:member].rate, 0), :class => "small") +
|
||||||
help.submit_tag(GLoc.l(:button_change), :class => "small") + "</form>"
|
help.submit_tag(GLoc.l(:button_change), :class => "small") + "</form>"
|
||||||
|
|
||||||
return help.content_tag(:td, form, :align => 'center' )
|
return help.content_tag(:td, form, :align => 'center' )
|
||||||
|
else
|
||||||
|
return ''
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Reference in new issue
Block a user