Browse Source

fix(lib): disable mutating the injected readonly data

pull/6337/head
KenTandrian 1 month ago
parent
commit
d520e69345
  1. 11
      libs/ui/src/lib/historical-market-data-editor/historical-market-data-editor-dialog/historical-market-data-editor-dialog.component.ts
  2. 3
      libs/ui/src/lib/historical-market-data-editor/historical-market-data-editor-dialog/historical-market-data-editor-dialog.html

11
libs/ui/src/lib/historical-market-data-editor/historical-market-data-editor-dialog/historical-market-data-editor-dialog.component.ts

@ -7,7 +7,8 @@ import {
CUSTOM_ELEMENTS_SCHEMA,
inject,
OnDestroy,
OnInit
OnInit,
signal
} from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { MatButtonModule } from '@angular/material/button';
@ -51,6 +52,8 @@ export class GfHistoricalMarketDataEditorDialogComponent
public readonly data =
inject<HistoricalMarketDataEditorDialogParams>(MAT_DIALOG_DATA);
protected readonly marketPrice = signal(this.data.marketPrice);
private readonly locale =
this.data.user.settings.locale ?? inject<string>(MAT_DATE_LOCALE);
private readonly unsubscribeSubject = new Subject<void>();
@ -82,14 +85,14 @@ export class GfHistoricalMarketDataEditorDialogComponent
})
.pipe(takeUntil(this.unsubscribeSubject))
.subscribe(({ marketPrice }) => {
this.data.marketPrice = marketPrice;
this.marketPrice.set(marketPrice);
this.changeDetectorRef.markForCheck();
});
}
public onUpdate() {
if (this.data.marketPrice === undefined) {
if (this.marketPrice() === undefined) {
return;
}
@ -100,7 +103,7 @@ export class GfHistoricalMarketDataEditorDialogComponent
marketData: [
{
date: this.data.dateString,
marketPrice: this.data.marketPrice
marketPrice: this.marketPrice()
}
]
},

3
libs/ui/src/lib/historical-market-data-editor/historical-market-data-editor-dialog/historical-market-data-editor-dialog.html

@ -28,7 +28,8 @@
matInput
name="marketPrice"
type="number"
[(ngModel)]="data.marketPrice"
[ngModel]="marketPrice()"
(ngModelChange)="marketPrice.set($event)"
/>
<span class="ml-2" matTextSuffix>{{ data.currency }}</span>
</mat-form-field>

Loading…
Cancel
Save