diff --git a/lib/budget_issue_hook.rb b/lib/budget_issue_hook.rb index 198903c..7aecccf 100644 --- a/lib/budget_issue_hook.rb +++ b/lib/budget_issue_hook.rb @@ -8,8 +8,12 @@ class BudgetIssueHook < Redmine::Plugin::Hook::Base # * :issue => Issue being rendered # def self.issue_show(context = { }) - data = "Deliverable :#{help.html_escape context[:issue].deliverable.subject unless context[:issue].deliverable.nil?}" - return "#{data}" + if context[:project].module_enabled?('budget_module') + data = "Deliverable :#{help.html_escape context[:issue].deliverable.subject unless context[:issue].deliverable.nil?}" + return "#{data}" + else + return '' + end end # Renders a select tag with all the Deliverables @@ -19,8 +23,12 @@ class BudgetIssueHook < Redmine::Plugin::Hook::Base # * :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 "

#{select}

" + if context[:project].module_enabled?('budget_module') + select = context[:form].select :deliverable_id, Deliverable.find_all_by_project_id(context[:project]).collect { |d| [d.subject, d.id] }, :include_blank => true + return "

#{select}

" + else + return '' + end end # 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 # 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)) + if context[:project].module_enabled?('budget_module') + 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, "") + return help.content_tag(:p, "") + else + return '' + end end # Saves the Deliverable assignment to the issue diff --git a/lib/budget_project_hook.rb b/lib/budget_project_hook.rb index 78414e4..a3d4208 100644 --- a/lib/budget_project_hook.rb +++ b/lib/budget_project_hook.rb @@ -6,7 +6,11 @@ class BudgetProjectHook < Redmine::Plugin::Hook::Base # # Context: none def self.member_list_header(context ={ }) - return "#{GLoc.l(:label_member_rate) }" + if context[:project].module_enabled?('budget_module') + return "#{GLoc.l(:label_member_rate) }" + else + return '' + end end # 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 # def self.member_list_column_three(context = { }) - - # 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}, - :onsubmit => help.remote_function(:url => { - :controller => 'members', - :action => 'edit', - :id => context[:member].id, - :host => Setting.host_name - }, - :host => Setting.host_name, - :form => true, - :method => 'post', - :return => 'false' )+ '; return false;') + - 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") + "" - - return help.content_tag(:td, form, :align => 'center' ) - + if context[:project].module_enabled?('budget_module') + # 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}, + :onsubmit => help.remote_function(:url => { + :controller => 'members', + :action => 'edit', + :id => context[:member].id, + :host => Setting.host_name + }, + :host => Setting.host_name, + :form => true, + :method => 'post', + :return => 'false' )+ '; return false;') + + 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") + "" + + return help.content_tag(:td, form, :align => 'center' ) + else + return '' + end end end