Added the rest of the form for setting a rate on a project. #1923
This commit is contained in:
1 parent
aab2d83d48
commit
b6bffb2c05
2 files changed
+43
-24
No files matched your search
+1
-1
@@ -6,4 +6,4 @@ rate_label_new_rate: New Rate
|
|||||||
rate_label_currency: $
|
rate_label_currency: $
|
||||||
rate_error_user_not_found: User not found
|
rate_error_user_not_found: User not found
|
||||||
rate_label_set_rate: Set Rate
|
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]
|
project = context[:project]
|
||||||
rate = Rate.for(member.user, project)
|
rate = Rate.for(member.user, project)
|
||||||
|
|
||||||
url = {
|
content = ''
|
||||||
: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)
|
if rate.nil? || rate.default?
|
||||||
form << hidden_field(:rate,:date_in_effect, :value => Date.today.to_s)
|
if rate && rate.default?
|
||||||
form << hidden_field(:rate, :project_id, :value => project.id)
|
content << "<em>#{number_to_currency(rate.amount)}</em> "
|
||||||
form << hidden_field(:rate, :user_id, :value => member.user.id)
|
end
|
||||||
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")
|
url = {
|
||||||
|
:controller => 'rates',
|
||||||
return content_tag(:td, form, :align => 'left', :id => "rate_#{project.id}_#{member.user.id}" )
|
: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
|
||||||
end
|
end
|
||||||
|
|
||||||
Reference in new issue
Block a user