diff options
author | Phil Hughes <me@iamphill.com> | 2016-10-03 09:10:20 +0100 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2016-10-03 09:10:20 +0100 |
commit | cc88fa4d5be9ec0d5fb42f1bb5efa0b82f30a589 (patch) | |
tree | 1b9facaf15466aa7f5b0393e97cb1eabfdcafa7e /app/helpers/milestones_helper.rb | |
parent | 69db604e55de2bdf1a28c274be6cc9131534517d (diff) | |
parent | f2c0f8237124d2dc539120bd77f301f216453cb7 (diff) | |
download | gitlab-ce-cc88fa4d5be9ec0d5fb42f1bb5efa0b82f30a589.tar.gz |
Merge branch 'master' into revert-c676283b
Diffstat (limited to 'app/helpers/milestones_helper.rb')
-rw-r--r-- | app/helpers/milestones_helper.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/app/helpers/milestones_helper.rb b/app/helpers/milestones_helper.rb index e3d6fbd06ef..83a2a4ad3ec 100644 --- a/app/helpers/milestones_helper.rb +++ b/app/helpers/milestones_helper.rb @@ -35,6 +35,30 @@ module MilestonesHelper milestone.issues.with_label(label.title).send(state).size end + # Returns count of milestones for different states + # Uses explicit hash keys as the 'opened' state URL params differs from the db value + # and we need to add the total + def milestone_counts(milestones) + counts = milestones.reorder(nil).group(:state).count + + { + opened: counts['active'] || 0, + closed: counts['closed'] || 0, + all: counts.values.sum || 0 + } + end + + # Show 'active' class if provided GET param matches check + # `or_blank` allows the function to return 'active' when given an empty param + # Could be refactored to be simpler but that may make it harder to read + def milestone_class_for_state(param, check, match_blank_param = false) + if match_blank_param + 'active' if param.blank? || param == check + else + 'active' if param == check + end + end + def milestone_progress_bar(milestone) options = { class: 'progress-bar progress-bar-success', |