summaryrefslogtreecommitdiffstats
path: root/models/cards.js
diff options
context:
space:
mode:
Diffstat (limited to 'models/cards.js')
-rw-r--r--models/cards.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/models/cards.js b/models/cards.js
index 00ec14c2..6edffb79 100644
--- a/models/cards.js
+++ b/models/cards.js
@@ -215,6 +215,27 @@ Cards.helpers({
return this.checklistItemCount() !== 0;
},
+ subtasks() {
+ return Subtasks.find({cardId: this._id}, {sort: { sort: 1 } });
+ },
+
+ subtasksCount() {
+ return Subtasks.find({cardId: this._id}).count();
+ },
+
+ subtasksFinishedCount() {
+ return Subtasks.find({cardId: this._id, isFinished: true}).count();
+ },
+
+ subtasksFinished() {
+ const finishCount = this.subtasksFinishedCount();
+ return finishCount > 0 && this.subtasksCount() === finishCount;
+ },
+
+ hasSubtasks() {
+ return this.subtasksCount() !== 0;
+ },
+
customFieldIndex(customFieldId) {
return _.pluck(this.customFields, '_id').indexOf(customFieldId);
},
@@ -513,6 +534,9 @@ function cardRemover(userId, doc) {
Checklists.remove({
cardId: doc._id,
});
+ Subtasks.remove({
+ cardId: doc._id,
+ });
CardComments.remove({
cardId: doc._id,
});