summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicu Tofan <nicu.tofan@gmail.com>2018-06-27 16:25:57 +0300
committerNicu Tofan <nicu.tofan@gmail.com>2018-06-27 16:25:57 +0300
commit19d239f4cf90686db9c775bb0c3899b65760b06c (patch)
tree7399538d4053a9d5dcabb9a0fe4f75222cc8614f
parent18467dfe40f2f715262b79c35f6084cc7814d363 (diff)
downloadwekan-19d239f4cf90686db9c775bb0c3899b65760b06c.tar.gz
wekan-19d239f4cf90686db9c775bb0c3899b65760b06c.tar.bz2
wekan-19d239f4cf90686db9c775bb0c3899b65760b06c.zip
Prevent errors due to missing date fields
-rw-r--r--client/components/cards/cardDate.js57
1 files changed, 36 insertions, 21 deletions
diff --git a/client/components/cards/cardDate.js b/client/components/cards/cardDate.js
index c3e0524d..02ea09ae 100644
--- a/client/components/cards/cardDate.js
+++ b/client/components/cards/cardDate.js
@@ -218,10 +218,13 @@ class CardReceivedDate extends CardDate {
}
classes() {
- let classes = 'received-date' + ' ';
- if (this.date.get().isBefore(this.now.get(), 'minute') &&
- this.now.get().isBefore(this.data().dueAt)) {
- classes += 'current';
+ let classes = 'received-date ';
+ const dueAt = this.data().dueAt;
+ if (dueAt) {
+ if (this.date.get().isBefore(this.now.get(), 'minute') &&
+ this.now.get().isBefore(dueAt)) {
+ classes += 'current';
+ }
}
return classes;
}
@@ -249,9 +252,12 @@ class CardStartDate extends CardDate {
classes() {
let classes = 'start-date' + ' ';
- if (this.date.get().isBefore(this.now.get(), 'minute') &&
- this.now.get().isBefore(this.data().dueAt)) {
- classes += 'current';
+ const dueAt = this.data().dueAt;
+ if (dueAt) {
+ if (this.date.get().isBefore(this.now.get(), 'minute') &&
+ this.now.get().isBefore(dueAt)) {
+ classes += 'current';
+ }
}
return classes;
}
@@ -279,18 +285,23 @@ class CardDueDate extends CardDate {
classes() {
let classes = 'due-date' + ' ';
+
// if endAt exists & is < dueAt, dueAt doesn't need to be flagged
- if ((this.data().endAt !== 0) &&
- (this.data().endAt !== null) &&
- (this.data().endAt !== '') &&
- (this.data().endAt !== undefined) &&
- (this.date.get().isBefore(this.data().endAt)))
+ const endAt = this.data().endAt;
+ const theDate = this.date.get();
+ const now = this.now.get();
+
+ if ((endAt !== 0) &&
+ (endAt !== null) &&
+ (endAt !== '') &&
+ (endAt !== undefined) &&
+ (theDate.isBefore(endAt)))
classes += 'current';
- else if (this.now.get().diff(this.date.get(), 'days') >= 2)
+ else if (now.diff(theDate, 'days') >= 2)
classes += 'long-overdue';
- else if (this.now.get().diff(this.date.get(), 'minute') >= 0)
+ else if (now.diff(theDate, 'minute') >= 0)
classes += 'due';
- else if (this.now.get().diff(this.date.get(), 'days') >= -1)
+ else if (now.diff(theDate, 'days') >= -1)
classes += 'almost-due';
return classes;
}
@@ -318,12 +329,16 @@ class CardEndDate extends CardDate {
classes() {
let classes = 'end-date' + ' ';
- if (this.data.dueAt.diff(this.date.get(), 'days') >= 2)
- classes += 'long-overdue';
- else if (this.data.dueAt.diff(this.date.get(), 'days') > 0)
- classes += 'due';
- else if (this.data.dueAt.diff(this.date.get(), 'days') <= 0)
- classes += 'current';
+ const dueAt = this.data.dueAt;
+ if (dueAt) {
+ const diff = dueAt.diff(this.date.get(), 'days');
+ if (diff >= 2)
+ classes += 'long-overdue';
+ else if (diff > 0)
+ classes += 'due';
+ else if (diff <= 0)
+ classes += 'current';
+ }
return classes;
}