|
|
@@ -22,9 +22,9 @@ import { Family } from '../../models/family';
|
|
22
|
22
|
export class FamilyEdit {
|
|
23
|
23
|
danka: Danka | undefined;
|
|
24
|
24
|
family: Family | undefined;
|
|
|
25
|
+ families: Family[] = [];
|
|
25
|
26
|
dankaId: string = '';
|
|
26
|
27
|
familyId: string | null = null;
|
|
27
|
|
- isEditing = false;
|
|
28
|
28
|
|
|
29
|
29
|
constructor(
|
|
30
|
30
|
private familyService: FamilyService,
|
|
|
@@ -33,6 +33,7 @@ export class FamilyEdit {
|
|
33
|
33
|
) {
|
|
34
|
34
|
this.dankaId = this.route.snapshot.params['dankaId'];
|
|
35
|
35
|
this.familyId = this.route.snapshot.params['familyId'];
|
|
|
36
|
+ this.families = this.familyService.getFamiliesByDankaId(this.dankaId);
|
|
36
|
37
|
if (this.familyId) {
|
|
37
|
38
|
this.family = this.familyService.getFamilyById(this.familyId);
|
|
38
|
39
|
if (this.family) {
|
|
|
@@ -53,6 +54,9 @@ export class FamilyEdit {
|
|
53
|
54
|
relationship: new FormControl(''),
|
|
54
|
55
|
birthDate: new FormControl('', Validators.required),
|
|
55
|
56
|
note: new FormControl(''),
|
|
|
57
|
+ fatherId: new FormControl(''),
|
|
|
58
|
+ motherId: new FormControl(''),
|
|
|
59
|
+ spouseId: new FormControl(''),
|
|
56
|
60
|
});
|
|
57
|
61
|
|
|
58
|
62
|
getAgeText() {
|
|
|
@@ -71,6 +75,10 @@ export class FamilyEdit {
|
|
71
|
75
|
return `${age}歳`;
|
|
72
|
76
|
}
|
|
73
|
77
|
|
|
|
78
|
+ getFamilyOptions(): Family[] {
|
|
|
79
|
+ return this.families.filter((family) => family.id !== this.familyId);
|
|
|
80
|
+ }
|
|
|
81
|
+
|
|
74
|
82
|
saveFamily() {
|
|
75
|
83
|
if (this.familyForm.invalid) {
|
|
76
|
84
|
return;
|
|
|
@@ -87,9 +95,13 @@ export class FamilyEdit {
|
|
87
|
95
|
relationship: formValue.relationship?.trim() ?? '',
|
|
88
|
96
|
birthDate: formValue.birthDate?.trim() ?? '',
|
|
89
|
97
|
note: formValue.note?.trim() ?? '',
|
|
|
98
|
+ fatherId: this.familyForm.value.fatherId ?? '',
|
|
|
99
|
+ motherId: this.familyForm.value.motherId ?? '',
|
|
|
100
|
+ spouseId: this.familyForm.value.spouseId ?? '',
|
|
90
|
101
|
};
|
|
91
|
102
|
this.familyService.saveFamily(updatedFamily);
|
|
92
|
|
- this.router.navigate(['/danka-detail', dankaId], { queryParams: { tab: 'family' } }); }
|
|
|
103
|
+ this.router.navigate(['/danka-detail', dankaId], { queryParams: { tab: 'family' } });
|
|
|
104
|
+ }
|
|
93
|
105
|
|
|
94
|
106
|
cancelFamilyEdit(): void {
|
|
95
|
107
|
const dankaId = this.dankaId;
|