Starts fixing: U4-2947 Fix complex property editors with $watch expressions

This commit is contained in:
Shannon
2013-09-30 20:33:19 +10:00
parent 9ff74b39f8
commit 472ef6e48c
2 changed files with 17 additions and 7 deletions

View File

@@ -55,8 +55,19 @@ function contentEditingHelper($location, $routeParams, notificationsService, ser
for (var p in allOrigProps) {
var newProp = getNewProp(allOrigProps[p].alias);
if (newProp && !_.isEqual(allOrigProps[p].value, newProp.value)) {
//they have changed so set the origContent prop to the new one
var origVal = allOrigProps[p].value;
allOrigProps[p].value = newProp.value;
//instead of having a property editor $watch their expression to check if it has
// been updated, instead we'll check for the existence of a special method on their model
// and just call it.
if (angular.isFunction(allOrigProps[p].onValueChanged)) {
//send the newVal + oldVal
allOrigProps[p].onValueChanged(allOrigProps[p].value, origVal);
}
changed.push(allOrigProps[p]);
}
}

View File

@@ -12,12 +12,11 @@ angular.module('umbraco').controller("Umbraco.Editors.UrlListController",
formatDisplayValue();
//we need to put a watch on the real model because when it changes we have to update our renderModel
$scope.$watch("model.value", function (newVal, oldVal) {
if (newVal !== null && newVal !== undefined && newVal !== oldVal) {
//update the display val again
formatDisplayValue();
}
});
//here we declare a special method which will be called whenever the value has changed from the server
//this is instead of doing a watch on the model.value = faster
$scope.model.onValueChanged = function(newVal, oldVal) {
//update the display val again
formatDisplayValue();
};
});