V8: Show the breadcrumb when creating new content (#6128)

This commit is contained in:
Kenn Jacobsen
2019-09-30 18:51:05 +02:00
committed by Sebastiaan Janssen
parent f1b724bdc4
commit 985df6e32b
4 changed files with 17 additions and 11 deletions

View File

@@ -36,14 +36,13 @@
//initializes any watches
function startWatches(content) {
//watch for changes to isNew & the content.id, set the page.isNew accordingly and load the breadcrumb if we can
$scope.$watchGroup(['isNew', 'content.id'], function (newVal, oldVal) {
var contentId = newVal[1];
$scope.page.isNew = Object.toBoolean(newVal[0]);
//watch for changes to isNew, set the page.isNew accordingly and load the breadcrumb if we can
$scope.$watch('isNew', function (newVal, oldVal) {
$scope.page.isNew = Object.toBoolean(newVal);
//We fetch all ancestors of the node to generate the footer breadcrumb navigation
if (!$scope.page.isNew && contentId && content.parentId && content.parentId !== -1) {
if (content.parentId && content.parentId !== -1) {
loadBreadcrumb();
if (!watchingCulture) {
$scope.$watch('culture',
@@ -115,7 +114,12 @@
}
function loadBreadcrumb() {
entityResource.getAncestors($scope.content.id, "document", $scope.culture)
// load the parent breadcrumb when creating new content
var id = $scope.page.isNew ? $scope.content.parentId : $scope.content.id;
if (!id) {
return;
}
entityResource.getAncestors(id, "document", $scope.culture)
.then(function (anc) {
$scope.ancestors = anc;
});

View File

@@ -96,6 +96,7 @@ Use this directive to generate a list of breadcrumbs.
templateUrl: 'views/components/editor/umb-breadcrumbs.html',
scope: {
ancestors: "=",
forNewEntity: "=",
entityType: "@",
onOpen: "&"
},

View File

@@ -24,6 +24,7 @@
<umb-breadcrumbs
ng-if="ancestors && ancestors.length > 0"
ancestors="ancestors"
for-new-entity="page.isNew"
entity-type="content">
</umb-breadcrumbs>

View File

@@ -2,14 +2,14 @@
<li class="umb-breadcrumbs__ancestor" ng-repeat="ancestor in ancestors">
<!-- go to node on click -->
<a ng-if="!$last && !allowOnOpen" ng-href="#{{::pathTo(ancestor)}}" ng-click="openPath(ancestor, $event)" class="umb-breadcrumbs__ancestor-link" title="{{ancestor.name}}">{{ancestor.name}}</a>
<a ng-if="(!$last || forNewEntity) && !allowOnOpen" ng-href="#{{::pathTo(ancestor)}}" ng-click="openPath(ancestor, $event)" class="umb-breadcrumbs__ancestor-link" title="{{ancestor.name}}">{{ancestor.name}}</a>
<!-- use callback to handle click -->
<a ng-if="!$last && allowOnOpen" href="#" ng-click="open(ancestor)" class="umb-breadcrumbs__ancestor-link" title="{{ancestor.name}}" prevent-default>{{ancestor.name}}</a>
<a ng-if="(!$last || forNewEntity) && allowOnOpen" href="#" ng-click="open(ancestor)" class="umb-breadcrumbs__ancestor-link" title="{{ancestor.name}}" prevent-default>{{ancestor.name}}</a>
<span ng-if="!$last" class="umb-breadcrumbs__separator">&#47;</span>
<span ng-if="(!$last || forNewEntity)" class="umb-breadcrumbs__separator">&#47;</span>
<span class="umb-breadcrumbs__ancestor-text" ng-if="$last" title="{{ancestor.name}}">{{ancestor.name}}</span>
<span class="umb-breadcrumbs__ancestor-text" ng-if="$last && !forNewEntity" title="{{ancestor.name}}">{{ancestor.name}}</span>
</li>
</ul>