some progress in porting for rm2.x
This commit is contained in:
@@ -27,7 +27,7 @@ module RateHelper
|
||||
# Trunk version of sort_link. Was modified in r2571 of Redmine
|
||||
def rate_sort_link_trunk_version(column, caption, default_order, options = { })
|
||||
css, order = nil, default_order
|
||||
|
||||
|
||||
if column.to_s == @sort_criteria.first_key
|
||||
if @sort_criteria.first_asc?
|
||||
css = 'sort asc'
|
||||
@@ -42,7 +42,7 @@ module RateHelper
|
||||
sort_options = { :sort => @sort_criteria.add(column.to_s, order).to_param }
|
||||
# don't reuse params if filters are present
|
||||
url_options = params.has_key?(:set_filter) ? sort_options : params.merge(sort_options)
|
||||
|
||||
|
||||
# Add project_id to url_options
|
||||
url_options = url_options.merge(:project_id => params[:project_id]) if params.has_key?(:project_id)
|
||||
|
||||
@@ -52,11 +52,11 @@ module RateHelper
|
||||
url_options[:user_id] ||= options[:user_id]
|
||||
#####
|
||||
|
||||
|
||||
link_to_remote(caption,
|
||||
{:update => options[:update] || "content", :url => url_options, :method => options[:method] || :post},
|
||||
{:href => url_for(url_options),
|
||||
:class => css})
|
||||
# link_to caption, :remote => true
|
||||
end
|
||||
|
||||
private
|
||||
@@ -76,11 +76,11 @@ module RateHelper
|
||||
order = default_order
|
||||
end
|
||||
caption = titleize(ActiveSupport::Inflector::humanize(column)) unless caption
|
||||
|
||||
|
||||
sort_options = { :sort_key => column, :sort_order => order }
|
||||
# don't reuse params if filters are present
|
||||
url_options = params.has_key?(:set_filter) ? sort_options : params.merge(sort_options)
|
||||
|
||||
|
||||
##### Hard code url to the Rates index
|
||||
url_options[:controller] = 'rates'
|
||||
url_options[:action] = 'index'
|
||||
@@ -92,5 +92,5 @@ module RateHelper
|
||||
{:href => url_for(url_options)}) +
|
||||
(icon ? nbsp(2) + image_tag(icon) : '')
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
%td{:align => "left", :id => "rate_#{project.id}_#{member.user.id}"}
|
||||
- if rate.nil? || rate.default?
|
||||
- if rate && rate.default?
|
||||
%em #{number_to_currency(rate.amount)}
|
||||
- if User.current.admin?
|
||||
= form_tag form_url, :method => :post, :remote => true do
|
||||
= text_field :rate, :amount, :size => 8
|
||||
= hidden_field(:rate,:date_in_effect, :value => Date.today.to_s)
|
||||
= hidden_field(:rate, :project_id, :value => project.id)
|
||||
= hidden_field(:rate, :user_id, :value => member.user.id)
|
||||
= hidden_field_tag("back_url", url_for(:controller => 'projects', :action => 'settings', :id => project, :tab => 'members'))
|
||||
= submit_tag(l(:rate_label_set_rate), :class => "small")
|
||||
- else
|
||||
%strong
|
||||
- if User.current.admin?
|
||||
= link_to number_to_currency(rate.amount), :controller => 'users', :action => 'edit', :id => member.user, :tab => 'rates'
|
||||
- else
|
||||
= number_to_currency(rate.amount)
|
||||
@@ -1,4 +1,4 @@
|
||||
<% form_for(@rate) do |f| %>
|
||||
<%= form_for(@rate) do |f| %>
|
||||
<table class="list">
|
||||
<thead>
|
||||
<th style="width:15%"><%= l(:label_date) %></th>
|
||||
@@ -14,7 +14,7 @@
|
||||
<td>
|
||||
<%= # TODO: move to controller once a hook is in place for the Admin panel
|
||||
projects = Project.find(:all, :conditions => { :status => Project::STATUS_ACTIVE})
|
||||
|
||||
|
||||
select_tag("rate[project_id]", project_options_for_select_with_selected(projects, @rate.project))
|
||||
%>
|
||||
</td>
|
||||
|
||||
@@ -3,21 +3,18 @@
|
||||
|
||||
<% if rate.nil? || rate.default? %>
|
||||
<% if rate && rate.default? %>
|
||||
<em><%= number_to_currency(rate.amount) %></em>
|
||||
<em><%= number_to_currency(rate.amount) %></em>
|
||||
<% end %>
|
||||
|
||||
<% remote_form_for(:rate, :url => rates_path(:format => 'js')) do |f| %>
|
||||
|
||||
<%= f.text_field :amount %>
|
||||
<%= f.hidden_field :date_in_effect, :value => Date.today.to_s, :id => "" %>
|
||||
<%= f.hidden_field :project_id, :value => membership.project.id %>
|
||||
<%= f.hidden_field :user_id, :value => user.id %>
|
||||
<%= hidden_field_tag "back_url", url_for(:controller => 'users', :action => 'edit', :id => user, :tab => 'memberships') %>
|
||||
|
||||
<%= submit_tag(l(:rate_label_set_rate), :class => "small") %>
|
||||
aaa
|
||||
<%= form_for(:rate, :url => rates_path(:format => 'js'), :remote => true) do |f| %>
|
||||
<%= f.text_field :amount %>
|
||||
<%= f.hidden_field :date_in_effect, :value => Date.today.to_s, :id => "" %>
|
||||
<%= f.hidden_field :project_id, :value => membership.project.id %>
|
||||
<%= f.hidden_field :user_id, :value => user.id %>
|
||||
<%= hidden_field_tag "back_url", url_for(:controller => 'users', :action => 'edit', :id => user, :tab => 'memberships') %>
|
||||
<%= submit_tag(l(:rate_label_set_rate), :class => "small") %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<strong><%= link_to number_to_currency(rate.amount), { :action => 'edit', :id => user, :tab => 'rates'} %></strong>
|
||||
<strong><%= link_to number_to_currency(rate.amount), { :action => 'edit', :id => user, :tab => 'rates'} %></strong>
|
||||
<% end %>
|
||||
|
||||
</td>
|
||||
|
||||
@@ -16,8 +16,8 @@ ActionDispatch::Callbacks.to_prepare do
|
||||
end
|
||||
|
||||
# Hooks
|
||||
require 'rate_project_hook'
|
||||
require 'rate_memberships_hook'
|
||||
require_dependency 'rate_project_hook'
|
||||
require_dependency 'rate_memberships_hook'
|
||||
|
||||
Redmine::Plugin.register :redmine_rate do
|
||||
name 'Rate'
|
||||
@@ -27,7 +27,7 @@ Redmine::Plugin.register :redmine_rate do
|
||||
description "The Rate plugin provides an API that can be used to find the rate for a Member of a Project at a specific date. It also stores historical rate data so calculations will remain correct in the future."
|
||||
version '0.2.1'
|
||||
|
||||
requires_redmine :version_or_higher => '1.0.0'
|
||||
requires_redmine :version_or_higher => '2.0.0'
|
||||
|
||||
# These settings are set automatically when caching
|
||||
settings(:default => {
|
||||
|
||||
@@ -5,11 +5,11 @@ class RateMembershipsHook < Redmine::Hook::ViewListener
|
||||
|
||||
def view_users_memberships_table_row(context={})
|
||||
return context[:controller].send(:render_to_string, {
|
||||
:partial => 'users/membership_rate',
|
||||
:locals => {
|
||||
:membership => context[:membership],
|
||||
:user => context[:user]
|
||||
}})
|
||||
|
||||
:partial => 'users/membership_rate',
|
||||
:locals => {
|
||||
:membership => context[:membership],
|
||||
:user => context[:user]
|
||||
}
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
+18
-53
@@ -10,9 +10,9 @@ class RateProjectHook < Redmine::Hook::ViewListener
|
||||
# Context:
|
||||
# * :project => Current project
|
||||
#
|
||||
def view_projects_settings_members_table_header(context ={ })
|
||||
def view_projects_settings_members_table_header(context={})
|
||||
return '' unless (User.current.allowed_to?(:view_rate, context[:project]) || User.current.admin?)
|
||||
return "<th>#{l(:rate_label_rate)} #{l(:rate_label_currency)}</td>"
|
||||
return content_tag(:th, "#{l(:rate_label_rate)} #{l(:rate_label_currency)}")
|
||||
end
|
||||
|
||||
# Renders an AJAX from to update the member's billing rate
|
||||
@@ -22,64 +22,29 @@ class RateProjectHook < Redmine::Hook::ViewListener
|
||||
# * :member => Current Member record
|
||||
#
|
||||
# TODO: Move to a view
|
||||
def view_projects_settings_members_table_row(context = { })
|
||||
member = context[:member]
|
||||
project = context[:project]
|
||||
|
||||
return '' unless (User.current.allowed_to?(:view_rate, project) || User.current.admin?)
|
||||
def view_projects_settings_members_table_row(context={})
|
||||
return '' unless (User.current.allowed_to?(:view_rate, context[:project]) || User.current.admin?)
|
||||
|
||||
if Object.const_defined? 'Group' # 0.8.x compatibility
|
||||
# Groups cannot have a rate
|
||||
return content_tag(:td,'') if member.principal.is_a? Group
|
||||
rate = Rate.for(member.principal, project)
|
||||
return content_tag(:td,'') if context[:member].principal.is_a? Group
|
||||
rate = Rate.for(context[:member].principal, context[:project])
|
||||
else
|
||||
rate = Rate.for(member.user, project)
|
||||
rate = Rate.for(context[:member].user, context[:project])
|
||||
end
|
||||
|
||||
content = ''
|
||||
|
||||
if rate.nil? || rate.default?
|
||||
if rate && rate.default?
|
||||
content << "<em>#{number_to_currency(rate.amount)}</em> "
|
||||
end
|
||||
|
||||
if (User.current.admin?)
|
||||
|
||||
url = {
|
||||
:controller => 'rates',
|
||||
:action => 'create',
|
||||
:method => :post,
|
||||
:protocol => Setting.protocol,
|
||||
:host => Setting.host_name
|
||||
return context[:controller].send(:render_to_string, {
|
||||
partial: "projects/settings_members",
|
||||
locals: {
|
||||
form_url: {
|
||||
:controller => 'rates',
|
||||
:action => 'create'
|
||||
},
|
||||
rate: rate,
|
||||
member: context[:member],
|
||||
project: context[:project]
|
||||
}
|
||||
form = form_tag(url, :remote => true)
|
||||
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")
|
||||
form << "</form>"
|
||||
|
||||
content << form
|
||||
end
|
||||
else
|
||||
if (User.current.admin?)
|
||||
|
||||
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
|
||||
}))
|
||||
else
|
||||
content << content_tag(:strong, number_to_currency(rate.amount))
|
||||
end
|
||||
end
|
||||
return content_tag(:td, content, :align => 'left', :id => "rate_#{project.id}_#{member.user.id}" )
|
||||
})
|
||||
end
|
||||
|
||||
def model_project_copy_before_save(context = {})
|
||||
|
||||
Reference in New Issue
Block a user