From ef3a7b720f0bddf4d78b517ca0d1e4b4cc1b255d Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Fri, 6 Feb 2015 15:11:57 +0530 Subject: [PATCH] pass empty result to updateAnnotation to handle invalid entity input --- static/js/editor.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/static/js/editor.js b/static/js/editor.js index e585c114d..3fbcc4196 100644 --- a/static/js/editor.js +++ b/static/js/editor.js @@ -149,14 +149,16 @@ pandora.ui.editor = function(data) { Ox.Log('', 'editAnnotation', data); function callback(result) { Ox.Log('', 'editAnnotation result', result); - result.data.date = Ox.formatDate( - result.data.modified.slice(0, 10), '%B %e, %Y' - ); - result.data.languages = ( - result.data.languages || [pandora.site.language] - ).map(function(language) { - return Ox.getLanguageNameByCode(language); - }); + if (!Ox.isEmpty(result.data)) { + result.data.date = Ox.formatDate( + result.data.modified.slice(0, 10), '%B %e, %Y' + ); + result.data.languages = ( + result.data.languages || [pandora.site.language] + ).map(function(language) { + return Ox.getLanguageNameByCode(language); + }); + } that.updateAnnotation(data.id, result.data); Ox.Request.clearCache(); };