Browse Source

Add language and unit system selection to a user form.

pull/14101/head
deaflynx 1 year ago
parent
commit
df1dc91b7e
  1. 18
      ui-ngx/src/app/modules/home/pages/user/user.component.html
  2. 10
      ui-ngx/src/app/modules/home/pages/user/user.component.ts

18
ui-ngx/src/app/modules/home/pages/user/user.component.html

@ -98,6 +98,24 @@
formControlName="phone"> formControlName="phone">
</tb-phone-input> </tb-phone-input>
<div formGroupName="additionalInfo" class="flex flex-col"> <div formGroupName="additionalInfo" class="flex flex-col">
<mat-form-field class="mat-block">
<mat-label translate>language.language</mat-label>
<mat-select formControlName="lang">
<mat-option *ngFor="let lang of languageList" [value]="lang">
{{ lang ? ('language.locales.' + lang | translate) : ''}}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field class="mat-block" floatLabel="always">
<mat-label translate>unit.unit-system</mat-label>
<mat-select formControlName="unitSystem"
[placeholder]="'unit.unit-system-type.AUTO' | translate">
<mat-option [value]="null">{{ 'unit.unit-system-type.AUTO' | translate }}</mat-option>
@for(unit of UnitSystems; track unit) {
<mat-option [value]="unit">{{ 'unit.unit-system-type.' + unit | translate }}</mat-option>
}
</mat-select>
</mat-form-field>
<mat-form-field class="mat-block"> <mat-form-field class="mat-block">
<mat-label translate>user.description</mat-label> <mat-label translate>user.description</mat-label>
<textarea matInput formControlName="description" rows="2"></textarea> <textarea matInput formControlName="description" rows="2"></textarea>

10
ui-ngx/src/app/modules/home/pages/user/user.component.ts

@ -27,6 +27,8 @@ import { isDefinedAndNotNull } from '@core/utils';
import { EntityTableConfig } from '@home/models/entity/entities-table-config.models'; import { EntityTableConfig } from '@home/models/entity/entities-table-config.models';
import { ActionNotificationShow } from '@app/core/notification/notification.actions'; import { ActionNotificationShow } from '@app/core/notification/notification.actions';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { environment as env } from '@env/environment';
import { UnitSystems } from '@shared/models/unit.models';
@Component({ @Component({
selector: 'tb-user', selector: 'tb-user',
@ -36,6 +38,8 @@ import { TranslateService } from '@ngx-translate/core';
export class UserComponent extends EntityComponent<User> { export class UserComponent extends EntityComponent<User> {
authority = Authority; authority = Authority;
languageList = env.supportedLangs;
UnitSystems = UnitSystems;
loginAsUserEnabled$ = this.store.pipe( loginAsUserEnabled$ = this.store.pipe(
select(selectAuth), select(selectAuth),
@ -77,6 +81,8 @@ export class UserComponent extends EntityComponent<User> {
additionalInfo: this.fb.group( additionalInfo: this.fb.group(
{ {
description: [entity && entity.additionalInfo ? entity.additionalInfo.description : ''], description: [entity && entity.additionalInfo ? entity.additionalInfo.description : ''],
lang: [entity && entity.additionalInfo ? entity.additionalInfo.lang : null],
unitSystem: [entity && entity.additionalInfo ? entity.additionalInfo.unitSystem : null],
defaultDashboardId: [entity && entity.additionalInfo ? entity.additionalInfo.defaultDashboardId : null], defaultDashboardId: [entity && entity.additionalInfo ? entity.additionalInfo.defaultDashboardId : null],
defaultDashboardFullscreen: [entity && entity.additionalInfo ? entity.additionalInfo.defaultDashboardFullscreen : false], defaultDashboardFullscreen: [entity && entity.additionalInfo ? entity.additionalInfo.defaultDashboardFullscreen : false],
homeDashboardId: [entity && entity.additionalInfo ? entity.additionalInfo.homeDashboardId : null], homeDashboardId: [entity && entity.additionalInfo ? entity.additionalInfo.homeDashboardId : null],
@ -94,6 +100,10 @@ export class UserComponent extends EntityComponent<User> {
this.entityForm.patchValue({lastName: entity.lastName}); this.entityForm.patchValue({lastName: entity.lastName});
this.entityForm.patchValue({phone: entity.phone}); this.entityForm.patchValue({phone: entity.phone});
this.entityForm.patchValue({additionalInfo: {description: entity.additionalInfo ? entity.additionalInfo.description : ''}}); this.entityForm.patchValue({additionalInfo: {description: entity.additionalInfo ? entity.additionalInfo.description : ''}});
this.entityForm.patchValue({additionalInfo:
{lang: entity.additionalInfo ? entity.additionalInfo.lang : env.defaultLang}});
this.entityForm.patchValue({additionalInfo:
{unitSystem: entity.additionalInfo ? entity.additionalInfo.unitSystem : null}});
this.entityForm.patchValue({additionalInfo: this.entityForm.patchValue({additionalInfo:
{defaultDashboardId: entity.additionalInfo ? entity.additionalInfo.defaultDashboardId : null}}); {defaultDashboardId: entity.additionalInfo ? entity.additionalInfo.defaultDashboardId : null}});
this.entityForm.patchValue({additionalInfo: this.entityForm.patchValue({additionalInfo:

Loading…
Cancel
Save