Adds new field on Dataset Template that link back to Open DMP entities (Dataset Descriptions) (Issue #129).

This commit is contained in:
gkolokythas 2019-07-30 13:35:06 +03:00
parent 81fb715a9d
commit ff8ab5ad3e
19 changed files with 200 additions and 27 deletions

View File

@ -70,8 +70,8 @@ public class ModelBuilder {
if (dataElement.getAttribute("type").equals("researchers")) { if (dataElement.getAttribute("type").equals("researchers")) {
return (FieldData<U>) new ResearchersAutoCompleteData().fromData(data); return (FieldData<U>) new ResearchersAutoCompleteData().fromData(data);
} }
// } else if (dataElement.getAttribute("type").equals("wordlist")) else if (dataElement.getAttribute("type").equals("datasets"))
// return (FieldData<U>) new WordListData().fromData(data); return (FieldData<U>) new DatasetsAutoCompleteData().fromData(data);
} }
} }
if (type.equals("booleanDecision")) return (FieldData<U>) new BooleanDecisionData().fromData(data); if (type.equals("booleanDecision")) return (FieldData<U>) new BooleanDecisionData().fromData(data);
@ -96,6 +96,9 @@ public class ModelBuilder {
if (internalDmpEntitiesType.equals("researchers")) { if (internalDmpEntitiesType.equals("researchers")) {
return (FieldData<U>) new ResearchersAutoCompleteData().fromData(data); return (FieldData<U>) new ResearchersAutoCompleteData().fromData(data);
} }
else if (internalDmpEntitiesType.equals("datasets")) {
return (FieldData<U>) new DatasetsAutoCompleteData().fromData(data);
}
} }
if (type.equals("booleanDecision")) return (FieldData<U>) new BooleanDecisionData().fromData(data); if (type.equals("booleanDecision")) return (FieldData<U>) new BooleanDecisionData().fromData(data);
if (type.equals("radiobox")) return (FieldData<U>) new RadioBoxData().fromData(data); if (type.equals("radiobox")) return (FieldData<U>) new RadioBoxData().fromData(data);
@ -105,6 +108,4 @@ public class ModelBuilder {
if (type.equals("datePicker")) return (FieldData<U>) new DatePickerData().fromData(data); if (type.equals("datePicker")) return (FieldData<U>) new DatePickerData().fromData(data);
return null; return null;
} }
} }

View File

@ -0,0 +1,59 @@
package eu.eudat.models.data.components.commons.datafield;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.util.HashMap;
import java.util.Map;
public class DatasetsAutoCompleteData extends InternalDmpEntitiesData<DatasetsAutoCompleteData> {
private Boolean multiAutoComplete;
public Boolean getMultiAutoComplete() {
return multiAutoComplete;
}
public void setMultiAutoComplete(Boolean multiAutoComplete) {
this.multiAutoComplete = multiAutoComplete;
}
@Override
public Element toXml(Document doc) {
Element root = super.toXml(doc);
root.setAttribute("multiAutoComplete", this.multiAutoComplete.toString());
return root;
}
@Override
public DatasetsAutoCompleteData fromXml(Element item) {
super.fromXml(item);
this.multiAutoComplete = Boolean.parseBoolean(item.getAttribute("multiAutoComplete"));
return this;
}
@Override
public DatasetsAutoCompleteData fromData(Object data) {
super.fromData(data);
if (data != null) {
this.multiAutoComplete = (Boolean) ((Map<Boolean, Object>) data).get("multiAutoComplete");
}
return this;
}
@Override
public Object toData() {
// TODO Auto-generated method stub
return null;
}
@Override
public Map<String, Object> toMap(Element item) {
HashMap dataMap = new HashMap();
dataMap.put("label", item != null ? item.getAttribute("label") : "");
dataMap.put("type", item != null ? item.getAttribute("type") : "researchers");
return dataMap;
}
}

View File

