|
|
|
@ -7,11 +7,15 @@ import { |
|
|
|
CUSTOM_ELEMENTS_SCHEMA, |
|
|
|
DestroyRef, |
|
|
|
OnInit, |
|
|
|
inject, |
|
|
|
signal |
|
|
|
inject |
|
|
|
} from '@angular/core'; |
|
|
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; |
|
|
|
import { FormsModule, ReactiveFormsModule } from '@angular/forms'; |
|
|
|
import { |
|
|
|
FormControl, |
|
|
|
FormGroup, |
|
|
|
ReactiveFormsModule, |
|
|
|
Validators |
|
|
|
} from '@angular/forms'; |
|
|
|
import { MatButtonModule } from '@angular/material/button'; |
|
|
|
import { DateAdapter, MAT_DATE_LOCALE } from '@angular/material/core'; |
|
|
|
import { MatDatepickerModule } from '@angular/material/datepicker'; |
|
|
|
@ -33,7 +37,6 @@ import { HistoricalMarketDataEditorDialogParams } from './interfaces/interfaces' |
|
|
|
changeDetection: ChangeDetectionStrategy.OnPush, |
|
|
|
host: { class: 'h-100' }, |
|
|
|
imports: [ |
|
|
|
FormsModule, |
|
|
|
IonIcon, |
|
|
|
MatButtonModule, |
|
|
|
MatDatepickerModule, |
|
|
|
@ -51,7 +54,10 @@ export class GfHistoricalMarketDataEditorDialogComponent implements OnInit { |
|
|
|
public readonly data = |
|
|
|
inject<HistoricalMarketDataEditorDialogParams>(MAT_DIALOG_DATA); |
|
|
|
|
|
|
|
protected readonly marketPrice = signal(this.data.marketPrice); |
|
|
|
protected readonly historicalMarketDataForm = new FormGroup({ |
|
|
|
date: new FormControl({ disabled: true, value: this.data.dateString }), |
|
|
|
marketPrice: new FormControl(this.data.marketPrice, Validators.required) |
|
|
|
}); |
|
|
|
|
|
|
|
private readonly destroyRef = inject(DestroyRef); |
|
|
|
private readonly locale = |
|
|
|
@ -84,14 +90,19 @@ export class GfHistoricalMarketDataEditorDialogComponent implements OnInit { |
|
|
|
}) |
|
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
|
.subscribe(({ marketPrice }) => { |
|
|
|
this.marketPrice.set(marketPrice); |
|
|
|
this.historicalMarketDataForm.controls.marketPrice.setValue( |
|
|
|
marketPrice |
|
|
|
); |
|
|
|
|
|
|
|
this.historicalMarketDataForm.controls.marketPrice.markAsDirty(); |
|
|
|
|
|
|
|
this.changeDetectorRef.markForCheck(); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
public onUpdate() { |
|
|
|
const marketPrice = this.marketPrice(); |
|
|
|
const marketPrice = |
|
|
|
this.historicalMarketDataForm.controls.marketPrice.value; |
|
|
|
|
|
|
|
if (isNil(marketPrice)) { |
|
|
|
return; |
|
|
|
|