From 3a9ad91f8ff8d60f29d7579ca04c0acf403caf7a Mon Sep 17 00:00:00 2001 From: Per Ploug Date: Wed, 18 Mar 2015 11:45:22 +0100 Subject: [PATCH] Adds better error handling to missing grid editors --- .../propertyeditors/grid/editors/error.html | 2 ++ .../propertyeditors/grid/grid.controller.js | 25 ++++++++++++++----- 2 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/editors/error.html diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/editors/error.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/editors/error.html new file mode 100644 index 0000000000..67ef4ea112 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/editors/error.html @@ -0,0 +1,2 @@ +

Something went wrong with this editor, below is the data stored:

+
{{control | json}}
\ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/grid.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/grid.controller.js index f802173a25..11afb678a2 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/grid.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/grid.controller.js @@ -572,18 +572,31 @@ angular.module("umbraco") control.$index = index; control.$uniqueId = $scope.setUniqueId(); + //error handling in case of missing editor.. + //should only happen if stripped earlier + if(!control.editor){ + control.$editorPath = "views/propertyeditors/grid/editors/error.html"; + } + if(!control.$editorPath){ var editorConfig = $scope.getEditor(control.editor.alias); - control.editor = editorConfig; - //if its a path - if(_.indexOf(control.editor.view, "/") >= 0){ - control.$editorPath = control.editor.view; + if(editorConfig){ + control.editor = editorConfig; + + //if its a path + if(_.indexOf(control.editor.view, "/") >= 0){ + control.$editorPath = control.editor.view; + }else{ + //use convention + control.$editorPath = "views/propertyeditors/grid/editors/" + control.editor.view + ".html"; + } }else{ - //use convention - control.$editorPath = "views/propertyeditors/grid/editors/" + control.editor.view + ".html"; + control.$editorPath = "views/propertyeditors/grid/editors/error.html"; } } + + };