mirror of
https://github.com/wekan/wekan.git
synced 2026-02-01 14:11:48 +01:00
Fixes #2596 incorrect date types for created & updated
This commit is contained in:
parent
2c78aab3dc
commit
3b9f2ca7c2
22 changed files with 103 additions and 33 deletions
|
|
@ -20,6 +20,8 @@ AccountSettings.attachSchema(
|
|||
autoValue() {
|
||||
if (this.isInsert) {
|
||||
return new Date();
|
||||
} else if (this.isUpsert) {
|
||||
return { $setOnInsert: new Date() };
|
||||
} else {
|
||||
this.unset();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,16 @@ Actions.allow({
|
|||
},
|
||||
});
|
||||
|
||||
Actions.before.insert((userId, doc) => {
|
||||
doc.createdAt = new Date();
|
||||
doc.modifiedAt = doc.createdAt;
|
||||
});
|
||||
|
||||
Actions.before.update((userId, doc, fieldNames, modifier) => {
|
||||
modifier.$set = modifier.$set || {};
|
||||
modifier.$set.modifiedAt = new Date();
|
||||
});
|
||||
|
||||
Actions.helpers({
|
||||
description() {
|
||||
return this.desc;
|
||||
|
|
|
|||
|
|
@ -62,8 +62,14 @@ Activities.helpers({
|
|||
//},
|
||||
});
|
||||
|
||||
Activities.before.update((userId, doc, fieldNames, modifier) => {
|
||||
modifier.$set = modifier.$set || {};
|
||||
modifier.$set.modifiedAt = new Date();
|
||||
});
|
||||
|
||||
Activities.before.insert((userId, doc) => {
|
||||
doc.createdAt = new Date();
|
||||
doc.modifiedAt = doc.createdAt;
|
||||
});
|
||||
|
||||
Activities.after.insert((userId, doc) => {
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ Announcements.attachSchema(
|
|||
autoValue() {
|
||||
if (this.isInsert) {
|
||||
return new Date();
|
||||
} else if (this.isUpsert) {
|
||||
return { $setOnInsert: new Date() };
|
||||
} else {
|
||||
this.unset();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,6 +55,8 @@ Boards.attachSchema(
|
|||
autoValue() {
|
||||
if (this.isInsert) {
|
||||
return new Date();
|
||||
} else if (this.isUpsert) {
|
||||
return { $setOnInsert: new Date() };
|
||||
} else {
|
||||
this.unset();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@ CardComments.attachSchema(
|
|||
autoValue() {
|
||||
if (this.isInsert) {
|
||||
return new Date();
|
||||
} else if (this.isUpsert) {
|
||||
return { $setOnInsert: new Date() };
|
||||
} else {
|
||||
this.unset();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -107,6 +107,8 @@ Cards.attachSchema(
|
|||
autoValue() {
|
||||
if (this.isInsert) {
|
||||
return new Date();
|
||||
} else if (this.isUpsert) {
|
||||
return { $setOnInsert: new Date() };
|
||||
} else {
|
||||
this.unset();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,8 @@ ChecklistItems.attachSchema(
|
|||
autoValue() {
|
||||
if (this.isInsert) {
|
||||
return new Date();
|
||||
} else if (this.isUpsert) {
|
||||
return { $setOnInsert: new Date() };
|
||||
} else {
|
||||
this.unset();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ Checklists.attachSchema(
|
|||
autoValue() {
|
||||
if (this.isInsert) {
|
||||
return new Date();
|
||||
} else if (this.isUpsert) {
|
||||
return { $setOnInsert: new Date() };
|
||||
} else {
|
||||
this.unset();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,6 +78,8 @@ CustomFields.attachSchema(
|
|||
autoValue() {
|
||||
if (this.isInsert) {
|
||||
return new Date();
|
||||
} else if (this.isUpsert) {
|
||||
return { $setOnInsert: new Date() };
|
||||
} else {
|
||||
this.unset();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,6 +63,8 @@ Integrations.attachSchema(
|
|||
autoValue() {
|
||||
if (this.isInsert) {
|
||||
return new Date();
|
||||
} else if (this.isUpsert) {
|
||||
return { $setOnInsert: new Date() };
|
||||
} else {
|
||||
this.unset();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ InvitationCodes.attachSchema(
|
|||
autoValue() {
|
||||
if (this.isInsert) {
|
||||
return new Date();
|
||||
} else if (this.isUpsert) {
|
||||
return { $setOnInsert: new Date() };
|
||||
} else {
|
||||
this.unset();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,6 +45,8 @@ Lists.attachSchema(
|
|||
autoValue() {
|
||||
if (this.isInsert) {
|
||||
return new Date();
|
||||
} else if (this.isUpsert) {
|
||||
return { $setOnInsert: new Date() };
|
||||
} else {
|
||||
this.unset();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,6 +98,8 @@ Org.attachSchema(
|
|||
autoValue() {
|
||||
if (this.isInsert) {
|
||||
return new Date();
|
||||
} else if (this.isUpsert) {
|
||||
return { $setOnInsert: new Date() };
|
||||
} else {
|
||||
this.unset();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,6 +49,8 @@ OrgUser.attachSchema(
|
|||
autoValue() {
|
||||
if (this.isInsert) {
|
||||
return new Date();
|
||||
} else if (this.isUpsert) {
|
||||
return { $setOnInsert: new Date() };
|
||||
} else {
|
||||
this.unset();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ Rules.attachSchema(
|
|||
autoValue() {
|
||||
if (this.isInsert) {
|
||||
return new Date();
|
||||
} else if (this.isUpsert) {
|
||||
return { $setOnInsert: new Date() };
|
||||
} else {
|
||||
this.unset();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,6 +60,8 @@ Settings.attachSchema(
|
|||
autoValue() {
|
||||
if (this.isInsert) {
|
||||
return new Date();
|
||||
} else if (this.isUpsert) {
|
||||
return { $setOnInsert: new Date() };
|
||||
} else {
|
||||
this.unset();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ Swimlanes.attachSchema(
|
|||
autoValue() {
|
||||
if (this.isInsert) {
|
||||
return new Date();
|
||||
} else if (this.isUpsert) {
|
||||
return { $setOnInsert: new Date() };
|
||||
} else {
|
||||
this.unset();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,16 @@ Triggers.mutations({
|
|||
},
|
||||
});
|
||||
|
||||
Triggers.before.insert((userId, doc) => {
|
||||
doc.createdAt = new Date();
|
||||
doc.updatedAt = doc.createdAt;
|
||||
});
|
||||
|
||||
Triggers.before.update((userId, doc, fieldNames, modifier) => {
|
||||
modifier.$set = modifier.$set || {};
|
||||
modifier.$set.updatedAt = new Date();
|
||||
});
|
||||
|
||||
Triggers.allow({
|
||||
insert(userId, doc) {
|
||||
return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId));
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ UnsavedEditCollection.attachSchema(
|
|||
autoValue() {
|
||||
if (this.isInsert) {
|
||||
return new Date();
|
||||
} else if (this.isUpsert) {
|
||||
return { $setOnInsert: new Date() };
|
||||
} else {
|
||||
this.unset();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,6 +54,8 @@ Users.attachSchema(
|
|||
autoValue() {
|
||||
if (this.isInsert) {
|
||||
return new Date();
|
||||
} else if (this.isUpsert) {
|
||||
return { $setOnInsert: new Date() };
|
||||
} else {
|
||||
this.unset();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue