do not update content previews when the content has not changed

This commit is contained in:
2019-10-22 11:45:09 +02:00
parent d263caba29
commit cd019d5617
@@ -12,6 +12,7 @@ angular.module('umbraco.directives').directive('unContent', function ($compile)
}, },
link: function (scope, element) link: function (scope, element)
{ {
var content = null;
// get template // get template
var template = scope.config && scope.config.nameTemplate ? scope.config.nameTemplate : null; var template = scope.config && scope.config.nameTemplate ? scope.config.nameTemplate : null;
@@ -31,6 +32,11 @@ angular.module('umbraco.directives').directive('unContent', function ($compile)
// compile & render template // compile & render template
function render() function render()
{ {
if (content === JSON.stringify(scope.item))
{
return;
}
// merge element values into local scope // merge element values into local scope
angular.merge(scope, scope.item); angular.merge(scope, scope.item);
@@ -45,6 +51,8 @@ angular.module('umbraco.directives').directive('unContent', function ($compile)
// create html and compile // create html and compile
element.html(template); element.html(template);
$compile(element.contents())(scope); $compile(element.contents())(scope);
content = JSON.stringify(scope.item);
} }
var unsubscribe = scope.$watch('item', function (value) var unsubscribe = scope.$watch('item', function (value)
@@ -468,7 +476,6 @@ angular.module("umbraco.directives").directive('uNestingContentEditor', [
{ {
if (tab.alias.toLowerCase() === $scope.selectedTab.alias.toLowerCase()) if (tab.alias.toLowerCase() === $scope.selectedTab.alias.toLowerCase())
{ {
var localPropsMap = $scope.selectedTab.properties.reduce(function (map, obj) var localPropsMap = $scope.selectedTab.properties.reduce(function (map, obj)
{ {
map[obj.alias] = obj; map[obj.alias] = obj;