summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorGuilherme Salazar <gmesalazar@gmail.com>2016-09-26 18:36:11 -0300
committerGuilherme Salazar <gmesalazar@gmail.com>2016-10-28 14:01:36 -0200
commit32913b74b836c7b689e681a030de00da0552954a (patch)
tree3e13e52f35e8236049c8413e695a47bae8f3a671 /app/models
parent4fd015183cdb280083384c69261c2ab5d475a54b (diff)
downloadgitlab-ce-32913b74b836c7b689e681a030de00da0552954a.tar.gz
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')
-rw-r--r--app/models/concerns/issuable.rb1
-rw-r--r--app/models/concerns/taskable.rb16
-rw-r--r--app/models/issue.rb1
-rw-r--r--app/models/merge_request.rb1
4 files changed, 15 insertions, 4 deletions
diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb
index 17c3b526c97..613444e0d70 100644
--- a/app/models/concerns/issuable.rb
+++ b/app/models/concerns/issuable.rb
@@ -12,6 +12,7 @@ module Issuable
include Subscribable
include StripAttribute
include Awardable
+ include Taskable
included do
cache_markdown_field :title, pipeline: :single_line
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
diff --git a/app/models/issue.rb b/app/models/issue.rb
index e356fe06363..4f02b02c488 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -5,7 +5,6 @@ class Issue < ActiveRecord::Base
include Issuable
include Referable
include Sortable
- include Taskable
include Spammable
include FasterCacheKeys
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb
index 4872f8b8649..0397c57f935 100644
--- a/app/models/merge_request.rb
+++ b/app/models/merge_request.rb
@@ -3,7 +3,6 @@ class MergeRequest < ActiveRecord::Base
include Issuable
include Referable
include Sortable
- include Taskable
include Importable
belongs_to :target_project, class_name: "Project"