Browse Source

Feature/add live preview of date and number format to user settings (#7558)

* Add live preview of date and number format

* Update changelog
pull/7559/head
Thomas Kaul 1 day ago
committed by GitHub
parent
commit
9b24193042
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 9
      apps/client/src/app/components/user-account-settings/user-account-settings.component.ts
  3. 24
      apps/client/src/app/components/user-account-settings/user-account-settings.html

1
CHANGELOG.md

@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added ### Added
- Added a live preview of the date and number format to the user settings
- Added the country flag to the currency selector - Added the country flag to the currency selector
- Added a _Storybook_ story for the currency selector component - Added a _Storybook_ story for the currency selector component

9
apps/client/src/app/components/user-account-settings/user-account-settings.component.ts

@ -22,6 +22,7 @@ import {
ChangeDetectionStrategy, ChangeDetectionStrategy,
ChangeDetectorRef, ChangeDetectorRef,
Component, Component,
computed,
CUSTOM_ELEMENTS_SCHEMA, CUSTOM_ELEMENTS_SCHEMA,
DestroyRef, DestroyRef,
inject, inject,
@ -50,6 +51,7 @@ import { format, parseISO } from 'date-fns';
import { addIcons } from 'ionicons'; import { addIcons } from 'ionicons';
import { eyeOffOutline, eyeOutline } from 'ionicons/icons'; import { eyeOffOutline, eyeOutline } from 'ionicons/icons';
import ms from 'ms'; import ms from 'ms';
import { DeviceDetectorService } from 'ngx-device-detector';
import { EMPTY, throwError } from 'rxjs'; import { EMPTY, throwError } from 'rxjs';
import { catchError } from 'rxjs/operators'; import { catchError } from 'rxjs/operators';
@ -108,10 +110,17 @@ export class GfUserAccountSettingsComponent implements OnInit {
'uk', 'uk',
'zh' 'zh'
]; ];
protected readonly previewDate = new Date().toISOString();
protected readonly previewValue = 9999.99;
protected user: User; protected user: User;
protected readonly deviceType = computed(
() => this.deviceDetectorService.deviceInfo().deviceType
);
private readonly changeDetectorRef = inject(ChangeDetectorRef); private readonly changeDetectorRef = inject(ChangeDetectorRef);
private readonly dataService = inject(DataService); private readonly dataService = inject(DataService);
private readonly deviceDetectorService = inject(DeviceDetectorService);
private readonly destroyRef = inject(DestroyRef); private readonly destroyRef = inject(DestroyRef);
private readonly notificationService = inject(NotificationService); private readonly notificationService = inject(NotificationService);
private readonly settingsStorageService = inject(SettingsStorageService); private readonly settingsStorageService = inject(SettingsStorageService);

24
apps/client/src/app/components/user-account-settings/user-account-settings.html

@ -146,7 +146,7 @@
</mat-form-field> </mat-form-field>
</div> </div>
</div> </div>
<div class="align-items-center d-flex mb-2"> <div class="align-items-center d-flex mb-4">
<div class="pr-1 w-50"> <div class="pr-1 w-50">
<div i18n>Locale</div> <div i18n>Locale</div>
<div class="hint-text text-muted"> <div class="hint-text text-muted">
@ -154,7 +154,10 @@
</div> </div>
</div> </div>
<div class="pl-1 w-50"> <div class="pl-1 w-50">
<mat-form-field appearance="outline" class="w-100 without-hint"> <mat-form-field
appearance="outline"
class="w-100 with-value-hint"
>
<mat-select <mat-select
name="locale" name="locale"
[disabled]="!hasPermissionToUpdateUserSettings" [disabled]="!hasPermissionToUpdateUserSettings"
@ -168,6 +171,23 @@
<mat-option [value]="locale">{{ locale }}</mat-option> <mat-option [value]="locale">{{ locale }}</mat-option>
} }
</mat-select> </mat-select>
<mat-hint class="d-flex mt-2 text-muted">
<gf-value
[deviceType]="deviceType()"
[isDate]="true"
[isLoading]="isLoading"
[locale]="user.settings.locale"
[value]="previewDate"
/>
<span class="mx-1">·</span>
<gf-value
[isCurrency]="true"
[isLoading]="isLoading"
[locale]="user.settings.locale"
[unit]="user.settings.baseCurrency"
[value]="previewValue"
/>
</mat-hint>
</mat-form-field> </mat-form-field>
</div> </div>
</div> </div>

Loading…
Cancel
Save