select account to work on

This commit is contained in:
Wolfgang Ludger Hottgenroth 2022-04-03 14:43:17 +02:00
parent f7eca3844d
commit fcd2633c72
Signed by: wn
GPG Key ID: 6C1E5E531E0D5D7F
2 changed files with 19 additions and 9 deletions

View File

@ -5,6 +5,16 @@
</mat-card-title>
</mat-card-header>
<mat-card-content>
<app-account #fallbackAccountComponent [selectedAccountId]="fallbackAccountId" [shallBeRentPayment]="false"></app-account>
<div>
<span>Konto auswählen: </span>
<mat-form-field appearance="outline">
<mat-select #mapSelect [(ngModel)]="accountId" name="account">
<mat-label>Mieter</mat-label>
<mat-option *ngFor="let p of accounts" [value]="p.id">{{p.description}}</mat-option>
</mat-select>
</mat-form-field>
</div>
<app-account [selectedAccountId]="accountId" [shallBeRentPayment]="false"></app-account>
</mat-card-content>
</mat-card>

View File

@ -1,5 +1,6 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { AccountComponent } from '../account/account.component';
import { AccountService } from '../data-object-service';
import { Account } from '../data-objects';
import { ExtApiService } from '../ext-data-object-service';
import { MessageService } from '../message.service';
@ -11,23 +12,23 @@ import { MessageService } from '../message.service';
})
export class LedgerComponent implements OnInit {
fallbackAccount: Account
fallbackAccountId: number
accounts: Account[]
accountId: number
@ViewChild('fallbackAccountComponent') fallbackAccountComponent: AccountComponent
@ViewChild('accountComponent') accountComponent: AccountComponent
constructor(
private extApiService: ExtApiService,
private accountService: AccountService,
private messageService: MessageService
) { }
async getAccount(): Promise<void> {
try {
this.messageService.add("Trying to load fallback account")
this.fallbackAccount = await this.extApiService.getAccountByDescription('fallback_account')
this.messageService.add("Account loaded")
this.messageService.add("Trying to load accounts")
this.accounts = await this.accountService.getAccounts()
this.messageService.add("Accounts loaded")
} catch (err) {
this.messageService.add(JSON.stringify(err, undefined, 4))
}
@ -35,7 +36,6 @@ export class LedgerComponent implements OnInit {
async ngOnInit(): Promise<void> {
await this.getAccount()
this.fallbackAccountId = this.fallbackAccount.id
}
}