diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component.ts index 6b6ffcc1f9..8f3a2e5edd 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component.ts @@ -317,6 +317,7 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo const modalComp = this.modalRef.componentInstance; if (hasValue(this.model.value)) { modalComp.query = this.model.value.value; + modalComp.selectEvent.pipe(take(1)).subscribe(() => this.model.setValue(undefined)) } modalComp.repeatable = this.model.repeatable; modalComp.listId = this.listId; @@ -324,6 +325,7 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo modalComp.metadataFields = this.model.metadataFields; modalComp.item = this.item; modalComp.submissionId = this.model.submissionId; + } /** diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/models/array-group/dynamic-form-array.component.html b/src/app/shared/form/builder/ds-dynamic-form-ui/models/array-group/dynamic-form-array.component.html index ab2513eadd..956128a154 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/models/array-group/dynamic-form-array.component.html +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/models/array-group/dynamic-form-array.component.html @@ -15,7 +15,6 @@ - {{idx}} diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/models/array-group/dynamic-form-array.component.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/models/array-group/dynamic-form-array.component.ts index 89e4fbc10d..ca21ce0576 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/models/array-group/dynamic-form-array.component.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/models/array-group/dynamic-form-array.component.ts @@ -82,7 +82,7 @@ export class DsDynamicFormArrayComponent extends DynamicFormArrayComponent imple ) ).subscribe((item) => this.submissionItem = item); - // this.updateReorderables(); + this.updateReorderables(); } private updateReorderables(): void { @@ -185,12 +185,12 @@ export class DsDynamicFormArrayComponent extends DynamicFormArrayComponent imple onChange($event) { let event = $event; - // if (hasNoValue($event.context)) { - // const context = Object.assign({}, $event.context, { index: this.reorderables.length }); - // event = Object.assign({}, $event, { context }); - // } else { - // this.updateReorderables(); - // } + if (hasNoValue($event.context)) { + const context = Object.assign({}, $event.context, { index: this.reorderables.length }); + event = Object.assign({}, $event, { context }); + } else { + this.updateReorderables(); + } super.onChange(event); } diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/dynamic-lookup-relation-modal.component.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/dynamic-lookup-relation-modal.component.ts index 302c3e8c2b..f62d7e57f8 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/dynamic-lookup-relation-modal.component.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/dynamic-lookup-relation-modal.component.ts @@ -1,4 +1,4 @@ -import { Component, NgZone, OnDestroy, OnInit } from '@angular/core'; +import { Component, EventEmitter, NgZone, OnDestroy, OnInit, Output } from '@angular/core'; import { combineLatest, Observable, Subscription } from 'rxjs'; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; import { hasValue } from '../../../../empty.util'; @@ -34,6 +34,7 @@ import { Context } from '../../../../../core/shared/context.model'; * Represents a modal where the submitter can select items to be added as a certain relationship type to the object being submitted */ export class DsDynamicLookupRelationModalComponent implements OnInit, OnDestroy { + @Output() selectEvent: EventEmitter = new EventEmitter(); relationshipOptions: RelationshipOptions; listId: string; item; @@ -74,6 +75,7 @@ export class DsDynamicLookupRelationModalComponent implements OnInit, OnDestroy } select(...selectableObjects: Array>) { + this.selectEvent.emit(selectableObjects); this.zone.runOutsideAngular( () => { const obs: Observable = combineLatest(...selectableObjects.map((sri: SearchResult) => { diff --git a/src/app/shared/form/form.component.html b/src/app/shared/form/form.component.html index 370a5d53d1..3e792c2f7b 100644 --- a/src/app/shared/form/form.component.html +++ b/src/app/shared/form/form.component.html @@ -11,8 +11,6 @@ (dfChange)="onChange($event)" (dfFocus)="onFocus($event)"> - {{group.index}}-{{index}} -
diff --git a/src/app/shared/form/form.component.ts b/src/app/shared/form/form.component.ts index e44d2a6e88..dd09370fb9 100644 --- a/src/app/shared/form/form.component.ts +++ b/src/app/shared/form/form.component.ts @@ -302,7 +302,9 @@ export class FormComponent implements OnDestroy, OnInit { insertItem($event, arrayContext: DynamicFormArrayModel, index: number): void { const formArrayControl = this.formGroup.get(this.formBuilderService.getPath(arrayContext)) as FormArray; this.formBuilderService.addFormArrayGroup(formArrayControl, arrayContext); - this.formBuilderService.moveFormArrayGroup(0, formArrayControl.length - 1, formArrayControl, arrayContext); + const value = formArrayControl.controls[index].value; + formArrayControl.controls[formArrayControl.length - 1].setValue(value); + formArrayControl.controls[index].reset(); this.addArrayItem.emit(this.getEvent($event, arrayContext, index, 'add')); this.formService.changeForm(this.formId, this.formModel); }