From 075b3f54817c88c82974a80953cfe040cae7ddc5 Mon Sep 17 00:00:00 2001 From: Ryan Date: Mon, 19 Feb 2024 17:19:36 +0000 Subject: [PATCH] Fix multi-select regression. Change custom section table to 2/3rds layout --- .../gap/applybackend/service/OdtService.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/gov/cabinetoffice/gap/applybackend/service/OdtService.java b/src/main/java/gov/cabinetoffice/gap/applybackend/service/OdtService.java index 7e6cd31..c960176 100644 --- a/src/main/java/gov/cabinetoffice/gap/applybackend/service/OdtService.java +++ b/src/main/java/gov/cabinetoffice/gap/applybackend/service/OdtService.java @@ -232,6 +232,10 @@ private static void populateQuestionResponseTable(AtomicInteger count, AtomicInteger questionIndex = new AtomicInteger(0); OdfTable table = OdfTable.newTable(odt, section.getQuestions().size(), 2); + long firstColumnWidth = table.getWidth() / 3; + long secondColumnWidth = 2 * table.getWidth() / 3; + table.getColumnByIndex(0).setWidth(firstColumnWidth); + table.getColumnByIndex(1).setWidth(secondColumnWidth); section.getQuestions().forEach(question -> { populateDocumentFromQuestionResponse(question, documentText, questionIndex, table); @@ -246,7 +250,7 @@ private static void populateDocumentFromQuestionResponse(SubmissionQuestion ques AtomicInteger questionIndex, OdfTable table) { switch (question.getResponseType()) { - case AddressInput, MultipleSelection -> { + case AddressInput -> { table.getRowByIndex(questionIndex.get()).getCellByIndex(0).setStringValue(question.getFieldTitle()); if (question.getMultiResponse() != null) { table.getRowByIndex(questionIndex.get()).getCellByIndex(1).setStringValue(String.join(",\n", @@ -255,6 +259,15 @@ private static void populateDocumentFromQuestionResponse(SubmissionQuestion ques table.getRowByIndex(questionIndex.get()).getCellByIndex(1).setStringValue("Not provided"); } } + case MultipleSelection -> { + table.getRowByIndex(questionIndex.get()).getCellByIndex(0).setStringValue(question.getFieldTitle()); + if (question.getMultiResponse() != null && !Arrays.stream(question.getMultiResponse()).allMatch(String::isEmpty)) { + table.getRowByIndex(questionIndex.get()).getCellByIndex(1).setStringValue(String.join(",\n", + question.getMultiResponse()) + "\n"); + } else { + table.getRowByIndex(questionIndex.get()).getCellByIndex(1).setStringValue("Not provided"); + } + } case SingleFileUpload -> { table.getRowByIndex(questionIndex.get()).getCellByIndex(0).setStringValue(question.getFieldTitle()); if (question.getResponse() != null) {