Mercurial > hg > soundsoftware-site
diff app/helpers/versions_helper.rb @ 1339:c03a6c3c4db9 luisf
Merge
author | luisf <luis.figueira@eecs.qmul.ac.uk> |
---|---|
date | Thu, 20 Jun 2013 14:34:42 +0100 |
parents | 433d4f72a19b |
children | 622f24f53b42 261b3d9a4903 |
line wrap: on
line diff
--- a/app/helpers/versions_helper.rb Wed Nov 21 18:16:32 2012 +0000 +++ b/app/helpers/versions_helper.rb Thu Jun 20 14:34:42 2013 +0100 @@ -1,7 +1,7 @@ # encoding: utf-8 # # Redmine - project management software -# Copyright (C) 2006-2011 Jean-Philippe Lang +# Copyright (C) 2006-2012 Jean-Philippe Lang # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -19,10 +19,18 @@ module VersionsHelper - STATUS_BY_CRITERIAS = %w(category tracker status priority author assigned_to) + def version_anchor(version) + if @project == version.project + anchor version.name + else + anchor "#{version.project.try(:identifier)}-#{version.name}" + end + end + + STATUS_BY_CRITERIAS = %w(tracker status priority author assigned_to category) def render_issue_status_by(version, criteria) - criteria = 'category' unless STATUS_BY_CRITERIAS.include?(criteria) + criteria = 'tracker' unless STATUS_BY_CRITERIAS.include?(criteria) h = Hash.new {|k,v| k[v] = [0, 0]} begin @@ -36,7 +44,8 @@ rescue ActiveRecord::RecordNotFound # When grouping by an association, Rails throws this exception if there's no result (bug) end - counts = h.keys.compact.sort.collect {|k| {:group => k, :total => h[k][0], :open => h[k][1], :closed => (h[k][0] - h[k][1])}} + # Sort with nil keys in last position + counts = h.keys.sort {|a,b| a.nil? ? 1 : (b.nil? ? -1 : a <=> b)}.collect {|k| {:group => k, :total => h[k][0], :open => h[k][1], :closed => (h[k][0] - h[k][1])}} max = counts.collect {|c| c[:total]}.max render :partial => 'issue_counts', :locals => {:version => version, :criteria => criteria, :counts => counts, :max => max}