count subtasks just like checklists

reviewable/pr3765/r2
ryanMushy 4 years ago
parent 9a2d3e15e8
commit 63c1bb9e17
  1. 5
      client/components/cards/minicard.jade
  2. 41
      models/cards.js

@ -129,3 +129,8 @@ template(name="minicard")
.badge(class="{{#if checklistFinished}}is-finished{{/if}}")
span.badge-icon.fa.fa-check-square-o
span.badge-text.check-list-text {{checklistFinishedCount}}/{{checklistItemCount}}
if allSubtasks.count
.badge
span.badge-icon.fa.fa-sitemap
span.badge-text.check-list-text {{subtasksFinishedCount}}/{{allSubtasksCount}}
//{{subtasksFinishedCount}}/{{subtasksCount}} does not work because when a subtaks is archived, the count goes down

@ -641,37 +641,32 @@ Cards.helpers({
);
},
allSubtasks() {
return Cards.find(
{
parentId: this._id,
archived: false,
},
{
sort: {
sort: 1,
},
},
);
subtasksFinished() {
return Cards.find({
parentId: this._id,
archived: true,
});
},
subtasksCount() {
allSubtasks() {
return Cards.find({
parentId: this._id,
archived: false,
}).count();
parentId: this._id
});
},
subtasksCount() {
const subtasks = this.subtasks();
return subtasks.count();
},
subtasksFinishedCount() {
return Cards.find({
parentId: this._id,
archived: true,
}).count();
const subtasksArchived = this.subtasksFinished();
return subtasksArchived.count();
},
subtasksFinished() {
const finishCount = this.subtasksFinishedCount();
return finishCount > 0 && this.subtasksCount() === finishCount;
allSubtasksCount() {
const allSubtasks = this.allSubtasks();
return allSubtasks.count();
},
allowsSubtasks() {

Loading…
Cancel
Save