@ -1,8 +1,12 @@
import { CreateOrderDto } from '@ghostfolio/api/app/order/create-order.dto' ;
import { CreateOrderDto } from '@ghostfolio/api/app/order/create-order.dto' ;
import { UpdateOrderDto } from '@ghostfolio/api/app/order/update-order.dto' ;
import { UpdateOrderDto } from '@ghostfolio/api/app/order/update-order.dto' ;
import { UserService } from '@ghostfolio/client/services/user/user.service' ;
import { UserService } from '@ghostfolio/client/services/user/user.service' ;
import { ASSET_CLASS_MAPPING } from '@ghostfolio/common/config' ;
import { getDateFormatString } from '@ghostfolio/common/helper' ;
import { getDateFormatString } from '@ghostfolio/common/helper' ;
import { LookupItem } from '@ghostfolio/common/interfaces' ;
import {
AssetClassSelectorOption ,
LookupItem
} from '@ghostfolio/common/interfaces' ;
import { hasPermission , permissions } from '@ghostfolio/common/permissions' ;
import { hasPermission , permissions } from '@ghostfolio/common/permissions' ;
import { GfEntityLogoComponent } from '@ghostfolio/ui/entity-logo' ;
import { GfEntityLogoComponent } from '@ghostfolio/ui/entity-logo' ;
import { translate } from '@ghostfolio/ui/i18n' ;
import { translate } from '@ghostfolio/ui/i18n' ;
@ -37,7 +41,7 @@ import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input' ;
import { MatInputModule } from '@angular/material/input' ;
import { MatSelectModule } from '@angular/material/select' ;
import { MatSelectModule } from '@angular/material/select' ;
import { IonIcon } from '@ionic/angular/standalone' ;
import { IonIcon } from '@ionic/angular/standalone' ;
import { AssetClass , AssetSubClass , Tag , Type } from '@prisma/client' ;
import { AssetClass , Tag , Type } from '@prisma/client' ;
import { isAfter , isToday } from 'date-fns' ;
import { isAfter , isToday } from 'date-fns' ;
import { addIcons } from 'ionicons' ;
import { addIcons } from 'ionicons' ;
import { calendarClearOutline , refreshOutline } from 'ionicons/icons' ;
import { calendarClearOutline , refreshOutline } from 'ionicons/icons' ;
@ -73,12 +77,16 @@ import { CreateOrUpdateActivityDialogParams } from './interfaces/interfaces';
} )
} )
export class GfCreateOrUpdateActivityDialog implements OnDestroy {
export class GfCreateOrUpdateActivityDialog implements OnDestroy {
public activityForm : FormGroup ;
public activityForm : FormGroup ;
public assetClasses = Object . keys ( AssetClass ) . map ( ( assetClass ) = > {
return { id : assetClass , label : translate ( assetClass ) } ;
public assetClassOptions : AssetClassSelectorOption [ ] = Object . keys ( AssetClass )
} ) ;
. map ( ( id ) = > {
public assetSubClasses = Object . keys ( AssetSubClass ) . map ( ( assetSubClass ) = > {
return { id , label : translate ( id ) } as AssetClassSelectorOption ;
return { id : assetSubClass , label : translate ( assetSubClass ) } ;
} )
. sort ( ( a , b ) = > {
return a . label . localeCompare ( b . label ) ;
} ) ;
} ) ;
public assetSubClassOptions : AssetClassSelectorOption [ ] = [ ] ;
public currencies : string [ ] = [ ] ;
public currencies : string [ ] = [ ] ;
public currencyOfAssetProfile : string ;
public currencyOfAssetProfile : string ;
public currentMarketPrice = null ;
public currentMarketPrice = null ;
@ -273,6 +281,26 @@ export class GfCreateOrUpdateActivityDialog implements OnDestroy {
}
}
} ) ;
} ) ;
this . activityForm
. get ( 'assetClass' )
. valueChanges . pipe ( takeUntil ( this . unsubscribeSubject ) )
. subscribe ( ( assetClass ) = > {
const assetSubClasses = ASSET_CLASS_MAPPING . get ( assetClass ) ? ? [ ] ;
this . assetSubClassOptions = assetSubClasses
. map ( ( assetSubClass ) = > {
return {
id : assetSubClass ,
label : translate ( assetSubClass )
} ;
} )
. sort ( ( a , b ) = > a . label . localeCompare ( b . label ) ) ;
this . activityForm . get ( 'assetSubClass' ) . setValue ( null ) ;
this . changeDetectorRef . markForCheck ( ) ;
} ) ;
this . activityForm . get ( 'date' ) . valueChanges . subscribe ( ( ) = > {
this . activityForm . get ( 'date' ) . valueChanges . subscribe ( ( ) = > {
if ( isToday ( this . activityForm . get ( 'date' ) . value ) ) {
if ( isToday ( this . activityForm . get ( 'date' ) . value ) ) {
this . activityForm . get ( 'updateAccountBalance' ) . enable ( ) ;
this . activityForm . get ( 'updateAccountBalance' ) . enable ( ) ;