|
@ -2,6 +2,7 @@ import { Activity } from '@ghostfolio/api/app/order/interfaces/activities.interf |
|
|
import { GfAccountsTableModule } from '@ghostfolio/client/components/accounts-table/accounts-table.module'; |
|
|
import { GfAccountsTableModule } from '@ghostfolio/client/components/accounts-table/accounts-table.module'; |
|
|
import { GfDialogFooterModule } from '@ghostfolio/client/components/dialog-footer/dialog-footer.module'; |
|
|
import { GfDialogFooterModule } from '@ghostfolio/client/components/dialog-footer/dialog-footer.module'; |
|
|
import { GfDialogHeaderModule } from '@ghostfolio/client/components/dialog-header/dialog-header.module'; |
|
|
import { GfDialogHeaderModule } from '@ghostfolio/client/components/dialog-header/dialog-header.module'; |
|
|
|
|
|
import { AdminService } from '@ghostfolio/client/services/admin.service'; |
|
|
import { DataService } from '@ghostfolio/client/services/data.service'; |
|
|
import { DataService } from '@ghostfolio/client/services/data.service'; |
|
|
import { UserService } from '@ghostfolio/client/services/user/user.service'; |
|
|
import { UserService } from '@ghostfolio/client/services/user/user.service'; |
|
|
import { NUMERICAL_PRECISION_THRESHOLD } from '@ghostfolio/common/config'; |
|
|
import { NUMERICAL_PRECISION_THRESHOLD } from '@ghostfolio/common/config'; |
|
@ -48,8 +49,8 @@ import { Router } from '@angular/router'; |
|
|
import { Account, Tag } from '@prisma/client'; |
|
|
import { Account, Tag } from '@prisma/client'; |
|
|
import { format, isSameMonth, isToday, parseISO } from 'date-fns'; |
|
|
import { format, isSameMonth, isToday, parseISO } from 'date-fns'; |
|
|
import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; |
|
|
import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; |
|
|
import { Subject } from 'rxjs'; |
|
|
import { forkJoin, Subject } from 'rxjs'; |
|
|
import { takeUntil } from 'rxjs/operators'; |
|
|
import { map, switchMap, takeUntil } from 'rxjs/operators'; |
|
|
|
|
|
|
|
|
import { HoldingDetailDialogParams } from './interfaces/interfaces'; |
|
|
import { HoldingDetailDialogParams } from './interfaces/interfaces'; |
|
|
|
|
|
|
|
@ -128,6 +129,7 @@ export class GfHoldingDetailDialogComponent implements OnDestroy, OnInit { |
|
|
private unsubscribeSubject = new Subject<void>(); |
|
|
private unsubscribeSubject = new Subject<void>(); |
|
|
|
|
|
|
|
|
public constructor( |
|
|
public constructor( |
|
|
|
|
|
private adminService: AdminService, |
|
|
private changeDetectorRef: ChangeDetectorRef, |
|
|
private changeDetectorRef: ChangeDetectorRef, |
|
|
private dataService: DataService, |
|
|
private dataService: DataService, |
|
|
public dialogRef: MatDialogRef<GfHoldingDetailDialogComponent>, |
|
|
public dialogRef: MatDialogRef<GfHoldingDetailDialogComponent>, |
|
@ -150,15 +152,45 @@ export class GfHoldingDetailDialogComponent implements OnDestroy, OnInit { |
|
|
this.activityForm |
|
|
this.activityForm |
|
|
.get('tags') |
|
|
.get('tags') |
|
|
.valueChanges.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.valueChanges.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.subscribe((tags) => { |
|
|
.subscribe((tags: Tag[]) => { |
|
|
this.dataService |
|
|
const newTags = tags.filter((tag) => { |
|
|
.putHoldingTags({ |
|
|
return tag.id === undefined; |
|
|
tags, |
|
|
}); |
|
|
dataSource: this.data.dataSource, |
|
|
|
|
|
symbol: this.data.symbol |
|
|
if (this.hasPermissionToCreateTags && newTags.length > 0) { |
|
|
}) |
|
|
const createTagObservables = newTags.map((newTag) => { |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
return this.adminService.postTag({ name: newTag.name }).pipe(); |
|
|
.subscribe(); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
forkJoin(createTagObservables) |
|
|
|
|
|
.pipe( |
|
|
|
|
|
map((createdTags) => [ |
|
|
|
|
|
...tags.filter((tag) => tag.id !== undefined), |
|
|
|
|
|
...createdTags |
|
|
|
|
|
]), |
|
|
|
|
|
switchMap((updatedTags) => { |
|
|
|
|
|
this.activityForm |
|
|
|
|
|
.get('tags') |
|
|
|
|
|
.setValue(updatedTags, { emitEvent: false }); |
|
|
|
|
|
return this.dataService.putHoldingTags({ |
|
|
|
|
|
tags: updatedTags, |
|
|
|
|
|
dataSource: this.data.dataSource, |
|
|
|
|
|
symbol: this.data.symbol |
|
|
|
|
|
}); |
|
|
|
|
|
}), |
|
|
|
|
|
takeUntil(this.unsubscribeSubject) |
|
|
|
|
|
) |
|
|
|
|
|
.subscribe(); |
|
|
|
|
|
} else { |
|
|
|
|
|
this.dataService |
|
|
|
|
|
.putHoldingTags({ |
|
|
|
|
|
tags, |
|
|
|
|
|
dataSource: this.data.dataSource, |
|
|
|
|
|
symbol: this.data.symbol |
|
|
|
|
|
}) |
|
|
|
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
|
|
|
.subscribe(); |
|
|
|
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
this.dataService |
|
|
this.dataService |
|
|