Added the rest of the form for setting a rate on a project. #1923
This commit is contained in:
+1
-1
@@ -6,4 +6,4 @@ rate_label_new_rate: New Rate
|
||||
rate_label_currency: $
|
||||
rate_error_user_not_found: User not found
|
||||
rate_label_set_rate: Set Rate
|
||||
|
||||
rate_label_default: Default Rate
|
||||
|
||||
+42
-23
@@ -25,31 +25,50 @@ class RateProjectHook < Redmine::Hook::ViewListener
|
||||
project = context[:project]
|
||||
rate = Rate.for(member.user, project)
|
||||
|
||||
url = {
|
||||
:controller => 'rates',
|
||||
:action => 'create',
|
||||
:method => :post,
|
||||
:protocol => Setting.protocol,
|
||||
:host => Setting.host_name
|
||||
}
|
||||
# Build a form_remote_tag by hand since this isn't in the scope of a controller
|
||||
# and url_rewriter doesn't like that fact.
|
||||
form = form_tag(url, :onsubmit => remote_function(:url => url,
|
||||
:host => Setting.host_name,
|
||||
:protocol => Setting.protocol,
|
||||
:form => true,
|
||||
:method => 'post',
|
||||
:return => 'false' )+ '; return false;')
|
||||
content = ''
|
||||
|
||||
form << text_field(:rate, :amount)
|
||||
form << hidden_field(:rate,:date_in_effect, :value => Date.today.to_s)
|
||||
form << hidden_field(:rate, :project_id, :value => project.id)
|
||||
form << hidden_field(:rate, :user_id, :value => member.user.id)
|
||||
form << hidden_field_tag("back_url", url_for(:controller => 'projects', :action => 'settings', :id => project, :tab => 'members', :protocol => Setting.protocol, :host => Setting.host_name))
|
||||
if rate.nil? || rate.default?
|
||||
if rate && rate.default?
|
||||
content << "<em>#{number_to_currency(rate.amount)}</em> "
|
||||
end
|
||||
|
||||
form << submit_tag(l(:rate_label_set_rate), :class => "small")
|
||||
|
||||
return content_tag(:td, form, :align => 'left', :id => "rate_#{project.id}_#{member.user.id}" )
|
||||
url = {
|
||||
:controller => 'rates',
|
||||
:action => 'create',
|
||||
:method => :post,
|
||||
:protocol => Setting.protocol,
|
||||
:host => Setting.host_name
|
||||
}
|
||||
# Build a form_remote_tag by hand since this isn't in the scope of a controller
|
||||
# and url_rewriter doesn't like that fact.
|
||||
form = form_tag(url, :onsubmit => remote_function(:url => url,
|
||||
:host => Setting.host_name,
|
||||
:protocol => Setting.protocol,
|
||||
:form => true,
|
||||
:method => 'post',
|
||||
:return => 'false' )+ '; return false;')
|
||||
|
||||
form << text_field(:rate, :amount)
|
||||
form << hidden_field(:rate,:date_in_effect, :value => Date.today.to_s)
|
||||
form << hidden_field(:rate, :project_id, :value => project.id)
|
||||
form << hidden_field(:rate, :user_id, :value => member.user.id)
|
||||
form << hidden_field_tag("back_url", url_for(:controller => 'projects', :action => 'settings', :id => project, :tab => 'members', :protocol => Setting.protocol, :host => Setting.host_name))
|
||||
|
||||
form << submit_tag(l(:rate_label_set_rate), :class => "small")
|
||||
|
||||
content << form
|
||||
else
|
||||
content << content_tag(:strong, link_to(number_to_currency(rate.amount), {
|
||||
:controller => 'users',
|
||||
:action => 'edit',
|
||||
:id => member.user,
|
||||
:tab => 'rates',
|
||||
:protocol => Setting.protocol,
|
||||
:host => Setting.host_name
|
||||
}))
|
||||
|
||||
end
|
||||
return content_tag(:td, content, :align => 'left', :id => "rate_#{project.id}_#{member.user.id}" )
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user