mirror of
https://github.com/wekan/wekan.git
synced 2026-01-31 13:45:17 +01:00
Some inspiration from checklists to subtasks
This commit is contained in:
parent
c3037b155f
commit
b627ced605
1 changed files with 34 additions and 0 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue