summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorNicu Tofan <nicu.tofan@gmail.com>2018-06-18 23:25:56 +0300
committerNicu Tofan <nicu.tofan@gmail.com>2018-06-26 14:32:47 +0300
commitd59583915cca24d53a11251c54ca7caf6b5edb4e (patch)
treea425bb136877a3f93c8a9871008be2606eb5427c /models
parentb627ced605f0ab98eb2977420da954f31df4f592 (diff)
downloadwekan-d59583915cca24d53a11251c54ca7caf6b5edb4e.tar.gz
wekan-d59583915cca24d53a11251c54ca7caf6b5edb4e.tar.bz2
wekan-d59583915cca24d53a11251c54ca7caf6b5edb4e.zip
Initial implementation for subtasks
Diffstat (limited to 'models')
-rw-r--r--models/activities.js3
-rw-r--r--models/cards.js24
-rw-r--r--models/export.js2
-rw-r--r--models/subtasks.js8
4 files changed, 30 insertions, 7 deletions
diff --git a/models/activities.js b/models/activities.js
index f64b53f8..1ff0a299 100644
--- a/models/activities.js
+++ b/models/activities.js
@@ -44,6 +44,9 @@ Activities.helpers({
checklistItem() {
return ChecklistItems.findOne(this.checklistItemId);
},
+ subtasks() {
+ return Subtasks.findOne(this.subtaskId);
+ },
customField() {
return CustomFields.findOne(this.customFieldId);
},
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,
});
diff --git a/models/export.js b/models/export.js
index aff66801..778633f9 100644
--- a/models/export.js
+++ b/models/export.js
@@ -58,9 +58,11 @@ class Exporter {
result.activities = Activities.find(byBoard, noBoardId).fetch();
result.checklists = [];
result.checklistItems = [];
+ result.subtaskItems = [];
result.cards.forEach((card) => {
result.checklists.push(...Checklists.find({ cardId: card._id }).fetch());
result.checklistItems.push(...ChecklistItems.find({ cardId: card._id }).fetch());
+ result.subtaskItems.push(...Subtasks.find({ cardId: card._id }).fetch());
});
// [Old] for attachments we only export IDs and absolute url to original doc
diff --git a/models/subtasks.js b/models/subtasks.js
index e842d11d..3f8b932c 100644
--- a/models/subtasks.js
+++ b/models/subtasks.js
@@ -41,13 +41,7 @@ Subtasks.attachSchema(new SimpleSchema({
}));
Subtasks.helpers({
- isFinished() {
- return 0 !== this.itemCount() && this.itemCount() === this.finishedCount();
- },
- itemIndex(itemId) {
- const items = self.findOne({_id : this._id}).items;
- return _.pluck(items, '_id').indexOf(itemId);
- },
+ // ...
});
Subtasks.allow({