Browse Source

feat(lib): change defaultDateFormat to computed signal

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

2
libs/ui/src/lib/historical-market-data-editor/historical-market-data-editor.component.html

@ -17,7 +17,7 @@
}" }"
[title]=" [title]="
(`${itemByMonth.key}-${formatDay(i + 1)}` (`${itemByMonth.key}-${formatDay(i + 1)}`
| date: defaultDateFormat) ?? '' | date: defaultDateFormat()) ?? ''
" "
(click)=" (click)="
onOpenMarketDataDetail({ onOpenMarketDataDetail({

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

@ -12,6 +12,7 @@ import type { HttpErrorResponse } from '@angular/common/http';
import { import {
ChangeDetectionStrategy, ChangeDetectionStrategy,
Component, Component,
computed,
EventEmitter, EventEmitter,
input, input,
Input, Input,
@ -72,7 +73,6 @@ export class GfHistoricalMarketDataEditorComponent
@Output() marketDataChanged = new EventEmitter<boolean>(); @Output() marketDataChanged = new EventEmitter<boolean>();
public defaultDateFormat: string;
public deviceType: string; public deviceType: string;
public historicalDataForm = this.formBuilder.group({ public historicalDataForm = this.formBuilder.group({
historicalData: this.formBuilder.group({ historicalData: this.formBuilder.group({
@ -93,6 +93,9 @@ export class GfHistoricalMarketDataEditorComponent
public readonly locale = input(getLocale()); public readonly locale = input(getLocale());
protected readonly days = Array(31); protected readonly days = Array(31);
protected readonly defaultDateFormat = computed(() =>
getDateFormatString(this.locale())
);
private unsubscribeSubject = new Subject<void>(); private unsubscribeSubject = new Subject<void>();
@ -111,8 +114,6 @@ export class GfHistoricalMarketDataEditorComponent
} }
public ngOnChanges() { public ngOnChanges() {
this.defaultDateFormat = getDateFormatString(this.locale());
this.historicalDataItems = this.marketData.map(({ date, marketPrice }) => { this.historicalDataItems = this.marketData.map(({ date, marketPrice }) => {
return { return {
date: format(date, DATE_FORMAT), date: format(date, DATE_FORMAT),

Loading…
Cancel
Save