diff --git a/dmp-frontend/src/app/core/common/enum/description-template-field-data-internal-dmp-entry-type.ts b/dmp-frontend/src/app/core/common/enum/description-template-field-data-internal-dmp-entry-type.ts
deleted file mode 100644
index bc0952436..000000000
--- a/dmp-frontend/src/app/core/common/enum/description-template-field-data-internal-dmp-entry-type.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-export enum DescriptionTemplateFieldDataInternalDmpEntryType {
- Researchers = 'researchers',
- Dmps = 'dmps',
- Datasets = 'datasets'
-}
\ No newline at end of file
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 708980f29..d401a85f1 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
@@ -33,6 +33,7 @@ import { NotificationNotifyState } from '@app/core/common/enum/notification-noti
import { NotificationTrackingState } from '@app/core/common/enum/notification-tracking-state';
import { NotificationTrackingProcess } from '@app/core/common/enum/notification-tracking-process';
import { DmpAccessType } from '@app/core/common/enum/dmp-access-type';
+import { DescriptionTemplateFieldDataExternalDatasetType } from '@app/core/common/enum/description-template-field-data-external-dataset-type';
@Injectable()
export class EnumUtils {
@@ -385,5 +386,15 @@ export class EnumUtils {
case DmpAccessType.Restricted: return this.language.instant('TYPES.DMP-ACCESS-TYPE.RESTRICTED');
}
}
+
+ public toDescriptionTemplateFieldDataExternalDatasetTypeString(value: DescriptionTemplateFieldDataExternalDatasetType): string {
+ switch (value) {
+ case DescriptionTemplateFieldDataExternalDatasetType.ReusedDataset: return this.language.instant('TYPES.DESCRIPTION-TEMPLATE-FIELD-EXTERNAL-DATASET-TYPE.REUSED');
+ case DescriptionTemplateFieldDataExternalDatasetType.ProducedDataset: return this.language.instant('TYPES.DESCRIPTION-TEMPLATE-FIELD-EXTERNAL-DATASET-TYPE.PRODUCED');
+ case DescriptionTemplateFieldDataExternalDatasetType.Other: return this.language.instant('TYPES.DESCRIPTION-TEMPLATE-FIELD-EXTERNAL-DATASET-TYPE.OTHER');
+ }
+ }
+
+
}
diff --git a/dmp-frontend/src/app/ui/admin/description-template/description-template.module.ts b/dmp-frontend/src/app/ui/admin/description-template/description-template.module.ts
index 8d2359e22..e2946275d 100644
--- a/dmp-frontend/src/app/ui/admin/description-template/description-template.module.ts
+++ b/dmp-frontend/src/app/ui/admin/description-template/description-template.module.ts
@@ -28,6 +28,7 @@ import { DescriptionTemplateListingComponent } from './listing/description-templ
import { DescriptionTemplateListingFiltersComponent } from "./listing/filters/description-template-listing-filters.component";
import { ImportDescriptionTemplateDialogComponent } from './listing/import-description-template/import-description-template.dialog.component';
import { DescriptionTemplateEditorRadioBoxFieldComponent } from './editor/components/field-type/radio-box/description-template-editor-radio-box-field.component';
+import { DescriptionTemplateEditorExternalDatasetsFieldComponent } from './editor/components/field-type/external-datasets/description-template-editor-external-datasets-field.component';
@NgModule({
imports: [
@@ -70,7 +71,8 @@ import { DescriptionTemplateEditorRadioBoxFieldComponent } from './editor/compon
DescriptionTemplateEditorSelectFieldComponent,
DescriptionTemplateEditorPlaceholderFieldComponent,
DescriptionTemplateEditorMultiplicityFieldComponent,
- DescriptionTemplateEditorRadioBoxFieldComponent
+ DescriptionTemplateEditorRadioBoxFieldComponent,
+ DescriptionTemplateEditorExternalDatasetsFieldComponent
]
})
export class DescriptionTemplateModule { }
diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/external-datasets/dataset-profile-editor-external-datasets-field.component.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/external-datasets/dataset-profile-editor-external-datasets-field.component.ts
deleted file mode 100644
index dbd2e951e..000000000
--- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/external-datasets/dataset-profile-editor-external-datasets-field.component.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-import { Component, Input, OnInit } from '@angular/core';
-import { UntypedFormGroup } from '@angular/forms';
-import { DatePickerDataEditorModel } from '../../../../admin/field-data/date-picker-data-editor-models';
-import { ExternalDatasetsDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/external-datasets-data-editor-models';
-import { ExternalDatasetTypeEnum } from '@app/core/common/enum/external-dataset-type-enum';
-
-@Component({
- selector: 'app-dataset-profile-editor-external-datasets-field-component',
- styleUrls: ['./dataset-profile-editor-external-datasets-field.component.scss'],
- templateUrl: './dataset-profile-editor-external-datasets-field.component.html'
-})
-export class DatasetProfileEditorExternalDatasetsFieldComponent implements OnInit {
-
- @Input() form: UntypedFormGroup;
- private data: ExternalDatasetsDataEditorModel = new ExternalDatasetsDataEditorModel();
-
- externalDatasetTypes = [
- ... Object.keys(ExternalDatasetTypeEnum).map(key=>{
- return {
- label: this.parseExtrernalDatasetTypeKey(key),
- value: ExternalDatasetTypeEnum[key]
- };
- })
- ];
- ngOnInit() {
- if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); }
- }
-
- parseExtrernalDatasetTypeKey(key: string): string{
- if(ExternalDatasetTypeEnum[key] === ExternalDatasetTypeEnum.ProducedDataset){
- return 'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.EXTERNAL-DATASET-TYPES.PRODUCED';
- }
- if(ExternalDatasetTypeEnum[key] === ExternalDatasetTypeEnum.ReusedDataset){
- return 'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.EXTERNAL-DATASET-TYPES.REUSED';
- }
- if(ExternalDatasetTypeEnum[key] === ExternalDatasetTypeEnum.Other){
- return 'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.EXTERNAL-DATASET-TYPES.OTHER';
- }
- return key;
- }
-}
diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/external-datasets/dataset-profile-editor-external-datasets-field.component.html b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/external-datasets/description-template-editor-external-datasets-field.component.html
similarity index 83%
rename from dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/external-datasets/dataset-profile-editor-external-datasets-field.component.html
rename to dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/external-datasets/description-template-editor-external-datasets-field.component.html
index 8149e044a..db5790a8e 100644
--- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/external-datasets/dataset-profile-editor-external-datasets-field.component.html
+++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/external-datasets/description-template-editor-external-datasets-field.component.html
@@ -10,13 +10,13 @@
{{form.get('data').get('label').getError('backendError').message}}
-
+
diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/external-datasets/dataset-profile-editor-external-datasets-field.component.scss b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/external-datasets/description-template-editor-external-datasets-field.component.scss
similarity index 100%
rename from dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/external-datasets/dataset-profile-editor-external-datasets-field.component.scss
rename to dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/external-datasets/description-template-editor-external-datasets-field.component.scss
diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/external-datasets/description-template-editor-external-datasets-field.component.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/external-datasets/description-template-editor-external-datasets-field.component.ts
new file mode 100644
index 000000000..32c3f905b
--- /dev/null
+++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/external-datasets/description-template-editor-external-datasets-field.component.ts
@@ -0,0 +1,22 @@
+import { Component, Input, OnInit } from '@angular/core';
+import { UntypedFormGroup } from '@angular/forms';
+import { DescriptionTemplateFieldDataExternalDatasetType } from '@app/core/common/enum/description-template-field-data-external-dataset-type';
+import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
+
+@Component({
+ selector: 'app-description-template-editor-external-datasets-field-component',
+ styleUrls: ['./description-template-editor-external-datasets-field.component.scss'],
+ templateUrl: './description-template-editor-external-datasets-field.component.html'
+})
+export class DescriptionTemplateEditorExternalDatasetsFieldComponent implements OnInit {
+
+ @Input() form: UntypedFormGroup;
+ externalDatasetTypeEnumValues = this.enumUtils.getEnumValues(DescriptionTemplateFieldDataExternalDatasetType);
+ constructor(
+ private enumUtils: EnumUtils
+ ) {}
+
+ ngOnInit() {
+
+ }
+}
diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.html b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.html
index e4dac473c..318dc9383 100644
--- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.html
+++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.html
@@ -215,11 +215,11 @@
+
-
diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.ts
index 9cc0bc73e..8a6a6637d 100644
--- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.ts
+++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.ts
@@ -353,7 +353,7 @@ export class DescriptionTemplateEditorFieldComponent extends BaseComponent imple
const data: DescriptionTemplateResearcherAutoCompleteData = {
label: '',
multiAutoComplete: false,
- fieldType: DescriptionTemplateFieldType.INTERNAL_DMP_ENTRIES_RESEARCHERS
+ fieldType: DescriptionTemplateFieldType.RESEARCHERS
}
field.data = data;
break;
diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.model.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.model.ts
index 92a613108..46a11a03a 100644
--- a/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.model.ts
+++ b/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.model.ts
@@ -1,11 +1,12 @@
import { FormArray, FormControl, UntypedFormArray, UntypedFormBuilder, UntypedFormGroup, Validators } from "@angular/forms";
import { DescriptionTemplateFieldAutocompleteType } from "@app/core/common/enum/description-template-field-autocomplete-type";
+import { DescriptionTemplateFieldDataExternalDatasetType } from "@app/core/common/enum/description-template-field-data-external-dataset-type";
import { DescriptionTemplateFieldType } from "@app/core/common/enum/description-template-field-type";
import { DescriptionTemplateFieldValidationType } from "@app/core/common/enum/description-template-field-validation-type";
import { DescriptionTemplateStatus } from "@app/core/common/enum/description-template-status";
import { UserDescriptionTemplateRole } from "@app/core/common/enum/user-description-template-role";
import { DescriptionTemplate, DescriptionTemplateDefinition, DescriptionTemplateField, DescriptionTemplateFieldSet, DescriptionTemplateMultiplicity, DescriptionTemplatePage, DescriptionTemplateRule, DescriptionTemplateSection } from "@app/core/model/description-template/description-template";
-import { DescriptionTemplateAuthAutoCompleteDataPersist, DescriptionTemplateAutoCompleteDataPersist, DescriptionTemplateAutoCompleteSingleDataPersist, DescriptionTemplateBaseFieldDataPersist, DescriptionTemplateComboBoxOptionPersist, DescriptionTemplateDefinitionPersist, DescriptionTemplateFieldPersist, DescriptionTemplateFieldSetPersist, DescriptionTemplateMultiplicityPersist, DescriptionTemplatePagePersist, DescriptionTemplatePersist, DescriptionTemplatePlaceholderAndMultiplicityDataPersist, DescriptionTemplateRadioBoxDataPersist, DescriptionTemplateRadioBoxOptionPersist, DescriptionTemplateRulePersist, DescriptionTemplateSectionPersist, DescriptionTemplateUploadDataPersist, DescriptionTemplateUploadOptionPersist, DescriptionTemplateSelectDataPersist, UserDescriptionTemplatePersist } from "@app/core/model/description-template/description-template-persist";
+import { DescriptionTemplateAuthAutoCompleteDataPersist, DescriptionTemplateAutoCompleteDataPersist, DescriptionTemplateAutoCompleteSingleDataPersist, DescriptionTemplateBaseFieldDataPersist, DescriptionTemplateComboBoxOptionPersist, DescriptionTemplateDefinitionPersist, DescriptionTemplateFieldPersist, DescriptionTemplateFieldSetPersist, DescriptionTemplateMultiplicityPersist, DescriptionTemplatePagePersist, DescriptionTemplatePersist, DescriptionTemplatePlaceholderAndMultiplicityDataPersist, DescriptionTemplateRadioBoxDataPersist, DescriptionTemplateRadioBoxOptionPersist, DescriptionTemplateRulePersist, DescriptionTemplateSectionPersist, DescriptionTemplateUploadDataPersist, DescriptionTemplateUploadOptionPersist, DescriptionTemplateSelectDataPersist, UserDescriptionTemplatePersist, DescriptionTemplateExternalDatasetDataPersist } from "@app/core/model/description-template/description-template-persist";
import { BaseEditorModel } from "@common/base/base-form-editor-model";
import { BackendErrorValidator } from "@common/forms/validation/custom-validator";
import { ValidationErrorModel } from "@common/forms/validation/error-model/validation-error-model";
@@ -842,6 +843,8 @@ export class DescriptionTemplateFieldEditorModel implements DescriptionTemplateF
case DescriptionTemplateFieldType.RESEARCHERS:
case DescriptionTemplateFieldType.ORGANIZATIONS:
return new DescriptionTemplatePlaceholderAndMultiplicityFieldEditorModel(this.validationErrorModel);
+ case DescriptionTemplateFieldType.EXTERNAL_DATASETS:
+ return new DescriptionTemplateExternalDatasetFieldEditorModel(this.validationErrorModel);
case DescriptionTemplateFieldType.UPLOAD:
return new DescriptionTemplateUploadFieldEditorModel(this.validationErrorModel);
}
@@ -1016,6 +1019,76 @@ export class DescriptionTemplatePlaceholderAndMultiplicityFieldEditorModel exten
}
}
+//
+//
+// External Dataset Field
+//
+//
+export class DescriptionTemplateExternalDatasetFieldEditorModel extends DescriptionTemplatePlaceholderAndMultiplicityFieldEditorModel implements DescriptionTemplateExternalDatasetDataPersist {
+ type: DescriptionTemplateFieldDataExternalDatasetType;
+ protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
+
+ constructor(
+ public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
+ ) { super(validationErrorModel); }
+
+ fromModel(item: DescriptionTemplateExternalDatasetDataPersist): DescriptionTemplateExternalDatasetFieldEditorModel {
+ if (item) {
+ super.fromModel(item);
+ this.type = item.type;
+ }
+ return this;
+ }
+
+ buildForm(params?: {
+ context?: ValidationContext,
+ disabled?: boolean,
+ rootPath?: string
+ }): UntypedFormGroup {
+ let { context = null, disabled = false, rootPath } = params ?? {}
+ if (context == null) {
+ context = DescriptionTemplateExternalDatasetFieldEditorModel.createValidationContext({
+ validationErrorModel: this.validationErrorModel,
+ rootPath
+ });
+ }
+
+ const formGroup = super.buildForm({ context, disabled, rootPath });
+ formGroup.setControl('type', new FormControl({ value: this.type, disabled: disabled }, context.getValidation('type').validators));
+ return formGroup;
+ }
+
+ static createValidationContext(params: {
+ rootPath?: string,
+ validationErrorModel: ValidationErrorModel
+ }): ValidationContext {
+ const { rootPath = '', validationErrorModel } = params;
+ const baseContext: ValidationContext = super.createValidationContext({ rootPath, validationErrorModel });
+ baseContext.validation.push({ key: 'type', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}type`)] });
+ return baseContext;
+ }
+
+ static reapplyValidators(params: {
+ formGroup: UntypedFormGroup,
+ validationErrorModel: ValidationErrorModel,
+ rootPath: string
+ }): void {
+
+ const { formGroup, rootPath, validationErrorModel } = params;
+ const context = DescriptionTemplateExternalDatasetFieldEditorModel.createValidationContext({
+ rootPath,
+ validationErrorModel
+ });
+
+ ['type'].forEach(keyField => {
+ const control = formGroup?.get(keyField);
+ control?.clearValidators();
+ control?.addValidators(context.getValidation(keyField).validators);
+ })
+ }
+}
+
+
//
//
// Autocomplete Field
diff --git a/dmp-frontend/src/assets/i18n/en.json b/dmp-frontend/src/assets/i18n/en.json
index 32185b6ea..136f9835d 100644
--- a/dmp-frontend/src/assets/i18n/en.json
+++ b/dmp-frontend/src/assets/i18n/en.json
@@ -2410,6 +2410,11 @@
"DMP-ACCESS-TYPE": {
"PUBLIC": "Public",
"RESTRICTED": "Restricted Access"
+ },
+ "DESCRIPTION-TEMPLATE-FIELD-EXTERNAL-DATASET-TYPE": {
+ "PRODUCED": "Produced dataset",
+ "REUSED": "Reused dataset",
+ "OTHER": "Other"
}
},
"ADDRESEARCHERS-EDITOR": {