diff --git a/app/views/users/_memberships.rhtml b/app/views/users/_memberships.rhtml index bd6d7d0..5b0c774 100644 --- a/app/views/users/_memberships.rhtml +++ b/app/views/users/_memberships.rhtml @@ -58,7 +58,12 @@


<% 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) %> diff --git a/lib/rate_sort_helper_patch.rb b/lib/rate_sort_helper_patch.rb index 87ffa11..39a7545 100644 --- a/lib/rate_sort_helper_patch.rb +++ b/lib/rate_sort_helper_patch.rb @@ -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 @@ -54,6 +65,40 @@ module RateSortHelperPatch {:href => url_for(url_options), :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