diff options
author | Dan Rowden <hello@danrowden.com> | 2016-07-26 16:30:14 +0300 |
---|---|---|
committer | Alfredo Sumaran <alfredo@gitlab.com> | 2016-09-07 23:27:14 +0300 |
commit | 894bd04decf1a2e6a7ca7b1450db9ac7bddd4735 (patch) | |
tree | d4fb409bc83abcd48ee16e7ef52f333277afb149 /app/helpers/milestones_helper.rb | |
parent | db116fa0811b41c220a2dd843426d81e40db42e7 (diff) |
Added a small helper to reduce logic in the view
Diffstat (limited to 'app/helpers/milestones_helper.rb')
-rw-r--r-- | app/helpers/milestones_helper.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/app/helpers/milestones_helper.rb b/app/helpers/milestones_helper.rb index 404a116d951..27f4354cf42 100644 --- a/app/helpers/milestones_helper.rb +++ b/app/helpers/milestones_helper.rb @@ -47,6 +47,17 @@ module MilestonesHelper } 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', |