summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicu Tofan <nicu.tofan@gmail.com>2018-06-17 22:55:01 +0300
committerNicu Tofan <nicu.tofan@gmail.com>2018-06-26 14:32:47 +0300
commitb627ced605f0ab98eb2977420da954f31df4f592 (patch)
tree79e176a19fc3d69c322cfcea30070c412d10a283
parentc3037b155fc0de1ef44d1d1c1fc65c25790ca3ad (diff)
downloadwekan-b627ced605f0ab98eb2977420da954f31df4f592.tar.gz
wekan-b627ced605f0ab98eb2977420da954f31df4f592.tar.bz2
wekan-b627ced605f0ab98eb2977420da954f31df4f592.zip
Some inspiration from checklists to subtasks
-rw-r--r--models/subtasks.js34
1 files changed, 34 insertions, 0 deletions
diff --git a/models/subtasks.js b/models/subtasks.js
index 6c42072e..e842d11d 100644
--- a/models/subtasks.js
+++ b/models/subtasks.js
@@ -4,6 +4,29 @@ Subtasks.attachSchema(new SimpleSchema({
title: {
type: String,
},
+ startAt: { // this is a predicted time
+ type: Date,
+ optional: true,
+ },
+ endAt: { // this is a predicted time
+ type: Date,
+ optional: true,
+ },
+ finishedAt: { // The date & time when it is marked as being done
+ type: Date,
+ optional: true,
+ },
+ createdAt: {
+ type: Date,
+ denyUpdate: false,
+ autoValue() { // eslint-disable-line consistent-return
+ if (this.isInsert) {
+ return new Date();
+ } else {
+ this.unset();
+ }
+ },
+ },
sort: {
type: Number,
decimal: true,
@@ -17,6 +40,16 @@ 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({
insert(userId, doc) {
return allowIsBoardMemberByCard(userId, Cards.findOne(doc.cardId));
@@ -31,6 +64,7 @@ Subtasks.allow({
});
Subtasks.before.insert((userId, doc) => {
+ doc.createdAt = new Date();
if (!doc.userId) {
doc.userId = userId;
}