null-checking in date display for approved sites.
parent
d67a492b6c
commit
c1607b53e4
|
@ -118,22 +118,37 @@ var ApprovedSiteView = Backbone.View.extend({
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
|
|
||||||
var creationDate = moment(this.model.get("creationDate"));
|
var creationDate = this.model.get("creationDate");
|
||||||
var accessDate = moment(this.model.get("accessDate"));
|
var accessDate = this.model.get("accessDate");
|
||||||
|
var timeoutDate = this.model.get("timeoutDate");
|
||||||
var timeoutDate = moment(this.model.get("timeoutDate")).calendar();
|
|
||||||
|
|
||||||
|
if (creationDate == null) {
|
||||||
|
creationDate = "Unknown";
|
||||||
|
} else {
|
||||||
|
creationDate = moment(creationDate);
|
||||||
if (moment().diff(creationDate, 'months') < 6) {
|
if (moment().diff(creationDate, 'months') < 6) {
|
||||||
creationDate = creationDate.fromNow();
|
creationDate = creationDate.fromNow();
|
||||||
} else {
|
} else {
|
||||||
creationDate = creationDate.format("MMMM Do, YYYY");
|
creationDate = creationDate.format("MMMM Do, YYYY");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (accessDate == null) {
|
||||||
|
accessDate = "Unknown";
|
||||||
|
} else {
|
||||||
|
accessDate = moment(accessDate);
|
||||||
if (moment().diff(accessDate, 'months') < 6) {
|
if (moment().diff(accessDate, 'months') < 6) {
|
||||||
accessDate = accessDate.fromNow();
|
accessDate = accessDate.fromNow();
|
||||||
} else {
|
} else {
|
||||||
accessDate = accessDate.format("MMMM Do, YYYY");
|
accessDate = accessDate.format("MMMM Do, YYYY");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (timeoutDate == null) {
|
||||||
|
timeoutDate = "Never";
|
||||||
|
} else {
|
||||||
|
timeoutDate = moment(timeoutDate).calendar();
|
||||||
|
}
|
||||||
|
|
||||||
var formattedDate = {creationDate: creationDate, accessDate: accessDate, timeoutDate: timeoutDate};
|
var formattedDate = {creationDate: creationDate, accessDate: accessDate, timeoutDate: timeoutDate};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue