Browse Source

feat(lib): make locale an input signal

pull/6352/head
KenTandrian 1 month ago
parent
commit
4fbbc523a2
  1. 4
      libs/ui/src/lib/account-balances/account-balances.component.html
  2. 8
      libs/ui/src/lib/account-balances/account-balances.component.ts

4
libs/ui/src/lib/account-balances/account-balances.component.html

@ -12,7 +12,7 @@
<ng-container i18n>Date</ng-container> <ng-container i18n>Date</ng-container>
</th> </th>
<td *matCellDef="let element" class="px-2" mat-cell> <td *matCellDef="let element" class="px-2" mat-cell>
<gf-value [isDate]="true" [locale]="locale" [value]="element?.date" /> <gf-value [isDate]="true" [locale]="locale()" [value]="element?.date" />
</td> </td>
<td *matFooterCellDef class="px-2" mat-footer-cell> <td *matFooterCellDef class="px-2" mat-footer-cell>
<mat-form-field appearance="outline" class="py-1 without-hint"> <mat-form-field appearance="outline" class="py-1 without-hint">
@ -37,7 +37,7 @@
<div class="d-flex justify-content-end"> <div class="d-flex justify-content-end">
<gf-value <gf-value
[isCurrency]="true" [isCurrency]="true"
[locale]="locale" [locale]="locale()"
[unit]="element?.account?.currency" [unit]="element?.account?.currency"
[value]="element?.value" [value]="element?.value"
/> />

8
libs/ui/src/lib/account-balances/account-balances.component.ts

@ -15,7 +15,8 @@ import {
OnInit, OnInit,
Output, Output,
ViewChild, ViewChild,
inject inject,
input
} from '@angular/core'; } from '@angular/core';
import { import {
FormGroup, FormGroup,
@ -66,7 +67,6 @@ export class GfAccountBalancesComponent implements OnChanges, OnInit {
@Input() accountBalances: AccountBalancesResponse['balances']; @Input() accountBalances: AccountBalancesResponse['balances'];
@Input() accountCurrency: string; @Input() accountCurrency: string;
@Input() accountId: string; @Input() accountId: string;
@Input() locale = getLocale();
@Input() showActions = true; @Input() showActions = true;
@Output() accountBalanceCreated = new EventEmitter<CreateAccountBalanceDto>(); @Output() accountBalanceCreated = new EventEmitter<CreateAccountBalanceDto>();
@ -85,6 +85,8 @@ export class GfAccountBalancesComponent implements OnChanges, OnInit {
public displayedColumns: string[] = ['date', 'value', 'actions']; public displayedColumns: string[] = ['date', 'value', 'actions'];
protected readonly locale = input(getLocale());
private dateAdapter = inject<DateAdapter<Date, string>>(DateAdapter); private dateAdapter = inject<DateAdapter<Date, string>>(DateAdapter);
private notificationService = inject(NotificationService); private notificationService = inject(NotificationService);
@ -93,7 +95,7 @@ export class GfAccountBalancesComponent implements OnChanges, OnInit {
} }
public ngOnInit() { public ngOnInit() {
this.dateAdapter.setLocale(this.locale); this.dateAdapter.setLocale(this.locale());
} }
public ngOnChanges() { public ngOnChanges() {

Loading…
Cancel
Save