Skip to content

Commit

Permalink
Observation edit links attachments to correct form
Browse files Browse the repository at this point in the history
  • Loading branch information
newmanw committed Jul 7, 2021
1 parent cdaeca4 commit 9fed17b
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChangeDetectorRef, Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core';
import { ChangeDetectorRef, Component, Input, OnInit } from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms';

interface AttachmentField {
Expand Down Expand Up @@ -40,7 +40,13 @@ export class ObservationEditAttachmentComponent implements OnInit {
}

allAttachments(): any[] {
const attachments = this.attachments || []
const observationFormId = this.formGroup.get('id')?.value
const attachments = (this.attachments || []).filter(attachment => {
return attachment.url &&
attachment.observationFormId === observationFormId &&
attachment.fieldName === this.definition.name
});

return this.control.value ? attachments.concat(this.control.value) : attachments
}

Expand Down

0 comments on commit 9fed17b

Please sign in to comment.