fixed compilation issues

This commit is contained in:
lotte
2020-04-17 13:13:04 +02:00
parent 450bfe6b3f
commit 5aa09eb363
13 changed files with 58 additions and 63 deletions

View File

@@ -103,15 +103,16 @@ describe('DsDynamicFormControlContainerComponent test suite', () => {
new DynamicSwitchModel({ id: 'switch' }), new DynamicSwitchModel({ id: 'switch' }),
new DynamicTextAreaModel({ id: 'textarea' }), new DynamicTextAreaModel({ id: 'textarea' }),
new DynamicTimePickerModel({ id: 'timepicker' }), 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({ new DynamicScrollableDropdownModel({
id: 'scrollableDropdown', id: 'scrollableDropdown',
authorityOptions: authorityOptions, authorityOptions: authorityOptions,
metadataFields: [], metadataFields: [],
repeatable: false, 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({ new DynamicListCheckboxGroupModel({
id: 'checkboxList', id: 'checkboxList',
authorityOptions: authorityOptions, authorityOptions: authorityOptions,
@@ -132,11 +133,12 @@ describe('DsDynamicFormControlContainerComponent test suite', () => {
scopeUUID: '', scopeUUID: '',
submissionScope: '', submissionScope: '',
repeatable: false, repeatable: false,
metadataFields: [] metadataFields: [],
hasSelectableMetadata: false
}), }),
new DynamicDsDatePickerModel({ id: 'datepicker' }), new DynamicDsDatePickerModel({ id: 'datepicker' }),
new DynamicLookupModel({ id: 'lookup', 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' }), new DynamicLookupNameModel({ id: 'lookupName', metadataFields: [], repeatable: false, submissionId: '1234', hasSelectableMetadata: false}),
new DynamicQualdropModel({ id: 'combobox', readOnly: false, required: false }) new DynamicQualdropModel({ id: 'combobox', readOnly: false, required: false })
]; ];
const testModel = formModel[8]; const testModel = formModel[8];

View File

@@ -1,20 +1,12 @@
import { CdkDragDrop } from '@angular/cdk/drag-drop'; import { CdkDragDrop } from '@angular/cdk/drag-drop';
import { import { ChangeDetectorRef, Component, EventEmitter, Input, NgZone, OnInit, Output, QueryList } from '@angular/core';
ChangeDetectorRef,
Component,
EventEmitter,
Input,
NgZone,
OnInit,
Output,
QueryList
} from '@angular/core';
import { AbstractControl, FormControl, FormGroup } from '@angular/forms'; import { AbstractControl, FormControl, FormGroup } from '@angular/forms';
import { import {
DynamicFormArrayComponent, DynamicFormArrayComponent,
DynamicFormArrayGroupModel, DynamicFormArrayGroupModel,
DynamicFormControlCustomEvent, DynamicFormControlCustomEvent,
DynamicFormControlEvent, DynamicFormControlEventType, DynamicFormControlEvent,
DynamicFormControlEventType,
DynamicFormLayout, DynamicFormLayout,
DynamicFormLayoutService, DynamicFormLayoutService,
DynamicFormService, DynamicFormService,
@@ -22,25 +14,18 @@ import {
DynamicTemplateDirective DynamicTemplateDirective
} from '@ng-dynamic-forms/core'; } from '@ng-dynamic-forms/core';
import { combineLatest as observableCombineLatest, Observable, of as observableOf } from 'rxjs'; 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 { RelationshipService } from '../../../../../../core/data/relationship.service';
import { RemoteData } from '../../../../../../core/data/remote-data'; import { RemoteData } from '../../../../../../core/data/remote-data';
import { Relationship } from '../../../../../../core/shared/item-relationships/relationship.model'; import { Relationship } from '../../../../../../core/shared/item-relationships/relationship.model';
import { Item } from '../../../../../../core/shared/item.model'; import { Item } from '../../../../../../core/shared/item.model';
import { MetadataValue } from '../../../../../../core/shared/metadata.models'; import { MetadataValue } from '../../../../../../core/shared/metadata.models';
import { import { getRemoteDataPayload, getSucceededRemoteData } from '../../../../../../core/shared/operators';
getRemoteDataPayload,
getSucceededRemoteData
} from '../../../../../../core/shared/operators';
import { SubmissionObject } from '../../../../../../core/submission/models/submission-object.model'; import { SubmissionObject } from '../../../../../../core/submission/models/submission-object.model';
import { SubmissionObjectDataService } from '../../../../../../core/submission/submission-object-data.service'; import { SubmissionObjectDataService } from '../../../../../../core/submission/submission-object-data.service';
import { hasValue, isNotEmpty } from '../../../../../empty.util'; import { hasValue, isNotEmpty } from '../../../../../empty.util';
import { FormFieldMetadataValueObject } from '../../../models/form-field-metadata-value.model'; import { FormFieldMetadataValueObject } from '../../../models/form-field-metadata-value.model';
import { import { Reorderable, ReorderableFormFieldMetadataValue, ReorderableRelationship } from '../../existing-metadata-list-element/existing-metadata-list-element.component';
Reorderable,
ReorderableFormFieldMetadataValue,
ReorderableRelationship
} from '../../existing-metadata-list-element/existing-metadata-list-element.component';
import { DynamicConcatModel } from '../ds-dynamic-concat.model'; import { DynamicConcatModel } from '../ds-dynamic-concat.model';
import { DynamicRowArrayModel } from '../ds-dynamic-row-array-model'; import { DynamicRowArrayModel } from '../ds-dynamic-row-array-model';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
@@ -181,13 +166,10 @@ export class DsDynamicFormArrayComponent extends DynamicFormArrayComponent imple
this.reorderables = reorderables; this.reorderables = reorderables;
if (shouldPropagateChanges) { if (shouldPropagateChanges) {
const movedReoRels: Array<Reorderable> = []; const movedReoRels: Reorderable[] = [];
let hasMetadataField = false; let hasMetadataField = false;
this.reorderables.forEach((reorderable: Reorderable, index: number) => { this.reorderables.forEach((reorderable: Reorderable, index: number) => {
if (reorderable.hasMoved) { if (reorderable.hasMoved) {
const prevIndex = reorderable.oldIndex;
const updatedReorderable = reorderable.update().pipe(take(1));
updatedReorderables.push(updatedReorderable);
if (reorderable instanceof ReorderableFormFieldMetadataValue) { if (reorderable instanceof ReorderableFormFieldMetadataValue) {
const prevIndex = reorderable.oldIndex; const prevIndex = reorderable.oldIndex;
hasMetadataField = true; hasMetadataField = true;

View File

@@ -15,7 +15,7 @@ describe('DsDynamicDisabledComponent', () => {
let model; let model;
function init() { 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(() => { beforeEach(async(() => {

View File

@@ -15,7 +15,7 @@ import { DynamicFormsNGBootstrapUIModule } from '@ng-dynamic-forms/ui-ng-bootstr
import { AuthorityService } from '../../../../../../core/integration/authority.service'; import { AuthorityService } from '../../../../../../core/integration/authority.service';
import { AuthorityServiceStub } from '../../../../../testing/authority-service-stub'; import { AuthorityServiceStub } from '../../../../../testing/authority-service-stub';
import { DsDynamicLookupComponent } from './dynamic-lookup.component'; 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 { InfiniteScrollModule } from 'ngx-infinite-scroll';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { FormFieldMetadataValueObject } from '../../../models/form-field-metadata-value.model'; 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 { WorkspaceitemsEditPageModule } from '../../../../../../+workspaceitems-edit-page/workspaceitems-edit-page.module';
import { WorkspaceItem } from '../../../../../../core/submission/models/workspaceitem.model'; import { WorkspaceItem } from '../../../../../../core/submission/models/workspaceitem.model';
let LOOKUP_TEST_MODEL_CONFIG = { let LOOKUP_TEST_MODEL_CONFIG: DynamicLookupModelConfig = {
authorityOptions: { authorityOptions: {
closed: false, closed: false,
metadata: 'lookup', metadata: 'lookup',
@@ -47,11 +47,11 @@ let LOOKUP_TEST_MODEL_CONFIG = {
readOnly: false, readOnly: false,
required: true, required: true,
repeatable: true, repeatable: true,
separator: ',',
validators: { required: null }, validators: { required: null },
value: undefined, value: undefined,
metadataFields: [], metadataFields: [],
submissionId: '1234' submissionId: '1234',
hasSelectableMetadata: false
}; };
let LOOKUP_NAME_TEST_MODEL_CONFIG = { let LOOKUP_NAME_TEST_MODEL_CONFIG = {
@@ -71,11 +71,11 @@ let LOOKUP_NAME_TEST_MODEL_CONFIG = {
readOnly: false, readOnly: false,
required: true, required: true,
repeatable: true, repeatable: true,
separator: ',',
validators: { required: null }, validators: { required: null },
value: undefined, value: undefined,
metadataFields: [], metadataFields: [],
submissionId: '1234' submissionId: '1234',
hasSelectableMetadata: false
}; };
let LOOKUP_TEST_GROUP = new FormGroup({ let LOOKUP_TEST_GROUP = new FormGroup({
@@ -104,11 +104,11 @@ describe('Dynamic Lookup component', () => {
readOnly: false, readOnly: false,
required: true, required: true,
repeatable: true, repeatable: true,
separator: ',',
validators: { required: null }, validators: { required: null },
value: undefined, value: undefined,
metadataFields: [], metadataFields: [],
submissionId: '1234' submissionId: '1234',
hasSelectableMetadata: false
}; };
LOOKUP_NAME_TEST_MODEL_CONFIG = { LOOKUP_NAME_TEST_MODEL_CONFIG = {
@@ -128,11 +128,11 @@ describe('Dynamic Lookup component', () => {
readOnly: false, readOnly: false,
required: true, required: true,
repeatable: true, repeatable: true,
separator: ',',
validators: { required: null }, validators: { required: null },
value: undefined, value: undefined,
metadataFields: [], metadataFields: [],
submissionId: '1234' submissionId: '1234',
hasSelectableMetadata: false
}; };
LOOKUP_TEST_GROUP = new FormGroup({ LOOKUP_TEST_GROUP = new FormGroup({

View File

@@ -82,7 +82,8 @@ function init() {
submissionScope: undefined, submissionScope: undefined,
validators: { required: null }, validators: { required: null },
repeatable: false, repeatable: false,
metadataFields: [] metadataFields: [],
hasSelectableMetadata: false
} as DynamicRelationGroupModelConfig; } as DynamicRelationGroupModelConfig;
FORM_GROUP_TEST_GROUP = new FormGroup({ FORM_GROUP_TEST_GROUP = new FormGroup({

View File

@@ -40,7 +40,8 @@ export const SD_TEST_MODEL_CONFIG = {
repeatable: false, repeatable: false,
value: undefined, value: undefined,
metadataFields: [], metadataFields: [],
submissionId: '1234' submissionId: '1234',
hasSelectableMetadata: false
}; };
describe('Dynamic Dynamic Scrollable Dropdown component', () => { describe('Dynamic Dynamic Scrollable Dropdown component', () => {

View File

@@ -63,7 +63,7 @@ describe('DsDynamicLookupRelationModalComponent', () => {
listID = '6b0c8221-fcb4-47a8-b483-ca32363fffb3'; listID = '6b0c8221-fcb4-47a8-b483-ca32363fffb3';
selection$ = observableOf([searchResult1, searchResult2]); selection$ = observableOf([searchResult1, searchResult2]);
selectableListService = { getSelectableList: () => selection$ }; 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.'; nameVariant = 'Doe, J.';
metadataField = 'dc.contributor.author'; metadataField = 'dc.contributor.author';
pSearchOptions = new PaginatedSearchOptions({}); pSearchOptions = new PaginatedSearchOptions({});

View File

@@ -39,7 +39,7 @@ describe('DsDynamicLookupRelationSearchTabComponent', () => {
let lookupRelationService; let lookupRelationService;
function init() { 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({}); pSearchOptions = new PaginatedSearchOptions({});
item1 = Object.assign(new Item(), { uuid: 'e1c51c69-896d-42dc-8221-1d5f2ad5516e' }); item1 = Object.assign(new Item(), { uuid: 'e1c51c69-896d-42dc-8221-1d5f2ad5516e' });
item2 = Object.assign(new Item(), { uuid: 'c8279647-1acc-41ae-b036-951d5f65649b' }); item2 = Object.assign(new Item(), { uuid: 'c8279647-1acc-41ae-b036-951d5f65649b' });

View File

@@ -195,11 +195,11 @@ describe('FormBuilderService test suite', () => {
new DynamicColorPickerModel({ id: 'testColorPicker' }), 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 }), new DynamicListCheckboxGroupModel({ id: 'testCheckboxList', authorityOptions: authorityOptions, repeatable: true }),
@@ -221,7 +221,7 @@ describe('FormBuilderService test suite', () => {
authority: 'RPAuthority', authority: 'RPAuthority',
closed: false, closed: false,
metadata: 'dc.contributor.author' metadata: 'dc.contributor.author'
}], }]
} as FormFieldModel] } as FormFieldModel]
} as FormRowModel, { } as FormRowModel, {
fields: [{ fields: [{
@@ -244,14 +244,15 @@ describe('FormBuilderService test suite', () => {
scopeUUID: '', scopeUUID: '',
submissionScope: '', submissionScope: '',
repeatable: false, repeatable: false,
metadataFields: [] metadataFields: [],
hasSelectableMetadata: true
}), }),
new DynamicDsDatePickerModel({ id: 'testDate' }), 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 }), new DynamicQualdropModel({ id: 'testCombobox', readOnly: false, required: false }),
@@ -269,7 +270,8 @@ describe('FormBuilderService test suite', () => {
}, },
required: false, required: false,
metadataKey: 'dc.contributor.author', metadataKey: 'dc.contributor.author',
metadataFields: ['dc.contributor.author'] metadataFields: ['dc.contributor.author'],
hasSelectableMetadata: true
}, },
), ),
]; ];

View File

@@ -60,7 +60,7 @@ export class SubmissionEditComponent implements OnDestroy, OnInit {
* @type {Array} * @type {Array}
*/ */
private subs: Subscription[] = []; private subs: Subscription[] = [];
private item: Item; public item: Item;
/** /**
* Initialize instance variables * Initialize instance variables

View File

@@ -39,6 +39,7 @@ import {
mockSubmissionSelfUrl, mockSubmissionSelfUrl,
mockSubmissionState mockSubmissionState
} from '../../shared/mocks/mock-submission'; } from '../../shared/mocks/mock-submission';
import { Item } from '../../core/shared/item.model';
describe('submissionReducer test suite', () => { 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); const newState = submissionObjectReducer({}, action);
expect(newState).toEqual(expectedState); 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); const newState = submissionObjectReducer(initState, action);
expect(newState).toEqual(expectedState); expect(newState).toEqual(expectedState);
@@ -241,7 +242,7 @@ describe('submissionReducer test suite', () => {
isValid: false isValid: false
} as any; } 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); let newState = submissionObjectReducer({}, action);
action = new InitSectionAction( action = new InitSectionAction(

View File

@@ -122,11 +122,11 @@ const testFormConfiguration = {
const testFormModel = [ const testFormModel = [
new DynamicRowGroupModel({ new DynamicRowGroupModel({
id: 'df-row-group-config-1', 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({ new DynamicRowGroupModel({
id: 'df-row-group-config-2', 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 })],
}) })
]; ];

View File

@@ -47,6 +47,7 @@ import { getMockSearchService } from '../shared/mocks/mock-search-service';
import { getMockRequestService } from '../shared/mocks/mock-request.service'; import { getMockRequestService } from '../shared/mocks/mock-request.service';
import { RequestService } from '../core/data/request.service'; import { RequestService } from '../core/data/request.service';
import { SearchService } from '../core/shared/search/search.service'; import { SearchService } from '../core/shared/search/search.service';
import { Item } from '../core/shared/item.model';
describe('SubmissionService test suite', () => { describe('SubmissionService test suite', () => {
const config = MOCK_SUBMISSION_CONFIG; const config = MOCK_SUBMISSION_CONFIG;
@@ -441,6 +442,7 @@ describe('SubmissionService test suite', () => {
selfUrl, selfUrl,
submissionDefinition, submissionDefinition,
{}, {},
new Item(),
[] []
); );
const expected = new InitSubmissionFormAction( const expected = new InitSubmissionFormAction(
@@ -449,6 +451,7 @@ describe('SubmissionService test suite', () => {
selfUrl, selfUrl,
submissionDefinition, submissionDefinition,
{}, {},
new Item(),
[]); []);
expect((service as any).store.dispatch).toHaveBeenCalledWith(expected); expect((service as any).store.dispatch).toHaveBeenCalledWith(expected);
@@ -844,14 +847,17 @@ describe('SubmissionService test suite', () => {
submissionId, submissionId,
selfUrl, selfUrl,
submissionDefinition, submissionDefinition,
{} {},
); new Item()
)
;
const expected = new ResetSubmissionFormAction( const expected = new ResetSubmissionFormAction(
collectionId, collectionId,
submissionId, submissionId,
selfUrl, selfUrl,
{}, {},
submissionDefinition submissionDefinition,
new Item()
); );
expect((service as any).store.dispatch).toHaveBeenCalledWith(expected); expect((service as any).store.dispatch).toHaveBeenCalledWith(expected);