one-way-binding in account entry form works now
This commit is contained in:
@ -1,12 +1,12 @@
|
|||||||
<div id="firstBlock">
|
<div id="firstBlock">
|
||||||
<form (ngSubmit)="addAccountEntry(userForm)" #userForm="ngForm">
|
<form (ngSubmit)="addAccountEntry(accountEntryForm)" #accountEntryForm="ngForm">
|
||||||
<mat-form-field appearance="outline" id="addEntryfield">
|
<mat-form-field appearance="outline" id="addEntryfield">
|
||||||
<mat-label>Datum</mat-label>
|
<mat-label>Datum</mat-label>
|
||||||
<input matInput ngModel name="createdAt" [matDatepicker]="createdAtPicker"/>
|
<input matInput ngModel name="createdAt" [matDatepicker]="createdAtPicker"/>
|
||||||
<mat-datepicker-toggle matSuffix [for]="createdAtPicker"></mat-datepicker-toggle>
|
<mat-datepicker-toggle matSuffix [for]="createdAtPicker"></mat-datepicker-toggle>
|
||||||
<mat-datepicker #createdAtPicker></mat-datepicker>
|
<mat-datepicker #createdAtPicker></mat-datepicker>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<mat-form-field appearance="outline">
|
<mat-form-field appearance="outline" *ngIf="!shallBeRentPayment">
|
||||||
<mat-label>Kategorie</mat-label>
|
<mat-label>Kategorie</mat-label>
|
||||||
<mat-select ngModel name="category" [disabled]="shallBeRentPayment">
|
<mat-select ngModel name="category" [disabled]="shallBeRentPayment">
|
||||||
<mat-option *ngFor="let p of accountEntryCategories" [value]="p.id">{{p.description}}</mat-option>
|
<mat-option *ngFor="let p of accountEntryCategories" [value]="p.id">{{p.description}}</mat-option>
|
||||||
|
@ -39,7 +39,6 @@ export class AccountComponent implements OnInit {
|
|||||||
accountEntryCategoriesMap: Map<number, AccountEntryCategory>
|
accountEntryCategoriesMap: Map<number, AccountEntryCategory>
|
||||||
accountEntryCategoriesInverseMap: Map<string, AccountEntryCategory>
|
accountEntryCategoriesInverseMap: Map<string, AccountEntryCategory>
|
||||||
|
|
||||||
// newAccountEntry: AccountEntry = NULL_AccountEntry
|
|
||||||
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@ -87,24 +86,38 @@ export class AccountComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async addAccountEntry(userForm: any): Promise<void> {
|
async addAccountEntry(formData: any): Promise<void> {
|
||||||
this.messageService.add(`${JSON.stringify(userForm.value, undefined, 4)}`)
|
try {
|
||||||
userForm.reset()
|
this.addAccountEntryButton.disabled = true
|
||||||
/*
|
this.messageService.add(`${JSON.stringify(formData.value, undefined, 4)}`)
|
||||||
try {
|
let newAccountEntry: AccountEntry = {
|
||||||
this.addAccountEntryButton.disabled = true
|
description: formData.value.description,
|
||||||
this.newAccountEntry.account = this.account.id
|
account: this.account.id,
|
||||||
this.messageService.add(`addAccountEntry: ${ JSON.stringify(this.newAccountEntry, undefined, 4) }`)
|
created_at: formData.value.createdAt,
|
||||||
this.newAccountEntry = await this.accountEntryService.postAccountEntry(this.newAccountEntry)
|
amount: formData.value.amount,
|
||||||
this.messageService.add(`New accountEntry created: ${this.newAccountEntry.id}`)
|
id: 0,
|
||||||
this.newAccountEntry = { 'account': this.account.id, 'amount': undefined, 'created_at': '', 'description': '', 'id': 0, 'account_entry_category': 0 }
|
account_entry_category: 0
|
||||||
this.getAccountEntries()
|
|
||||||
} catch (err) {
|
|
||||||
this.messageService.add(`Error in addAccountEntry: ${JSON.stringify(err, undefined, 4)}`)
|
|
||||||
} finally {
|
|
||||||
this.addAccountEntryButton.disabled = false
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
if (this.shallBeRentPayment) {
|
||||||
|
newAccountEntry.account_entry_category = this.accountEntryCategoriesInverseMap.get('Mietzahlung').id
|
||||||
|
this.messageService.add(`shall be rentpayment, category is ${newAccountEntry.account_entry_category}`)
|
||||||
|
} else {
|
||||||
|
newAccountEntry.account_entry_category = formData.value.category
|
||||||
|
this.messageService.add(`category is ${newAccountEntry.account_entry_category}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
this.messageService.add(`addAccountEntry: ${ JSON.stringify(newAccountEntry, undefined, 4) }`)
|
||||||
|
newAccountEntry = await this.accountEntryService.postAccountEntry(newAccountEntry)
|
||||||
|
this.messageService.add(`New accountEntry created: ${newAccountEntry.id}`)
|
||||||
|
|
||||||
|
this.getAccountEntries()
|
||||||
|
} catch (err) {
|
||||||
|
this.messageService.add(`Error in addAccountEntry: ${JSON.stringify(err, undefined, 4)}`)
|
||||||
|
} finally {
|
||||||
|
formData.reset()
|
||||||
|
this.addAccountEntryButton.disabled = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async getAccountEntryCategories(): Promise<void> {
|
async getAccountEntryCategories(): Promise<void> {
|
||||||
@ -125,13 +138,8 @@ export class AccountComponent implements OnInit {
|
|||||||
|
|
||||||
private async init(): Promise<void> {
|
private async init(): Promise<void> {
|
||||||
this.messageService.add(`AccountComponent.init, account: ${this.selectedAccountId}`)
|
this.messageService.add(`AccountComponent.init, account: ${this.selectedAccountId}`)
|
||||||
this.newAccountEntry = NULL_AccountEntry
|
|
||||||
this.getAccount()
|
this.getAccount()
|
||||||
await this.getAccountEntryCategories()
|
await this.getAccountEntryCategories()
|
||||||
if (this.shallBeRentPayment) {
|
|
||||||
this.messageService.add('shall be rentpayment')
|
|
||||||
this.newAccountEntry.account_entry_category = this.accountEntryCategoriesInverseMap.get('Mietzahlung').id
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// export const serviceBaseUrl = "https://api.hv.nober.de";
|
export const serviceBaseUrl = "https://api.hv.nober.de";
|
||||||
// export const serviceBaseUrl = "http://172.16.10.38:5000";
|
// export const serviceBaseUrl = "http://172.16.10.38:5000";
|
||||||
export const serviceBaseUrl = "http://localhost:8080"
|
// export const serviceBaseUrl = "http://localhost:8080"
|
||||||
export const authserviceBaseUrl = "https://authservice.hottis.de"
|
export const authserviceBaseUrl = "https://authservice.hottis.de"
|
||||||
export const applicationId = "hv2"
|
export const applicationId = "hv2"
|
||||||
|
Reference in New Issue
Block a user