Adds new field on Dataset Template that link back to Open DMP entities (Researchers) (Issue #129).
This commit is contained in:
parent
7a7e445120
commit
7b4490a723
|
@ -65,6 +65,15 @@ public class ModelBuilder {
|
|||
return (FieldData<U>) new WordListData().fromData(data);
|
||||
}
|
||||
}
|
||||
if (type.equals("internalDmpEntities")) {
|
||||
if (dataElement != null) {
|
||||
if (dataElement.getAttribute("type").equals("researchers")) {
|
||||
return (FieldData<U>) new ResearchersAutoCompleteData().fromData(data);
|
||||
}
|
||||
// } else if (dataElement.getAttribute("type").equals("wordlist"))
|
||||
// return (FieldData<U>) new WordListData().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("checkBox")) return (FieldData<U>) new CheckBoxData().fromData(data);
|
||||
|
@ -82,6 +91,12 @@ public class ModelBuilder {
|
|||
} else if (comboboxType.equals("wordlist"))
|
||||
return (FieldData<U>) new WordListData().fromData(data);
|
||||
}
|
||||
if (type.equals("internalDmpEntities")) {
|
||||
String internalDmpEntitiesType = (String) ((Map<String, Object>) data).get("type");
|
||||
if (internalDmpEntitiesType.equals("researchers")) {
|
||||
return (FieldData<U>) new ResearchersAutoCompleteData().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("checkBox")) return (FieldData<U>) new CheckBoxData().fromData(data);
|
||||
|
|
|
@ -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<T> extends FieldData<T> {
|
||||
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<String, Object>) data).get("type");
|
||||
this.setLabel((String) ((Map<String, Object>) data).get("label"));
|
||||
}
|
||||
|
||||
return (T) 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") : "");
|
||||
dataMap.put("type", item != null ? item.getAttribute("type") : "researchers");
|
||||
return dataMap;
|
||||
}
|
||||
}
|
|
@ -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<ResearchersAutoCompleteData> {
|
||||
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<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;
|
||||
}
|
||||
}
|
|
@ -5,6 +5,6 @@ export enum DatasetProfileFieldViewStyle {
|
|||
CheckBox = "checkBox",
|
||||
FreeText = "freetext",
|
||||
RadioBox = "radiobox",
|
||||
DatePicker = "datePicker"
|
||||
|
||||
}
|
||||
DatePicker = "datePicker",
|
||||
InternalDmpEntities = "internalDmpEntities"
|
||||
}
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
export enum DatasetProfileInternalDmpEntitiesType {
|
||||
Researchers = "researchers",
|
||||
Dmps = "dmps",
|
||||
Dataset = "dataset"
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<ResearchersAutoCompleteFieldDataEditorModel> {
|
||||
|
||||
public type: DatasetProfileInternalDmpEntitiesType = DatasetProfileInternalDmpEntitiesType.Researchers;
|
||||
public multiAutoComplete: boolean;
|
||||
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('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;
|
||||
}
|
||||
}
|
|
@ -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); }
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -38,6 +38,10 @@
|
|||
<mat-error *ngIf="form.hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<!-- InternalDmpEntities -->
|
||||
<mat-form-field class="col-md-12" *ngIf="viewStyle === viewStyleEnum.InternalDmpEntities && internalDmpEntitiesType === internalDmpEntitiesTypeEnum.Researchers">
|
||||
<input matInput type="text" [placeholder]="placeHolder" [formControl]="form" [required]="required">
|
||||
</mat-form-field>
|
||||
|
||||
<!-- FreeText -->
|
||||
<mat-form-field class="col-md-12" *ngIf="viewStyle === viewStyleEnum.FreeText">
|
||||
|
@ -63,7 +67,7 @@
|
|||
<!-- DatePicker -->
|
||||
<mat-form-field class="col-12" *ngIf="viewStyle === viewStyleEnum.DatePicker">
|
||||
<!--(focus)="date.open()" (click)="date.open()"-->
|
||||
<input matInput
|
||||
<input matInput
|
||||
[placeholder]="placeHolder" class="table-input" [matDatepicker]="date"
|
||||
[formControl]="form" [required]="required">
|
||||
<mat-datepicker-toggle matSuffix [for]="date"></mat-datepicker-toggle>
|
||||
|
@ -71,4 +75,4 @@
|
|||
<mat-error *ngIf="form.hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -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() { }
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<div class="row">
|
||||
<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-option [value]="options.Researchers">{{enumUtils.toDatasetProfileInternalDmpEntitiesTypeString(options.Researchers)}}</mat-option>
|
||||
</mat-select>
|
||||
</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>
|
||||
</div>
|
|
@ -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();
|
||||
})
|
||||
}
|
||||
}
|
|
@ -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-RESEARCHERS-PLACEHOLDER' | translate}}"
|
||||
[formControl]="form.get('data').get('label')">
|
||||
</mat-form-field>
|
||||
</div>
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -12,6 +12,7 @@
|
|||
<mat-option [value]="viewStyleEnum.BooleanDecision">{{enumUtils.toDatasetProfileFieldViewStyleString(viewStyleEnum.BooleanDecision)}}</mat-option>
|
||||
<mat-option [value]="viewStyleEnum.CheckBox">{{enumUtils.toDatasetProfileFieldViewStyleString(viewStyleEnum.CheckBox)}}</mat-option>
|
||||
<mat-option [value]="viewStyleEnum.ComboBox">{{enumUtils.toDatasetProfileFieldViewStyleString(viewStyleEnum.ComboBox)}}</mat-option>
|
||||
<mat-option [value]="viewStyleEnum.InternalDmpEntities">{{enumUtils.toDatasetProfileFieldViewStyleString(viewStyleEnum.InternalDmpEntities)}}</mat-option>
|
||||
<mat-option [value]="viewStyleEnum.FreeText">{{enumUtils.toDatasetProfileFieldViewStyleString(viewStyleEnum.FreeText)}}</mat-option>
|
||||
<mat-option [value]="viewStyleEnum.RadioBox">{{enumUtils.toDatasetProfileFieldViewStyleString(viewStyleEnum.RadioBox)}}</mat-option>
|
||||
<mat-option [value]="viewStyleEnum.TextArea">{{enumUtils.toDatasetProfileFieldViewStyleString(viewStyleEnum.TextArea)}}</mat-option>
|
||||
|
@ -25,8 +26,9 @@
|
|||
<!-- Default Value -->
|
||||
<app-component-profile-editor-default-value-component *ngIf="form.get('viewStyle').get('renderStyle').value" class="col"
|
||||
[viewStyle]="form.get('viewStyle').get('renderStyle').value" [form]="this.form.get('defaultValue').get('value')" [formArrayOptions]="form.get('data')?.get('options')"
|
||||
[comboBoxType]="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)"></app-component-profile-editor-default-value-component>
|
||||
[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)">
|
||||
</app-component-profile-editor-default-value-component>
|
||||
|
||||
|
||||
<mat-form-field class="col" *ngIf="!(defaulValueRequired(form.get('viewStyle').get('renderStyle').value))">
|
||||
|
@ -39,11 +41,12 @@
|
|||
</div>
|
||||
<div class="row" [ngSwitch]="form.get('viewStyle').get('renderStyle').value">
|
||||
<app-dataset-profile-editor-combo-box-field-component *ngSwitchCase="viewStyleEnum.ComboBox" class="col-12" [form]="form"></app-dataset-profile-editor-combo-box-field-component>
|
||||
<app-dataset-profile-internal-dmp-entities-field-component *ngSwitchCase="viewStyleEnum.InternalDmpEntities" class="col-12" [form]="form"></app-dataset-profile-internal-dmp-entities-field-component>
|
||||
<app-dataset-profile-editor-radio-box-field-component *ngSwitchCase="viewStyleEnum.RadioBox" class="col-12" [form]="form"></app-dataset-profile-editor-radio-box-field-component>
|
||||
<app-dataset-profile-editor-free-text-field-component *ngSwitchCase="viewStyleEnum.FreeText" class="col-12" [form]="form"></app-dataset-profile-editor-free-text-field-component>
|
||||
<app-dataset-profile-editor-text-area-field-component *ngSwitchCase="viewStyleEnum.TextArea" class="col-12" [form]="form"></app-dataset-profile-editor-text-area-field-component>
|
||||
<app-dataset-profile-editor-date-picker-field-component *ngSwitchCase="viewStyleEnum.DatePicker" class="col-12" [form]="form"></app-dataset-profile-editor-date-picker-field-component>
|
||||
|
||||
|
||||
<app-dataset-profile-editor-boolean-decision-field-component *ngSwitchCase="viewStyleEnum.BooleanDecision" class="col-12"
|
||||
[form]="form"></app-dataset-profile-editor-boolean-decision-field-component>
|
||||
<app-dataset-profile-editor-checkbox-field-component *ngSwitchCase="viewStyleEnum.CheckBox" class="col-12" [form]="form"></app-dataset-profile-editor-checkbox-field-component>
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -42,6 +42,26 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div *ngSwitchCase="datasetProfileFieldViewStyleEnum.InternalDmpEntities" class="col-12">
|
||||
<div class="row">
|
||||
<mat-form-field class="col-md-12" *ngIf="form.get('data').value.type === this.datasetProfileInternalDmpEntitiesTypeEnum.Researchers">
|
||||
<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 *ngSwitchCase="datasetProfileFieldViewStyleEnum.CheckBox" class="col-12">
|
||||
<mat-checkbox [formControl]="form.get('value')" [required]="form.get('validationRequired').value">
|
||||
{{form.get('data').value.label}}</mat-checkbox>
|
||||
|
|
|
@ -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<ResearcherCriteria> = new RequestItem();
|
||||
reasearcherAutocompleteRequestItem.criteria = new ResearcherCriteria;
|
||||
reasearcherAutocompleteRequestItem.criteria.name = query;
|
||||
return this.externalSourcesService.searchDMPResearchers(reasearcherAutocompleteRequestItem);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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": {
|
||||
|
|
Loading…
Reference in New Issue