diff options
author | Guilherme Salazar <gmesalazar@gmail.com> | 2016-09-27 00:36:11 +0300 |
---|---|---|
committer | Guilherme Salazar <gmesalazar@gmail.com> | 2016-10-28 19:01:36 +0300 |
commit | 32913b74b836c7b689e681a030de00da0552954a (patch) | |
tree | 3e13e52f35e8236049c8413e695a47bae8f3a671 /app/models/concerns/taskable.rb | |
parent | 4fd015183cdb280083384c69261c2ab5d475a54b (diff) |
add "x of y tasks completed" on issuable
fix issues pointed out in !6527
add task completion status feature to CHANGELOG
Diffstat (limited to 'app/models/concerns/taskable.rb')
-rw-r--r-- | app/models/concerns/taskable.rb | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/app/models/concerns/taskable.rb b/app/models/concerns/taskable.rb index a3ac577cf3e..ebc75100a54 100644 --- a/app/models/concerns/taskable.rb +++ b/app/models/concerns/taskable.rb @@ -53,10 +53,22 @@ module Taskable # Return a string that describes the current state of this Taskable's task # list items, e.g. "12 of 20 tasks completed" - def task_status + def task_status(short: false) return '' if description.blank? + prep, completed = if short + ['/', ''] + else + [' of ', ' completed'] + end + sum = tasks.summary - "#{sum.complete_count} of #{sum.item_count} #{'task'.pluralize(sum.item_count)} completed" + "#{sum.complete_count}#{prep}#{sum.item_count} #{'task'.pluralize(sum.item_count)}#{completed}" + end + + # Return a short string that describes the current state of this Taskable's + # task list items -- for small screens + def task_status_short + task_status(short: true) end end |