Skip to content
Snippets Groups Projects
Commit 27c0d2b4 authored by OZGCloud's avatar OZGCloud
Browse files

OZG-635 encode/decode uri param

parent 998eb521
No related branches found
No related tags found
No related merge requests found
......@@ -49,6 +49,11 @@ export class NavigationService {
return NavigationService.decodeParamUrl(this.routeParameter$.value[paramName]);
}
public getDecodedUriParam(paramName: string): string {
if (isEmptyObject(this.routeParameter$.value) || isUndefined(this.routeParameter$.value[paramName])) return undefined;
return decodeURI(this.routeParameter$.value[paramName]);
}
static decodeParamUrl(encodedUrl: string): string {
let decodeUrl: string;
......
......@@ -11,9 +11,9 @@
} as orderCommands">
<goofy-client-subnavigation>
<a routerLink="/" mat-icon-button data-test-id="back-button" class="back-button">
<button (click)="navigateToList()" mat-icon-button data-test-id="back-button" class="back-button">
<mat-icon>arrow_back</mat-icon>
</a>
</button>
<goofy-client-vorgang-detail-action-buttons
[vorgangWithEingang]="vorgangStateResource"
[annehmenCommand]="orderCommands.annehmen" (annehmen)="annehmen()"
......
import { EventEmitter } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { MatIcon } from '@angular/material/icon';
import { RouterTestingModule } from '@angular/router/testing';
import { createStateResource, StateResource } from '@goofy-client/tech-shared';
import { getElementFromFixtureByCss, getElementFromFixtureByType, mock } from '@goofy-client/test-utils';
import { VorgangService, VorgangWithEingang, VorgangWithEingangResource } from '@goofy-client/vorgang-shared';
......@@ -37,6 +38,9 @@ describe('VorgangDetailPageComponent', () => {
MockComponent(VorgangDetailActionButtonsComponent),
MockComponent(VorgangDetailFormularButtonsComponent)
],
imports: [
RouterTestingModule
],
providers: [
{
provide: VorgangService,
......
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { StateResource } from '@goofy-client/tech-shared';
import { VorgangService, VorgangWithEingangResource } from '@goofy-client/vorgang-shared';
import { CommandResource } from 'libs/command-shared/src/lib/command.model';
import { isEmpty, isNil } from 'lodash-es';
import { combineLatest, Observable } from 'rxjs';
import { map } from 'rxjs/operators';
......@@ -25,7 +27,7 @@ export class VorgangDetailPageComponent implements OnInit {
abschliessenCommand$: Observable<StateResource<CommandResource>>;
wiedereroeffnenCommand$: Observable<StateResource<CommandResource>>;
constructor(private vorgangService: VorgangService) { }
constructor(private vorgangService: VorgangService, private router: Router) { }
ngOnInit(): void {
this.vorgangStateResource$ = this.vorgangService.getVorgangWithEingang();
......@@ -73,4 +75,13 @@ export class VorgangDetailPageComponent implements OnInit {
private getCommandStateResourceConsiderVorgangStateResource(commandStateResource: StateResource<CommandResource>, vorgangStateResource: StateResource<VorgangWithEingangResource>) {
return { ...commandStateResource, loading: commandStateResource.loading || vorgangStateResource.loading }
}
navigateToList(): void {
const search: string = this.vorgangService.getSearchCriteria();
if (!isNil(search) && !isEmpty(search)) {
this.router.navigate(['search/', encodeURI(search)]);
} else {
this.router.navigateByUrl('/');
}
}
}
......@@ -25,7 +25,7 @@ export class VorgangSearchFormService {
const search: string = this.getValue();
if (!isEmpty(search)) {
this.router.navigate([this.SEARCH_FIELD + '/', search]);
this.router.navigate([this.SEARCH_FIELD + '/', encodeURI(search)]);
} else {
this.router.navigateByUrl('/');
}
......
......@@ -158,24 +158,20 @@ export class VorgangService {
if (NavigationService.isVorgangListPage(params)) {
this.clearVorgang();
this.clearPendingRedirectCommand();
if(!isNull(this.searchByCriteria$.value)){
this.searchByCriteria$.next(null);
this.reloadVorgangList();
}
this.preventDoubleLoadingOnReload();
}
if (NavigationService.isSearch(params)) {
const searchCriteria: string = this.navigationService.getParam(VorgangService.SEARCH);
const searchCriteria: string = this.navigationService.getDecodedUriParam(VorgangService.SEARCH);
if (typeof searchCriteria === 'string') {
this.searchByCriteria$.next(searchCriteria);
}
this.preventDoubleLoadingOnReload();
}
//TOASK
/* if (NavigationService.isVorgangDetailPage(params, VorgangService.VORGANG_WITH_EINGANG_URL)) {
this.clearVorgangList();
} */
}
//TOCHECK: warum is das nötig?; warum funktioniert das?
private preventDoubleLoadingOnReload() {
if (this.isCurrentListLoaded()) {
this.reloadVorgangList();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment