Added some compatibility wrappers for the stable 0.8.x version of Redmine.
This commit is contained in:
@@ -58,7 +58,12 @@
|
||||
<p>
|
||||
<label><%=l(:label_project_new)%></label><br/>
|
||||
<% form_tag({ :action => 'edit_membership', :id => @user }) do %>
|
||||
<%# 0.8.x compatibility %>
|
||||
<% if respond_to?(:options_for_membership_project_select) %>
|
||||
<%= select_tag 'membership[project_id]', options_for_membership_project_select(@user, @projects) %>
|
||||
<% else %>
|
||||
<%= select_tag 'membership[project_id]', projects_options_for_select(@projects) %>
|
||||
<% end %>
|
||||
<%= l(:label_role) %>:
|
||||
<%= select_tag 'membership[role_id]', options_from_collection_for_select(@roles, "id", "name") %>
|
||||
<%= submit_tag l(:button_add) %>
|
||||
|
||||
@@ -22,6 +22,17 @@ module RateSortHelperPatch
|
||||
# Allows more parameters than the standard sort_link and is hard coded to use
|
||||
# the RatesController and to have an :method and :update options
|
||||
def rate_sort_link(column, caption, default_order, options = { })
|
||||
# 0.8.x compatibility
|
||||
if SortHelper.const_defined? 'SortCriteria'
|
||||
rate_sort_link_trunk_version(column, caption, default_order, options)
|
||||
else
|
||||
rate_sort_link_08_version(column, caption, default_order, options)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# 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
|
||||
@@ -55,6 +66,40 @@ module RateSortHelperPatch
|
||||
:class => css})
|
||||
end
|
||||
|
||||
private
|
||||
# 0.8.x branch of sort_link.
|
||||
def rate_sort_link_08_version(column, caption, default_order, options = { })
|
||||
key, order = session[@sort_name][:key], session[@sort_name][:order]
|
||||
if key == column
|
||||
if order.downcase == 'asc'
|
||||
icon = 'sort_asc.png'
|
||||
order = 'desc'
|
||||
else
|
||||
icon = 'sort_desc.png'
|
||||
order = 'asc'
|
||||
end
|
||||
else
|
||||
icon = nil
|
||||
order = default_order
|
||||
end
|
||||
caption = titleize(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'
|
||||
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)}) +
|
||||
(icon ? nbsp(2) + image_tag(icon) : '')
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user