Browse Source

feat: add support for default value

pull/2487/head
Dhoni77 2 years ago
parent
commit
75f9da34fc
  1. 5
      apps/client/src/app/pages/accounts/create-or-update-account-dialog/create-or-update-account-dialog.component.ts
  2. 3
      apps/client/src/app/pages/accounts/create-or-update-account-dialog/create-or-update-account-dialog.html
  3. 10
      libs/ui/src/lib/currency-selector/currency-selector.component.ts

5
apps/client/src/app/pages/accounts/create-or-update-account-dialog/create-or-update-account-dialog.component.ts

@ -31,6 +31,7 @@ import { CreateOrUpdateAccountDialogParams } from './interfaces/interfaces';
})
export class CreateOrUpdateAccountDialog implements OnDestroy {
public accountForm: FormGroup;
public accountCurrency: Currency;
public currencies: Currency[] = [];
public filteredPlatforms: Observable<Platform[]>;
public platforms: Platform[];
@ -51,6 +52,10 @@ export class CreateOrUpdateAccountDialog implements OnDestroy {
label: currency,
value: currency
}));
this.accountCurrency = {
label: this.data.account.currency,
value: this.data.account.currency
};
this.platforms = platforms;
this.accountForm = this.formBuilder.group({

3
apps/client/src/app/pages/accounts/create-or-update-account-dialog/create-or-update-account-dialog.html

@ -23,6 +23,7 @@
<gf-currency-autocomplete
formControlName="currency"
[currencies]="currencies"
[defaultValue]="accountCurrency"
/>
</mat-form-field>
</div>
@ -36,7 +37,7 @@
(keydown.enter)="$event.stopPropagation()"
/>
<span class="ml-2" matTextSuffix
>{{ accountForm.controls['currency'].value }}</span
>{{ accountForm.controls['currency']?.value?.value }}</span
>
</mat-form-field>
</div>

10
libs/ui/src/lib/currency-selector/currency-selector.component.ts

@ -39,9 +39,9 @@ import { map, startWith, takeUntil } from 'rxjs/operators';
})
export class CurrencySelectorComponent
extends AbstractMatFormField<Currency>
implements OnInit, OnDestroy
{
implements OnInit, OnDestroy {
@Input() private currencies: Currency[] = [];
@Input() defaultValue: Currency;
@ViewChild(MatInput, { static: false }) private input: MatInput;
@ -64,6 +64,12 @@ export class CurrencySelectorComponent
this.controlType = 'currency-autocomplete';
}
public ngOnChanges() {
if (this.defaultValue) {
this.value = this.defaultValue;
}
}
public ngOnInit() {
if (this.disabled) {
this.control.disable();

Loading…
Cancel
Save