@ -1,5 +1,5 @@
export enum DatasetProfileInternalDmpEntitiesType { export enum DatasetProfileInternalDmpEntitiesType {
Researchers = "researchers", Researchers = "researchers",
Dmps = "dmps", Dmps = "dmps",
Dataset = "dataset" Datasets = "datasets"
} }

View File

@ -51,3 +51,8 @@ export interface ResearchersAutoCompleteFieldData extends FieldData {
type: DatasetProfileInternalDmpEntitiesType; type: DatasetProfileInternalDmpEntitiesType;
multiAutoComplete: boolean; multiAutoComplete: boolean;
} }
export interface DatasetsAutoCompleteFieldData extends FieldData {
type: DatasetProfileInternalDmpEntitiesType;
multiAutoComplete: boolean;
}

View File

@ -88,6 +88,7 @@ export class EnumUtils {
toDatasetProfileInternalDmpEntitiesTypeString(status: DatasetProfileInternalDmpEntitiesType): string { toDatasetProfileInternalDmpEntitiesTypeString(status: DatasetProfileInternalDmpEntitiesType): string {
switch (status) { switch (status) {
case DatasetProfileInternalDmpEntitiesType.Researchers: return this.language.instant('TYPES.DATASET-PROFILE-INTERNAL-DMP-ENTITIES-TYPE.RESEARCHERS'); case DatasetProfileInternalDmpEntitiesType.Researchers: return this.language.instant('TYPES.DATASET-PROFILE-INTERNAL-DMP-ENTITIES-TYPE.RESEARCHERS');
case DatasetProfileInternalDmpEntitiesType.Datasets: return this.language.instant('TYPES.DATASET-PROFILE-INTERNAL-DMP-ENTITIES-TYPE.DATASETS');
} }
} }
} }

View File

@ -0,0 +1,27 @@
import { FieldDataEditorModel } from "./field-data-editor-model";
import { DatasetProfileInternalDmpEntitiesType } from "../../../../../core/common/enum/dataset-profile-internal-dmp-entities-type";
import { FieldDataOptionEditorModel } from "./field-data-option-editor-model";
import { DatasetsAutoCompleteFieldData } from "../../../../../core/model/dataset-profile-definition/field-data/field-data";
import { FormGroup } from "@angular/forms";
export class DatasetsAutoCompleteFieldDataEditorModel extends FieldDataEditorModel<DatasetsAutoCompleteFieldDataEditorModel> {
public type: DatasetProfileInternalDmpEntitiesType = DatasetProfileInternalDmpEntitiesType.Datasets;
public multiAutoComplete: boolean = false;
public autoCompleteOptions: FieldDataOptionEditorModel = new FieldDataOptionEditorModel();
buildForm(disabled: boolean = false, skipDisable: Array<String> = []): FormGroup {
const formGroup = this.formBuilder.group({
label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('DatasetsAutoCompleteFieldDataEditorModel.label')) }],
type: [{ value: this.type, disabled: (disabled && !skipDisable.includes('DatasetsAutoCompleteFieldDataEditorModel.type')) }],
multiAutoComplete: [{ value: this.multiAutoComplete, disabled: (disabled && !skipDisable.includes('DatasetsAutoCompleteFieldDataEditorModel.multiAutoComplete')) }]
})
return formGroup;
}
fromModel(item: DatasetsAutoCompleteFieldData): DatasetsAutoCompleteFieldDataEditorModel {
this.label = item.label;
this.type = item.type;
this.multiAutoComplete = item.multiAutoComplete;
return this;
}
}

View File

