Skip to content

Commit

Permalink
Merge pull request #119 from nck974/fix-navigation-after-create-location
Browse files Browse the repository at this point in the history
Fix navigation after create location
  • Loading branch information
nck974 authored Nov 9, 2024
2 parents 086a06a + f83de4f commit d368e48
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Observable, Subscription, catchError, finalize, map, of, switchMap, tak
import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
import { Category } from 'src/app/models/Category';
import { CategoryService } from 'src/app/shared/services/category.service';
import { ActivatedRoute, ParamMap, Router } from '@angular/router';
import { ActivatedRoute, ParamMap } from '@angular/router';
import { MessageService } from 'src/app/shared/services/message.service';

@Component({
Expand All @@ -27,7 +27,6 @@ export class EditCategoryComponent {
private readonly fb: FormBuilder,
private readonly categoryService: CategoryService,
private readonly route: ActivatedRoute,
private readonly router: Router,
private readonly messageService: MessageService,
private readonly location: Location) {
this.categoryForm = this.fb.group({
Expand Down Expand Up @@ -140,7 +139,7 @@ export class EditCategoryComponent {
.subscribe(
category => {
this.messageService.add(`Category ${category.name} was ${categoryTypeMessage}`);
this.router.navigateByUrl("/categories");
this.location.back();
}
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Observable, Subscription, catchError, finalize, map, of, switchMap, tak
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Location } from 'src/app/models/Location';
import { LocationService } from 'src/app/shared/services/location.service';
import { ActivatedRoute, ParamMap, Router } from '@angular/router';
import { ActivatedRoute, ParamMap } from '@angular/router';
import { MessageService } from 'src/app/shared/services/message.service';
import { getMaterialIcons } from 'src/app/utils/material-icons';

Expand All @@ -26,12 +26,11 @@ export class EditLocationComponent {
isLoading: boolean = true;

constructor(
private fb: FormBuilder,
private locationService: LocationService,
private route: ActivatedRoute,
private router: Router,
private messageService: MessageService,
private locationCommon: LocationCommon) {
private readonly fb: FormBuilder,
private readonly locationService: LocationService,
private readonly route: ActivatedRoute,
private readonly messageService: MessageService,
private readonly locationCommon: LocationCommon) {
this.locationForm = this.fb.group({
name: ['', [Validators.required, Validators.maxLength(50)]],
description: ['', [Validators.maxLength(2000)]],
Expand Down Expand Up @@ -131,7 +130,7 @@ export class EditLocationComponent {
.subscribe(
location => {
this.messageService.add(`Location ${location.name} was ${locationTypeMessage}`);
this.router.navigateByUrl("/locations");
this.locationCommon.back();
}
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<!-- Displayed on open menu -->
<mat-menu #menu="matMenu">
<button mat-menu-item (click)="onNavigateToCategories()">Categories</button>
<button mat-menu-item (click)="onNavigateToLocations()">Locations</button>
<button mat-menu-item (click)="onNavigateToBulkImport()">Create from images</button>
<button mat-menu-item (click)="onLogout()">Logout</button>
</mat-menu>
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ export class InventoryMenuComponent {
this.router.navigateByUrl("/categories");
}

onNavigateToLocations(): void {
this.router.navigateByUrl("/locations");
}

onNavigateToBulkImport(): void {
this.router.navigateByUrl("/items/edit/new/bulk");
}
Expand Down

0 comments on commit d368e48

Please sign in to comment.