diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/property.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/umbproperty.directive.js similarity index 83% rename from src/Umbraco.Web.UI.Client/src/common/directives/property.directive.js rename to src/Umbraco.Web.UI.Client/src/common/directives/umbproperty.directive.js index 8d719c9d47..7c94c39ee7 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/property.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/umbproperty.directive.js @@ -1,5 +1,5 @@ angular.module("umbraco.directives") - .directive('umbProperty', function(){ + .directive('umbProperty', function (umbPropEditorHelper) { return { scope: true, restrict: 'E', @@ -20,18 +20,18 @@ angular.module("umbraco.directives") //the script loaded so load the view //NOTE: The use of $apply because we're operating outside of the angular scope with this callback. scope.$apply(function () { - scope.model.editorView = scope.model.view; + scope.model.editorView = umbPropEditorHelper.getViewPath(scope.model.view); }); }, function (err) { //an error occurred... most likely there is no JS file to load for this editor //NOTE: The use of $apply because we're operating outside of the angular scope with this callback. scope.$apply(function () { - scope.model.editorView = scope.model.view; + scope.model.editorView = umbPropEditorHelper.getViewPath(scope.model.view); }); }); } else { - scope.model.editorView = scope.model.view; + scope.model.editorView = umbPropEditorHelper.getViewPath(scope.model.view); } } }; diff --git a/src/Umbraco.Web.UI.Client/src/common/filters/propertyeditor.filter.js b/src/Umbraco.Web.UI.Client/src/common/filters/propertyeditor.filter.js deleted file mode 100644 index bc756f09db..0000000000 --- a/src/Umbraco.Web.UI.Client/src/common/filters/propertyeditor.filter.js +++ /dev/null @@ -1,25 +0,0 @@ -/** -* @ngdoc filter -* @name umbraco.filters:propertyEditor -* @description This will ensure that the view for the property editor is rendered correctly, meaning it will check for an absolute path, otherwise load it in the normal umbraco path -**/ -function propertyEditorFilter($log) { - return function (input) { - //if its not defined then return undefined - if (!input){ - return input; - } - - //Added logging here because this fires a ton of times and not sure that it should be! - //$log.info("Filtering property editor view: " + input); - var path = String(input); - if (path.startsWith('/')) { - return path; - } - else { - return "views/propertyeditors/" + path.replace('.', '/') + "/editor.html"; - } - }; -} - -angular.module("umbraco.filters").filter('propertyEditor', propertyEditorFilter); \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/common/services/utill.service.js b/src/Umbraco.Web.UI.Client/src/common/services/utill.service.js index 741d00d55f..dc7b1451fe 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/utill.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/utill.service.js @@ -1,5 +1,36 @@ /*Contains multiple services for various helper tasks */ +/** +* @ngdoc factory +* @name umbraco.services:umbPropertyEditorHelper +* @description A helper object used for property editors +**/ +function umbPropEditorHelper() { + return { + /** + * @ngdoc function + * @name getImagePropertyValue + * @methodOf umbPropEditorHelper + * @function + * + * @description + * Returns the correct view path for a property editor, it will detect if it is a full virtual path but if not then default to the internal umbraco one + * + * @param input {string} the view path currently stored for the property editor + */ + getViewPath: function (input) { + var path = String(input); + if (path.startsWith('/')) { + return path; + } + else { + return "views/propertyeditors/" + path.replace('.', '/') + "/editor.html"; + } + } + }; +} +angular.module('umbraco.services').factory('umbPropEditorHelper', umbPropEditorHelper); + /** * @ngdoc factory * @name umbraco.services:umbImageHelper diff --git a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/macropicker.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/macropicker.controller.js index 4d8a764716..cd78e3e7f3 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/macropicker.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/macropicker.controller.js @@ -1,10 +1,14 @@ //used for the macro picker dialog -angular.module("umbraco").controller("Umbraco.Dialogs.MacroPickerController", function ($scope, macroFactory) { +angular.module("umbraco").controller("Umbraco.Dialogs.MacroPickerController", function ($scope, macroFactory, umbPropEditorHelper) { $scope.macros = macroFactory.all(true); $scope.dialogMode = "list"; $scope.configureMacro = function(macro){ $scope.dialogMode = "configure"; $scope.dialogData.macro = macroFactory.getMacro(macro.alias); + //set the correct view for each item + for (var i = 0; i < dialogData.macro.properties.length; i++) { + dialogData.macro.properties[i].editorView = umbPropEditorHelper.getViewPath(dialogData.macro.properties[i].view); + } }; }); \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/macropicker.html b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/macropicker.html index 6c169f2d20..9918f13c8e 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/macropicker.html +++ b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/macropicker.html @@ -31,7 +31,7 @@