Removes property editor filter as it gets executed too many times, changed this into a helper method.

This commit is contained in:
Shannon
2013-06-18 19:02:53 +10:00
parent 9720717076
commit 3caa44d26b
7 changed files with 43 additions and 33 deletions

View File

@@ -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);
}
}
};

View File

@@ -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);

View File

@@ -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

View File

@@ -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);
}
};
});

View File

@@ -31,7 +31,7 @@
</label>
<div class="controls"
ng-include="model.view | propertyEditor">
ng-include="model.editorView">
</div>

View File

@@ -14,7 +14,7 @@
</label>
<div class="controls controls-row" >
<ng-include src="model.editorView | propertyEditor"></ng-include>
<ng-include src="model.editorView"></ng-include>
</div>
</div>

View File

@@ -14,7 +14,7 @@
</label>
<div class="controls controls-row" >
<ng-include src="model.editorView | propertyEditor"></ng-include>
<ng-include src="model.editorView"></ng-include>
</div>
</div>