AP-65 (#87)
closes #65 Reviewed-on: #87
This commit was merged in pull request #87.
This commit is contained in:
@@ -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]);
|
||||
|
||||
Reference in New Issue
Block a user