diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component.spec.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component.spec.ts index 125fcbb59a..3c026f0f37 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component.spec.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component.spec.ts @@ -103,15 +103,16 @@ describe('DsDynamicFormControlContainerComponent test suite', () => { new DynamicSwitchModel({ id: 'switch' }), new DynamicTextAreaModel({ id: 'textarea' }), new DynamicTimePickerModel({ id: 'timepicker' }), - new DynamicTypeaheadModel({ id: 'typeahead', metadataFields: [], repeatable: false, submissionId: '1234' }), + new DynamicTypeaheadModel({ id: 'typeahead', metadataFields: [], repeatable: false, submissionId: '1234', hasSelectableMetadata: false }), new DynamicScrollableDropdownModel({ id: 'scrollableDropdown', authorityOptions: authorityOptions, metadataFields: [], repeatable: false, - submissionId: '1234' + submissionId: '1234', + hasSelectableMetadata: false }), - new DynamicTagModel({ id: 'tag', metadataFields: [], repeatable: false, submissionId: '1234' }), + new DynamicTagModel({ id: 'tag', metadataFields: [], repeatable: false, submissionId: '1234', hasSelectableMetadata: false }), new DynamicListCheckboxGroupModel({ id: 'checkboxList', authorityOptions: authorityOptions, @@ -132,11 +133,12 @@ describe('DsDynamicFormControlContainerComponent test suite', () => { scopeUUID: '', submissionScope: '', repeatable: false, - metadataFields: [] + metadataFields: [], + hasSelectableMetadata: false }), new DynamicDsDatePickerModel({ id: 'datepicker' }), - new DynamicLookupModel({ id: 'lookup', metadataFields: [], repeatable: false, submissionId: '1234' }), - new DynamicLookupNameModel({ id: 'lookupName', metadataFields: [], repeatable: false, submissionId: '1234' }), + new DynamicLookupModel({ id: 'lookup', metadataFields: [], repeatable: false, submissionId: '1234', hasSelectableMetadata: false }), + new DynamicLookupNameModel({ id: 'lookupName', metadataFields: [], repeatable: false, submissionId: '1234', hasSelectableMetadata: false}), new DynamicQualdropModel({ id: 'combobox', readOnly: false, required: false }) ]; const testModel = formModel[8]; 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 1c604032d1..591539fd93 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 @@ -1,20 +1,12 @@ import { CdkDragDrop } from '@angular/cdk/drag-drop'; -import { - ChangeDetectorRef, - Component, - EventEmitter, - Input, - NgZone, - OnInit, - Output, - QueryList -} from '@angular/core'; +import { ChangeDetectorRef, Component, EventEmitter, Input, NgZone, OnInit, Output, QueryList } from '@angular/core'; import { AbstractControl, FormControl, FormGroup } from '@angular/forms'; import { DynamicFormArrayComponent, DynamicFormArrayGroupModel, DynamicFormControlCustomEvent, - DynamicFormControlEvent, DynamicFormControlEventType, + DynamicFormControlEvent, + DynamicFormControlEventType, DynamicFormLayout, DynamicFormLayoutService, DynamicFormService, @@ -22,25 +14,18 @@ import { DynamicTemplateDirective } from '@ng-dynamic-forms/core'; import { combineLatest as observableCombineLatest, Observable, of as observableOf } from 'rxjs'; -import { map, switchMap, take, tap, filter } from 'rxjs/operators'; +import { filter, map, switchMap, take } from 'rxjs/operators'; import { RelationshipService } from '../../../../../../core/data/relationship.service'; import { RemoteData } from '../../../../../../core/data/remote-data'; import { Relationship } from '../../../../../../core/shared/item-relationships/relationship.model'; import { Item } from '../../../../../../core/shared/item.model'; import { MetadataValue } from '../../../../../../core/shared/metadata.models'; -import { - getRemoteDataPayload, - getSucceededRemoteData -} from '../../../../../../core/shared/operators'; +import { getRemoteDataPayload, getSucceededRemoteData } from '../../../../../../core/shared/operators'; import { SubmissionObject } from '../../../../../../core/submission/models/submission-object.model'; import { SubmissionObjectDataService } from '../../../../../../core/submission/submission-object-data.service'; import { hasValue, isNotEmpty } from '../../../../../empty.util'; import { FormFieldMetadataValueObject } from '../../../models/form-field-metadata-value.model'; -import { - Reorderable, - ReorderableFormFieldMetadataValue, - ReorderableRelationship -} from '../../existing-metadata-list-element/existing-metadata-list-element.component'; +import { Reorderable, ReorderableFormFieldMetadataValue, ReorderableRelationship } from '../../existing-metadata-list-element/existing-metadata-list-element.component'; import { DynamicConcatModel } from '../ds-dynamic-concat.model'; import { DynamicRowArrayModel } from '../ds-dynamic-row-array-model'; import { Store } from '@ngrx/store'; @@ -181,13 +166,10 @@ export class DsDynamicFormArrayComponent extends DynamicFormArrayComponent imple this.reorderables = reorderables; if (shouldPropagateChanges) { - const movedReoRels: Array = []; + const movedReoRels: Reorderable[] = []; let hasMetadataField = false; this.reorderables.forEach((reorderable: Reorderable, index: number) => { if (reorderable.hasMoved) { - const prevIndex = reorderable.oldIndex; - const updatedReorderable = reorderable.update().pipe(take(1)); - updatedReorderables.push(updatedReorderable); if (reorderable instanceof ReorderableFormFieldMetadataValue) { const prevIndex = reorderable.oldIndex; hasMetadataField = true; diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/models/disabled/dynamic-disabled.component.spec.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/models/disabled/dynamic-disabled.component.spec.ts index c9e46106c5..3aaff1339f 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/models/disabled/dynamic-disabled.component.spec.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/models/disabled/dynamic-disabled.component.spec.ts @@ -15,7 +15,7 @@ describe('DsDynamicDisabledComponent', () => { let model; function init() { - model = new DynamicDisabledModel({ value: 'test', repeatable: false, metadataFields: [], submissionId: '1234', id: '1' }); + model = new DynamicDisabledModel({ value: 'test', repeatable: false, metadataFields: [], submissionId: '1234', id: '1', hasSelectableMetadata: false }); } beforeEach(async(() => { diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/models/lookup/dynamic-lookup.component.spec.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/models/lookup/dynamic-lookup.component.spec.ts index c1f8ad69ba..2dfeb78d46 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/models/lookup/dynamic-lookup.component.spec.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/models/lookup/dynamic-lookup.component.spec.ts @@ -15,7 +15,7 @@ import { DynamicFormsNGBootstrapUIModule } from '@ng-dynamic-forms/ui-ng-bootstr import { AuthorityService } from '../../../../../../core/integration/authority.service'; import { AuthorityServiceStub } from '../../../../../testing/authority-service-stub'; import { DsDynamicLookupComponent } from './dynamic-lookup.component'; -import { DynamicLookupModel } from './dynamic-lookup.model'; +import { DynamicLookupModel, DynamicLookupModelConfig } from './dynamic-lookup.model'; import { InfiniteScrollModule } from 'ngx-infinite-scroll'; import { TranslateModule } from '@ngx-translate/core'; import { FormFieldMetadataValueObject } from '../../../models/form-field-metadata-value.model'; @@ -30,7 +30,7 @@ import { MOCK_SUBMISSION_CONFIG } from '../../../../../testing/mock-submission-c import { WorkspaceitemsEditPageModule } from '../../../../../../+workspaceitems-edit-page/workspaceitems-edit-page.module'; import { WorkspaceItem } from '../../../../../../core/submission/models/workspaceitem.model'; -let LOOKUP_TEST_MODEL_CONFIG = { +let LOOKUP_TEST_MODEL_CONFIG: DynamicLookupModelConfig = { authorityOptions: { closed: false, metadata: 'lookup', @@ -47,11 +47,11 @@ let LOOKUP_TEST_MODEL_CONFIG = { readOnly: false, required: true, repeatable: true, - separator: ',', validators: { required: null }, value: undefined, metadataFields: [], - submissionId: '1234' + submissionId: '1234', + hasSelectableMetadata: false }; let LOOKUP_NAME_TEST_MODEL_CONFIG = { @@ -71,11 +71,11 @@ let LOOKUP_NAME_TEST_MODEL_CONFIG = { readOnly: false, required: true, repeatable: true, - separator: ',', validators: { required: null }, value: undefined, metadataFields: [], - submissionId: '1234' + submissionId: '1234', + hasSelectableMetadata: false }; let LOOKUP_TEST_GROUP = new FormGroup({ @@ -104,11 +104,11 @@ describe('Dynamic Lookup component', () => { readOnly: false, required: true, repeatable: true, - separator: ',', validators: { required: null }, value: undefined, metadataFields: [], - submissionId: '1234' + submissionId: '1234', + hasSelectableMetadata: false }; LOOKUP_NAME_TEST_MODEL_CONFIG = { @@ -128,11 +128,11 @@ describe('Dynamic Lookup component', () => { readOnly: false, required: true, repeatable: true, - separator: ',', validators: { required: null }, value: undefined, metadataFields: [], - submissionId: '1234' + submissionId: '1234', + hasSelectableMetadata: false }; LOOKUP_TEST_GROUP = new FormGroup({ diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/models/relation-group/dynamic-relation-group.component.spec.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/models/relation-group/dynamic-relation-group.component.spec.ts index eb0f8f76f9..ead08344fd 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/models/relation-group/dynamic-relation-group.component.spec.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/models/relation-group/dynamic-relation-group.component.spec.ts @@ -82,7 +82,8 @@ function init() { submissionScope: undefined, validators: { required: null }, repeatable: false, - metadataFields: [] + metadataFields: [], + hasSelectableMetadata: false } as DynamicRelationGroupModelConfig; FORM_GROUP_TEST_GROUP = new FormGroup({ diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/models/scrollable-dropdown/dynamic-scrollable-dropdown.component.spec.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/models/scrollable-dropdown/dynamic-scrollable-dropdown.component.spec.ts index 16446e624e..9df909e0b8 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/models/scrollable-dropdown/dynamic-scrollable-dropdown.component.spec.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/models/scrollable-dropdown/dynamic-scrollable-dropdown.component.spec.ts @@ -40,7 +40,8 @@ export const SD_TEST_MODEL_CONFIG = { repeatable: false, value: undefined, metadataFields: [], - submissionId: '1234' + submissionId: '1234', + hasSelectableMetadata: false }; describe('Dynamic Dynamic Scrollable Dropdown component', () => { diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/dynamic-lookup-relation-modal.component.spec.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/dynamic-lookup-relation-modal.component.spec.ts index b0140906cc..ae30845f8f 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/dynamic-lookup-relation-modal.component.spec.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/dynamic-lookup-relation-modal.component.spec.ts @@ -63,7 +63,7 @@ describe('DsDynamicLookupRelationModalComponent', () => { listID = '6b0c8221-fcb4-47a8-b483-ca32363fffb3'; selection$ = observableOf([searchResult1, searchResult2]); selectableListService = { getSelectableList: () => selection$ }; - relationship = { filter: 'filter', relationshipType: 'isAuthorOfPublication', nameVariants: true } as RelationshipOptions; + relationship = Object.assign(new RelationshipOptions(), { filter: 'filter', relationshipType: 'isAuthorOfPublication', nameVariants: true, searchConfiguration: 'personConfig' }); nameVariant = 'Doe, J.'; metadataField = 'dc.contributor.author'; pSearchOptions = new PaginatedSearchOptions({}); diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/search-tab/dynamic-lookup-relation-search-tab.component.spec.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/search-tab/dynamic-lookup-relation-search-tab.component.spec.ts index ced6c8b88b..b8cb512e7d 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/search-tab/dynamic-lookup-relation-search-tab.component.spec.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/search-tab/dynamic-lookup-relation-search-tab.component.spec.ts @@ -39,7 +39,7 @@ describe('DsDynamicLookupRelationSearchTabComponent', () => { let lookupRelationService; function init() { - relationship = { filter: 'filter', relationshipType: 'isAuthorOfPublication', nameVariants: true } as RelationshipOptions; + relationship = Object.assign(new RelationshipOptions(), { filter: 'filter', relationshipType: 'isAuthorOfPublication', nameVariants: true, searchConfiguration: 'personConfig' }); pSearchOptions = new PaginatedSearchOptions({}); item1 = Object.assign(new Item(), { uuid: 'e1c51c69-896d-42dc-8221-1d5f2ad5516e' }); item2 = Object.assign(new Item(), { uuid: 'c8279647-1acc-41ae-b036-951d5f65649b' }); diff --git a/src/app/shared/form/builder/form-builder.service.spec.ts b/src/app/shared/form/builder/form-builder.service.spec.ts index 1e6ac85625..400ba0daff 100644 --- a/src/app/shared/form/builder/form-builder.service.spec.ts +++ b/src/app/shared/form/builder/form-builder.service.spec.ts @@ -195,11 +195,11 @@ describe('FormBuilderService test suite', () => { new DynamicColorPickerModel({ id: 'testColorPicker' }), - new DynamicTypeaheadModel({ id: 'testTypeahead', repeatable: false, metadataFields: [], submissionId: '1234' }), + new DynamicTypeaheadModel({ id: 'testTypeahead', repeatable: false, metadataFields: [], submissionId: '1234', hasSelectableMetadata: false }), - new DynamicScrollableDropdownModel({ id: 'testScrollableDropdown', authorityOptions: authorityOptions, repeatable: false, metadataFields: [], submissionId: '1234' }), + new DynamicScrollableDropdownModel({ id: 'testScrollableDropdown', authorityOptions: authorityOptions, repeatable: false, metadataFields: [], submissionId: '1234', hasSelectableMetadata: false }), - new DynamicTagModel({ id: 'testTag', repeatable: false, metadataFields: [], submissionId: '1234' }), + new DynamicTagModel({ id: 'testTag', repeatable: false, metadataFields: [], submissionId: '1234', hasSelectableMetadata: false }), new DynamicListCheckboxGroupModel({ id: 'testCheckboxList', authorityOptions: authorityOptions, repeatable: true }), @@ -221,7 +221,7 @@ describe('FormBuilderService test suite', () => { authority: 'RPAuthority', closed: false, metadata: 'dc.contributor.author' - }], + }] } as FormFieldModel] } as FormRowModel, { fields: [{ @@ -244,14 +244,15 @@ describe('FormBuilderService test suite', () => { scopeUUID: '', submissionScope: '', repeatable: false, - metadataFields: [] + metadataFields: [], + hasSelectableMetadata: true }), new DynamicDsDatePickerModel({ id: 'testDate' }), - new DynamicLookupModel({ id: 'testLookup', repeatable: false, metadataFields: [], submissionId: '1234' }), + new DynamicLookupModel({ id: 'testLookup', repeatable: false, metadataFields: [], submissionId: '1234', hasSelectableMetadata: true }), - new DynamicLookupNameModel({ id: 'testLookupName', repeatable: false, metadataFields: [], submissionId: '1234' }), + new DynamicLookupNameModel({ id: 'testLookupName', repeatable: false, metadataFields: [], submissionId: '1234', hasSelectableMetadata: true }), new DynamicQualdropModel({ id: 'testCombobox', readOnly: false, required: false }), @@ -269,7 +270,8 @@ describe('FormBuilderService test suite', () => { }, required: false, metadataKey: 'dc.contributor.author', - metadataFields: ['dc.contributor.author'] + metadataFields: ['dc.contributor.author'], + hasSelectableMetadata: true }, ), ]; diff --git a/src/app/submission/edit/submission-edit.component.ts b/src/app/submission/edit/submission-edit.component.ts index 2340f52ac8..12811173dd 100644 --- a/src/app/submission/edit/submission-edit.component.ts +++ b/src/app/submission/edit/submission-edit.component.ts @@ -60,7 +60,7 @@ export class SubmissionEditComponent implements OnDestroy, OnInit { * @type {Array} */ private subs: Subscription[] = []; - private item: Item; + public item: Item; /** * Initialize instance variables diff --git a/src/app/submission/objects/submission-objects.reducer.spec.ts b/src/app/submission/objects/submission-objects.reducer.spec.ts index 7fdccf3ebb..61b31388af 100644 --- a/src/app/submission/objects/submission-objects.reducer.spec.ts +++ b/src/app/submission/objects/submission-objects.reducer.spec.ts @@ -39,6 +39,7 @@ import { mockSubmissionSelfUrl, mockSubmissionState } from '../../shared/mocks/mock-submission'; +import { Item } from '../../core/shared/item.model'; describe('submissionReducer test suite', () => { @@ -67,7 +68,7 @@ describe('submissionReducer test suite', () => { } }; - const action = new InitSubmissionFormAction(collectionId, submissionId, selfUrl, submissionDefinition, {}, []); + const action = new InitSubmissionFormAction(collectionId, submissionId, selfUrl, submissionDefinition, {}, new Item(), []); const newState = submissionObjectReducer({}, action); expect(newState).toEqual(expectedState); @@ -100,7 +101,7 @@ describe('submissionReducer test suite', () => { } }; - const action = new ResetSubmissionFormAction(collectionId, submissionId, selfUrl, {}, submissionDefinition); + const action = new ResetSubmissionFormAction(collectionId, submissionId, selfUrl, {}, submissionDefinition, new Item()); const newState = submissionObjectReducer(initState, action); expect(newState).toEqual(expectedState); @@ -241,7 +242,7 @@ describe('submissionReducer test suite', () => { isValid: false } as any; - let action: any = new InitSubmissionFormAction(collectionId, submissionId, selfUrl, submissionDefinition, {}, []); + let action: any = new InitSubmissionFormAction(collectionId, submissionId, selfUrl, submissionDefinition, {}, new Item(), []); let newState = submissionObjectReducer({}, action); action = new InitSectionAction( diff --git a/src/app/submission/sections/form/section-form.component.spec.ts b/src/app/submission/sections/form/section-form.component.spec.ts index 99427a9e46..b4bc86b456 100644 --- a/src/app/submission/sections/form/section-form.component.spec.ts +++ b/src/app/submission/sections/form/section-form.component.spec.ts @@ -122,11 +122,11 @@ const testFormConfiguration = { const testFormModel = [ new DynamicRowGroupModel({ id: 'df-row-group-config-1', - group: [new DsDynamicInputModel({ id: 'dc.title', metadataFields: [], repeatable: false, submissionId: '1234' })], + group: [new DsDynamicInputModel({ id: 'dc.title', metadataFields: [], repeatable: false, submissionId: '1234', hasSelectableMetadata: false })], }), new DynamicRowGroupModel({ id: 'df-row-group-config-2', - group: [new DsDynamicInputModel({ id: 'dc.contributor', metadataFields: [], repeatable: false, submissionId: '1234' })], + group: [new DsDynamicInputModel({ id: 'dc.contributor', metadataFields: [], repeatable: false, submissionId: '1234', hasSelectableMetadata: false })], }) ]; diff --git a/src/app/submission/submission.service.spec.ts b/src/app/submission/submission.service.spec.ts index 1b346a56eb..1690d074de 100644 --- a/src/app/submission/submission.service.spec.ts +++ b/src/app/submission/submission.service.spec.ts @@ -47,6 +47,7 @@ import { getMockSearchService } from '../shared/mocks/mock-search-service'; import { getMockRequestService } from '../shared/mocks/mock-request.service'; import { RequestService } from '../core/data/request.service'; import { SearchService } from '../core/shared/search/search.service'; +import { Item } from '../core/shared/item.model'; describe('SubmissionService test suite', () => { const config = MOCK_SUBMISSION_CONFIG; @@ -441,6 +442,7 @@ describe('SubmissionService test suite', () => { selfUrl, submissionDefinition, {}, + new Item(), [] ); const expected = new InitSubmissionFormAction( @@ -449,6 +451,7 @@ describe('SubmissionService test suite', () => { selfUrl, submissionDefinition, {}, + new Item(), []); expect((service as any).store.dispatch).toHaveBeenCalledWith(expected); @@ -844,14 +847,17 @@ describe('SubmissionService test suite', () => { submissionId, selfUrl, submissionDefinition, - {} - ); + {}, + new Item() + ) + ; const expected = new ResetSubmissionFormAction( collectionId, submissionId, selfUrl, {}, - submissionDefinition + submissionDefinition, + new Item() ); expect((service as any).store.dispatch).toHaveBeenCalledWith(expected);