Refactort the scope.nodeUrl to be updated whenever save is hit in the existing update watcher

This commit is contained in:
Jan Skovgaard
2018-08-21 14:52:00 +02:00
parent e6597d47e3
commit 8f2c253138

View File

@@ -11,8 +11,8 @@
scope.allowOpenMediaType = true;
// get document type details
scope.mediaType = scope.node.contentType;
// get node url
scope.nodeUrl = scope.node.mediaLink;
// set the media link initially
setMediaLink();
// make sure dates are formatted to the user's locale
formatDatesToLocal();
}
@@ -25,16 +25,25 @@
});
}
function setMediaLink(){
scope.nodeUrl = scope.node.mediaLink;
}
scope.openMediaType = function (mediaType) {
// remove first "#" from url if it is prefixed else the path won't work
var url = "/settings/mediaTypes/edit/" + mediaType.id;
$location.path(url);
};
// watch for content updates - reload content when node is saved, published etc.
scope.$watch('node.updateDate', function(newValue, oldValue){
if(!newValue) { return; }
if(newValue === oldValue) { return; }
// Update the media link
setMediaLink();
// Update the create and update dates
formatDatesToLocal();
});
@@ -46,7 +55,6 @@
});
onInit();
}
var directive = {
@@ -64,4 +72,4 @@
angular.module('umbraco.directives').directive('umbMediaNodeInfo', MediaNodeInfoDirective);
})();
})();