diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/word/WordBuilder.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/word/WordBuilder.java index f37b69e22..72f521b02 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/word/WordBuilder.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/word/WordBuilder.java @@ -1,9 +1,13 @@ package eu.eudat.logic.utilities.documents.word; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; import eu.eudat.logic.services.forms.VisibilityRuleService; import eu.eudat.logic.utilities.documents.types.ParagraphStyle; import eu.eudat.logic.utilities.documents.types.TextStyle; import eu.eudat.logic.utilities.interfaces.ApplierWithValue; +import eu.eudat.models.data.components.commons.datafield.CheckBoxData; +import eu.eudat.models.data.components.commons.datafield.ComboBoxData; import eu.eudat.models.data.user.components.datasetprofile.Field; import eu.eudat.models.data.user.components.datasetprofile.FieldSet; import eu.eudat.models.data.user.components.datasetprofile.Section; @@ -139,9 +143,13 @@ public class WordBuilder { fields.forEach(field -> { if (visibilityRuleService.isElementVisible(field.getId())) { if (!createListing) { - XWPFParagraph paragraph = addParagraphContent(field.getValue() == null ? "" : field.getValue(), mainDocumentPart, ParagraphStyle.TEXT, numId); - CTDecimalNumber number = paragraph.getCTP().getPPr().getNumPr().addNewIlvl(); - number.setVal(BigInteger.valueOf(indent)); + try { + XWPFParagraph paragraph = addParagraphContent(this.formatter(field), mainDocumentPart, ParagraphStyle.TEXT, numId); + CTDecimalNumber number = paragraph.getCTP().getPPr().getNumPr().addNewIlvl(); + number.setVal(BigInteger.valueOf(indent)); + } catch (IOException e) { + e.printStackTrace(); + } } } }); @@ -180,4 +188,38 @@ public class WordBuilder { } } + public String formatter(Field field) throws IOException { + switch (field.getViewStyle().getRenderStyle()) { + case "combobox": { + String comboboxType = ((ComboBoxData) field.getData()).getType(); + if (comboboxType.equals("autocomplete")) { + ObjectMapper mapper = new ObjectMapper(); + if (field.getValue() == null) return null; + Map map = mapper.readValue(field.getValue(), new TypeReference>() { + }); + return map.get("label"); + } else if (comboboxType.equals("wordlist")) { + ObjectMapper mapper = new ObjectMapper(); + if (field.getValue() == null) return null; + Map map = mapper.readValue(field.getValue(), new TypeReference>() { + }); + return map.get("label"); + } + } + case "booleanDecision": + if (field.getValue() != null && field.getValue().equals("true")) return "Yes"; + else return "No"; + case "radiobox": + return field.getValue(); + case "checkBox": + CheckBoxData data = (CheckBoxData) field.getData(); + return data.getLabel(); + case "freetext": + return field.getValue(); + case "textarea": + return field.getValue(); + } + return null; + } + } diff --git a/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-checkbox/dynamic-field-checkbox.html b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-checkbox/dynamic-field-checkbox.html index e4aaf4246..df5d98780 100644 --- a/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-checkbox/dynamic-field-checkbox.html +++ b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-checkbox/dynamic-field-checkbox.html @@ -3,4 +3,4 @@ - \ No newline at end of file + diff --git a/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-dropdown/dynamic-field-dropdown.css b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-dropdown/dynamic-field-dropdown.css index bf67b66d0..e69de29bb 100644 --- a/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-dropdown/dynamic-field-dropdown.css +++ b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-dropdown/dynamic-field-dropdown.css @@ -1 +0,0 @@ -@CHARSET "UTF-8"; \ No newline at end of file diff --git a/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-dropdown/dynamic-field-dropdown.html b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-dropdown/dynamic-field-dropdown.html index a0ba2b0fd..77a558544 100644 --- a/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-dropdown/dynamic-field-dropdown.html +++ b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-dropdown/dynamic-field-dropdown.html @@ -1,9 +1,9 @@
- - - {{opt.label}} - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - + + + {{opt.label}} + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + -
\ No newline at end of file + diff --git a/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-dropdown/dynamic-field-dropdown.ts b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-dropdown/dynamic-field-dropdown.ts index dcca8a330..55e8a8d44 100644 --- a/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-dropdown/dynamic-field-dropdown.ts +++ b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-dropdown/dynamic-field-dropdown.ts @@ -17,4 +17,13 @@ export class DynamicFieldDropdownComponent implements OnInit { ngOnInit() { } + + assign(item: any) { + if (!item) { return null; } + return this.transform(item); + } + + transform(item: any) { + if (typeof item === 'string') { return JSON.parse(item); } else { return JSON.stringify(item); } + } } diff --git a/dmp-frontend/src/app/form/dynamic-fields/dynamic-form-field.component.html b/dmp-frontend/src/app/form/dynamic-fields/dynamic-form-field.component.html index 29044d937..d81ca2bd0 100644 --- a/dmp-frontend/src/app/form/dynamic-fields/dynamic-form-field.component.html +++ b/dmp-frontend/src/app/form/dynamic-fields/dynamic-form-field.component.html @@ -1,67 +1,71 @@
- + -
-
{{field.description}}
-
- {{field.extendedDescription}} -
+
+
{{field.description}}
+
+ {{field.extendedDescription}} +
-
- - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - -
+
+ + + {{'GENERAL.VALIDATION.REQUIRED' + | translate}} + +
-
- -
- -
-
- -
+
+ +
+ +
+
+ +
+
-
+
+ +
-
- -
+
+ + - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - + + {{'GENERAL.VALIDATION.REQUIRED' + | translate}} + -
+
-
- -
+
+ +
-
- -
+
+ +
-
+
- -
+