merge tag '875-Breadcrumb-Remission-Review-Zuruecksetzen-Verhalten' into develop

This commit is contained in:
Michael Auer
2020-09-01 15:25:37 +02:00
3 changed files with 78 additions and 40 deletions

View File

@@ -6,13 +6,16 @@ import {
ChangeDetectionStrategy,
ViewChild,
ElementRef,
AfterViewInit
AfterViewInit,
} from '@angular/core';
import { Subject, Observable } from 'rxjs';
import { Breadcrumb } from '../../core/models/breadcrumb.model';
import { Process } from '../../core/models/process.model';
import { Store, Select } from '@ngxs/store';
import { ChangeCurrentRoute, ResetProcessProductFilters } from '../../core/store/actions/process.actions';
import {
ChangeCurrentRoute,
ResetProcessProductFilters,
} from '../../core/store/actions/process.actions';
import { Router } from '@angular/router';
import { takeUntil, switchMap, distinctUntilChanged } from 'rxjs/operators';
import { SharedSelectors } from '../../core/store/selectors/shared.selectors';
@@ -21,8 +24,6 @@ import { AppService } from '../../core/services/app.service';
import { ModuleSwitcher } from '../../core/models/app-switcher.enum';
import { BranchProcess } from '../../core/models/branch-process.model';
import { SetBranchProcessCurrentPath } from '../../core/store/actions/branch-process.actions';
import { SetRemissionStarted, ResetRemissionShippingDocument } from '../../core/store/actions/remission.actions';
import { RemissionSelectors } from '../../core/store/selectors/remission.selectors';
import { AppState } from '../../core/store/state/app.state';
import { FILIALE_LANDING_PAGE } from '../../core/utils/app.constants';
@@ -30,12 +31,17 @@ import { FILIALE_LANDING_PAGE } from '../../core/utils/app.constants';
selector: 'app-breadcrumbs',
templateUrl: './breadcrumbs.component.html',
styleUrls: ['./breadcrumbs.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class BreadcrumbsComponent implements OnInit, OnDestroy, AfterViewInit {
@ViewChild('container', { read: ElementRef, static: false }) public container: ElementRef<any>;
@Select(SharedSelectors.getBreadcrumbs) breadcrumbs$: Observable<Breadcrumb[]>;
@Select(SharedSelectors.getCurrentProcess) currentProcess$: Observable<Process>;
@ViewChild('container', { read: ElementRef, static: false })
public container: ElementRef<any>;
@Select(SharedSelectors.getBreadcrumbs) breadcrumbs$: Observable<
Breadcrumb[]
>;
@Select(SharedSelectors.getCurrentProcess) currentProcess$: Observable<
Process
>;
module: ModuleSwitcher;
destroy$ = new Subject();
breadcrumbs: Breadcrumb[] = [];
@@ -65,7 +71,10 @@ export class BreadcrumbsComponent implements OnInit, OnDestroy, AfterViewInit {
}
get backArrow() {
return this.router.url.substring(0, 16) === '/product/details' && this.breadsCount > 1;
return (
this.router.url.substring(0, 16) === '/product/details' &&
this.breadsCount > 1
);
}
get selectedBreadCrumbIndex() {
@@ -78,7 +87,7 @@ export class BreadcrumbsComponent implements OnInit, OnDestroy, AfterViewInit {
const endOfRouteWithOutParams = this.currentRoute.indexOf('?');
route = this.currentRoute.substring(0, endOfRouteWithOutParams);
}
return this.breadcrumbs.findIndex(t => t && t.path.indexOf(route) >= 0);
return this.breadcrumbs.findIndex((t) => t && t.path.indexOf(route) >= 0);
}
get lowerMargin() {
@@ -94,7 +103,12 @@ export class BreadcrumbsComponent implements OnInit, OnDestroy, AfterViewInit {
return false;
}
constructor(private store: Store, private router: Router, private cdrf: ChangeDetectorRef, private appService: AppService) { }
constructor(
private store: Store,
private router: Router,
private cdrf: ChangeDetectorRef,
private appService: AppService
) {}
getBreadcrumbsFromCurentProcess() {
this.currentProcess$
@@ -106,7 +120,10 @@ export class BreadcrumbsComponent implements OnInit, OnDestroy, AfterViewInit {
}
setTimeout(() => {
this.container.nativeElement.scrollTo({ left: this.container.nativeElement.scrollWidth, behavior: 'smooth' });
this.container.nativeElement.scrollTo({
left: this.container.nativeElement.scrollWidth,
behavior: 'smooth',
});
}, 400);
return this.breadcrumbs$;
}),
@@ -118,16 +135,24 @@ export class BreadcrumbsComponent implements OnInit, OnDestroy, AfterViewInit {
this.showBackNavigationArrow = false;
if (breadcrumbs) {
const breadName =
breadcrumbs.length > 0 ? (breadcrumbs[breadcrumbs.length - 1] ? breadcrumbs[breadcrumbs.length - 1].name : '') : '';
this.showBack = !(breadName === 'Bestellbestätigung' || breadName === 'Remission');
breadcrumbs.length > 0
? breadcrumbs[breadcrumbs.length - 1]
? breadcrumbs[breadcrumbs.length - 1].name
: ''
: '';
this.showBack = !(
breadName === 'Bestellbestätigung' || breadName === 'Remission'
);
this.breadcrumbs = breadcrumbs;
this.breadsCount = Object.keys(this.breadcrumbs) ? Object.keys(this.breadcrumbs).length : 0;
this.breadsCount = Object.keys(this.breadcrumbs)
? Object.keys(this.breadcrumbs).length
: 0;
this.cdrf.detectChanges();
if (!this.isIPad) {
setTimeout(() => {
try {
this.initNavigationalArrow();
} catch (error) { }
} catch (error) {}
}, 1000);
}
}
@@ -136,16 +161,6 @@ export class BreadcrumbsComponent implements OnInit, OnDestroy, AfterViewInit {
selectBreadcrumb(breadcrumb: Breadcrumb) {
if (breadcrumb && breadcrumb.path) {
if (breadcrumb.path === '/remission/create') {
const shipingDocumentProductCount = this.store.selectSnapshot(RemissionSelectors.getRemissionShippingDocumentProductCount);
if (shipingDocumentProductCount === 0) {
this.store.dispatch(new SetRemissionStarted(false));
this.store.dispatch(new ResetRemissionShippingDocument());
} else {
this.appService.openStartedRemissionLeavingDialog();
return;
}
}
if (breadcrumb.path === '/product/search') {
this.store.dispatch(new ResetFilters());
this.store.dispatch(new ResetProcessProductFilters());
@@ -153,9 +168,13 @@ export class BreadcrumbsComponent implements OnInit, OnDestroy, AfterViewInit {
if (this.module === ModuleSwitcher.Customer) {
this.store.dispatch(new ChangeCurrentRoute(breadcrumb.path, true));
} else {
this.store.dispatch(new SetBranchProcessCurrentPath(breadcrumb.path, true));
this.store.dispatch(
new SetBranchProcessCurrentPath(breadcrumb.path, true)
);
}
this.router.navigate([breadcrumb.path], { queryParams: breadcrumb.queryParams ? breadcrumb.queryParams : {} });
this.router.navigate([breadcrumb.path], {
queryParams: breadcrumb.queryParams ? breadcrumb.queryParams : {},
});
}
}
@@ -165,7 +184,9 @@ export class BreadcrumbsComponent implements OnInit, OnDestroy, AfterViewInit {
this.store.dispatch(new ChangeCurrentRoute(breadcrumb.path, false));
this.router.navigate(['/product/results']);
} else {
this.store.dispatch(new SetBranchProcessCurrentPath(breadcrumb.path, false));
this.store.dispatch(
new SetBranchProcessCurrentPath(breadcrumb.path, false)
);
this.router.navigate([FILIALE_LANDING_PAGE]);
}
}
@@ -188,7 +209,7 @@ export class BreadcrumbsComponent implements OnInit, OnDestroy, AfterViewInit {
setTimeout(() => {
try {
this.initNavigationalArrow();
} catch (error) { }
} catch (error) {}
}, 100);
}
}
@@ -200,7 +221,7 @@ export class BreadcrumbsComponent implements OnInit, OnDestroy, AfterViewInit {
addOne() {
this.breadcrumbs.push({
name: 'test' + (this.breadcrumbs ? this.breadcrumbs.length : 0),
path: './i'
path: './i',
});
}
@@ -215,7 +236,10 @@ export class BreadcrumbsComponent implements OnInit, OnDestroy, AfterViewInit {
elementProcessed++;
childrenWidth += this.container.nativeElement.children[i].offsetWidth;
}
if (breadcrumbs === elementProcessed && containerWidth <= childrenWidth) {
if (
breadcrumbs === elementProcessed &&
containerWidth <= childrenWidth
) {
this.showBackNavigationArrow = true;
this.cdrf.detectChanges();
} else {
@@ -233,7 +257,11 @@ export class BreadcrumbsComponent implements OnInit, OnDestroy, AfterViewInit {
hideBackNavArrow(event) {
if (event) {
const e = event.toElement || event.relatedTarget;
if (e && e.classList && (e.classList[0] === 'icon' || e.classList[0] === 'ng-star-inserted')) {
if (
e &&
e.classList &&
(e.classList[0] === 'icon' || e.classList[0] === 'ng-star-inserted')
) {
return;
}
this.showBackArrow = false;
@@ -251,7 +279,11 @@ export class BreadcrumbsComponent implements OnInit, OnDestroy, AfterViewInit {
hideForwardNavArrow(event) {
if (event) {
const e = event.toElement || event.relatedTarget;
if (e && e.classList && (e.classList[0] === 'icon' || e.classList[0] === 'ng-star-inserted')) {
if (
e &&
e.classList &&
(e.classList[0] === 'icon' || e.classList[0] === 'ng-star-inserted')
) {
return;
}
this.showForrwardArrow = false;
@@ -267,7 +299,10 @@ export class BreadcrumbsComponent implements OnInit, OnDestroy, AfterViewInit {
if (scrollLeft <= 121) {
this.showBackNavigationArrow = false;
}
this.container.nativeElement.scrollTo({ left: scrollLeft - 120, behavior: 'smooth' });
this.container.nativeElement.scrollTo({
left: scrollLeft - 120,
behavior: 'smooth',
});
this.showForwardNavigationalArrow = true;
this.cdrf.detectChanges();
}
@@ -279,7 +314,10 @@ export class BreadcrumbsComponent implements OnInit, OnDestroy, AfterViewInit {
if (scrollLeft + 119 + containerWidth <= scrollWidth) {
this.showForwardNavigationalArrow = false;
}
this.container.nativeElement.scrollTo({ left: scrollLeft + 120, behavior: 'smooth' });
this.container.nativeElement.scrollTo({
left: scrollLeft + 120,
behavior: 'smooth',
});
this.showBackNavigationArrow = true;
this.cdrf.detectChanges();
}

6
package-lock.json generated
View File

@@ -3285,9 +3285,9 @@
}
},
"@isa/remission": {
"version": "0.3.28",
"resolved": "https://pkgs.dev.azure.com/hugendubel/_packaging/hugendubel@Local/npm/registry/@isa/remission/-/remission-0.3.28.tgz",
"integrity": "sha1-5T0muSdyEYHJzYW6IJJfoShoqyw=",
"version": "0.3.29",
"resolved": "https://pkgs.dev.azure.com/hugendubel/_packaging/hugendubel/npm/registry/@isa/remission/-/remission-0.3.29.tgz",
"integrity": "sha1-JXGNa6DIGQnkcp75UrnBbxbxyDk=",
"requires": {
"tslib": "^1.9.0"
}

View File

@@ -59,7 +59,7 @@
"@isa/catsearch-api": "^0.0.56",
"@isa/print-api": "0.0.56",
"@isa/remi-api": "^0.0.56",
"@isa/remission": "^0.3.28",
"@isa/remission": "^0.3.29",
"@ng-idle/core": "^8.0.0-beta.4",
"@ng-idle/keepalive": "^8.0.0-beta.4",
"@ngxs/store": "^3.6.2",