diff --git a/backend/core/src/main/java/org/opencdmp/authorization/Permission.java b/backend/core/src/main/java/org/opencdmp/authorization/Permission.java index 0f0fe754f..fbf7f65c5 100644 --- a/backend/core/src/main/java/org/opencdmp/authorization/Permission.java +++ b/backend/core/src/main/java/org/opencdmp/authorization/Permission.java @@ -73,7 +73,6 @@ public final class Permission { //Dmp public static String BrowseDmp = "BrowseDmp"; public static String EditDmp = "EditDmp"; - public static String ReviewDmp = "ReviewDmp"; public static String NewDmp = "NewDmp"; public static String DepositDmp = "DepositDmp"; public static String DeleteDmp = "DeleteDmp"; diff --git a/dmp-frontend/src/app/core/common/enum/description-template-field-type.ts b/dmp-frontend/src/app/core/common/enum/description-template-field-type.ts index c189e5822..425765a64 100644 --- a/dmp-frontend/src/app/core/common/enum/description-template-field-type.ts +++ b/dmp-frontend/src/app/core/common/enum/description-template-field-type.ts @@ -10,9 +10,8 @@ export enum DescriptionTemplateFieldType { RICH_TEXT_AREA = "richTextarea", UPLOAD = "upload", DATE_PICKER = "datePicker", - EXTERNAL_DATASETS = "externalDatasets", - REFERENCE_TYPES = "referenceTypes", TAGS = "tags", + REFERENCE_TYPES = "referenceTypes", DATASET_IDENTIFIER = "datasetIdentifier", VALIDATION = "validation" -} \ No newline at end of file +} diff --git a/dmp-frontend/src/app/core/model/description/description.ts b/dmp-frontend/src/app/core/model/description/description.ts index 197132480..cd6fd094d 100644 --- a/dmp-frontend/src/app/core/model/description/description.ts +++ b/dmp-frontend/src/app/core/model/description/description.ts @@ -99,6 +99,7 @@ export interface DescriptionFieldPersist { textListValue: string[]; dateValue: Date; references: ReferencePersist[]; + reference: ReferencePersist; externalIdentifier?: DescriptionExternalIdentifierPersist; } diff --git a/dmp-frontend/src/app/core/pipes/field-value.pipe.ts b/dmp-frontend/src/app/core/pipes/field-value.pipe.ts index 41f2d40fb..ef9777c0c 100644 --- a/dmp-frontend/src/app/core/pipes/field-value.pipe.ts +++ b/dmp-frontend/src/app/core/pipes/field-value.pipe.ts @@ -2,6 +2,9 @@ import { DatePipe } from "@angular/common"; import { Pipe, PipeTransform } from "@angular/core"; import { DescriptionTemplateFieldType } from "../common/enum/description-template-field-type"; import { Reference } from "../model/reference/reference"; +import { DescriptionTemplateField, DescriptionTemplateRadioBoxData, DescriptionTemplateReferenceTypeData, DescriptionTemplateSelectData } from "../model/description-template/description-template"; +import { DescriptionFieldPersist } from "../model/description/description"; +import { Observable, of } from "rxjs"; @Pipe({ name: 'fieldValue' @@ -11,54 +14,62 @@ export class FieldValuePipe implements PipeTransform { constructor(private date: DatePipe) { } - transform(controlValue: any): string | null { - let value = controlValue?.value; - let renderStyle = controlValue?.viewStyle?.renderStyle; - if (renderStyle && value) { - switch (renderStyle) { + transform(controlValue: DescriptionFieldPersist, field: DescriptionTemplateField): Observable { + if (field?.data?.fieldType && controlValue) { + switch (field.data.fieldType) { case DescriptionTemplateFieldType.BOOLEAN_DECISION: - return value == 'true' ? 'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.BOOLEAN-DECISION.YES' : 'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.BOOLEAN-DECISION.NO'; + return of(controlValue.textValue == 'true' ? 'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.BOOLEAN-DECISION.YES' : 'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.BOOLEAN-DECISION.NO'); case DescriptionTemplateFieldType.CHECK_BOX: - return value ? 'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.BOOLEAN-DECISION.YES' : 'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.BOOLEAN-DECISION.NO'; - case DescriptionTemplateFieldType.RADIO_BOX: - if (value && controlValue.data.options) { - return controlValue.data.options.find(option => option.value === value).label; + return of(controlValue.textValue == 'true' ? 'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.BOOLEAN-DECISION.YES' : 'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.BOOLEAN-DECISION.NO'); + case DescriptionTemplateFieldType.RADIO_BOX: { + const data = field.data; + if (data?.options) { + return of(data.options?.find(option => option.value === controlValue.textValue)?.label); } break; + } case DescriptionTemplateFieldType.DATE_PICKER: - return this.date.transform(controlValue.value, 'dd/MM/yyyy'); + return of(this.date.transform(controlValue.dateValue, 'dd/MM/yyyy')); case DescriptionTemplateFieldType.FREE_TEXT: - return value; - case DescriptionTemplateFieldType.SELECT: - if (value && controlValue.data.options && !controlValue.data.multipleSelect) { - return controlValue.data.options.find(option => value == option.value).label; - } else if (value && controlValue.data.options && controlValue.data.multipleSelect) { - return controlValue.data.options.filter(option => value.includes(option.value)).map(option => option.label).join(','); + return of(controlValue.textValue); + case DescriptionTemplateFieldType.SELECT: { + const data = field.data; + if (data?.options && !data?.multipleSelect) { + return of(data.options?.find(option => controlValue.textValue == option.value)?.label); + } else if (data?.options && data?.multipleSelect) { + return of(data?.options?.filter(option => controlValue.textListValue.includes(option.value)).map(option => option.label).join(',')); } break; + } case DescriptionTemplateFieldType.RICH_TEXT_AREA: - if (value) { - return value.replace(/ /g, ' ').replace(/(\r\n|\n|\r| +(?= ))|\s\s+/gm, " ").replace(/<[^>]*>/g, ''); + if (controlValue.textValue) { + return of(controlValue.textValue.replace(/ /g, ' ').replace(/(\r\n|\n|\r| +(?= ))|\s\s+/gm, " ").replace(/<[^>]*>/g, '')); } break; case DescriptionTemplateFieldType.TEXT_AREA: - return value; - case DescriptionTemplateFieldType.REFERENCE_TYPES: - return (value as Reference)?.label; - case DescriptionTemplateFieldType.EXTERNAL_DATASETS: - case DescriptionTemplateFieldType.TAGS: - return this.parseJson(value); - case DescriptionTemplateFieldType.INTERNAL_ENTRIES_DMPS: - case DescriptionTemplateFieldType.INTERNAL_ENTRIES_DESCRIPTIONS: - return this.parseJson(value, 'label'); + return of(controlValue.textValue); + case DescriptionTemplateFieldType.REFERENCE_TYPES: { + const data = field.data; + if (!data?.multipleSelect && controlValue.reference) { + return of(controlValue.reference?.label); + } else if (data?.multipleSelect && controlValue.references) { + return of(controlValue.references.map(option => option.label).join(',')); + } + break; + } + // case DescriptionTemplateFieldType.TAGS: + // return this.parseJson(value); + // case DescriptionTemplateFieldType.INTERNAL_ENTRIES_DMPS: + // case DescriptionTemplateFieldType.INTERNAL_ENTRIES_DESCRIPTIONS: + // return this.parseJson(value, 'label'); case DescriptionTemplateFieldType.DATASET_IDENTIFIER: case DescriptionTemplateFieldType.VALIDATION: - if (value && value.identifier) { - return value.identifier; + if (controlValue.externalIdentifier?.identifier) { + return of(controlValue.externalIdentifier?.identifier); } break; default: - return null; + return of(null); } } return null; 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 8171f4027..780c307fe 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 @@ -154,7 +154,7 @@ export class EnumUtils { case DescriptionTemplateFieldType.RICH_TEXT_AREA: return this.language.instant('TYPES.DESCRIPTION-TEMPLATE-FIELD-TYPE.RICH-TEXT-AREA'); case DescriptionTemplateFieldType.UPLOAD: return this.language.instant('TYPES.DESCRIPTION-TEMPLATE-FIELD-TYPE.UPLOAD'); case DescriptionTemplateFieldType.DATE_PICKER: return this.language.instant('TYPES.DESCRIPTION-TEMPLATE-FIELD-TYPE.DATE-PICKER'); - case DescriptionTemplateFieldType.EXTERNAL_DATASETS: return this.language.instant('TYPES.DESCRIPTION-TEMPLATE-FIELD-TYPE.EXTERNAL-DATASETS'); + // case DescriptionTemplateFieldType.EXTERNAL_DATASETS: return this.language.instant('TYPES.DESCRIPTION-TEMPLATE-FIELD-TYPE.EXTERNAL-DATASETS'); case DescriptionTemplateFieldType.TAGS: return this.language.instant('TYPES.DESCRIPTION-TEMPLATE-FIELD-TYPE.TAGS'); case DescriptionTemplateFieldType.REFERENCE_TYPES: return this.language.instant('TYPES.DESCRIPTION-TEMPLATE-FIELD-TYPE.REFERENCE-TYPES'); case DescriptionTemplateFieldType.DATASET_IDENTIFIER: return this.language.instant('TYPES.DESCRIPTION-TEMPLATE-FIELD-TYPE.DATASET-IDENTIFIER'); diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/composite-field/description-template-editor-composite-field.component.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/components/composite-field/description-template-editor-composite-field.component.ts index 426c4cf1e..22dc8decd 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/composite-field/description-template-editor-composite-field.component.ts +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/composite-field/description-template-editor-composite-field.component.ts @@ -562,15 +562,15 @@ export class DescriptionTemplateEditorCompositeFieldComponent extends BaseCompon field.data = data; break; } - case DescriptionTemplateFieldType.EXTERNAL_DATASETS: { - const data: DescriptionTemplateExternalDatasetData = { - label: '', - multipleSelect: false, - fieldType: type - } - field.data = data; - break; - } + // case DescriptionTemplateFieldType.EXTERNAL_DATASETS: { + // const data: DescriptionTemplateExternalDatasetData = { + // label: '', + // multipleSelect: false, + // fieldType: type + // } + // field.data = data; + // break; + // } case DescriptionTemplateFieldType.UPLOAD: { const data: DescriptionTemplateUploadData = { label: '', 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 2ef8118b4..f5d808cde 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 @@ -170,15 +170,15 @@ export class DescriptionTemplateEditorFieldComponent extends BaseComponent imple field.data = data; break; } - case DescriptionTemplateFieldType.EXTERNAL_DATASETS: { - const data: DescriptionTemplateExternalDatasetData = { - label: '', - multipleSelect: false, - fieldType: type - } - field.data = data; - break; - } + // case DescriptionTemplateFieldType.EXTERNAL_DATASETS: { + // const data: DescriptionTemplateExternalDatasetData = { + // label: '', + // multipleSelect: false, + // fieldType: type + // } + // field.data = data; + // break; + // } case DescriptionTemplateFieldType.UPLOAD: { const data: DescriptionTemplateUploadData = { label: '', 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 8333c8a02..c09a718a9 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 @@ -802,8 +802,8 @@ export class DescriptionTemplateFieldEditorModel implements DescriptionTemplateF case DescriptionTemplateFieldType.INTERNAL_ENTRIES_DMPS: case DescriptionTemplateFieldType.INTERNAL_ENTRIES_DESCRIPTIONS: return new DescriptionTemplateLabelAndMultiplicityDataEditorModel(this.validationErrorModel); - case DescriptionTemplateFieldType.EXTERNAL_DATASETS: - return new DescriptionTemplateExternalDatasetDataEditorModel(this.validationErrorModel); + // case DescriptionTemplateFieldType.EXTERNAL_DATASETS: + // return new DescriptionTemplateExternalDatasetDataEditorModel(this.validationErrorModel); case DescriptionTemplateFieldType.UPLOAD: return new DescriptionTemplateUploadDataEditorModel(this.validationErrorModel); } @@ -862,12 +862,12 @@ export class DescriptionTemplateFieldEditorModel implements DescriptionTemplateF rootPath: `${rootPath}data.`, validationErrorModel: validationErrorModel }); - case DescriptionTemplateFieldType.EXTERNAL_DATASETS: - DescriptionTemplateExternalDatasetDataEditorModel.reapplyValidators({ - formGroup: formGroup?.get('data') as UntypedFormGroup, - rootPath: `${rootPath}data.`, - validationErrorModel: validationErrorModel - }); + // case DescriptionTemplateFieldType.EXTERNAL_DATASETS: + // DescriptionTemplateExternalDatasetDataEditorModel.reapplyValidators({ + // formGroup: formGroup?.get('data') as UntypedFormGroup, + // rootPath: `${rootPath}data.`, + // validationErrorModel: validationErrorModel + // }); break; } diff --git a/dmp-frontend/src/app/ui/description/editor/description-editor.model.ts b/dmp-frontend/src/app/ui/description/editor/description-editor.model.ts index 9f60d43af..8d70044fb 100644 --- a/dmp-frontend/src/app/ui/description/editor/description-editor.model.ts +++ b/dmp-frontend/src/app/ui/description/editor/description-editor.model.ts @@ -723,9 +723,9 @@ export class DescriptionFieldIndicator { case DescriptionTemplateFieldType.DATE_PICKER: this.type = "dateValue"; break; - case DescriptionTemplateFieldType.EXTERNAL_DATASETS: - this.type = ""; - break; + // case DescriptionTemplateFieldType.EXTERNAL_DATASETS: + // this.type = ""; + // break; case DescriptionTemplateFieldType.INTERNAL_ENTRIES_DESCRIPTIONS: if (multipleSelect) this.type = "textListValue"; else this.type = "textValue" diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.html b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.html index 982dfc2da..db7ecb3d1 100644 --- a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.html +++ b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.html @@ -52,7 +52,7 @@ - {{fieldSetItemPropertiesControl.get('fields').get(field.id).get('value').getRawValue()}} + {{ fieldSetItemPropertiesControl.get('fields')?.get(field.id)?.getRawValue() | fieldValue: field | async }} diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.ts b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.ts index fc58f2496..3d9fd5567 100644 --- a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.ts +++ b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.ts @@ -130,17 +130,17 @@ export class DescriptionFormFieldComponent extends BaseComponent implements OnIn this.isRequired = this.field.validations?.includes(DescriptionTemplateFieldValidationType.Required); switch (this.field?.data?.fieldType) { - case DescriptionTemplateFieldType.EXTERNAL_DATASETS: - //TODO: refactor - // this.multipleReferenceAutoCompleteConfiguration = { - // filterFn: this.filterOrganisations.bind(this), - // initialItems: (excludedItems: any[]) => this.filterOrganisations('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))), - // displayFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name } catch { return '' } }, - // titleFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name } catch { return '' } }, - // subtitleFn: (item) => { try { return item['tag'] ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['tag'] : (item['key'] ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['key'] : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE')) } catch { return '' } }, - // valueAssign: (item) => { try { return typeof (item) == 'string' ? item : JSON.stringify(item) } catch { return '' } } - // }; - break; + // case DescriptionTemplateFieldType.EXTERNAL_DATASETS: + // //TODO: refactor + // // this.multipleReferenceAutoCompleteConfiguration = { + // // filterFn: this.filterOrganisations.bind(this), + // // initialItems: (excludedItems: any[]) => this.filterOrganisations('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))), + // // displayFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name } catch { return '' } }, + // // titleFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name } catch { return '' } }, + // // subtitleFn: (item) => { try { return item['tag'] ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['tag'] : (item['key'] ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['key'] : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE')) } catch { return '' } }, + // // valueAssign: (item) => { try { return typeof (item) == 'string' ? item : JSON.stringify(item) } catch { return '' } } + // // }; + // break; case DescriptionTemplateFieldType.TAGS: this.tagsAutoCompleteConfiguration = { filterFn: this.filterTags.bind(this), @@ -295,7 +295,7 @@ export class DescriptionFormFieldComponent extends BaseComponent implements OnIn this.onCallbackUploadFail(error.error); }) - + } private createFileNameDisplay(name: string, extension: string){ @@ -325,7 +325,7 @@ export class DescriptionFormFieldComponent extends BaseComponent implements OnIn } else { let fileToUpload = this.filesToUpload[0]; const data = this.field.data as DescriptionTemplateUploadData; - if (data && data.types + if (data && data.types && data.types.map(type => type.value).includes(fileToUpload.type) && data.maxFileSizeInMB && data.maxFileSizeInMB * 1048576 >= fileToUpload.size) { @@ -375,6 +375,6 @@ export class DescriptionFormFieldComponent extends BaseComponent implements OnIn FileSaver.saveAs(blob, filename); }); } - + } }