@ -7,7 +7,7 @@ import { ResearchersAutoCompleteFieldData } from "../../../../../core/model/data
export class ResearchersAutoCompleteFieldDataEditorModel extends FieldDataEditorModel<ResearchersAutoCompleteFieldDataEditorModel> { export class ResearchersAutoCompleteFieldDataEditorModel extends FieldDataEditorModel<ResearchersAutoCompleteFieldDataEditorModel> {
public type: DatasetProfileInternalDmpEntitiesType = DatasetProfileInternalDmpEntitiesType.Researchers; public type: DatasetProfileInternalDmpEntitiesType = DatasetProfileInternalDmpEntitiesType.Researchers;
public multiAutoComplete: boolean; public multiAutoComplete: boolean = false;
public autoCompleteOptions: FieldDataOptionEditorModel = new FieldDataOptionEditorModel(); public autoCompleteOptions: FieldDataOptionEditorModel = new FieldDataOptionEditorModel();
buildForm(disabled: boolean = false, skipDisable: Array<String> = []): FormGroup { buildForm(disabled: boolean = false, skipDisable: Array<String> = []): FormGroup {

View File

@ -16,6 +16,7 @@ import { VisibilityEditorModel } from './visibility-editor-model';
import { DatasetProfileEditorDatePickerFieldComponent } from '../editor/components/field-type/datepicker/dataset-profile-editor-date-picker-field.component'; import { DatasetProfileEditorDatePickerFieldComponent } from '../editor/components/field-type/datepicker/dataset-profile-editor-date-picker-field.component';
import { DatePickerDataEditorModel } from './field-data/date-picker-data-editor-models'; import { DatePickerDataEditorModel } from './field-data/date-picker-data-editor-models';
import { ResearchersAutoCompleteFieldDataEditorModel } from './field-data/researchers-auto-complete-field-data-editor-model'; import { ResearchersAutoCompleteFieldDataEditorModel } from './field-data/researchers-auto-complete-field-data-editor-model';
import { DatasetsAutoCompleteFieldDataEditorModel } from './field-data/datasets-autocomplete-field-data-editor-mode';
export class FieldEditorModel extends BaseFormModel { export class FieldEditorModel extends BaseFormModel {
@ -44,6 +45,7 @@ export class FieldEditorModel extends BaseFormModel {
if (item.data.type === 'wordlist') { this.data = new WordListFieldDataEditorModel().fromModel(item.data); } if (item.data.type === 'wordlist') { this.data = new WordListFieldDataEditorModel().fromModel(item.data); }
} else if (this.viewStyle.renderStyle === 'internalDmpEntities') { } else if (this.viewStyle.renderStyle === 'internalDmpEntities') {
if (item.data.type === 'researchers') { this.data = new ResearchersAutoCompleteFieldDataEditorModel().fromModel(item.data); } if (item.data.type === 'researchers') { this.data = new ResearchersAutoCompleteFieldDataEditorModel().fromModel(item.data); }
if (item.data.type === 'datasets') { this.data = new DatasetsAutoCompleteFieldDataEditorModel().fromModel(item.data); }
} else { } else {
if (this.viewStyle.renderStyle === 'radiobox') { this.data = new RadioBoxFieldDataEditorModel().fromModel(item.data); } if (this.viewStyle.renderStyle === 'radiobox') { this.data = new RadioBoxFieldDataEditorModel().fromModel(item.data); }
if (this.viewStyle.renderStyle === 'checkBox') { this.data = new CheckBoxFieldDataEditorModel().fromModel(item.data); } if (this.viewStyle.renderStyle === 'checkBox') { this.data = new CheckBoxFieldDataEditorModel().fromModel(item.data); }

View File

@ -25,6 +25,7 @@ import { DatasetProfileEditorDatePickerFieldComponent } from './editor/component
import { DialodConfirmationUploadDatasetProfiles } from './listing/criteria/dialog-confirmation-upload-profile/dialog-confirmation-upload-profiles.component'; import { DialodConfirmationUploadDatasetProfiles } from './listing/criteria/dialog-confirmation-upload-profile/dialog-confirmation-upload-profiles.component';
import { DatasetProfileEditorInternalDmpEntitiesFieldComponent } from './editor/components/field-type/internal-dmp-entities/dataset-profile-editor-internal-dmp-entities-field.component'; import { DatasetProfileEditorInternalDmpEntitiesFieldComponent } from './editor/components/field-type/internal-dmp-entities/dataset-profile-editor-internal-dmp-entities-field.component';
import { DatasetProfileEditorResearchersAutoCompleteFieldComponent } from './editor/components/field-type/researchers-auto-complete/dataset-profile-editor-researchers-auto-complete-field.component'; import { DatasetProfileEditorResearchersAutoCompleteFieldComponent } from './editor/components/field-type/researchers-auto-complete/dataset-profile-editor-researchers-auto-complete-field.component';
import { DatasetProfileEditorDatasetsAutoCompleteFieldComponent } from './editor/components/field-type/datasets-auto-complete/dataset-profile-editor-datasets-autocomplete-field.component';
@NgModule({ @NgModule({
imports: [ imports: [
@ -55,7 +56,8 @@ import { DatasetProfileEditorResearchersAutoCompleteFieldComponent } from './edi
DatasetProfileEditorDefaultValueComponent, DatasetProfileEditorDefaultValueComponent,
DialodConfirmationUploadDatasetProfiles, DialodConfirmationUploadDatasetProfiles,
DatasetProfileEditorInternalDmpEntitiesFieldComponent, DatasetProfileEditorInternalDmpEntitiesFieldComponent,
DatasetProfileEditorResearchersAutoCompleteFieldComponent DatasetProfileEditorResearchersAutoCompleteFieldComponent,
DatasetProfileEditorDatasetsAutoCompleteFieldComponent
], ],
entryComponents: [ entryComponents: [
DialodConfirmationUploadDatasetProfiles DialodConfirmationUploadDatasetProfiles

View File

@ -41,6 +41,9 @@
<!-- InternalDmpEntities --> <!-- InternalDmpEntities -->
<mat-form-field class="col-md-12" *ngIf="viewStyle === viewStyleEnum.InternalDmpEntities && internalDmpEntitiesType === internalDmpEntitiesTypeEnum.Researchers"> <mat-form-field class="col-md-12" *ngIf="viewStyle === viewStyleEnum.InternalDmpEntities && internalDmpEntitiesType === internalDmpEntitiesTypeEnum.Researchers">
<input matInput type="text" [placeholder]="placeHolder" [formControl]="form" [required]="required"> <input matInput type="text" [placeholder]="placeHolder" [formControl]="form" [required]="required">
</mat-form-field>
<mat-form-field class="col-md-12" *ngIf="viewStyle === viewStyleEnum.InternalDmpEntities && internalDmpEntitiesType === internalDmpEntitiesTypeEnum.Datasets">
<input matInput type="text" [placeholder]="placeHolder" [formControl]="form" [required]="required">
</mat-form-field> </mat-form-field>
<!-- FreeText --> <!-- FreeText -->

View File

@ -0,0 +1,12 @@
<div class="row" *ngIf="form.get('data')">
<h5 style="font-weight: bold" class="col-auto">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-TITLE' | translate}}</h5>
<mat-checkbox class="col-auto" [formControl]="this.form.get('data').get('multiAutoComplete')">
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-MULTIPLE-AUTOCOMPLETE' | translate}}
</mat-checkbox>
<mat-form-field class="col-12">
<input matInput type="string" placeholder="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-DATASETS-PLACEHOLDER' | translate}}"
[formControl]="form.get('data').get('label')">
</mat-form-field>
</div>

View File

@ -0,0 +1,19 @@
import { OnInit, Input, Component } from "@angular/core";
import { FormGroup } from "@angular/forms";
import { DatasetProfileInternalDmpEntitiesType } from "../../../../../../../core/common/enum/dataset-profile-internal-dmp-entities-type";
import { DatasetsAutoCompleteFieldDataEditorModel } from "../../../../admin/field-data/datasets-autocomplete-field-data-editor-mode";
@Component({
selector: 'app-dataset-profile-editor-datasets-autocomplete-field-component',
styleUrls: ['./dataset-profile-editor-datasets-autocomplete-field.component.scss'],
templateUrl: './dataset-profile-editor-datasets-autocomplete-field.component.html'
})
export class DatasetProfileEditorDatasetsAutoCompleteFieldComponent implements OnInit {
@Input() form: FormGroup;
private data: DatasetsAutoCompleteFieldDataEditorModel = new DatasetsAutoCompleteFieldDataEditorModel();
ngOnInit() {
this.data.type = DatasetProfileInternalDmpEntitiesType.Datasets;
}
}

View File

@ -2,7 +2,9 @@
<mat-form-field class="col-12"> <mat-form-field class="col-12">
<mat-select placeholder="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-INTERNAL-DMP-ENTITIES-TYPE' | translate}}" [formControl]="this.form.get('data').get('type')"> <mat-select placeholder="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-INTERNAL-DMP-ENTITIES-TYPE' | translate}}" [formControl]="this.form.get('data').get('type')">
<mat-option [value]="options.Researchers">{{enumUtils.toDatasetProfileInternalDmpEntitiesTypeString(options.Researchers)}}</mat-option> <mat-option [value]="options.Researchers">{{enumUtils.toDatasetProfileInternalDmpEntitiesTypeString(options.Researchers)}}</mat-option>
<mat-option [value]="options.Datasets">{{enumUtils.toDatasetProfileInternalDmpEntitiesTypeString(options.Datasets)}}</mat-option>
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>
<app-dataset-profile-editor-researchers-auto-complete-field-component *ngIf="this.form.get('data').get('type').value === options.Researchers" class="col-12" [form]="form"></app-dataset-profile-editor-researchers-auto-complete-field-component> <app-dataset-profile-editor-researchers-auto-complete-field-component *ngIf="this.form.get('data').get('type').value === options.Researchers" class="col-12" [form]="form"></app-dataset-profile-editor-researchers-auto-complete-field-component>
<app-dataset-profile-editor-datasets-autocomplete-field-component *ngIf="this.form.get('data').get('type').value === options.Datasets" class="col-12" [form]="form"></app-dataset-profile-editor-datasets-autocomplete-field-component>
</div> </div>

View File

@ -5,6 +5,8 @@ import { FormGroup } from "@angular/forms";
import { BaseComponent } from "../../../../../../../core/common/base/base.component"; import { BaseComponent } from "../../../../../../../core/common/base/base.component";
import { takeUntil } from "rxjs/operators"; import { takeUntil } from "rxjs/operators";
import { ResearchersAutoCompleteFieldDataEditorModel } from "../../../../admin/field-data/researchers-auto-complete-field-data-editor-model"; import { ResearchersAutoCompleteFieldDataEditorModel } from "../../../../admin/field-data/researchers-auto-complete-field-data-editor-model";
import { DatasetsAutoCompleteFieldDataEditorModel } from "../../../../admin/field-data/datasets-autocomplete-field-data-editor-mode";
@Component({ @Component({
selector: 'app-dataset-profile-internal-dmp-entities-field-component', selector: 'app-dataset-profile-internal-dmp-entities-field-component',
@ -30,6 +32,8 @@ export class DatasetProfileEditorInternalDmpEntitiesFieldComponent extends BaseC
if (this.form.get('data')) { this.form.removeControl('data'); } if (this.form.get('data')) { this.form.removeControl('data'); }
if (x === DatasetProfileInternalDmpEntitiesType.Researchers) { if (x === DatasetProfileInternalDmpEntitiesType.Researchers) {
this.form.addControl('data', new ResearchersAutoCompleteFieldDataEditorModel().buildForm()); this.form.addControl('data', new ResearchersAutoCompleteFieldDataEditorModel().buildForm());
} else if (x === DatasetProfileInternalDmpEntitiesType.Datasets) {
this.form.addControl('data', new DatasetsAutoCompleteFieldDataEditorModel().buildForm());
} }
this.setupListeners(); this.setupListeners();
}) })

View File

@ -30,7 +30,6 @@
placeHolder="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.DEFAULT-VALUE' | translate}}" [required]="defaulValueRequired(form.get('viewStyle').get('renderStyle').value)"> placeHolder="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.DEFAULT-VALUE' | translate}}" [required]="defaulValueRequired(form.get('viewStyle').get('renderStyle').value)">
</app-component-profile-editor-default-value-component> </app-component-profile-editor-default-value-component>
<mat-form-field class="col" *ngIf="!(defaulValueRequired(form.get('viewStyle').get('renderStyle').value))"> <mat-form-field class="col" *ngIf="!(defaulValueRequired(form.get('viewStyle').get('renderStyle').value))">
<mat-select placeholder="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.VALIDATION' | translate}}" [formControl]="this.form.get('validations')" <mat-select placeholder="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.VALIDATION' | translate}}" [formControl]="this.form.get('validations')"
multiple> multiple>

View File

@ -59,6 +59,21 @@
</div> </div>
<mat-hint>{{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }}</mat-hint> <mat-hint>{{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }}</mat-hint>
</mat-form-field> </mat-form-field>
<mat-form-field class="col-md-12" *ngIf="form.get('data').value.type === this.datasetProfileInternalDmpEntitiesTypeEnum.Datasets">
<div *ngIf="form.get('data').value.multiAutoComplete">
<app-multiple-auto-complete placeholder="{{ form.get('data').value.label | translate }}" [formControl]="form.get('value')"
[configuration]="multipleAutoCompleteConfiguration" (optionRemoved)="_optionRemove($event)">
</app-multiple-auto-complete>
</div>
<div *ngIf="!(form.get('data').value.multiAutoComplete)">
<app-single-auto-complete placeholder="{{ form.get('data').value.label | translate }}" [formControl]="form.get('value')"
[configuration]="singleAutoCompleteConfiguration" [required]="form.get('validationRequired').value">
</app-single-auto-complete>
<mat-error *ngIf="form.get('value').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}
</mat-error>
</div>
<mat-hint>{{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }}</mat-hint>
</mat-form-field>
</div> </div>
</div> </div>

View File

@ -14,6 +14,9 @@ import { DatasetProfileInternalDmpEntitiesType } from '../../../../../core/commo
import { ResearcherCriteria } from '../../../../../core/query/researcher/researcher-criteria'; import { ResearcherCriteria } from '../../../../../core/query/researcher/researcher-criteria';
import { ExternalSourcesService } from '../../../../../core/services/external-sources/external-sources.service'; import { ExternalSourcesService } from '../../../../../core/services/external-sources/external-sources.service';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { DatasetCriteria } from '../../../../../core/query/dataset/dataset-criteria';
import { DatasetService } from '../../../../../core/services/dataset/dataset.service';
import { DataTableRequest } from '../../../../../core/model/data-table/data-table-request';
@Component({ @Component({
selector: 'app-form-field', selector: 'app-form-field',
@ -40,7 +43,8 @@ export class FormFieldComponent extends BaseComponent implements OnInit {
public visibilityRulesService: VisibilityRulesService, public visibilityRulesService: VisibilityRulesService,
private datasetExternalAutocompleteService: DatasetExternalAutocompleteService, private datasetExternalAutocompleteService: DatasetExternalAutocompleteService,
private externalSourcesService: ExternalSourcesService, private externalSourcesService: ExternalSourcesService,
public language: TranslateService, private language: TranslateService,
private datasetService: DatasetService
) { super(); } ) { super(); }
ngOnInit() { ngOnInit() {
@ -74,24 +78,10 @@ export class FormFieldComponent extends BaseComponent implements OnInit {
if (this.form.get('viewStyle').value.renderStyle === DatasetProfileFieldViewStyle.InternalDmpEntities) { if (this.form.get('viewStyle').value.renderStyle === DatasetProfileFieldViewStyle.InternalDmpEntities) {
if (this.form.get('data').value.type === DatasetProfileInternalDmpEntitiesType.Researchers) { if (this.form.get('data').value.type === DatasetProfileInternalDmpEntitiesType.Researchers) {
if (!(this.form.controls['data'].value.multiAutoComplete)) { this.makeAutocompleteConfiguration(this.searchResearchers.bind(this), "name", "tag");
this.singleAutoCompleteConfiguration = { }
filterFn: this.searchResearchers.bind(this), else if (this.form.get('data').value.type === DatasetProfileInternalDmpEntitiesType.Datasets) {
initialItems: (extraData) => this.searchResearchers(''), this.makeAutocompleteConfiguration(this.searchDatasets.bind(this), "label");
displayFn: (item) => (item != null && item.length > 1) ? JSON.parse(item).name : item['name'],
titleFn: (item) => item['name'],
valueAssign: (item) => JSON.stringify(item)
};
}
else {
this.multipleAutoCompleteConfiguration = {
filterFn: this.searchResearchers.bind(this),
initialItems: (extraData) => this.searchResearchers(''),
displayFn: (item) => item['name'],
titleFn: (item) => item['name'],
valueAssign: this._transformValue
}
}
} }
} }
@ -135,4 +125,35 @@ export class FormFieldComponent extends BaseComponent implements OnInit {
reasearcherAutocompleteRequestItem.criteria.name = query; reasearcherAutocompleteRequestItem.criteria.name = query;
return this.externalSourcesService.searchDMPResearchers(reasearcherAutocompleteRequestItem); return this.externalSourcesService.searchDMPResearchers(reasearcherAutocompleteRequestItem);
} }
searchDatasets(query: string) {
let fields: Array<string> = new Array();
const datasetsAutocompleteRequestItem: DataTableRequest<DatasetCriteria> = new DataTableRequest(0, 25, { fields: fields });
datasetsAutocompleteRequestItem.criteria = new DatasetCriteria();
datasetsAutocompleteRequestItem.criteria.like = query;
return this.datasetService.getPaged(datasetsAutocompleteRequestItem).map(item => item.data);
}
makeAutocompleteConfiguration(myfunc: Function, title: string, subtitle?: string): void {
if (!(this.form.controls['data'].value.multiAutoComplete)) {
this.singleAutoCompleteConfiguration = {
filterFn: myfunc.bind(this),
initialItems: (extraData) => myfunc(''),
displayFn: (item) => (item != null && item.length > 1) ? JSON.parse(item)[title] : item[title],
titleFn: (item) => item[title],
valueAssign: (item) => JSON.stringify(item),
subtitleFn: (item) => item[subtitle]
};
}
else {
this.multipleAutoCompleteConfiguration = {
filterFn: myfunc.bind(this),
initialItems: (extraData) => myfunc(''),
displayFn: (item) => item[title],
titleFn: (item) => item[title],
valueAssign: this._transformValue,
subtitleFn: (item) => item[subtitle]
}
}
}
} }

View File

@ -207,6 +207,7 @@
"FIELD-INTERNAL-DMP-ENTITIES-TYPE": "Type of Internal DMP Entity", "FIELD-INTERNAL-DMP-ENTITIES-TYPE": "Type of Internal DMP Entity",
"FIELD-RESEARCHERS-TITLE": "Researchers Autocomplete", "FIELD-RESEARCHERS-TITLE": "Researchers Autocomplete",
"FIELD-RESEARCHERS-PLACEHOLDER": "Input Placeholder", "FIELD-RESEARCHERS-PLACEHOLDER": "Input Placeholder",
"FIELD-DATASETS-PLACEHOLDER": "Input Placeholder",
"FIELD-RADIO-BOX-TITLE": "Radio Box Data", "FIELD-RADIO-BOX-TITLE": "Radio Box Data",
"FIELD-RADIO-BOX-PLACEHOLDER": "Input Placeholder", "FIELD-RADIO-BOX-PLACEHOLDER": "Input Placeholder",
"FIELD-RADIO-BOX-LABEL": "Label", "FIELD-RADIO-BOX-LABEL": "Label",