From ea0b298b78d9104695ff3b0236f797a5b9177466 Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Mon, 14 Oct 2013 12:59:39 +0100 Subject: [PATCH] Deal with viewing date fields that don't exist --- core/modules/new_widgets/view.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/core/modules/new_widgets/view.js b/core/modules/new_widgets/view.js index 988c96964..e78a7bd0a 100755 --- a/core/modules/new_widgets/view.js +++ b/core/modules/new_widgets/view.js @@ -80,7 +80,11 @@ ViewWidget.prototype.getValueAsText = function() { // Calling getTiddlerText() triggers lazy loading of skinny tiddlers text = this.wiki.getTiddlerText(this.viewTitle); } else { - text = tiddler.fields[this.viewField]; + if($tw.utils.hop(tiddler.fields,this.viewField)) { + text = tiddler.fields[this.viewField]; + } else { + text = ""; + } } } else { // Use a special value if the tiddler is missing switch(this.viewField) { @@ -112,8 +116,12 @@ ViewWidget.prototype.getValueAsDate = function(format) { }; ViewWidget.prototype.getValueAsRelativeDate = function(format) { - var d = new Date(this.getValueAsText()); - return $tw.utils.getRelativeDate((new Date()) - d).description; + var value = this.getValueAsText(); + if(value) { + return $tw.utils.getRelativeDate((new Date()) - (new Date(value))).description; + } else { + return ""; + } }; /*