diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/builders/ModelBuilder.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/builders/ModelBuilder.java index 9f239ed36..de28f0c1c 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/builders/ModelBuilder.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/builders/ModelBuilder.java @@ -65,6 +65,15 @@ public class ModelBuilder { return (FieldData) new WordListData().fromData(data); } } + if (type.equals("internalDmpEntities")) { + if (dataElement != null) { + if (dataElement.getAttribute("type").equals("researchers")) { + return (FieldData) new ResearchersAutoCompleteData().fromData(data); + } +// } else if (dataElement.getAttribute("type").equals("wordlist")) +// return (FieldData) new WordListData().fromData(data); + } + } if (type.equals("booleanDecision")) return (FieldData) new BooleanDecisionData().fromData(data); if (type.equals("radiobox")) return (FieldData) new RadioBoxData().fromData(data); if (type.equals("checkBox")) return (FieldData) new CheckBoxData().fromData(data); @@ -82,6 +91,12 @@ public class ModelBuilder { } else if (comboboxType.equals("wordlist")) return (FieldData) new WordListData().fromData(data); } + if (type.equals("internalDmpEntities")) { + String internalDmpEntitiesType = (String) ((Map) data).get("type"); + if (internalDmpEntitiesType.equals("researchers")) { + return (FieldData) new ResearchersAutoCompleteData().fromData(data); + } + } if (type.equals("booleanDecision")) return (FieldData) new BooleanDecisionData().fromData(data); if (type.equals("radiobox")) return (FieldData) new RadioBoxData().fromData(data); if (type.equals("checkBox")) return (FieldData) new CheckBoxData().fromData(data); diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/InternalDmpEntitiesData.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/InternalDmpEntitiesData.java new file mode 100644 index 000000000..63fbc6ea9 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/InternalDmpEntitiesData.java @@ -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 abstract class InternalDmpEntitiesData extends FieldData { + private String type; + + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + + @Override + public Element toXml(Document doc) { + Element root = doc.createElement("data"); + root.setAttribute("type", this.type); + root.setAttribute("label", this.getLabel()); + return root; + } + + @Override + public T fromXml(Element item) { + this.setLabel(item.getAttribute("label")); + this.type = item.getAttribute("type"); + return (T) this; + } + + @Override + public T fromData(Object data) { + + if (data != null) { + this.type = (String) ((Map) data).get("type"); + this.setLabel((String) ((Map) data).get("label")); + } + + return (T) this; + } + + @Override + public Object toData() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Map toMap(Element item) { + HashMap dataMap = new HashMap(); + dataMap.put("label", item != null ? item.getAttribute("label") : ""); + dataMap.put("type", item != null ? item.getAttribute("type") : ""); + dataMap.put("type", item != null ? item.getAttribute("type") : "researchers"); + return dataMap; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/ResearchersAutoCompleteData.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/ResearchersAutoCompleteData.java new file mode 100644 index 000000000..74cdff16b --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/ResearchersAutoCompleteData.java @@ -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 ResearchersAutoCompleteData extends InternalDmpEntitiesData { + 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 ResearchersAutoCompleteData fromXml(Element item) { + super.fromXml(item); + this.multiAutoComplete = Boolean.parseBoolean(item.getAttribute("multiAutoComplete")); + + return this; + } + + @Override + public ResearchersAutoCompleteData fromData(Object data) { + super.fromData(data); + if (data != null) { + this.multiAutoComplete = (Boolean) ((Map) data).get("multiAutoComplete"); + } + + return this; + } + + @Override + public Object toData() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Map 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; + } +} diff --git a/dmp-frontend/src/app/core/common/enum/dataset-profile-field-view-style.ts b/dmp-frontend/src/app/core/common/enum/dataset-profile-field-view-style.ts index 7a697ec5f..a7efc33f4 100644 --- a/dmp-frontend/src/app/core/common/enum/dataset-profile-field-view-style.ts +++ b/dmp-frontend/src/app/core/common/enum/dataset-profile-field-view-style.ts @@ -5,6 +5,6 @@ export enum DatasetProfileFieldViewStyle { CheckBox = "checkBox", FreeText = "freetext", RadioBox = "radiobox", - DatePicker = "datePicker" - -} \ No newline at end of file + DatePicker = "datePicker", + InternalDmpEntities = "internalDmpEntities" +} diff --git a/dmp-frontend/src/app/core/common/enum/dataset-profile-internal-dmp-entities-type.ts b/dmp-frontend/src/app/core/common/enum/dataset-profile-internal-dmp-entities-type.ts new file mode 100644 index 000000000..39669e6ea --- /dev/null +++ b/dmp-frontend/src/app/core/common/enum/dataset-profile-internal-dmp-entities-type.ts @@ -0,0 +1,5 @@ +export enum DatasetProfileInternalDmpEntitiesType { + Researchers = "researchers", + Dmps = "dmps", + Dataset = "dataset" +} diff --git a/dmp-frontend/src/app/core/model/dataset-profile-definition/field-data/field-data.ts b/dmp-frontend/src/app/core/model/dataset-profile-definition/field-data/field-data.ts index 43a5d8e88..0bc59e210 100644 --- a/dmp-frontend/src/app/core/model/dataset-profile-definition/field-data/field-data.ts +++ b/dmp-frontend/src/app/core/model/dataset-profile-definition/field-data/field-data.ts @@ -1,4 +1,5 @@ import { DatasetProfileComboBoxType } from "../../../common/enum/dataset-profile-combo-box-type"; +import { DatasetProfileInternalDmpEntitiesType } from "../../../common/enum/dataset-profile-internal-dmp-entities-type"; export interface FieldData { label: string; @@ -45,3 +46,8 @@ export interface FieldDataOption extends FieldData { export interface DatePickerFieldData extends FieldData { } + +export interface ResearchersAutoCompleteFieldData extends FieldData { + type: DatasetProfileInternalDmpEntitiesType; + multiAutoComplete: boolean; +} diff --git a/dmp-frontend/src/app/core/services/utilities/enum-utils.service.ts b/dmp-frontend/src/app/core/services/utilities/enum-utils.service.ts index 70d35175a..970af10d4 100644 --- a/dmp-frontend/src/app/core/services/utilities/enum-utils.service.ts +++ b/dmp-frontend/src/app/core/services/utilities/enum-utils.service.ts @@ -8,6 +8,7 @@ import { DmpProfileFieldDataType } from '../../common/enum/dmp-profile-field-typ import { DmpProfileType } from '../../common/enum/dmp-profile-type'; import { DmpStatus } from '../../common/enum/dmp-status'; import { ValidationType } from '../../common/enum/validation-type'; +import { DatasetProfileInternalDmpEntitiesType } from '../../common/enum/dataset-profile-internal-dmp-entities-type'; @Injectable() export class EnumUtils { @@ -68,6 +69,7 @@ export class EnumUtils { case DatasetProfileFieldViewStyle.BooleanDecision: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.BOOLEAN-DECISION'); case DatasetProfileFieldViewStyle.CheckBox: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.CHECKBOX'); case DatasetProfileFieldViewStyle.ComboBox: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.COMBO-BOX'); + case DatasetProfileFieldViewStyle.InternalDmpEntities: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.INTERNAL-DMP-ENTITIES'); case DatasetProfileFieldViewStyle.FreeText: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.FREE-TEXT'); case DatasetProfileFieldViewStyle.RadioBox: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.RADIO-BOX'); case DatasetProfileFieldViewStyle.TextArea: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.TEXT-AREA'); @@ -81,4 +83,10 @@ export class EnumUtils { case DatasetProfileComboBoxType.Autocomplete: return this.language.instant('TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.AUTOCOMPLETE'); } } + + toDatasetProfileInternalDmpEntitiesTypeString(status: DatasetProfileInternalDmpEntitiesType): string { + switch (status) { + case DatasetProfileInternalDmpEntitiesType.Researchers: return this.language.instant('TYPES.DATASET-PROFILE-INTERNAL-DMP-ENTITIES-TYPE.RESEARCHERS'); + } + } } diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/researchers-auto-complete-field-data-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/researchers-auto-complete-field-data-editor-model.ts new file mode 100644 index 000000000..87c7c8c75 --- /dev/null +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/researchers-auto-complete-field-data-editor-model.ts @@ -0,0 +1,31 @@ +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 { FormGroup } from "@angular/forms"; +import { ResearchersAutoCompleteFieldData } from "../../../../../core/model/dataset-profile-definition/field-data/field-data"; + +export class ResearchersAutoCompleteFieldDataEditorModel extends FieldDataEditorModel { + + public type: DatasetProfileInternalDmpEntitiesType = DatasetProfileInternalDmpEntitiesType.Researchers; + public multiAutoComplete: boolean; + public autoCompleteOptions: FieldDataOptionEditorModel = new FieldDataOptionEditorModel(); + + buildForm(disabled: boolean = false, skipDisable: Array = []): FormGroup { + const formGroup = this.formBuilder.group({ + label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('ResearchersAutoCompleteFieldDataEditorModel.label')) }], + type: [{ value: this.type, disabled: (disabled && !skipDisable.includes('ResearchersAutoCompleteFieldDataEditorModel.type')) }], + multiAutoComplete: [{ value: this.multiAutoComplete, disabled: (disabled && !skipDisable.includes('ResearchersAutoCompleteFieldDataEditorModel.multiAutoComplete')) }] + }) + //formGroup.addControl('autoCompleteOptions', this.autoCompleteOptions.buildForm(disabled, skipDisable)); + + return formGroup; + } + + fromModel(item: ResearchersAutoCompleteFieldData): ResearchersAutoCompleteFieldDataEditorModel { + this.label = item.label; + this.type = item.type; + this.multiAutoComplete = item.multiAutoComplete; + // this.autoCompleteOptions = new FieldDataOptionEditorModel().fromModel(item.autoCompleteOptions); + return this; + } +} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-editor-model.ts index f2c803ba9..d394166c9 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-editor-model.ts +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-editor-model.ts @@ -15,6 +15,7 @@ import { ViewStyleEditorModel } from './view-style-editor-model'; import { VisibilityEditorModel } from './visibility-editor-model'; 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 { ResearchersAutoCompleteFieldDataEditorModel } from './field-data/researchers-auto-complete-field-data-editor-model'; export class FieldEditorModel extends BaseFormModel { @@ -41,6 +42,8 @@ export class FieldEditorModel extends BaseFormModel { if (this.viewStyle.renderStyle === 'combobox') { if (item.data.type === 'autocomplete') { this.data = new AutoCompleteFieldDataEditorModel().fromModel(item.data); } if (item.data.type === 'wordlist') { this.data = new WordListFieldDataEditorModel().fromModel(item.data); } + } else if (this.viewStyle.renderStyle === 'internalDmpEntities') { + if (item.data.type === 'researchers') { this.data = new ResearchersAutoCompleteFieldDataEditorModel().fromModel(item.data); } } else { if (this.viewStyle.renderStyle === 'radiobox') { this.data = new RadioBoxFieldDataEditorModel().fromModel(item.data); } if (this.viewStyle.renderStyle === 'checkBox') { this.data = new CheckBoxFieldDataEditorModel().fromModel(item.data); } diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/dataset-profile.module.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/dataset-profile.module.ts index 4947a547f..32a50abe7 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/dataset-profile.module.ts +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/dataset-profile.module.ts @@ -23,6 +23,8 @@ import { DatasetProfileListingComponent } from './listing/dataset-profile-listin import { ConfirmationDialogModule } from '../../../library/confirmation-dialog/confirmation-dialog.module'; import { DatasetProfileEditorDatePickerFieldComponent } from './editor/components/field-type/datepicker/dataset-profile-editor-date-picker-field.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 { DatasetProfileEditorResearchersAutoCompleteFieldComponent } from './editor/components/field-type/researchers-auto-complete/dataset-profile-editor-researchers-auto-complete-field.component'; @NgModule({ imports: [ @@ -51,8 +53,9 @@ import { DialodConfirmationUploadDatasetProfiles } from './listing/criteria/dial DatasetProfileEditorDatePickerFieldComponent, DatasetProfileEditorWordListFieldComponent, DatasetProfileEditorDefaultValueComponent, - DialodConfirmationUploadDatasetProfiles - + DialodConfirmationUploadDatasetProfiles, + DatasetProfileEditorInternalDmpEntitiesFieldComponent, + DatasetProfileEditorResearchersAutoCompleteFieldComponent ], entryComponents: [ DialodConfirmationUploadDatasetProfiles diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-profile-editor-default-value/component-profile-editor-default-value.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-profile-editor-default-value/component-profile-editor-default-value.component.html index 99b31f13a..323dd5813 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-profile-editor-default-value/component-profile-editor-default-value.component.html +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-profile-editor-default-value/component-profile-editor-default-value.component.html @@ -38,6 +38,10 @@ {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + + + @@ -63,7 +67,7 @@ - @@ -71,4 +75,4 @@ {{'GENERAL.VALIDATION.REQUIRED' | translate}} - \ No newline at end of file + diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-profile-editor-default-value/component-profile-editor-default-value.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-profile-editor-default-value/component-profile-editor-default-value.component.ts index f20085697..aedb1fa72 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-profile-editor-default-value/component-profile-editor-default-value.component.ts +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-profile-editor-default-value/component-profile-editor-default-value.component.ts @@ -2,6 +2,7 @@ import { Component, Input, OnInit } from '@angular/core'; import { FormArray, FormControl } from '@angular/forms'; import { DatasetProfileComboBoxType } from '../../../../../../core/common/enum/dataset-profile-combo-box-type'; import { DatasetProfileFieldViewStyle } from '../../../../../../core/common/enum/dataset-profile-field-view-style'; +import { DatasetProfileInternalDmpEntitiesType } from '../../../../../../core/common/enum/dataset-profile-internal-dmp-entities-type'; @Component({ selector: 'app-component-profile-editor-default-value-component', @@ -14,11 +15,12 @@ export class DatasetProfileEditorDefaultValueComponent implements OnInit { @Input() form: FormControl; @Input() formArrayOptions: FormArray; @Input() comboBoxType: DatasetProfileComboBoxType; + @Input() internalDmpEntitiesType: DatasetProfileInternalDmpEntitiesType; @Input() placeHolder: String; @Input() required: Boolean; - comboBoxTypeEnum = DatasetProfileComboBoxType; + internalDmpEntitiesTypeEnum = DatasetProfileInternalDmpEntitiesType; viewStyleEnum = DatasetProfileFieldViewStyle; constructor() { } diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/internal-dmp-entities/dataset-profile-editor-internal-dmp-entities-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/internal-dmp-entities/dataset-profile-editor-internal-dmp-entities-field.component.html new file mode 100644 index 000000000..186ccf1b1 --- /dev/null +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/internal-dmp-entities/dataset-profile-editor-internal-dmp-entities-field.component.html @@ -0,0 +1,8 @@ +
+ + + {{enumUtils.toDatasetProfileInternalDmpEntitiesTypeString(options.Researchers)}} + + + +
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/internal-dmp-entities/dataset-profile-editor-internal-dmp-entities-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/internal-dmp-entities/dataset-profile-editor-internal-dmp-entities-field.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/internal-dmp-entities/dataset-profile-editor-internal-dmp-entities-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/internal-dmp-entities/dataset-profile-editor-internal-dmp-entities-field.component.ts new file mode 100644 index 000000000..4f6cbc96d --- /dev/null +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/internal-dmp-entities/dataset-profile-editor-internal-dmp-entities-field.component.ts @@ -0,0 +1,37 @@ +import { DatasetProfileInternalDmpEntitiesType } from "../../../../../../../core/common/enum/dataset-profile-internal-dmp-entities-type"; +import { EnumUtils } from "../../../../../../../core/services/utilities/enum-utils.service"; +import { Component, Input, OnInit } from "@angular/core"; +import { FormGroup } from "@angular/forms"; +import { BaseComponent } from "../../../../../../../core/common/base/base.component"; +import { takeUntil } from "rxjs/operators"; +import { ResearchersAutoCompleteFieldDataEditorModel } from "../../../../admin/field-data/researchers-auto-complete-field-data-editor-model"; + +@Component({ + selector: 'app-dataset-profile-internal-dmp-entities-field-component', + styleUrls: ['./dataset-profile-editor-internal-dmp-entities-field.component.scss'], + templateUrl: './dataset-profile-editor-internal-dmp-entities-field.component.html' +}) +export class DatasetProfileEditorInternalDmpEntitiesFieldComponent extends BaseComponent implements OnInit { + @Input() form: FormGroup; + options = DatasetProfileInternalDmpEntitiesType; + + constructor( + public enumUtils: EnumUtils + ) { super() } + + ngOnInit() { + this.setupListeners(); + } + + setupListeners() { + this.form.get('data').get('type').valueChanges + .pipe(takeUntil(this._destroyed)) + .subscribe(x => { + if (this.form.get('data')) { this.form.removeControl('data'); } + if (x === DatasetProfileInternalDmpEntitiesType.Researchers) { + this.form.addControl('data', new ResearchersAutoCompleteFieldDataEditorModel().buildForm()); + } + this.setupListeners(); + }) + } +} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers-auto-complete/dataset-profile-editor-researchers-auto-complete-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers-auto-complete/dataset-profile-editor-researchers-auto-complete-field.component.html new file mode 100644 index 000000000..7de5c855f --- /dev/null +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers-auto-complete/dataset-profile-editor-researchers-auto-complete-field.component.html @@ -0,0 +1,12 @@ +
+ +
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-TITLE' | translate}}
+ + {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-MULTIPLE-AUTOCOMPLETE' | translate}} + + + + + +
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers-auto-complete/dataset-profile-editor-researchers-auto-complete-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers-auto-complete/dataset-profile-editor-researchers-auto-complete-field.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers-auto-complete/dataset-profile-editor-researchers-auto-complete-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers-auto-complete/dataset-profile-editor-researchers-auto-complete-field.component.ts new file mode 100644 index 000000000..304fc137e --- /dev/null +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers-auto-complete/dataset-profile-editor-researchers-auto-complete-field.component.ts @@ -0,0 +1,19 @@ +import { ResearchersAutoCompleteFieldDataEditorModel } from "../../../../admin/field-data/researchers-auto-complete-field-data-editor-model"; +import { FormGroup } from "@angular/forms"; +import { Input, Component, OnInit } from "@angular/core"; +import { DatasetProfileInternalDmpEntitiesType } from "../../../../../../../core/common/enum/dataset-profile-internal-dmp-entities-type"; + +@Component({ + selector: 'app-dataset-profile-editor-researchers-auto-complete-field-component', + styleUrls: ['./dataset-profile-editor-researchers-auto-complete-field.component.scss'], + templateUrl: './dataset-profile-editor-researchers-auto-complete-field.component.html' +}) +export class DatasetProfileEditorResearchersAutoCompleteFieldComponent implements OnInit { + + @Input() form: FormGroup; + private data: ResearchersAutoCompleteFieldDataEditorModel = new ResearchersAutoCompleteFieldDataEditorModel(); + + ngOnInit() { + this.data.type = DatasetProfileInternalDmpEntitiesType.Researchers; + } +} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component.html index 58615d87b..19fb777fd 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component.html +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component.html @@ -12,6 +12,7 @@ {{enumUtils.toDatasetProfileFieldViewStyleString(viewStyleEnum.BooleanDecision)}} {{enumUtils.toDatasetProfileFieldViewStyleString(viewStyleEnum.CheckBox)}} {{enumUtils.toDatasetProfileFieldViewStyleString(viewStyleEnum.ComboBox)}} + {{enumUtils.toDatasetProfileFieldViewStyleString(viewStyleEnum.InternalDmpEntities)}} {{enumUtils.toDatasetProfileFieldViewStyleString(viewStyleEnum.FreeText)}} {{enumUtils.toDatasetProfileFieldViewStyleString(viewStyleEnum.RadioBox)}} {{enumUtils.toDatasetProfileFieldViewStyleString(viewStyleEnum.TextArea)}} @@ -25,8 +26,9 @@ + [comboBoxType]="this.form.get('data')?.get('type')?.value" [internalDmpEntitiesType]="this.form.get('data')?.get('type')?.value" + placeHolder="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.DEFAULT-VALUE' | translate}}" [required]="defaulValueRequired(form.get('viewStyle').get('renderStyle').value)"> + @@ -39,11 +41,12 @@
+ - + diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component.ts index 63cf465b8..1d109c26e 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component.ts +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component.ts @@ -14,6 +14,8 @@ import { TextAreaFieldDataEditorModel } from '../../../admin/field-data/text-are import { WordListFieldDataEditorModel } from '../../../admin/field-data/word-list-field-data-editor-model'; import { RuleEditorModel } from '../../../admin/rule-editor-model'; import { DatePickerDataEditorModel } from '../../../admin/field-data/date-picker-data-editor-models'; +import { ResearchersAutoCompleteFieldDataEditorModel } from '../../../admin/field-data/researchers-auto-complete-field-data-editor-model'; +import { DatasetProfileInternalDmpEntitiesType } from '../../../../../../core/common/enum/dataset-profile-internal-dmp-entities-type'; @Component({ selector: 'app-dataset-profile-editor-field-component', @@ -58,6 +60,9 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements case DatasetProfileFieldViewStyle.ComboBox: this.form.addControl('data', new WordListFieldDataEditorModel().buildForm()); break; + case DatasetProfileFieldViewStyle.InternalDmpEntities: + this.form.addControl('data', new ResearchersAutoCompleteFieldDataEditorModel().buildForm()); + break; case DatasetProfileFieldViewStyle.FreeText: this.form.addControl('data', new FreeTextFieldDataEditorModel().buildForm()); break; @@ -83,6 +88,7 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements case DatasetProfileFieldViewStyle.TextArea: case DatasetProfileFieldViewStyle.FreeText: case DatasetProfileFieldViewStyle.ComboBox: + case DatasetProfileFieldViewStyle.InternalDmpEntities: case DatasetProfileFieldViewStyle.BooleanDecision: case DatasetProfileFieldViewStyle.DatePicker: return false; diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-field/form-field.component.html b/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-field/form-field.component.html index cdfe25ac8..2143eaf6b 100644 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-field/form-field.component.html +++ b/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-field/form-field.component.html @@ -42,6 +42,26 @@
+
+
+ +
+ + +
+
+ + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + +
+ {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} +
+
+
+
{{form.get('data').value.label}} diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-field/form-field.component.ts b/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-field/form-field.component.ts index aa2716ee3..6d79f7f1f 100644 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-field/form-field.component.ts +++ b/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-field/form-field.component.ts @@ -10,6 +10,9 @@ import { DatasetExternalAutocompleteService } from '../../../../../core/services import { SingleAutoCompleteConfiguration } from '../../../../../library/auto-complete/single/single-auto-complete-configuration'; import { VisibilityRulesService } from '../../visibility-rules/visibility-rules.service'; import { MultipleAutoCompleteConfiguration } from '../../../../../library/auto-complete/multiple/multiple-auto-complete-configuration'; +import { DatasetProfileInternalDmpEntitiesType } from '../../../../../core/common/enum/dataset-profile-internal-dmp-entities-type'; +import { ResearcherCriteria } from '../../../../../core/query/researcher/researcher-criteria'; +import { ExternalSourcesService } from '../../../../../core/services/external-sources/external-sources.service'; @Component({ selector: 'app-form-field', @@ -30,10 +33,12 @@ export class FormFieldComponent extends BaseComponent implements OnInit { public multipleAutoCompleteConfiguration: MultipleAutoCompleteConfiguration; datasetProfileFieldViewStyleEnum = DatasetProfileFieldViewStyle; datasetProfileComboBoxTypeEnum = DatasetProfileComboBoxType; + datasetProfileInternalDmpEntitiesTypeEnum = DatasetProfileInternalDmpEntitiesType; constructor( public visibilityRulesService: VisibilityRulesService, - private datasetExternalAutocompleteService: DatasetExternalAutocompleteService + private datasetExternalAutocompleteService: DatasetExternalAutocompleteService, + private externalSourcesService: ExternalSourcesService ) { super(); } ngOnInit() { @@ -63,6 +68,29 @@ export class FormFieldComponent extends BaseComponent implements OnInit { } } + if (this.form.get('viewStyle').value.renderStyle === DatasetProfileFieldViewStyle.InternalDmpEntities) { + if (this.form.get('data').value.type === DatasetProfileInternalDmpEntitiesType.Researchers) { + if (!(this.form.controls['data'].value.multiAutoComplete)) { + this.singleAutoCompleteConfiguration = { + filterFn: this.searchResearchers.bind(this), + initialItems: (extraData) => this.searchResearchers(''), + 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 + } + } + } + } + // this.form = this.visibilityRulesService.getFormGroup(this.field.id); this.form.get('value').valueChanges .pipe(takeUntil(this._destroyed)) @@ -96,4 +124,11 @@ export class FormFieldComponent extends BaseComponent implements OnInit { autocompleteRequestItem.criteria.like = query; return this.datasetExternalAutocompleteService.queryAutocomplete(autocompleteRequestItem); } + + searchResearchers(query: string) { + const reasearcherAutocompleteRequestItem: RequestItem = new RequestItem(); + reasearcherAutocompleteRequestItem.criteria = new ResearcherCriteria; + reasearcherAutocompleteRequestItem.criteria.name = query; + return this.externalSourcesService.searchDMPResearchers(reasearcherAutocompleteRequestItem); + } } diff --git a/dmp-frontend/src/assets/i18n/en.json b/dmp-frontend/src/assets/i18n/en.json index f68ca8b55..0398871be 100644 --- a/dmp-frontend/src/assets/i18n/en.json +++ b/dmp-frontend/src/assets/i18n/en.json @@ -203,6 +203,9 @@ "FIELD-WORD-LIST-PLACEHOLDER": "Input Placeholder", "FIELD-WORD-LIST-LABEL": "Label", "FIELD-WORD-LIST-VALUE": "Value", + "FIELD-INTERNAL-DMP-ENTITIES-TYPE": "Type of Internal DMP Entity", + "FIELD-RESEARCHERS-TITLE": "Researchers Autocomplete", + "FIELD-RESEARCHERS-PLACEHOLDER": "Input Placeholder", "FIELD-RADIO-BOX-TITLE": "Radio Box Data", "FIELD-RADIO-BOX-PLACEHOLDER": "Input Placeholder", "FIELD-RADIO-BOX-LABEL": "Label", @@ -716,6 +719,7 @@ "BOOLEAN-DECISION": "Boolean Decision", "CHECKBOX": "Checkbox", "COMBO-BOX": "Combo Box", + "INTERNAL-DMP-ENTITIES": "Internal DMP Entities", "FREE-TEXT": "Free Text", "RADIO-BOX": "Radio Box", "TEXT-AREA": "Text Area", @@ -725,6 +729,12 @@ "WORD-LIST": "Word List", "AUTOCOMPLETE": "Autocomplete", "EXTERNAL-SOURCE-HINT": "External source" + }, + "DATASET-PROFILE-INTERNAL-DMP-ENTITIES-TYPE": { + "RESEARCHERS": "Researchers", + "DMPS": "DMPs", + "DATASETS": "Datasets", + "EXTERNAL-SOURCE-HINT": "External source" } }, "ADDRESEARCHERS-EDITOR": {