Starts fixing: U4-2947 Fix complex property editors with $watch expressions
This commit is contained in:
@@ -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]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
};
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user