Browse Source

Migrate clone, create and edit activity dialogs to dedicated routes

pull/7343/head
Thomas Kaul 6 days ago
parent
commit
7c8f6f792f
  1. 15
      apps/client/src/app/components/account-detail-dialog/account-detail-dialog.component.ts
  2. 15
      apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.component.ts
  3. 31
      apps/client/src/app/pages/portfolio/activities/activity-dialog-host/activity-dialog-host.component.ts
  4. 2
      libs/common/src/lib/routes/routes.ts

15
apps/client/src/app/components/account-detail-dialog/account-detail-dialog.component.ts

@ -40,6 +40,7 @@ import { PageEvent } from '@angular/material/paginator';
import { Sort, SortDirection } from '@angular/material/sort'; import { Sort, SortDirection } from '@angular/material/sort';
import { MatTableDataSource } from '@angular/material/table'; import { MatTableDataSource } from '@angular/material/table';
import { MatTabsModule } from '@angular/material/tabs'; import { MatTabsModule } from '@angular/material/tabs';
import { NavigationStart, Router } from '@angular/router';
import { IonIcon } from '@ionic/angular/standalone'; import { IonIcon } from '@ionic/angular/standalone';
import { Big } from 'big.js'; import { Big } from 'big.js';
import { format, parseISO } from 'date-fns'; import { format, parseISO } from 'date-fns';
@ -51,7 +52,7 @@ import {
} from 'ionicons/icons'; } from 'ionicons/icons';
import { isNumber } from 'lodash'; import { isNumber } from 'lodash';
import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader';
import { forkJoin } from 'rxjs'; import { filter, forkJoin } from 'rxjs';
import { AccountDetailDialogParams } from './interfaces/interfaces'; import { AccountDetailDialogParams } from './interfaces/interfaces';
@ -112,9 +113,21 @@ export class GfAccountDetailDialogComponent implements OnInit {
private readonly destroyRef = inject(DestroyRef); private readonly destroyRef = inject(DestroyRef);
private readonly dialogRef = private readonly dialogRef =
inject<MatDialogRef<GfAccountDetailDialogComponent>>(MatDialogRef); inject<MatDialogRef<GfAccountDetailDialogComponent>>(MatDialogRef);
private readonly router = inject(Router);
private readonly userService = inject(UserService); private readonly userService = inject(UserService);
public constructor() { public constructor() {
this.router.events
.pipe(
filter((event) => {
return event instanceof NavigationStart;
}),
takeUntilDestroyed(this.destroyRef)
)
.subscribe(() => {
this.dialogRef.close();
});
this.userService.stateChanged this.userService.stateChanged
.pipe(takeUntilDestroyed(this.destroyRef)) .pipe(takeUntilDestroyed(this.destroyRef))
.subscribe((state) => { .subscribe((state) => {

15
apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.component.ts

@ -63,7 +63,7 @@ import { PageEvent } from '@angular/material/paginator';
import { SortDirection } from '@angular/material/sort'; import { SortDirection } from '@angular/material/sort';
import { MatTableDataSource } from '@angular/material/table'; import { MatTableDataSource } from '@angular/material/table';
import { MatTabsModule } from '@angular/material/tabs'; import { MatTabsModule } from '@angular/material/tabs';
import { Router, RouterModule } from '@angular/router'; import { NavigationStart, Router, RouterModule } from '@angular/router';
import { IonIcon } from '@ionic/angular/standalone'; import { IonIcon } from '@ionic/angular/standalone';
import { Account, MarketData, Tag } from '@prisma/client'; import { Account, MarketData, Tag } from '@prisma/client';
import { isUUID } from 'class-validator'; import { isUUID } from 'class-validator';
@ -80,7 +80,7 @@ import {
} from 'ionicons/icons'; } from 'ionicons/icons';
import { isNumber, round, uniqBy } from 'lodash'; import { isNumber, round, uniqBy } from 'lodash';
import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader';
import { switchMap } from 'rxjs/operators'; import { filter, switchMap } from 'rxjs/operators';
import { HoldingDetailDialogParams } from './interfaces/interfaces'; import { HoldingDetailDialogParams } from './interfaces/interfaces';
@ -200,6 +200,17 @@ export class GfHoldingDetailDialogComponent implements OnInit {
private readonly userService = inject(UserService); private readonly userService = inject(UserService);
public constructor() { public constructor() {
this.router.events
.pipe(
filter((event) => {
return event instanceof NavigationStart;
}),
takeUntilDestroyed(this.destroyRef)
)
.subscribe(() => {
this.dialogRef.close();
});
addIcons({ addIcons({
arrowDownCircleOutline, arrowDownCircleOutline,
createOutline, createOutline,

31
apps/client/src/app/pages/portfolio/activities/activity-dialog-host/activity-dialog-host.component.ts

@ -16,7 +16,7 @@ import { MatDialog } from '@angular/material/dialog';
import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { DeviceDetectorService } from 'ngx-device-detector'; import { DeviceDetectorService } from 'ngx-device-detector';
import { Observable, of } from 'rxjs'; import { Observable, of } from 'rxjs';
import { map, switchMap } from 'rxjs/operators'; import { finalize, map, switchMap } from 'rxjs/operators';
import { GfCreateOrUpdateActivityDialogComponent } from '../create-or-update-activity-dialog/create-or-update-activity-dialog.component'; import { GfCreateOrUpdateActivityDialogComponent } from '../create-or-update-activity-dialog/create-or-update-activity-dialog.component';
import { CreateOrUpdateActivityDialogParams } from '../create-or-update-activity-dialog/interfaces/interfaces'; import { CreateOrUpdateActivityDialogParams } from '../create-or-update-activity-dialog/interfaces/interfaces';
@ -106,22 +106,27 @@ export class GfActivityDialogHostComponent implements OnInit {
.afterClosed() .afterClosed()
.pipe(takeUntilDestroyed(this.destroyRef)) .pipe(takeUntilDestroyed(this.destroyRef))
.subscribe((result: CreateOrderDto | UpdateOrderDto | null) => { .subscribe((result: CreateOrderDto | UpdateOrderDto | null) => {
if (result) { if (!result) {
const request$: Observable<unknown> = isUpdate this.navigateBack();
? this.dataService.putActivity(result as UpdateOrderDto)
: this.dataService.postActivity(result as CreateOrderDto); return;
}
request$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe({ const request$: Observable<unknown> = isUpdate
? this.dataService.putActivity(result as UpdateOrderDto)
: this.dataService.postActivity(result as CreateOrderDto);
request$
.pipe(
finalize(() => {
this.navigateBack();
})
)
.subscribe({
next: () => { next: () => {
this.userService this.userService.get(true).subscribe();
.get(true)
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe();
} }
}); });
}
this.navigateBack();
}); });
} }
} }

2
libs/common/src/lib/routes/routes.ts

@ -127,7 +127,6 @@ export const internalRoutes = {
routerLink: ['/portfolio', 'activities'], routerLink: ['/portfolio', 'activities'],
subRoutes: { subRoutes: {
clone: { clone: {
excludeFromAssistant: true,
path: 'clone', path: 'clone',
title: $localize`Clone Activity` title: $localize`Clone Activity`
}, },
@ -137,7 +136,6 @@ export const internalRoutes = {
title: $localize`Add Activity` title: $localize`Add Activity`
}, },
update: { update: {
excludeFromAssistant: true,
path: 'update', path: 'update',
title: $localize`Update Activity` title: $localize`Update Activity`
} }

Loading…
Cancel
Save