diff options
author | Maxime Quandalle <maxime@quandalle.com> | 2016-07-18 15:40:41 +0200 |
---|---|---|
committer | Maxime Quandalle <maxime@quandalle.com> | 2016-07-18 15:40:41 +0200 |
commit | 4f5cecf738b2bbb9612338737de6172de8874669 (patch) | |
tree | c34087b23fe4fcc4d555d0d00775314f18955fb4 /models/cards.js | |
parent | 855f56c61a39b03442c4962e3afabd80f7fcd721 (diff) | |
parent | e521fe617ee923f72d5d6ca27cc03147d353eec4 (diff) | |
download | wekan-4f5cecf738b2bbb9612338737de6172de8874669.tar.gz wekan-4f5cecf738b2bbb9612338737de6172de8874669.tar.bz2 wekan-4f5cecf738b2bbb9612338737de6172de8874669.zip |
Merge #616 into devel
Diffstat (limited to 'models/cards.js')
-rw-r--r-- | models/cards.js | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/models/cards.js b/models/cards.js index 09c86191..aa19a64a 100644 --- a/models/cards.js +++ b/models/cards.js @@ -9,6 +9,11 @@ Cards.attachSchema(new SimpleSchema({ }, archived: { type: Boolean, + autoValue() { // eslint-disable-line consistent-return + if (this.isInsert && !this.isSet) { + return false; + } + }, }, listId: { type: String, @@ -25,10 +30,19 @@ Cards.attachSchema(new SimpleSchema({ }, createdAt: { type: Date, - denyUpdate: true, + autoValue() { // eslint-disable-line consistent-return + if (this.isInsert) { + return new Date(); + } else { + this.unset(); + } + }, }, dateLastActivity: { type: Date, + autoValue() { + return new Date(); + }, }, description: { type: String, @@ -46,6 +60,11 @@ Cards.attachSchema(new SimpleSchema({ // the `members` field? userId: { type: String, + autoValue() { // eslint-disable-line consistent-return + if (this.isInsert && !this.isSet) { + return this.userId; + } + }, }, sort: { type: Number, @@ -190,17 +209,6 @@ Cards.mutations({ }, }); -Cards.before.insert((userId, doc) => { - doc.createdAt = new Date(); - doc.dateLastActivity = new Date(); - if(!doc.hasOwnProperty('archived')){ - doc.archived = false; - } - if (!doc.userId) { - doc.userId = userId; - } -}); - if (Meteor.isServer) { Cards.after.insert((userId, doc) => { Activities.insert({ |