public
Description: Budget is a plugin to manage the set of deliverables for each project, automatically calculating key performance indicators.
Homepage: https://projects.littlestreamsoftware.com/projects/show/redmine-budget
Clone URL: git://github.com/edavis10/redmine-budget-plugin.git
redmine-budget-plugin / lib / budget_project_hook.rb
100644 52 lines (47 sloc) 2.314 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Hooks to attach to the Redmine Projects.
class BudgetProjectHook < Redmine::Hook::ViewListener
 
  def protect_against_forgery?
    false
  end
  
  # Renders an additional table header to the membership setting
  #
  # Context:
  # * :project => Current project
  #
  def view_projects_settings_members_table_header(context ={ })
    if context[:project].module_enabled?('budget_module')
      return "<th>#{GLoc.l(:label_member_rate) }</th>"
    else
      return ''
    end
  end
  
  # Renders an AJAX from to update the member's billing rate
  #
  # Context:
  # * :project => Current project
  # * :member => Current Member record
  #
  def view_projects_settings_members_table_row(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
      form = form_tag({:controller => 'members', :action => 'edit', :id => context[:member].id, :protocol => Setting.protocol, :host => Setting.host_name},
                           :onsubmit => remote_function(:url => {
                                                               :controller => 'members',
                                                               :action => 'edit',
                                                               :id => context[:member].id,
                                                               :protocol => Setting.protocol,
                                                               :host => Setting.host_name
                                                             },
                                                             :host => Setting.host_name,
                                                             :protocol => Setting.protocol,
                                                             :form => true,
                                                             :method => 'post',
                                                             :return => 'false' )+ '; return false;') +
        text_field_tag('member[rate]', number_with_precision(context[:member].rate, 0), :class => "small") +
        submit_tag(GLoc.l(:button_change), :class => "small") + "</form>"
      
      return content_tag(:td, form, :align => 'center' )
    else
      return ''
    end
  end
end