diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js index 2264d1351c..774d3276f1 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js @@ -49,6 +49,40 @@ } + function getNode() { + + $scope.page.loading = true; + + //we are editing so get the content item from the server + $scope.getMethod()($scope.contentId) + .then(function (data) { + + $scope.content = data; + + if (data.isChildOfListView && data.trashed === false) { + $scope.page.listViewPath = ($routeParams.page) ? + "/content/content/edit/" + data.parentId + "?page=" + $routeParams.page : + "/content/content/edit/" + data.parentId; + } + + init($scope.content); + + //in one particular special case, after we've created a new item we redirect back to the edit + // route but there might be server validation errors in the collection which we need to display + // after the redirect, so we will bind all subscriptions which will show the server validation errors + // if there are any and then clear them so the collection no longer persists them. + serverValidationManager.executeAndClearAllSubscriptions(); + + syncTreeNode($scope.content, data.path, true); + + resetLastListPageNumber($scope.content); + + $scope.page.loading = false; + + }); + + } + function createButtons(content) { var buttons = contentEditingHelper.configureContentEditorButtons({ create: $scope.page.isNew, @@ -152,35 +186,8 @@ } else { - $scope.page.loading = true; + getNode(); - //we are editing so get the content item from the server - $scope.getMethod()($scope.contentId) - .then(function (data) { - - $scope.content = data; - - if (data.isChildOfListView && data.trashed === false) { - $scope.page.listViewPath = ($routeParams.page) ? - "/content/content/edit/" + data.parentId + "?page=" + $routeParams.page : - "/content/content/edit/" + data.parentId; - } - - init($scope.content); - - //in one particular special case, after we've created a new item we redirect back to the edit - // route but there might be server validation errors in the collection which we need to display - // after the redirect, so we will bind all subscriptions which will show the server validation errors - // if there are any and then clear them so the collection no longer persists them. - serverValidationManager.executeAndClearAllSubscriptions(); - - syncTreeNode($scope.content, data.path, true); - - resetLastListPageNumber($scope.content); - - $scope.page.loading = false; - - }); } @@ -316,6 +323,9 @@ $scope.page.buttonRestore = "success"; notificationsService.success("Successfully restored " + node.name + " to " + target.name); + // reload the node + getNode(); + }, function (err) { $scope.page.buttonRestore = "error"; notificationsService.error("Cannot automatically restore this item", err); diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbcontentnodeinfo.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbcontentnodeinfo.directive.js index bbae025d3e..0f9a560ff2 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbcontentnodeinfo.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbcontentnodeinfo.directive.js @@ -1,9 +1,13 @@ (function () { 'use strict'; - function ContentNodeInfoDirective($timeout, $location, logResource, eventsService, userService) { + function ContentNodeInfoDirective($timeout, $location, logResource, eventsService, userService, localizationService) { function link(scope, element, attrs, ctrl) { + + var evts = []; + var isInfoTab = false; + scope.publishStatus = {}; function onInit() { @@ -32,15 +36,10 @@ // get document type details scope.documentType = scope.node.documentType; - // load audit trail when on the info tab - eventsService.on("app.tabChange", function (event, args) { - if (args.id === -1) { - loadAuditTrail(); - } - }); - // make sure dates are formatted to the user's locale formatDatesToLocal(); + + setNodePublishStatus(scope.node); } @@ -120,6 +119,34 @@ }); } + function setNodePublishStatus(node) { + + // deleted node + if(node.trashed === true) { + scope.publishStatus.label = localizationService.localize("general_deleted"); + scope.publishStatus.color = "danger"; + } + + // unpublished node + if(node.published === false && node.trashed === false) { + scope.publishStatus.label = localizationService.localize("content_unpublished"); + scope.publishStatus.color = "gray"; + } + + // published node + if(node.hasPublishedVersion === true && node.publishDate && node.published === true) { + scope.publishStatus.label = localizationService.localize("content_published"); + scope.publishStatus.color = "success"; + } + + // published node with pending changes + if(node.hasPublishedVersion === true && node.publishDate && node.published === false) { + scope.publishStatus.label = localizationService.localize("content_publishedPendingChanges"); + scope.publishStatus.color = "success" + } + + } + function setPublishDate(date) { // update publish value @@ -200,6 +227,38 @@ }); } + // load audit trail when on the info tab + evts.push(eventsService.on("app.tabChange", function (event, args) { + $timeout(function(){ + if (args.id === -1) { + isInfoTab = true; + loadAuditTrail(); + } else { + isInfoTab = false; + } + }); + })); + + // 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; } + + if(isInfoTab) { + loadAuditTrail(); + formatDatesToLocal(); + setNodePublishStatus(scope.node); + } + }); + + //ensure to unregister from all events! + scope.$on('$destroy', function () { + for (var e in evts) { + eventsService.unsubscribe(evts[e]); + } + }); + onInit(); } diff --git a/src/Umbraco.Web.UI.Client/src/views/components/content/umb-content-node-info.html b/src/Umbraco.Web.UI.Client/src/views/components/content/umb-content-node-info.html index 28f00ca0e3..1bb6e77840 100644 --- a/src/Umbraco.Web.UI.Client/src/views/components/content/umb-content-node-info.html +++ b/src/Umbraco.Web.UI.Client/src/views/components/content/umb-content-node-info.html @@ -165,6 +165,12 @@ + + + + {{publishStatus.label}} + + {{node.createDateFormatted}} by {{ node.owner.name }} diff --git a/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml b/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml index 8a5ab85793..b765116090 100644 --- a/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml +++ b/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml @@ -197,6 +197,8 @@ Could not get the url This document is published but its url would collide with content %0% Publish + Published + Published (pending changes) Publication Status Publish at Unpublish at @@ -209,6 +211,7 @@ Alternative text (optional) Type Unpublish + Unpublished Last edited Date/time this document was edited Remove file(s)