From 193e7410a8210bb55d36afea71518caa6dfc737d Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Mon, 1 Nov 2021 15:30:21 +0200 Subject: [PATCH] Added rich text area field type for response in dataset > chapter > section > questions. 1. dataset-profile.module.ts: Added in declarations "DatasetProfileEditorRichTextAreaFieldComponent". 2. dataset-profile-editor-composite-field.component.html: Added RichTextArea as input field type for response to a question. 3. dataset-profile-editor-composite-field.component.ts: In method "addNewInput()" added case for RichTextArea. 4. dataset-profile-field-view-style.ts & view-style-enum.ts: Added RichTextArea. 5. field-data.ts: Added interface RichTextAreaFieldData. 6. enum-utils.service.ts: In methods "toDatasetProfileFieldViewStyleString()" and "toDatasetProfileViewTypeString()" added cases for RichTextArea 7. field-editor-model.ts: Added richTextarea. 8. component-profile-editor-default-value.component.html: Added for RichTextArea (how rich text area is initialized when this type is selected as response). 9. dataset-profile-editor-field.component.html: Added for RichTextArea (to select it) and (to show it). 10. dataset-profile-editor-field.component.ts: Added RichTextArea case everywhere. 11. dataset-wizard.component.ts & dmp-editor.component.ts: In method "_getPlaceHolder()" added case for richTextarea. 12. dataset-description-form.module.ts: Imported RichTextEditorModule. 13. form-field.component.html: Added RichTextArea case with . 14. assets/i18n/: Added DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-RICH-TEXT-AREA-TITLE, DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-RICH-TEXT-AREA-PLACEHOLDER and DMP-EDITOR.TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.RICH-TEXT-AREA. 15. field-data/rich-text-area-field-data-editor-model.ts & field-type/rich-textarea/: [NEW] Files for Rich Text Area field type. --- .../enum/dataset-profile-field-view-style.ts | 1 + .../field-data/field-data.ts | 4 ++++ .../services/utilities/enum-utils.service.ts | 2 ++ .../rich-text-area-field-data-editor-model.ts | 18 ++++++++++++++++++ .../admin/field-editor-model.ts | 2 ++ .../dataset-profile/dataset-profile.module.ts | 2 ++ ...ofile-editor-composite-field.component.html | 6 ++++++ ...profile-editor-composite-field.component.ts | 16 ++++++++++++++++ ...profile-editor-default-value.component.html | 7 +++++++ ...-editor-rich-text-area-field.component.html | 13 +++++++++++++ ...-editor-rich-text-area-field.component.scss | 3 +++ ...le-editor-rich-text-area-field.component.ts | 18 ++++++++++++++++++ ...dataset-profile-editor-field.component.html | 5 +++++ .../dataset-profile-editor-field.component.ts | 16 +++++++++++++++- .../editor/components/field/view-style-enum.ts | 3 ++- .../dataset-wizard/dataset-wizard.component.ts | 3 ++- .../app/ui/dmp/editor/dmp-editor.component.ts | 3 ++- .../form-field/form-field.component.html | 13 +++++++++++++ .../dataset-description-form.module.ts | 4 +++- dmp-frontend/src/assets/i18n/de.json | 3 +++ dmp-frontend/src/assets/i18n/en.json | 3 +++ dmp-frontend/src/assets/i18n/es.json | 3 +++ dmp-frontend/src/assets/i18n/gr.json | 3 +++ dmp-frontend/src/assets/i18n/pt.json | 3 +++ dmp-frontend/src/assets/i18n/sk.json | 3 +++ dmp-frontend/src/assets/i18n/sr.json | 3 +++ dmp-frontend/src/assets/i18n/tr.json | 3 +++ 27 files changed, 158 insertions(+), 5 deletions(-) create mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/rich-text-area-field-data-editor-model.ts create mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/rich-textarea/dataset-profile-editor-rich-text-area-field.component.html create mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/rich-textarea/dataset-profile-editor-rich-text-area-field.component.scss create mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/rich-textarea/dataset-profile-editor-rich-text-area-field.component.ts 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 a82869dec..4344a5eea 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 @@ -1,5 +1,6 @@ export enum DatasetProfileFieldViewStyle { TextArea = "textarea", + RichTextArea = "richTextarea", BooleanDecision = "booleanDecision", ComboBox = "combobox", CheckBox = "checkBox", 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 ab020df4f..c1714c52b 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 @@ -39,6 +39,10 @@ export interface TextAreaFieldData extends FieldData { } +export interface RichTextAreaFieldData extends FieldData { + +} + export interface WordListFieldData extends FieldData { type: DatasetProfileComboBoxType; options: Array; 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 a7dada1f9..985806d78 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 @@ -79,6 +79,7 @@ export class EnumUtils { 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'); + case DatasetProfileFieldViewStyle.RichTextArea: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.RICH-TEXT-AREA'); case DatasetProfileFieldViewStyle.DatePicker: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.DATE-PICKER'); case DatasetProfileFieldViewStyle.ExternalDatasets: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.EXTERNAL-DATASETS'); case DatasetProfileFieldViewStyle.DataRepositories: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.DATA-REPOSITORIES'); @@ -101,6 +102,7 @@ export class EnumUtils { case ViewStyleType.FreeText: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.FREE-TEXT'); case ViewStyleType.RadioBox: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.RADIO-BOX'); case ViewStyleType.TextArea: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.TEXT-AREA'); + case ViewStyleType.RichTextArea: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.RICH-TEXT-AREA'); case ViewStyleType.DatePicker: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.DATE-PICKER'); case ViewStyleType.ExternalDatasets: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.EXTERNAL-DATASETS'); case ViewStyleType.DataRepositories: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.DATA-REPOSITORIES'); diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/rich-text-area-field-data-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/rich-text-area-field-data-editor-model.ts new file mode 100644 index 000000000..9ba1e2389 --- /dev/null +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/rich-text-area-field-data-editor-model.ts @@ -0,0 +1,18 @@ +import { FormGroup } from '@angular/forms'; +import { RichTextAreaFieldData } from '../../../../../core/model/dataset-profile-definition/field-data/field-data'; +import { FieldDataEditorModel } from './field-data-editor-model'; + +export class RichTextAreaFieldDataEditorModel extends FieldDataEditorModel { + + buildForm(disabled: boolean = false, skipDisable: Array = []): FormGroup { + const formGroup = this.formBuilder.group({ + label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('RichTextAreaFieldDataEditorModel.label')) }] + }); + return formGroup; + } + + fromModel(item: RichTextAreaFieldData): RichTextAreaFieldDataEditorModel { + this.label = item.label; + 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 51ebd8030..ad245c0c1 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 @@ -10,6 +10,7 @@ import { FieldDataEditorModel } from './field-data/field-data-editor-model'; import { FreeTextFieldDataEditorModel } from './field-data/free-text-field-data-editor-model'; import { RadioBoxFieldDataEditorModel } from './field-data/radio-box-field-data-editor-model'; import { TextAreaFieldDataEditorModel } from './field-data/text-area-field-data-editor-model'; +import { RichTextAreaFieldDataEditorModel } from './field-data/rich-text-area-field-data-editor-model'; import { WordListFieldDataEditorModel } from './field-data/word-list-field-data-editor-model'; import { ViewStyleEditorModel } from './view-style-editor-model'; import { VisibilityEditorModel } from './visibility-editor-model'; @@ -66,6 +67,7 @@ export class FieldEditorModel extends BaseFormModel { if (this.viewStyle.renderStyle === 'radiobox') { this.data = new RadioBoxFieldDataEditorModel().fromModel(item.data); } if (this.viewStyle.renderStyle === 'checkBox') { this.data = new CheckBoxFieldDataEditorModel().fromModel(item.data); } if (this.viewStyle.renderStyle === 'textarea') { this.data = new TextAreaFieldDataEditorModel().fromModel(item.data); } + if (this.viewStyle.renderStyle === 'richTextarea') { this.data = new RichTextAreaFieldDataEditorModel().fromModel(item.data); } if (this.viewStyle.renderStyle === 'freetext') { this.data = new FreeTextFieldDataEditorModel().fromModel(item.data); } if (this.viewStyle.renderStyle === 'booleanDecision') { this.data = new BooleanDecisionFieldDataEditorModel().fromModel(item.data); } if (this.viewStyle.renderStyle === 'datePicker') { this.data = new DatePickerDataEditorModel().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 ff0b0b52e..b5fd6b6b0 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 @@ -53,6 +53,7 @@ import { DatasetProfileTableOfContents } from './table-of-contents/table-of-cont import { DatasetProfileTableOfContentsInternalSection } from './table-of-contents/table-of-contents-internal-section/table-of-contents-internal-section'; import {TransitionGroupModule} from "@app/ui/transition-group/transition-group.module"; import { RichTextEditorModule } from "@app/library/rich-text-editor/rich-text-editor.module"; +import {DatasetProfileEditorRichTextAreaFieldComponent} from "@app/ui/admin/dataset-profile/editor/components/field-type/rich-textarea/dataset-profile-editor-rich-text-area-field.component"; @@ -90,6 +91,7 @@ import { RichTextEditorModule } from "@app/library/rich-text-editor/rich-text-ed DatasetProfileEditorFreeTextFieldComponent, DatasetProfileEditorRadioBoxFieldComponent, DatasetProfileEditorTextAreaFieldComponent, + DatasetProfileEditorRichTextAreaFieldComponent, DatasetProfileEditorDatePickerFieldComponent, DatasetProfileEditorWordListFieldComponent, DatasetProfileEditorDefaultValueComponent, diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.html index 434dd727d..e56e4ce9f 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.html +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.html @@ -268,6 +268,12 @@ {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.TextArea)}} +