AP-65 (#87)
All checks were successful
Backend Deploy / build (push) Successful in 22s
Backend Build and Test / build (push) Successful in 2m11s

closes #65

Reviewed-on: #87
This commit was merged in pull request #87.
This commit is contained in:
2025-05-26 09:52:10 +02:00
parent 550933db11
commit e7b4adfa95
6 changed files with 56 additions and 15 deletions

View File

@@ -40,7 +40,7 @@ export class EditAllowancePage implements OnInit {
this.allowanceService.getAllowanceList(this.userId).subscribe((list) => {
for (let allowance of list) {
this.possibleColors = this.possibleColors.filter(color => color !== allowance.colour);
if (!this.isAddMode && this.goalId === allowance.id) {
if (!this.isAddMode && +this.goalId === allowance.id) {
this.possibleColors.unshift(allowance.colour);
}
}
@@ -55,6 +55,25 @@ export class EditAllowancePage implements OnInit {
}
ngOnInit() {
if (!this.isAddMode) {
this.allowanceService.getAllowanceById(this.goalId, this.userId).subscribe((allowance) => {
if (+this.goalId === 0) {
this.form.setValue({
name: 'Main Allowance',
target: 0,
weight: allowance.weight,
color: '#9C4BE4'
});
} else {
this.form.setValue({
name: allowance.name,
target: allowance.target,
weight: allowance.weight,
color: allowance.colour
});
}
});
}
}
submit() {
@@ -68,6 +87,8 @@ export class EditAllowancePage implements OnInit {
if (this.isAddMode) {
this.allowanceService.createAllowance(allowance, this.userId);
} else {
this.allowanceService.updateAllowance(allowance, this.goalId, this.userId);
}
this.router.navigate(['/tabs/allowance', this.userId]);