mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-28 22:42:11 +01:00
#3051 Fix Remission Routing after Remission Completed
This commit is contained in:
@@ -17,6 +17,10 @@ export class CreateRemissionComponent implements OnInit {
|
||||
@ViewChild(UiSearchboxNextComponent)
|
||||
searchboxComponent: UiSearchboxNextComponent;
|
||||
|
||||
get processId() {
|
||||
return this._config.get('process.ids.remission');
|
||||
}
|
||||
|
||||
loading$ = new Subject<boolean>();
|
||||
|
||||
hint$ = new Subject<string>();
|
||||
@@ -38,8 +42,9 @@ export class CreateRemissionComponent implements OnInit {
|
||||
private readonly _config: Config
|
||||
) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.addBreadcrumbIfNotExists();
|
||||
async ngOnInit() {
|
||||
await this.removeBreadcrumbs();
|
||||
await this.addBreadcrumbIfNotExists();
|
||||
}
|
||||
|
||||
async startRemission(receiptNumber?: string) {
|
||||
@@ -80,8 +85,8 @@ export class CreateRemissionComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
addBreadcrumbIfNotExists() {
|
||||
this._breadcrumb.addBreadcrumbIfNotExists({
|
||||
async addBreadcrumbIfNotExists() {
|
||||
await this._breadcrumb.addBreadcrumbIfNotExists({
|
||||
key: this._config.get('process.ids.remission'),
|
||||
name: 'Warenbegleitschein eröffnen',
|
||||
path: '/filiale/remission/create',
|
||||
@@ -90,4 +95,11 @@ export class CreateRemissionComponent implements OnInit {
|
||||
tags: ['remission', 'create'],
|
||||
});
|
||||
}
|
||||
|
||||
async removeBreadcrumbs() {
|
||||
await this._breadcrumb.removeBreadcrumbsByKeyAndTags(this.processId, ['remission', 'shipping-documents']);
|
||||
await this._breadcrumb.removeBreadcrumbsByKeyAndTags(this.processId, ['remission', 'add-product']);
|
||||
await this._breadcrumb.removeBreadcrumbsByKeyAndTags(this.processId, ['remission', 'finish-shipping-document']);
|
||||
await this._breadcrumb.removeBreadcrumbsByKeyAndTags(this.processId, ['remission', 'finish-remission']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { ChangeDetectionStrategy, Component, OnDestroy, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { ApplicationService } from '@core/application';
|
||||
import { BreadcrumbService } from '@core/breadcrumb';
|
||||
import { CacheService } from '@core/cache';
|
||||
import { Config } from '@core/config';
|
||||
@@ -19,6 +20,7 @@ export class FinishRemissionComponent implements OnInit, OnDestroy {
|
||||
|
||||
constructor(
|
||||
private _activatedRoute: ActivatedRoute,
|
||||
private _applicationService: ApplicationService,
|
||||
private _modal: UiModalService,
|
||||
private _remissionService: DomainRemissionService,
|
||||
private _router: Router,
|
||||
@@ -41,8 +43,9 @@ export class FinishRemissionComponent implements OnInit, OnDestroy {
|
||||
if (returnId) {
|
||||
try {
|
||||
const returnDto = await this._remissionService.getReturn(returnId).toPromise();
|
||||
this._router.navigate(['/filiale', 'remission', 'create', returnDto.returnGroup], {
|
||||
queryParams: { supplierId: returnDto.supplier.id },
|
||||
this.clearProcessData();
|
||||
await this._router.navigate(['/filiale', 'remission', 'create', returnDto.returnGroup], {
|
||||
queryParams: { supplier: returnDto.supplier.id },
|
||||
});
|
||||
} catch (err) {
|
||||
this._modal.open({
|
||||
@@ -66,7 +69,8 @@ export class FinishRemissionComponent implements OnInit, OnDestroy {
|
||||
if (returnId) {
|
||||
try {
|
||||
await this._remissionService.completeRemission(returnId);
|
||||
this.navigateToList();
|
||||
this.clearProcessData();
|
||||
await this.navigateToList();
|
||||
} catch (err) {
|
||||
this._modal.open({
|
||||
content: UiErrorModalComponent,
|
||||
@@ -83,8 +87,16 @@ export class FinishRemissionComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
navigateToList() {
|
||||
this._router.navigate(['/filiale', 'remission', 'list']);
|
||||
async navigateToList() {
|
||||
await this._router.navigate(['/filiale', 'remission', 'list']);
|
||||
}
|
||||
|
||||
clearProcessData() {
|
||||
// Muss beim Abschließen der Remission erfolgen, da er sonst auf die Liste routet (siehe remission.component.ts updateProcess())
|
||||
this._applicationService.patchProcess(this.processId, {
|
||||
closeable: true,
|
||||
data: {},
|
||||
});
|
||||
}
|
||||
|
||||
addBreadcrumbIfNotExists() {
|
||||
|
||||
@@ -59,7 +59,6 @@ export class RemissionComponent implements OnInit, OnDestroy {
|
||||
async updateProcess() {
|
||||
const params = this._activatedRoute.snapshot.firstChild.params;
|
||||
const process = await this._applicationService.getProcessById$(this.processId).pipe(first()).toPromise();
|
||||
|
||||
if (!!params?.returnId) {
|
||||
if (process?.data?.active !== +params.returnId) {
|
||||
this._applicationService.patchProcess(this.processId, {
|
||||
@@ -68,7 +67,7 @@ export class RemissionComponent implements OnInit, OnDestroy {
|
||||
});
|
||||
}
|
||||
} else if (!!process?.data?.active) {
|
||||
this._router.navigate(['./', process?.data?.active, 'list'], { relativeTo: this._activatedRoute });
|
||||
await this._router.navigate(['./', process?.data?.active, 'list'], { relativeTo: this._activatedRoute });
|
||||
} else {
|
||||
this._applicationService.patchProcess(this.processId, {
|
||||
closeable: true,
|
||||
|
||||
Reference in New Issue
Block a user