Skip to content

Commit 25f4139

Browse files
committed
fix remove partern & render of options for resources if no partners
1 parent 9d7bcc4 commit 25f4139

2 files changed

Lines changed: 14 additions & 7 deletions

File tree

projects/social_platform/src/app/office/projects/edit/shared/project-partner-resources-step/project-partner-resources-step.component.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@
8080
type="icon"
8181
class="project__info--remove"
8282
color="red"
83-
(click)="removePartner(i, partners.value[i].company.id)"
83+
(click)="
84+
removePartner(i, partners.value[i]?.company?.id ?? partners.value[i]?.id ?? null)
85+
"
8486
>
8587
<i appIcon icon="basket" appSquare="14"></i>
8688
</app-button>

projects/social_platform/src/app/office/projects/edit/shared/project-partner-resources-step/project-partner-resources-step.component.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,17 @@ export class ProjectPartnerResourcesStepComponent implements OnDestroy {
103103
get resourcesCompanyOptions(): optionsListElement[] {
104104
const partners = this.partners.value || [];
105105

106-
const partnerOptions: optionsListElement[] = partners.map((partner: any, index: number) => ({
107-
id: partner.company.id ?? index,
108-
value: partner.company.id ?? null,
109-
label: partner.name,
110-
}));
106+
const partnerOptions: optionsListElement[] = partners.map((partner: any, index: number) => {
107+
const id = partner?.company?.id ?? partner?.id ?? index;
108+
const value = partner?.company?.id ?? partner?.id ?? null;
109+
const label = partner?.name;
110+
111+
return {
112+
id,
113+
value,
114+
label,
115+
} as optionsListElement;
116+
});
111117

112118
partnerOptions.push({
113119
id: -1,
@@ -128,7 +134,6 @@ export class ProjectPartnerResourcesStepComponent implements OnDestroy {
128134
addPartner(name?: string, inn?: string, contribution?: string, decisionMaker?: string): void {
129135
this.partners.push(
130136
this.fb.group({
131-
id: [null],
132137
name: [name, [Validators.required]],
133138
inn: [inn, [Validators.required]],
134139
contribution: [contribution, [Validators.required]],

0 commit comments

Comments
 (0)