mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 02:24:11 +00:00
[CST-3088] Renamed DsDynamicTypeaheadComponent to DsDynamicOneboxComponent
This commit is contained in:
@@ -49,10 +49,10 @@ import { DynamicListRadioGroupModel } from './models/list/dynamic-list-radio-gro
|
|||||||
import { DynamicLookupModel } from './models/lookup/dynamic-lookup.model';
|
import { DynamicLookupModel } from './models/lookup/dynamic-lookup.model';
|
||||||
import { DynamicScrollableDropdownModel } from './models/scrollable-dropdown/dynamic-scrollable-dropdown.model';
|
import { DynamicScrollableDropdownModel } from './models/scrollable-dropdown/dynamic-scrollable-dropdown.model';
|
||||||
import { DynamicTagModel } from './models/tag/dynamic-tag.model';
|
import { DynamicTagModel } from './models/tag/dynamic-tag.model';
|
||||||
import { DynamicTypeaheadModel } from './models/typeahead/dynamic-typeahead.model';
|
import { DynamicOneboxModel } from './models/onebox/dynamic-onebox.model';
|
||||||
import { DynamicQualdropModel } from './models/ds-dynamic-qualdrop.model';
|
import { DynamicQualdropModel } from './models/ds-dynamic-qualdrop.model';
|
||||||
import { DynamicLookupNameModel } from './models/lookup/dynamic-lookup-name.model';
|
import { DynamicLookupNameModel } from './models/lookup/dynamic-lookup-name.model';
|
||||||
import { DsDynamicTypeaheadComponent } from './models/typeahead/dynamic-typeahead.component';
|
import { DsDynamicOneboxComponent } from './models/onebox/dynamic-onebox.component';
|
||||||
import { DsDynamicScrollableDropdownComponent } from './models/scrollable-dropdown/dynamic-scrollable-dropdown.component';
|
import { DsDynamicScrollableDropdownComponent } from './models/scrollable-dropdown/dynamic-scrollable-dropdown.component';
|
||||||
import { DsDynamicTagComponent } from './models/tag/dynamic-tag.component';
|
import { DsDynamicTagComponent } from './models/tag/dynamic-tag.component';
|
||||||
import { DsDynamicListComponent } from './models/list/dynamic-list.component';
|
import { DsDynamicListComponent } from './models/list/dynamic-list.component';
|
||||||
@@ -101,7 +101,7 @@ 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 DynamicOneboxModel({ id: 'onebox', metadataFields: [], repeatable: false, submissionId: '1234' }),
|
||||||
new DynamicScrollableDropdownModel({
|
new DynamicScrollableDropdownModel({
|
||||||
id: 'scrollableDropdown',
|
id: 'scrollableDropdown',
|
||||||
vocabularyOptions: vocabularyOptions,
|
vocabularyOptions: vocabularyOptions,
|
||||||
@@ -312,7 +312,7 @@ describe('DsDynamicFormControlContainerComponent test suite', () => {
|
|||||||
expect(testFn(formModel[13])).toBeNull();
|
expect(testFn(formModel[13])).toBeNull();
|
||||||
expect(testFn(formModel[14])).toEqual(DynamicNGBootstrapTextAreaComponent);
|
expect(testFn(formModel[14])).toEqual(DynamicNGBootstrapTextAreaComponent);
|
||||||
expect(testFn(formModel[15])).toEqual(DynamicNGBootstrapTimePickerComponent);
|
expect(testFn(formModel[15])).toEqual(DynamicNGBootstrapTimePickerComponent);
|
||||||
expect(testFn(formModel[16])).toEqual(DsDynamicTypeaheadComponent);
|
expect(testFn(formModel[16])).toEqual(DsDynamicOneboxComponent);
|
||||||
expect(testFn(formModel[17])).toEqual(DsDynamicScrollableDropdownComponent);
|
expect(testFn(formModel[17])).toEqual(DsDynamicScrollableDropdownComponent);
|
||||||
expect(testFn(formModel[18])).toEqual(DsDynamicTagComponent);
|
expect(testFn(formModel[18])).toEqual(DsDynamicTagComponent);
|
||||||
expect(testFn(formModel[19])).toEqual(DsDynamicListComponent);
|
expect(testFn(formModel[19])).toEqual(DsDynamicListComponent);
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
ChangeDetectionStrategy, ChangeDetectorRef,
|
ChangeDetectionStrategy,
|
||||||
|
ChangeDetectorRef,
|
||||||
Component,
|
Component,
|
||||||
ComponentFactoryResolver,
|
ComponentFactoryResolver,
|
||||||
ContentChildren,
|
ContentChildren,
|
||||||
@@ -29,13 +30,15 @@ import {
|
|||||||
DYNAMIC_FORM_CONTROL_TYPE_SELECT,
|
DYNAMIC_FORM_CONTROL_TYPE_SELECT,
|
||||||
DYNAMIC_FORM_CONTROL_TYPE_TEXTAREA,
|
DYNAMIC_FORM_CONTROL_TYPE_TEXTAREA,
|
||||||
DYNAMIC_FORM_CONTROL_TYPE_TIMEPICKER,
|
DYNAMIC_FORM_CONTROL_TYPE_TIMEPICKER,
|
||||||
DynamicDatePickerModel, DynamicFormComponentService,
|
DynamicDatePickerModel,
|
||||||
|
DynamicFormComponentService,
|
||||||
DynamicFormControl,
|
DynamicFormControl,
|
||||||
DynamicFormControlContainerComponent,
|
DynamicFormControlContainerComponent,
|
||||||
DynamicFormControlEvent,
|
DynamicFormControlEvent,
|
||||||
DynamicFormControlModel,
|
DynamicFormControlModel,
|
||||||
DynamicFormLayout,
|
DynamicFormLayout,
|
||||||
DynamicFormLayoutService, DynamicFormRelationService,
|
DynamicFormLayoutService,
|
||||||
|
DynamicFormRelationService,
|
||||||
DynamicFormValidationService,
|
DynamicFormValidationService,
|
||||||
DynamicTemplateDirective,
|
DynamicTemplateDirective,
|
||||||
} from '@ng-dynamic-forms/core';
|
} from '@ng-dynamic-forms/core';
|
||||||
@@ -56,7 +59,7 @@ import {
|
|||||||
ReorderableRelationship
|
ReorderableRelationship
|
||||||
} from './existing-metadata-list-element/existing-metadata-list-element.component';
|
} from './existing-metadata-list-element/existing-metadata-list-element.component';
|
||||||
|
|
||||||
import { DYNAMIC_FORM_CONTROL_TYPE_TYPEAHEAD } from './models/typeahead/dynamic-typeahead.model';
|
import { DYNAMIC_FORM_CONTROL_TYPE_ONEBOX } from './models/onebox/dynamic-onebox.model';
|
||||||
import { DYNAMIC_FORM_CONTROL_TYPE_SCROLLABLE_DROPDOWN } from './models/scrollable-dropdown/dynamic-scrollable-dropdown.model';
|
import { DYNAMIC_FORM_CONTROL_TYPE_SCROLLABLE_DROPDOWN } from './models/scrollable-dropdown/dynamic-scrollable-dropdown.model';
|
||||||
import { DYNAMIC_FORM_CONTROL_TYPE_TAG } from './models/tag/dynamic-tag.model';
|
import { DYNAMIC_FORM_CONTROL_TYPE_TAG } from './models/tag/dynamic-tag.model';
|
||||||
import { DYNAMIC_FORM_CONTROL_TYPE_DSDATEPICKER } from './models/date-picker/date-picker.model';
|
import { DYNAMIC_FORM_CONTROL_TYPE_DSDATEPICKER } from './models/date-picker/date-picker.model';
|
||||||
@@ -68,7 +71,7 @@ import { DYNAMIC_FORM_CONTROL_TYPE_LOOKUP_NAME } from './models/lookup/dynamic-l
|
|||||||
import { DsDynamicTagComponent } from './models/tag/dynamic-tag.component';
|
import { DsDynamicTagComponent } from './models/tag/dynamic-tag.component';
|
||||||
import { DsDatePickerComponent } from './models/date-picker/date-picker.component';
|
import { DsDatePickerComponent } from './models/date-picker/date-picker.component';
|
||||||
import { DsDynamicListComponent } from './models/list/dynamic-list.component';
|
import { DsDynamicListComponent } from './models/list/dynamic-list.component';
|
||||||
import { DsDynamicTypeaheadComponent } from './models/typeahead/dynamic-typeahead.component';
|
import { DsDynamicOneboxComponent } from './models/onebox/dynamic-onebox.component';
|
||||||
import { DsDynamicScrollableDropdownComponent } from './models/scrollable-dropdown/dynamic-scrollable-dropdown.component';
|
import { DsDynamicScrollableDropdownComponent } from './models/scrollable-dropdown/dynamic-scrollable-dropdown.component';
|
||||||
import { DsDynamicLookupComponent } from './models/lookup/dynamic-lookup.component';
|
import { DsDynamicLookupComponent } from './models/lookup/dynamic-lookup.component';
|
||||||
import { DsDynamicFormGroupComponent } from './models/form-group/dynamic-form-group.component';
|
import { DsDynamicFormGroupComponent } from './models/form-group/dynamic-form-group.component';
|
||||||
@@ -78,7 +81,7 @@ import { DYNAMIC_FORM_CONTROL_TYPE_RELATION_GROUP } from './models/relation-grou
|
|||||||
import { DsDatePickerInlineComponent } from './models/date-picker-inline/dynamic-date-picker-inline.component';
|
import { DsDatePickerInlineComponent } from './models/date-picker-inline/dynamic-date-picker-inline.component';
|
||||||
import { DYNAMIC_FORM_CONTROL_TYPE_CUSTOM_SWITCH } from './models/custom-switch/custom-switch.model';
|
import { DYNAMIC_FORM_CONTROL_TYPE_CUSTOM_SWITCH } from './models/custom-switch/custom-switch.model';
|
||||||
import { CustomSwitchComponent } from './models/custom-switch/custom-switch.component';
|
import { CustomSwitchComponent } from './models/custom-switch/custom-switch.component';
|
||||||
import { map, startWith, switchMap, find } from 'rxjs/operators';
|
import { map, startWith, switchMap } from 'rxjs/operators';
|
||||||
import { combineLatest as observableCombineLatest, Observable, of as observableOf, Subscription } from 'rxjs';
|
import { combineLatest as observableCombineLatest, Observable, of as observableOf, Subscription } from 'rxjs';
|
||||||
import { SearchResult } from '../../../search/search-result.model';
|
import { SearchResult } from '../../../search/search-result.model';
|
||||||
import { DSpaceObject } from '../../../../core/shared/dspace-object.model';
|
import { DSpaceObject } from '../../../../core/shared/dspace-object.model';
|
||||||
@@ -88,7 +91,11 @@ import { SelectableListService } from '../../../object-list/selectable-list/sele
|
|||||||
import { DsDynamicDisabledComponent } from './models/disabled/dynamic-disabled.component';
|
import { DsDynamicDisabledComponent } from './models/disabled/dynamic-disabled.component';
|
||||||
import { DYNAMIC_FORM_CONTROL_TYPE_DISABLED } from './models/disabled/dynamic-disabled.model';
|
import { DYNAMIC_FORM_CONTROL_TYPE_DISABLED } from './models/disabled/dynamic-disabled.model';
|
||||||
import { DsDynamicLookupRelationModalComponent } from './relation-lookup-modal/dynamic-lookup-relation-modal.component';
|
import { DsDynamicLookupRelationModalComponent } from './relation-lookup-modal/dynamic-lookup-relation-modal.component';
|
||||||
import { getAllSucceededRemoteData, getRemoteDataPayload, getSucceededRemoteData } from '../../../../core/shared/operators';
|
import {
|
||||||
|
getAllSucceededRemoteData,
|
||||||
|
getRemoteDataPayload,
|
||||||
|
getSucceededRemoteData
|
||||||
|
} from '../../../../core/shared/operators';
|
||||||
import { RemoteData } from '../../../../core/data/remote-data';
|
import { RemoteData } from '../../../../core/data/remote-data';
|
||||||
import { Item } from '../../../../core/shared/item.model';
|
import { Item } from '../../../../core/shared/item.model';
|
||||||
import { ItemDataService } from '../../../../core/data/item-data.service';
|
import { ItemDataService } from '../../../../core/data/item-data.service';
|
||||||
@@ -136,8 +143,8 @@ export function dsDynamicFormControlMapFn(model: DynamicFormControlModel): Type<
|
|||||||
case DYNAMIC_FORM_CONTROL_TYPE_TIMEPICKER:
|
case DYNAMIC_FORM_CONTROL_TYPE_TIMEPICKER:
|
||||||
return DynamicNGBootstrapTimePickerComponent;
|
return DynamicNGBootstrapTimePickerComponent;
|
||||||
|
|
||||||
case DYNAMIC_FORM_CONTROL_TYPE_TYPEAHEAD:
|
case DYNAMIC_FORM_CONTROL_TYPE_ONEBOX:
|
||||||
return DsDynamicTypeaheadComponent;
|
return DsDynamicOneboxComponent;
|
||||||
|
|
||||||
case DYNAMIC_FORM_CONTROL_TYPE_SCROLLABLE_DROPDOWN:
|
case DYNAMIC_FORM_CONTROL_TYPE_SCROLLABLE_DROPDOWN:
|
||||||
return DsDynamicScrollableDropdownComponent;
|
return DsDynamicScrollableDropdownComponent;
|
||||||
|
@@ -41,7 +41,7 @@ export class DsDynamicInputModel extends DynamicInputModel {
|
|||||||
|
|
||||||
this.language = config.language;
|
this.language = config.language;
|
||||||
if (!this.language) {
|
if (!this.language) {
|
||||||
// TypeAhead
|
// Onebox
|
||||||
if (config.value instanceof FormFieldMetadataValueObject) {
|
if (config.value instanceof FormFieldMetadataValueObject) {
|
||||||
this.language = config.value.language;
|
this.language = config.value.language;
|
||||||
} else if (Array.isArray(config.value)) {
|
} else if (Array.isArray(config.value)) {
|
||||||
|
@@ -13,8 +13,8 @@ import { TranslateModule } from '@ngx-translate/core';
|
|||||||
import { VocabularyOptions } from '../../../../../../core/submission/vocabularies/models/vocabulary-options.model';
|
import { VocabularyOptions } from '../../../../../../core/submission/vocabularies/models/vocabulary-options.model';
|
||||||
import { VocabularyService } from '../../../../../../core/submission/vocabularies/vocabulary.service';
|
import { VocabularyService } from '../../../../../../core/submission/vocabularies/vocabulary.service';
|
||||||
import { VocabularyServiceStub } from '../../../../../testing/vocabulary-service.stub';
|
import { VocabularyServiceStub } from '../../../../../testing/vocabulary-service.stub';
|
||||||
import { DsDynamicTypeaheadComponent } from './dynamic-typeahead.component';
|
import { DsDynamicOneboxComponent } from './dynamic-onebox.component';
|
||||||
import { DynamicTypeaheadModel } from './dynamic-typeahead.model';
|
import { DynamicOneboxModel } from './dynamic-onebox.model';
|
||||||
import { FormFieldMetadataValueObject } from '../../../models/form-field-metadata-value.model';
|
import { FormFieldMetadataValueObject } from '../../../models/form-field-metadata-value.model';
|
||||||
import { createTestComponent } from '../../../../../testing/utils.test';
|
import { createTestComponent } from '../../../../../testing/utils.test';
|
||||||
import { AuthorityConfidenceStateDirective } from '../../../../../authority-confidence/authority-confidence-state.directive';
|
import { AuthorityConfidenceStateDirective } from '../../../../../authority-confidence/authority-confidence-state.directive';
|
||||||
@@ -26,27 +26,27 @@ import { CdkTreeModule } from '@angular/cdk/tree';
|
|||||||
import { TestScheduler } from 'rxjs/testing';
|
import { TestScheduler } from 'rxjs/testing';
|
||||||
import { getTestScheduler } from 'jasmine-marbles';
|
import { getTestScheduler } from 'jasmine-marbles';
|
||||||
|
|
||||||
export let TYPEAHEAD_TEST_GROUP;
|
export let ONEBOX_TEST_GROUP;
|
||||||
|
|
||||||
export let TYPEAHEAD_TEST_MODEL_CONFIG;
|
export let ONEBOX_TEST_MODEL_CONFIG;
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
TYPEAHEAD_TEST_GROUP = new FormGroup({
|
ONEBOX_TEST_GROUP = new FormGroup({
|
||||||
typeahead: new FormControl(),
|
onebox: new FormControl(),
|
||||||
});
|
});
|
||||||
|
|
||||||
TYPEAHEAD_TEST_MODEL_CONFIG = {
|
ONEBOX_TEST_MODEL_CONFIG = {
|
||||||
vocabularyOptions: {
|
vocabularyOptions: {
|
||||||
closed: false,
|
closed: false,
|
||||||
metadata: 'typeahead',
|
metadata: 'onebox',
|
||||||
name: 'vocabulary',
|
name: 'vocabulary',
|
||||||
scope: 'c1c16450-d56f-41bc-bb81-27f1d1eb5c23'
|
scope: 'c1c16450-d56f-41bc-bb81-27f1d1eb5c23'
|
||||||
} as VocabularyOptions,
|
} as VocabularyOptions,
|
||||||
disabled: false,
|
disabled: false,
|
||||||
id: 'typeahead',
|
id: 'onebox',
|
||||||
label: 'Conference',
|
label: 'Conference',
|
||||||
minChars: 3,
|
minChars: 3,
|
||||||
name: 'typeahead',
|
name: 'onebox',
|
||||||
placeholder: 'Conference',
|
placeholder: 'Conference',
|
||||||
readOnly: false,
|
readOnly: false,
|
||||||
required: false,
|
required: false,
|
||||||
@@ -55,13 +55,13 @@ function init() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('DsDynamicTypeaheadComponent test suite', () => {
|
describe('DsDynamicOneboxComponent test suite', () => {
|
||||||
|
|
||||||
let scheduler: TestScheduler;
|
let scheduler: TestScheduler;
|
||||||
let testComp: TestComponent;
|
let testComp: TestComponent;
|
||||||
let typeaheadComp: DsDynamicTypeaheadComponent;
|
let oneboxComponent: DsDynamicOneboxComponent;
|
||||||
let testFixture: ComponentFixture<TestComponent>;
|
let testFixture: ComponentFixture<TestComponent>;
|
||||||
let typeaheadFixture: ComponentFixture<DsDynamicTypeaheadComponent>;
|
let oneboxCompFixture: ComponentFixture<DsDynamicOneboxComponent>;
|
||||||
let vocabularyServiceStub: any;
|
let vocabularyServiceStub: any;
|
||||||
let html;
|
let html;
|
||||||
let modal;
|
let modal;
|
||||||
@@ -122,7 +122,7 @@ describe('DsDynamicTypeaheadComponent test suite', () => {
|
|||||||
CdkTreeModule
|
CdkTreeModule
|
||||||
],
|
],
|
||||||
declarations: [
|
declarations: [
|
||||||
DsDynamicTypeaheadComponent,
|
DsDynamicOneboxComponent,
|
||||||
TestComponent,
|
TestComponent,
|
||||||
AuthorityConfidenceStateDirective,
|
AuthorityConfidenceStateDirective,
|
||||||
ObjNgFor,
|
ObjNgFor,
|
||||||
@@ -130,7 +130,7 @@ describe('DsDynamicTypeaheadComponent test suite', () => {
|
|||||||
], // declare the test component
|
], // declare the test component
|
||||||
providers: [
|
providers: [
|
||||||
ChangeDetectorRef,
|
ChangeDetectorRef,
|
||||||
DsDynamicTypeaheadComponent,
|
DsDynamicOneboxComponent,
|
||||||
{ provide: VocabularyService, useValue: vocabularyServiceStub },
|
{ provide: VocabularyService, useValue: vocabularyServiceStub },
|
||||||
{ provide: DynamicFormLayoutService, useValue: {} },
|
{ provide: DynamicFormLayoutService, useValue: {} },
|
||||||
{ provide: DynamicFormValidationService, useValue: {} },
|
{ provide: DynamicFormValidationService, useValue: {} },
|
||||||
@@ -145,12 +145,12 @@ describe('DsDynamicTypeaheadComponent test suite', () => {
|
|||||||
// synchronous beforeEach
|
// synchronous beforeEach
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
html = `
|
html = `
|
||||||
<ds-dynamic-typeahead [bindId]="bindId"
|
<ds-dynamic-onebox [bindId]="bindId"
|
||||||
[group]="group"
|
[group]="group"
|
||||||
[model]="model"
|
[model]="model"
|
||||||
(blur)="onBlur($event)"
|
(blur)="onBlur($event)"
|
||||||
(change)="onValueChange($event)"
|
(change)="onValueChange($event)"
|
||||||
(focus)="onFocus($event)"></ds-dynamic-typeahead>`;
|
(focus)="onFocus($event)"></ds-dynamic-onebox>`;
|
||||||
|
|
||||||
spyOn(vocabularyServiceStub, 'findVocabularyById').and.returnValue(createSuccessfulRemoteDataObject$(vocabulary));
|
spyOn(vocabularyServiceStub, 'findVocabularyById').and.returnValue(createSuccessfulRemoteDataObject$(vocabulary));
|
||||||
testFixture = createTestComponent(html, TestComponent) as ComponentFixture<TestComponent>;
|
testFixture = createTestComponent(html, TestComponent) as ComponentFixture<TestComponent>;
|
||||||
@@ -160,7 +160,7 @@ describe('DsDynamicTypeaheadComponent test suite', () => {
|
|||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
testFixture.destroy();
|
testFixture.destroy();
|
||||||
});
|
});
|
||||||
it('should create DsDynamicTypeaheadComponent', inject([DsDynamicTypeaheadComponent], (app: DsDynamicTypeaheadComponent) => {
|
it('should create DsDynamicOneboxComponent', inject([DsDynamicOneboxComponent], (app: DsDynamicOneboxComponent) => {
|
||||||
expect(app).toBeDefined();
|
expect(app).toBeDefined();
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
@@ -173,190 +173,190 @@ describe('DsDynamicTypeaheadComponent test suite', () => {
|
|||||||
describe('when init model value is empty', () => {
|
describe('when init model value is empty', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|
||||||
typeaheadFixture = TestBed.createComponent(DsDynamicTypeaheadComponent);
|
oneboxCompFixture = TestBed.createComponent(DsDynamicOneboxComponent);
|
||||||
typeaheadComp = typeaheadFixture.componentInstance; // FormComponent test instance
|
oneboxComponent = oneboxCompFixture.componentInstance; // FormComponent test instance
|
||||||
typeaheadComp.group = TYPEAHEAD_TEST_GROUP;
|
oneboxComponent.group = ONEBOX_TEST_GROUP;
|
||||||
typeaheadComp.model = new DynamicTypeaheadModel(TYPEAHEAD_TEST_MODEL_CONFIG);
|
oneboxComponent.model = new DynamicOneboxModel(ONEBOX_TEST_MODEL_CONFIG);
|
||||||
typeaheadFixture.detectChanges();
|
oneboxCompFixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
typeaheadFixture.destroy();
|
oneboxCompFixture.destroy();
|
||||||
typeaheadComp = null;
|
oneboxComponent = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should init component properly', () => {
|
it('should init component properly', () => {
|
||||||
expect(typeaheadComp.currentValue).not.toBeDefined();
|
expect(oneboxComponent.currentValue).not.toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should search when 3+ characters typed', fakeAsync(() => {
|
it('should search when 3+ characters typed', fakeAsync(() => {
|
||||||
|
|
||||||
spyOn((typeaheadComp as any).vocabularyService, 'getVocabularyEntriesByValue').and.callThrough();
|
spyOn((oneboxComponent as any).vocabularyService, 'getVocabularyEntriesByValue').and.callThrough();
|
||||||
|
|
||||||
typeaheadComp.search(observableOf('test')).subscribe();
|
oneboxComponent.search(observableOf('test')).subscribe();
|
||||||
|
|
||||||
tick(300);
|
tick(300);
|
||||||
typeaheadFixture.detectChanges();
|
oneboxCompFixture.detectChanges();
|
||||||
|
|
||||||
expect((typeaheadComp as any).vocabularyService.getVocabularyEntriesByValue).toHaveBeenCalled();
|
expect((oneboxComponent as any).vocabularyService.getVocabularyEntriesByValue).toHaveBeenCalled();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should set model.value on input type when VocabularyOptions.closed is false', () => {
|
it('should set model.value on input type when VocabularyOptions.closed is false', () => {
|
||||||
const inputDe = typeaheadFixture.debugElement.query(By.css('input.form-control'));
|
const inputDe = oneboxCompFixture.debugElement.query(By.css('input.form-control'));
|
||||||
const inputElement = inputDe.nativeElement;
|
const inputElement = inputDe.nativeElement;
|
||||||
|
|
||||||
inputElement.value = 'test value';
|
inputElement.value = 'test value';
|
||||||
inputElement.dispatchEvent(new Event('input'));
|
inputElement.dispatchEvent(new Event('input'));
|
||||||
|
|
||||||
expect(typeaheadComp.inputValue).toEqual(new FormFieldMetadataValueObject('test value'))
|
expect(oneboxComponent.inputValue).toEqual(new FormFieldMetadataValueObject('test value'))
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not set model.value on input type when VocabularyOptions.closed is true', () => {
|
it('should not set model.value on input type when VocabularyOptions.closed is true', () => {
|
||||||
typeaheadComp.model.vocabularyOptions.closed = true;
|
oneboxComponent.model.vocabularyOptions.closed = true;
|
||||||
typeaheadFixture.detectChanges();
|
oneboxCompFixture.detectChanges();
|
||||||
const inputDe = typeaheadFixture.debugElement.query(By.css('input.form-control'));
|
const inputDe = oneboxCompFixture.debugElement.query(By.css('input.form-control'));
|
||||||
const inputElement = inputDe.nativeElement;
|
const inputElement = inputDe.nativeElement;
|
||||||
|
|
||||||
inputElement.value = 'test value';
|
inputElement.value = 'test value';
|
||||||
inputElement.dispatchEvent(new Event('input'));
|
inputElement.dispatchEvent(new Event('input'));
|
||||||
|
|
||||||
expect(typeaheadComp.model.value).not.toBeDefined();
|
expect(oneboxComponent.model.value).not.toBeDefined();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should emit blur Event onBlur when popup is closed', () => {
|
it('should emit blur Event onBlur when popup is closed', () => {
|
||||||
spyOn(typeaheadComp.blur, 'emit');
|
spyOn(oneboxComponent.blur, 'emit');
|
||||||
spyOn(typeaheadComp.instance, 'isPopupOpen').and.returnValue(false);
|
spyOn(oneboxComponent.instance, 'isPopupOpen').and.returnValue(false);
|
||||||
typeaheadComp.onBlur(new Event('blur'));
|
oneboxComponent.onBlur(new Event('blur'));
|
||||||
expect(typeaheadComp.blur.emit).toHaveBeenCalled();
|
expect(oneboxComponent.blur.emit).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not emit blur Event onBlur when popup is opened', () => {
|
it('should not emit blur Event onBlur when popup is opened', () => {
|
||||||
spyOn(typeaheadComp.blur, 'emit');
|
spyOn(oneboxComponent.blur, 'emit');
|
||||||
spyOn(typeaheadComp.instance, 'isPopupOpen').and.returnValue(true);
|
spyOn(oneboxComponent.instance, 'isPopupOpen').and.returnValue(true);
|
||||||
const input = typeaheadFixture.debugElement.query(By.css('input'));
|
const input = oneboxCompFixture.debugElement.query(By.css('input'));
|
||||||
|
|
||||||
input.nativeElement.blur();
|
input.nativeElement.blur();
|
||||||
expect(typeaheadComp.blur.emit).not.toHaveBeenCalled();
|
expect(oneboxComponent.blur.emit).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should emit change Event onBlur when VocabularyOptions.closed is false and inputValue is changed', () => {
|
it('should emit change Event onBlur when VocabularyOptions.closed is false and inputValue is changed', () => {
|
||||||
typeaheadComp.inputValue = 'test value';
|
oneboxComponent.inputValue = 'test value';
|
||||||
typeaheadFixture.detectChanges();
|
oneboxCompFixture.detectChanges();
|
||||||
spyOn(typeaheadComp.blur, 'emit');
|
spyOn(oneboxComponent.blur, 'emit');
|
||||||
spyOn(typeaheadComp.change, 'emit');
|
spyOn(oneboxComponent.change, 'emit');
|
||||||
spyOn(typeaheadComp.instance, 'isPopupOpen').and.returnValue(false);
|
spyOn(oneboxComponent.instance, 'isPopupOpen').and.returnValue(false);
|
||||||
typeaheadComp.onBlur(new Event('blur',));
|
oneboxComponent.onBlur(new Event('blur',));
|
||||||
expect(typeaheadComp.change.emit).toHaveBeenCalled();
|
expect(oneboxComponent.change.emit).toHaveBeenCalled();
|
||||||
expect(typeaheadComp.blur.emit).toHaveBeenCalled();
|
expect(oneboxComponent.blur.emit).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not emit change Event onBlur when VocabularyOptions.closed is false and inputValue is not changed', () => {
|
it('should not emit change Event onBlur when VocabularyOptions.closed is false and inputValue is not changed', () => {
|
||||||
typeaheadComp.inputValue = 'test value';
|
oneboxComponent.inputValue = 'test value';
|
||||||
typeaheadComp.model = new DynamicTypeaheadModel(TYPEAHEAD_TEST_MODEL_CONFIG);
|
oneboxComponent.model = new DynamicOneboxModel(ONEBOX_TEST_MODEL_CONFIG);
|
||||||
(typeaheadComp.model as any).value = 'test value';
|
(oneboxComponent.model as any).value = 'test value';
|
||||||
typeaheadFixture.detectChanges();
|
oneboxCompFixture.detectChanges();
|
||||||
spyOn(typeaheadComp.blur, 'emit');
|
spyOn(oneboxComponent.blur, 'emit');
|
||||||
spyOn(typeaheadComp.change, 'emit');
|
spyOn(oneboxComponent.change, 'emit');
|
||||||
spyOn(typeaheadComp.instance, 'isPopupOpen').and.returnValue(false);
|
spyOn(oneboxComponent.instance, 'isPopupOpen').and.returnValue(false);
|
||||||
typeaheadComp.onBlur(new Event('blur',));
|
oneboxComponent.onBlur(new Event('blur',));
|
||||||
expect(typeaheadComp.change.emit).not.toHaveBeenCalled();
|
expect(oneboxComponent.change.emit).not.toHaveBeenCalled();
|
||||||
expect(typeaheadComp.blur.emit).toHaveBeenCalled();
|
expect(oneboxComponent.blur.emit).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not emit change Event onBlur when VocabularyOptions.closed is false and inputValue is null', () => {
|
it('should not emit change Event onBlur when VocabularyOptions.closed is false and inputValue is null', () => {
|
||||||
typeaheadComp.inputValue = null;
|
oneboxComponent.inputValue = null;
|
||||||
typeaheadComp.model = new DynamicTypeaheadModel(TYPEAHEAD_TEST_MODEL_CONFIG);
|
oneboxComponent.model = new DynamicOneboxModel(ONEBOX_TEST_MODEL_CONFIG);
|
||||||
(typeaheadComp.model as any).value = 'test value';
|
(oneboxComponent.model as any).value = 'test value';
|
||||||
typeaheadFixture.detectChanges();
|
oneboxCompFixture.detectChanges();
|
||||||
spyOn(typeaheadComp.blur, 'emit');
|
spyOn(oneboxComponent.blur, 'emit');
|
||||||
spyOn(typeaheadComp.change, 'emit');
|
spyOn(oneboxComponent.change, 'emit');
|
||||||
spyOn(typeaheadComp.instance, 'isPopupOpen').and.returnValue(false);
|
spyOn(oneboxComponent.instance, 'isPopupOpen').and.returnValue(false);
|
||||||
typeaheadComp.onBlur(new Event('blur',));
|
oneboxComponent.onBlur(new Event('blur',));
|
||||||
expect(typeaheadComp.change.emit).not.toHaveBeenCalled();
|
expect(oneboxComponent.change.emit).not.toHaveBeenCalled();
|
||||||
expect(typeaheadComp.blur.emit).toHaveBeenCalled();
|
expect(oneboxComponent.blur.emit).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should emit focus Event onFocus', () => {
|
it('should emit focus Event onFocus', () => {
|
||||||
spyOn(typeaheadComp.focus, 'emit');
|
spyOn(oneboxComponent.focus, 'emit');
|
||||||
typeaheadComp.onFocus(new Event('focus'));
|
oneboxComponent.onFocus(new Event('focus'));
|
||||||
expect(typeaheadComp.focus.emit).toHaveBeenCalled();
|
expect(oneboxComponent.focus.emit).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when init model value is not empty', () => {
|
describe('when init model value is not empty', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
typeaheadFixture = TestBed.createComponent(DsDynamicTypeaheadComponent);
|
oneboxCompFixture = TestBed.createComponent(DsDynamicOneboxComponent);
|
||||||
typeaheadComp = typeaheadFixture.componentInstance; // FormComponent test instance
|
oneboxComponent = oneboxCompFixture.componentInstance; // FormComponent test instance
|
||||||
typeaheadComp.group = TYPEAHEAD_TEST_GROUP;
|
oneboxComponent.group = ONEBOX_TEST_GROUP;
|
||||||
typeaheadComp.model = new DynamicTypeaheadModel(TYPEAHEAD_TEST_MODEL_CONFIG);
|
oneboxComponent.model = new DynamicOneboxModel(ONEBOX_TEST_MODEL_CONFIG);
|
||||||
const entry = observableOf(Object.assign(new VocabularyEntry(), {
|
const entry = observableOf(Object.assign(new VocabularyEntry(), {
|
||||||
authority: null,
|
authority: null,
|
||||||
value: 'test',
|
value: 'test',
|
||||||
display: 'testDisplay'
|
display: 'testDisplay'
|
||||||
}));
|
}));
|
||||||
spyOn((typeaheadComp as any).vocabularyService, 'getVocabularyEntryByValue').and.returnValue(entry);
|
spyOn((oneboxComponent as any).vocabularyService, 'getVocabularyEntryByValue').and.returnValue(entry);
|
||||||
spyOn((typeaheadComp as any).vocabularyService, 'getVocabularyEntryByID').and.returnValue(entry);
|
spyOn((oneboxComponent as any).vocabularyService, 'getVocabularyEntryByID').and.returnValue(entry);
|
||||||
(typeaheadComp.model as any).value = new FormFieldMetadataValueObject('test', null, null, 'testDisplay');
|
(oneboxComponent.model as any).value = new FormFieldMetadataValueObject('test', null, null, 'testDisplay');
|
||||||
typeaheadFixture.detectChanges();
|
oneboxCompFixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
typeaheadFixture.destroy();
|
oneboxCompFixture.destroy();
|
||||||
typeaheadComp = null;
|
oneboxComponent = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should init component properly', fakeAsync(() => {
|
it('should init component properly', fakeAsync(() => {
|
||||||
tick();
|
tick();
|
||||||
expect(typeaheadComp.currentValue).toEqual(new FormFieldMetadataValueObject('test', null, null, 'testDisplay'));
|
expect(oneboxComponent.currentValue).toEqual(new FormFieldMetadataValueObject('test', null, null, 'testDisplay'));
|
||||||
expect((typeaheadComp as any).vocabularyService.getVocabularyEntryByValue).toHaveBeenCalled();
|
expect((oneboxComponent as any).vocabularyService.getVocabularyEntryByValue).toHaveBeenCalled();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should emit change Event onChange and currentValue is empty', () => {
|
it('should emit change Event onChange and currentValue is empty', () => {
|
||||||
typeaheadComp.currentValue = null;
|
oneboxComponent.currentValue = null;
|
||||||
spyOn(typeaheadComp.change, 'emit');
|
spyOn(oneboxComponent.change, 'emit');
|
||||||
typeaheadComp.onChange(new Event('change'));
|
oneboxComponent.onChange(new Event('change'));
|
||||||
expect(typeaheadComp.change.emit).toHaveBeenCalled();
|
expect(oneboxComponent.change.emit).toHaveBeenCalled();
|
||||||
expect(typeaheadComp.model.value).toBeNull();
|
expect(oneboxComponent.model.value).toBeNull();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when init model value is not empty and has authority', () => {
|
describe('when init model value is not empty and has authority', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
typeaheadFixture = TestBed.createComponent(DsDynamicTypeaheadComponent);
|
oneboxCompFixture = TestBed.createComponent(DsDynamicOneboxComponent);
|
||||||
typeaheadComp = typeaheadFixture.componentInstance; // FormComponent test instance
|
oneboxComponent = oneboxCompFixture.componentInstance; // FormComponent test instance
|
||||||
typeaheadComp.group = TYPEAHEAD_TEST_GROUP;
|
oneboxComponent.group = ONEBOX_TEST_GROUP;
|
||||||
typeaheadComp.model = new DynamicTypeaheadModel(TYPEAHEAD_TEST_MODEL_CONFIG);
|
oneboxComponent.model = new DynamicOneboxModel(ONEBOX_TEST_MODEL_CONFIG);
|
||||||
const entry = observableOf(Object.assign(new VocabularyEntry(), {
|
const entry = observableOf(Object.assign(new VocabularyEntry(), {
|
||||||
authority: 'test001',
|
authority: 'test001',
|
||||||
value: 'test001',
|
value: 'test001',
|
||||||
display: 'test'
|
display: 'test'
|
||||||
}));
|
}));
|
||||||
spyOn((typeaheadComp as any).vocabularyService, 'getVocabularyEntryByValue').and.returnValue(entry);
|
spyOn((oneboxComponent as any).vocabularyService, 'getVocabularyEntryByValue').and.returnValue(entry);
|
||||||
spyOn((typeaheadComp as any).vocabularyService, 'getVocabularyEntryByID').and.returnValue(entry);
|
spyOn((oneboxComponent as any).vocabularyService, 'getVocabularyEntryByID').and.returnValue(entry);
|
||||||
(typeaheadComp.model as any).value = new FormFieldMetadataValueObject('test', null, 'test001');
|
(oneboxComponent.model as any).value = new FormFieldMetadataValueObject('test', null, 'test001');
|
||||||
typeaheadFixture.detectChanges();
|
oneboxCompFixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
typeaheadFixture.destroy();
|
oneboxCompFixture.destroy();
|
||||||
typeaheadComp = null;
|
oneboxComponent = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should init component properly', fakeAsync(() => {
|
it('should init component properly', fakeAsync(() => {
|
||||||
tick();
|
tick();
|
||||||
expect(typeaheadComp.currentValue).toEqual(new FormFieldMetadataValueObject('test001', null, 'test001', 'test'));
|
expect(oneboxComponent.currentValue).toEqual(new FormFieldMetadataValueObject('test001', null, 'test001', 'test'));
|
||||||
expect((typeaheadComp as any).vocabularyService.getVocabularyEntryByID).toHaveBeenCalled();
|
expect((oneboxComponent as any).vocabularyService.getVocabularyEntryByID).toHaveBeenCalled();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should emit change Event onChange and currentValue is empty', () => {
|
it('should emit change Event onChange and currentValue is empty', () => {
|
||||||
typeaheadComp.currentValue = null;
|
oneboxComponent.currentValue = null;
|
||||||
spyOn(typeaheadComp.change, 'emit');
|
spyOn(oneboxComponent.change, 'emit');
|
||||||
typeaheadComp.onChange(new Event('change'));
|
oneboxComponent.onChange(new Event('change'));
|
||||||
expect(typeaheadComp.change.emit).toHaveBeenCalled();
|
expect(oneboxComponent.change.emit).toHaveBeenCalled();
|
||||||
expect(typeaheadComp.model.value).toBeNull();
|
expect(oneboxComponent.model.value).toBeNull();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -370,63 +370,63 @@ describe('DsDynamicTypeaheadComponent test suite', () => {
|
|||||||
describe('when init model value is empty', () => {
|
describe('when init model value is empty', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|
||||||
typeaheadFixture = TestBed.createComponent(DsDynamicTypeaheadComponent);
|
oneboxCompFixture = TestBed.createComponent(DsDynamicOneboxComponent);
|
||||||
typeaheadComp = typeaheadFixture.componentInstance; // FormComponent test instance
|
oneboxComponent = oneboxCompFixture.componentInstance; // FormComponent test instance
|
||||||
typeaheadComp.group = TYPEAHEAD_TEST_GROUP;
|
oneboxComponent.group = ONEBOX_TEST_GROUP;
|
||||||
typeaheadComp.model = new DynamicTypeaheadModel(TYPEAHEAD_TEST_MODEL_CONFIG);
|
oneboxComponent.model = new DynamicOneboxModel(ONEBOX_TEST_MODEL_CONFIG);
|
||||||
typeaheadFixture.detectChanges();
|
oneboxCompFixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
typeaheadFixture.destroy();
|
oneboxCompFixture.destroy();
|
||||||
typeaheadComp = null;
|
oneboxComponent = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should init component properly', () => {
|
it('should init component properly', () => {
|
||||||
expect(typeaheadComp.currentValue).not.toBeDefined();
|
expect(oneboxComponent.currentValue).not.toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should open tree properly', () => {
|
it('should open tree properly', () => {
|
||||||
scheduler.schedule(() => typeaheadComp.openTree(new Event('click')));
|
scheduler.schedule(() => oneboxComponent.openTree(new Event('click')));
|
||||||
scheduler.flush();
|
scheduler.flush();
|
||||||
|
|
||||||
expect((typeaheadComp as any).modalService.open).toHaveBeenCalled();
|
expect((oneboxComponent as any).modalService.open).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when init model value is not empty', () => {
|
describe('when init model value is not empty', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
typeaheadFixture = TestBed.createComponent(DsDynamicTypeaheadComponent);
|
oneboxCompFixture = TestBed.createComponent(DsDynamicOneboxComponent);
|
||||||
typeaheadComp = typeaheadFixture.componentInstance; // FormComponent test instance
|
oneboxComponent = oneboxCompFixture.componentInstance; // FormComponent test instance
|
||||||
typeaheadComp.group = TYPEAHEAD_TEST_GROUP;
|
oneboxComponent.group = ONEBOX_TEST_GROUP;
|
||||||
typeaheadComp.model = new DynamicTypeaheadModel(TYPEAHEAD_TEST_MODEL_CONFIG);
|
oneboxComponent.model = new DynamicOneboxModel(ONEBOX_TEST_MODEL_CONFIG);
|
||||||
const entry = observableOf(Object.assign(new VocabularyEntry(), {
|
const entry = observableOf(Object.assign(new VocabularyEntry(), {
|
||||||
authority: null,
|
authority: null,
|
||||||
value: 'test',
|
value: 'test',
|
||||||
display: 'testDisplay'
|
display: 'testDisplay'
|
||||||
}));
|
}));
|
||||||
spyOn((typeaheadComp as any).vocabularyService, 'getVocabularyEntryByValue').and.returnValue(entry);
|
spyOn((oneboxComponent as any).vocabularyService, 'getVocabularyEntryByValue').and.returnValue(entry);
|
||||||
spyOn((typeaheadComp as any).vocabularyService, 'getVocabularyEntryByID').and.returnValue(entry);
|
spyOn((oneboxComponent as any).vocabularyService, 'getVocabularyEntryByID').and.returnValue(entry);
|
||||||
(typeaheadComp.model as any).value = new FormFieldMetadataValueObject('test', null, null, 'testDisplay');
|
(oneboxComponent.model as any).value = new FormFieldMetadataValueObject('test', null, null, 'testDisplay');
|
||||||
typeaheadFixture.detectChanges();
|
oneboxCompFixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
typeaheadFixture.destroy();
|
oneboxCompFixture.destroy();
|
||||||
typeaheadComp = null;
|
oneboxComponent = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should init component properly', fakeAsync(() => {
|
it('should init component properly', fakeAsync(() => {
|
||||||
tick();
|
tick();
|
||||||
expect(typeaheadComp.currentValue).toEqual(new FormFieldMetadataValueObject('test', null, null, 'testDisplay'));
|
expect(oneboxComponent.currentValue).toEqual(new FormFieldMetadataValueObject('test', null, null, 'testDisplay'));
|
||||||
expect((typeaheadComp as any).vocabularyService.getVocabularyEntryByValue).toHaveBeenCalled();
|
expect((oneboxComponent as any).vocabularyService.getVocabularyEntryByValue).toHaveBeenCalled();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should open tree properly', () => {
|
it('should open tree properly', () => {
|
||||||
scheduler.schedule(() => typeaheadComp.openTree(new Event('click')));
|
scheduler.schedule(() => oneboxComponent.openTree(new Event('click')));
|
||||||
scheduler.flush();
|
scheduler.flush();
|
||||||
|
|
||||||
expect((typeaheadComp as any).modalService.open).toHaveBeenCalled();
|
expect((oneboxComponent as any).modalService.open).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -440,8 +440,8 @@ describe('DsDynamicTypeaheadComponent test suite', () => {
|
|||||||
})
|
})
|
||||||
class TestComponent {
|
class TestComponent {
|
||||||
|
|
||||||
group: FormGroup = TYPEAHEAD_TEST_GROUP;
|
group: FormGroup = ONEBOX_TEST_GROUP;
|
||||||
|
|
||||||
model = new DynamicTypeaheadModel(TYPEAHEAD_TEST_MODEL_CONFIG);
|
model = new DynamicOneboxModel(ONEBOX_TEST_MODEL_CONFIG);
|
||||||
|
|
||||||
}
|
}
|
@@ -17,7 +17,7 @@ import { Observable, of as observableOf, Subject, Subscription } from 'rxjs';
|
|||||||
import { NgbModal, NgbModalRef, NgbTypeahead, NgbTypeaheadSelectItemEvent } from '@ng-bootstrap/ng-bootstrap';
|
import { NgbModal, NgbModalRef, NgbTypeahead, NgbTypeaheadSelectItemEvent } from '@ng-bootstrap/ng-bootstrap';
|
||||||
|
|
||||||
import { VocabularyService } from '../../../../../../core/submission/vocabularies/vocabulary.service';
|
import { VocabularyService } from '../../../../../../core/submission/vocabularies/vocabulary.service';
|
||||||
import { DynamicTypeaheadModel } from './dynamic-typeahead.model';
|
import { DynamicOneboxModel } from './dynamic-onebox.model';
|
||||||
import { hasValue, isEmpty, isNotEmpty, isNotNull } from '../../../../../empty.util';
|
import { hasValue, isEmpty, isNotEmpty, isNotNull } from '../../../../../empty.util';
|
||||||
import { FormFieldMetadataValueObject } from '../../../models/form-field-metadata-value.model';
|
import { FormFieldMetadataValueObject } from '../../../models/form-field-metadata-value.model';
|
||||||
import { ConfidenceType } from '../../../../../../core/shared/confidence-type';
|
import { ConfidenceType } from '../../../../../../core/shared/confidence-type';
|
||||||
@@ -31,14 +31,14 @@ import { VocabularyTreeviewComponent } from '../../../../../vocabulary-treeview/
|
|||||||
import { VocabularyEntryDetail } from '../../../../../../core/submission/vocabularies/models/vocabulary-entry-detail.model';
|
import { VocabularyEntryDetail } from '../../../../../../core/submission/vocabularies/models/vocabulary-entry-detail.model';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-dynamic-typeahead',
|
selector: 'ds-dynamic-onebox',
|
||||||
styleUrls: ['./dynamic-typeahead.component.scss'],
|
styleUrls: ['./dynamic-onebox.component.scss'],
|
||||||
templateUrl: './dynamic-typeahead.component.html'
|
templateUrl: './dynamic-onebox.component.html'
|
||||||
})
|
})
|
||||||
export class DsDynamicTypeaheadComponent extends DsDynamicVocabularyComponent implements OnInit {
|
export class DsDynamicOneboxComponent extends DsDynamicVocabularyComponent implements OnInit {
|
||||||
@Input() bindId = true;
|
@Input() bindId = true;
|
||||||
@Input() group: FormGroup;
|
@Input() group: FormGroup;
|
||||||
@Input() model: DynamicTypeaheadModel;
|
@Input() model: DynamicOneboxModel;
|
||||||
|
|
||||||
@Output() blur: EventEmitter<any> = new EventEmitter<any>();
|
@Output() blur: EventEmitter<any> = new EventEmitter<any>();
|
||||||
@Output() change: EventEmitter<any> = new EventEmitter<any>();
|
@Output() change: EventEmitter<any> = new EventEmitter<any>();
|
||||||
@@ -76,7 +76,7 @@ export class DsDynamicTypeaheadComponent extends DsDynamicVocabularyComponent im
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a stream of text values from the `<input>` element to the stream of the array of items
|
* Converts a stream of text values from the `<input>` element to the stream of the array of items
|
||||||
* to display in the typeahead popup.
|
* to display in the onebox popup.
|
||||||
*/
|
*/
|
||||||
search = (text$: Observable<string>) => {
|
search = (text$: Observable<string>) => {
|
||||||
return text$.pipe(
|
return text$.pipe(
|
@@ -1,19 +1,19 @@
|
|||||||
import { AUTOCOMPLETE_OFF, DynamicFormControlLayout, serializable } from '@ng-dynamic-forms/core';
|
import { AUTOCOMPLETE_OFF, DynamicFormControlLayout, serializable } from '@ng-dynamic-forms/core';
|
||||||
import { DsDynamicInputModel, DsDynamicInputModelConfig } from '../ds-dynamic-input.model';
|
import { DsDynamicInputModel, DsDynamicInputModelConfig } from '../ds-dynamic-input.model';
|
||||||
|
|
||||||
export const DYNAMIC_FORM_CONTROL_TYPE_TYPEAHEAD = 'TYPEAHEAD';
|
export const DYNAMIC_FORM_CONTROL_TYPE_ONEBOX = 'ONEBOX';
|
||||||
|
|
||||||
export interface DsDynamicTypeaheadModelConfig extends DsDynamicInputModelConfig {
|
export interface DsDynamicOneboxModelConfig extends DsDynamicInputModelConfig {
|
||||||
minChars?: number;
|
minChars?: number;
|
||||||
value?: any;
|
value?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DynamicTypeaheadModel extends DsDynamicInputModel {
|
export class DynamicOneboxModel extends DsDynamicInputModel {
|
||||||
|
|
||||||
@serializable() minChars: number;
|
@serializable() minChars: number;
|
||||||
@serializable() readonly type: string = DYNAMIC_FORM_CONTROL_TYPE_TYPEAHEAD;
|
@serializable() readonly type: string = DYNAMIC_FORM_CONTROL_TYPE_ONEBOX;
|
||||||
|
|
||||||
constructor(config: DsDynamicTypeaheadModelConfig, layout?: DynamicFormControlLayout) {
|
constructor(config: DsDynamicOneboxModelConfig, layout?: DynamicFormControlLayout) {
|
||||||
|
|
||||||
super(config, layout);
|
super(config, layout);
|
||||||
|
|
@@ -34,7 +34,7 @@ import { DynamicScrollableDropdownModel } from './ds-dynamic-form-ui/models/scro
|
|||||||
import { DynamicRelationGroupModel } from './ds-dynamic-form-ui/models/relation-group/dynamic-relation-group.model';
|
import { DynamicRelationGroupModel } from './ds-dynamic-form-ui/models/relation-group/dynamic-relation-group.model';
|
||||||
import { DynamicLookupModel } from './ds-dynamic-form-ui/models/lookup/dynamic-lookup.model';
|
import { DynamicLookupModel } from './ds-dynamic-form-ui/models/lookup/dynamic-lookup.model';
|
||||||
import { DynamicDsDatePickerModel } from './ds-dynamic-form-ui/models/date-picker/date-picker.model';
|
import { DynamicDsDatePickerModel } from './ds-dynamic-form-ui/models/date-picker/date-picker.model';
|
||||||
import { DynamicTypeaheadModel } from './ds-dynamic-form-ui/models/typeahead/dynamic-typeahead.model';
|
import { DynamicOneboxModel } from './ds-dynamic-form-ui/models/onebox/dynamic-onebox.model';
|
||||||
import { DynamicListRadioGroupModel } from './ds-dynamic-form-ui/models/list/dynamic-list-radio-group.model';
|
import { DynamicListRadioGroupModel } from './ds-dynamic-form-ui/models/list/dynamic-list-radio-group.model';
|
||||||
import { VocabularyOptions } from '../../../core/submission/vocabularies/models/vocabulary-options.model';
|
import { VocabularyOptions } from '../../../core/submission/vocabularies/models/vocabulary-options.model';
|
||||||
import { FormFieldModel } from './models/form-field.model';
|
import { FormFieldModel } from './models/form-field.model';
|
||||||
@@ -195,7 +195,7 @@ describe('FormBuilderService test suite', () => {
|
|||||||
|
|
||||||
new DynamicColorPickerModel({id: 'testColorPicker'}),
|
new DynamicColorPickerModel({id: 'testColorPicker'}),
|
||||||
|
|
||||||
new DynamicTypeaheadModel({id: 'testTypeahead', repeatable: false, metadataFields: [], submissionId: '1234'}),
|
new DynamicOneboxModel({id: 'testOnebox', repeatable: false, metadataFields: [], submissionId: '1234'}),
|
||||||
|
|
||||||
new DynamicScrollableDropdownModel({id: 'testScrollableDropdown', vocabularyOptions: vocabularyOptions, repeatable: false, metadataFields: [], submissionId: '1234'}),
|
new DynamicScrollableDropdownModel({id: 'testScrollableDropdown', vocabularyOptions: vocabularyOptions, repeatable: false, metadataFields: [], submissionId: '1234'}),
|
||||||
|
|
||||||
@@ -433,7 +433,7 @@ describe('FormBuilderService test suite', () => {
|
|||||||
|
|
||||||
expect(formModel[2] instanceof DynamicRowGroupModel).toBe(true);
|
expect(formModel[2] instanceof DynamicRowGroupModel).toBe(true);
|
||||||
expect((formModel[2] as DynamicRowGroupModel).group.length).toBe(1);
|
expect((formModel[2] as DynamicRowGroupModel).group.length).toBe(1);
|
||||||
expect((formModel[2] as DynamicRowGroupModel).get(0) instanceof DynamicTypeaheadModel).toBe(true);
|
expect((formModel[2] as DynamicRowGroupModel).get(0) instanceof DynamicOneboxModel).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return form\'s fields value from form model', () => {
|
it('should return form\'s fields value from form model', () => {
|
||||||
@@ -449,7 +449,7 @@ describe('FormBuilderService test suite', () => {
|
|||||||
};
|
};
|
||||||
expect(service.getValueFromModel(formModel)).toEqual(value);
|
expect(service.getValueFromModel(formModel)).toEqual(value);
|
||||||
|
|
||||||
((formModel[2] as DynamicRowGroupModel).get(0) as DynamicTypeaheadModel).valueUpdates.next('test one');
|
((formModel[2] as DynamicRowGroupModel).get(0) as DynamicOneboxModel).valueUpdates.next('test one');
|
||||||
value = {
|
value = {
|
||||||
issue: [new FormFieldMetadataValueObject('test')],
|
issue: [new FormFieldMetadataValueObject('test')],
|
||||||
conference: [new FormFieldMetadataValueObject('test one')]
|
conference: [new FormFieldMetadataValueObject('test one')]
|
||||||
@@ -462,11 +462,11 @@ describe('FormBuilderService test suite', () => {
|
|||||||
const value = {} as any;
|
const value = {} as any;
|
||||||
|
|
||||||
((formModel[0] as DynamicRowGroupModel).get(1) as DsDynamicInputModel).valueUpdates.next('test');
|
((formModel[0] as DynamicRowGroupModel).get(1) as DsDynamicInputModel).valueUpdates.next('test');
|
||||||
((formModel[2] as DynamicRowGroupModel).get(0) as DynamicTypeaheadModel).valueUpdates.next('test one');
|
((formModel[2] as DynamicRowGroupModel).get(0) as DynamicOneboxModel).valueUpdates.next('test one');
|
||||||
|
|
||||||
service.clearAllModelsValue(formModel);
|
service.clearAllModelsValue(formModel);
|
||||||
expect(((formModel[0] as DynamicRowGroupModel).get(1) as DynamicTypeaheadModel).value).toEqual(undefined)
|
expect(((formModel[0] as DynamicRowGroupModel).get(1) as DynamicOneboxModel).value).toEqual(undefined)
|
||||||
expect(((formModel[2] as DynamicRowGroupModel).get(0) as DynamicTypeaheadModel).value).toEqual(undefined)
|
expect(((formModel[2] as DynamicRowGroupModel).get(0) as DynamicOneboxModel).value).toEqual(undefined)
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return true when model has a custom group model as parent', () => {
|
it('should return true when model has a custom group model as parent', () => {
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import { FormFieldModel } from '../models/form-field.model';
|
import { FormFieldModel } from '../models/form-field.model';
|
||||||
import { OneboxFieldParser } from './onebox-field-parser';
|
import { OneboxFieldParser } from './onebox-field-parser';
|
||||||
import { DynamicQualdropModel } from '../ds-dynamic-form-ui/models/ds-dynamic-qualdrop.model';
|
import { DynamicQualdropModel } from '../ds-dynamic-form-ui/models/ds-dynamic-qualdrop.model';
|
||||||
import { DynamicTypeaheadModel } from '../ds-dynamic-form-ui/models/typeahead/dynamic-typeahead.model';
|
import { DynamicOneboxModel } from '../ds-dynamic-form-ui/models/onebox/dynamic-onebox.model';
|
||||||
import { DsDynamicInputModel } from '../ds-dynamic-form-ui/models/ds-dynamic-input.model';
|
import { DsDynamicInputModel } from '../ds-dynamic-form-ui/models/ds-dynamic-input.model';
|
||||||
import { ParserOptions } from './parser-options';
|
import { ParserOptions } from './parser-options';
|
||||||
|
|
||||||
@@ -92,12 +92,12 @@ describe('OneboxFieldParser test suite', () => {
|
|||||||
expect(fieldModel instanceof DsDynamicInputModel).toBe(true);
|
expect(fieldModel instanceof DsDynamicInputModel).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a DynamicTypeaheadModel object when selectableMetadata has authority', () => {
|
it('should return a DynamicOneboxModel object when selectableMetadata has authority', () => {
|
||||||
const parser = new OneboxFieldParser(submissionId, field1, initFormValues, parserOptions);
|
const parser = new OneboxFieldParser(submissionId, field1, initFormValues, parserOptions);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
expect(fieldModel instanceof DynamicTypeaheadModel).toBe(true);
|
expect(fieldModel instanceof DynamicOneboxModel).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@@ -12,9 +12,9 @@ import { FormFieldMetadataValueObject } from '../models/form-field-metadata-valu
|
|||||||
import { isNotEmpty } from '../../../empty.util';
|
import { isNotEmpty } from '../../../empty.util';
|
||||||
import { DsDynamicInputModel, DsDynamicInputModelConfig } from '../ds-dynamic-form-ui/models/ds-dynamic-input.model';
|
import { DsDynamicInputModel, DsDynamicInputModelConfig } from '../ds-dynamic-form-ui/models/ds-dynamic-input.model';
|
||||||
import {
|
import {
|
||||||
DsDynamicTypeaheadModelConfig,
|
DsDynamicOneboxModelConfig,
|
||||||
DynamicTypeaheadModel
|
DynamicOneboxModel
|
||||||
} from '../ds-dynamic-form-ui/models/typeahead/dynamic-typeahead.model';
|
} from '../ds-dynamic-form-ui/models/onebox/dynamic-onebox.model';
|
||||||
|
|
||||||
export class OneboxFieldParser extends FieldParser {
|
export class OneboxFieldParser extends FieldParser {
|
||||||
|
|
||||||
@@ -76,11 +76,11 @@ export class OneboxFieldParser extends FieldParser {
|
|||||||
|
|
||||||
return new DynamicQualdropModel(inputSelectGroup, clsGroup);
|
return new DynamicQualdropModel(inputSelectGroup, clsGroup);
|
||||||
} else if (this.configData.selectableMetadata[0].controlledVocabulary) {
|
} else if (this.configData.selectableMetadata[0].controlledVocabulary) {
|
||||||
const typeaheadModelConfig: DsDynamicTypeaheadModelConfig = this.initModel(null, label);
|
const oneboxModelConfig: DsDynamicOneboxModelConfig = this.initModel(null, label);
|
||||||
this.setVocabularyOptions(typeaheadModelConfig, this.parserOptions.collectionUUID);
|
this.setVocabularyOptions(oneboxModelConfig, this.parserOptions.collectionUUID);
|
||||||
this.setValues(typeaheadModelConfig, fieldValue, true);
|
this.setValues(oneboxModelConfig, fieldValue, true);
|
||||||
|
|
||||||
return new DynamicTypeaheadModel(typeaheadModelConfig);
|
return new DynamicOneboxModel(oneboxModelConfig);
|
||||||
} else {
|
} else {
|
||||||
const inputModelConfig: DsDynamicInputModelConfig = this.initModel(null, label);
|
const inputModelConfig: DsDynamicInputModelConfig = this.initModel(null, label);
|
||||||
this.setValues(inputModelConfig, fieldValue);
|
this.setValues(inputModelConfig, fieldValue);
|
||||||
|
@@ -48,7 +48,7 @@ import { VarDirective } from './utils/var.directive';
|
|||||||
import { AuthNavMenuComponent } from './auth-nav-menu/auth-nav-menu.component';
|
import { AuthNavMenuComponent } from './auth-nav-menu/auth-nav-menu.component';
|
||||||
import { LogOutComponent } from './log-out/log-out.component';
|
import { LogOutComponent } from './log-out/log-out.component';
|
||||||
import { FormComponent } from './form/form.component';
|
import { FormComponent } from './form/form.component';
|
||||||
import { DsDynamicTypeaheadComponent } from './form/builder/ds-dynamic-form-ui/models/typeahead/dynamic-typeahead.component';
|
import { DsDynamicOneboxComponent } from './form/builder/ds-dynamic-form-ui/models/onebox/dynamic-onebox.component';
|
||||||
import { DsDynamicScrollableDropdownComponent } from './form/builder/ds-dynamic-form-ui/models/scrollable-dropdown/dynamic-scrollable-dropdown.component';
|
import { DsDynamicScrollableDropdownComponent } from './form/builder/ds-dynamic-form-ui/models/scrollable-dropdown/dynamic-scrollable-dropdown.component';
|
||||||
import {
|
import {
|
||||||
DsDynamicFormControlContainerComponent,
|
DsDynamicFormControlContainerComponent,
|
||||||
@@ -271,7 +271,7 @@ const COMPONENTS = [
|
|||||||
DsDynamicLookupRelationModalComponent,
|
DsDynamicLookupRelationModalComponent,
|
||||||
DsDynamicScrollableDropdownComponent,
|
DsDynamicScrollableDropdownComponent,
|
||||||
DsDynamicTagComponent,
|
DsDynamicTagComponent,
|
||||||
DsDynamicTypeaheadComponent,
|
DsDynamicOneboxComponent,
|
||||||
DsDynamicRelationGroupComponent,
|
DsDynamicRelationGroupComponent,
|
||||||
DsDatePickerComponent,
|
DsDatePickerComponent,
|
||||||
DsDynamicFormGroupComponent,
|
DsDynamicFormGroupComponent,
|
||||||
@@ -415,7 +415,7 @@ const ENTRY_COMPONENTS = [
|
|||||||
DsDynamicLookupRelationModalComponent,
|
DsDynamicLookupRelationModalComponent,
|
||||||
DsDynamicScrollableDropdownComponent,
|
DsDynamicScrollableDropdownComponent,
|
||||||
DsDynamicTagComponent,
|
DsDynamicTagComponent,
|
||||||
DsDynamicTypeaheadComponent,
|
DsDynamicOneboxComponent,
|
||||||
DsDynamicRelationGroupComponent,
|
DsDynamicRelationGroupComponent,
|
||||||
DsDatePickerComponent,
|
DsDatePickerComponent,
|
||||||
DsDynamicFormGroupComponent,
|
DsDynamicFormGroupComponent,
|
||||||
|
Reference in New Issue
Block a user