From ccbcf4b236b4d323a975178b3c4cc73228bbafa7 Mon Sep 17 00:00:00 2001 From: brianbrix Date: Tue, 1 Oct 2024 22:04:32 +0300 Subject: [PATCH 01/32] Ad import export structures buttons --- .../AmpStructuresFormSectionFeature.html | 32 ++++---- .../AmpStructuresFormSectionFeature.java | 75 +++++++++++++++++++ 2 files changed, 94 insertions(+), 13 deletions(-) diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html index f6f56f4004f..b8df6cb789d 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html +++ b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html @@ -3,6 +3,12 @@ + + + + + + @@ -14,12 +20,12 @@ - Title - Description - Latitude + Title + Description + Latitude Longitude - Shape -   + Shape +   @@ -27,21 +33,21 @@ - +
- +
- -
+ +
-
- + + +
+
+ + +
+
+ + +
+
+ + + diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/FileUploadModalPanel.java b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/FileUploadModalPanel.java new file mode 100644 index 00000000000..841b2c664e6 --- /dev/null +++ b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/FileUploadModalPanel.java @@ -0,0 +1,52 @@ +package org.dgfoundation.amp.onepager.components.features; +import org.apache.wicket.ajax.AjaxRequestTarget; +import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink; +import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow; +import org.apache.wicket.markup.html.form.Form; +import org.apache.wicket.markup.html.form.upload.FileUpload; +import org.apache.wicket.markup.html.form.upload.FileUploadField; +import org.apache.wicket.markup.html.panel.Panel; +import java.io.File; + +public class FileUploadModalPanel extends Panel { + + private FileUploadField fileUploadField; + + public FileUploadModalPanel(String id, ModalWindow modalWindow) { + super(id); + + // Create the form and mark it as multi-part for file uploads + Form form = new Form<>("uploadForm"); + form.setMultiPart(true); // Necessary for file upload + + // Add file upload field + fileUploadField = new FileUploadField("fileUploadField"); + form.add(fileUploadField); + + // Add AjaxSubmitLink to handle file upload via Ajax + form.add(new AjaxSubmitLink("uploadButton", form) { + protected void onSubmit(AjaxRequestTarget target) { + FileUpload upload = fileUploadField.getFileUpload(); + if (upload != null) { + try { + // Save the uploaded file or process it + File file = new File("/path/to/save/" + upload.getClientFileName()); + upload.writeTo(file); + System.out.println("File uploaded: " + upload.getClientFileName()); + } catch (Exception e) { + e.printStackTrace(); + } + } + // Close the modal window after successful upload + modalWindow.close(target); + } + + protected void onError(AjaxRequestTarget target) { + // Handle error scenario here + System.out.println("File upload failed"); + } + }); + + add(form); + } +} diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html index 01988f256ba..2ebf2bf651d 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html +++ b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html @@ -4,6 +4,7 @@ +
@@ -11,15 +12,7 @@ -
- -
+ diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java index edae2d843f5..6b154517327 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java +++ b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java @@ -41,11 +41,13 @@ import org.dgfoundation.amp.onepager.components.PagingListNavigator; import org.dgfoundation.amp.onepager.components.features.CustomResourceLinkResourceLink; import org.dgfoundation.amp.onepager.components.features.ExportExcelResourceReference; +import org.dgfoundation.amp.onepager.components.features.FileUploadModalPanel; import org.dgfoundation.amp.onepager.components.features.tables.AmpLocationFormTableFeature; import org.dgfoundation.amp.onepager.components.fields.AmpAjaxLinkField; import org.dgfoundation.amp.onepager.components.fields.AmpTextAreaFieldPanel; import org.dgfoundation.amp.onepager.components.fields.AmpTextFieldPanel; import org.dgfoundation.amp.onepager.components.fields.LatAndLongValidator; +import org.dgfoundation.amp.onepager.components.upload.FileUploadPanel; import org.dgfoundation.amp.onepager.helper.structure.ColorData; import org.dgfoundation.amp.onepager.helper.structure.CoordinateData; import org.dgfoundation.amp.onepager.helper.structure.MapData; @@ -329,39 +331,18 @@ public void onClick(AjaxRequestTarget target) { addbutton.getButton().add(new AttributeModifier("class", new Model("addStructure button_green_btm"))); add(addbutton); - final ModalWindow uploadModal = new ModalWindow("uploadModal"); + final ModalWindow modalWindow = new ModalWindow("modalWindow"); + add(modalWindow); - final FileUploadField fileUploadField = new FileUploadField("fileUpload"); + // Set the content of the modal window to the FileUploadModalPanel + modalWindow.setContent(new FileUploadModalPanel(modalWindow.getContentId(), modalWindow)); - uploadModal.setContent(new WebMarkupContainer(uploadModal.getContentId()) { - @Override - protected void onInitialize() { - super.onInitialize(); - add(fileUploadField); - add(new Button("uploadButton") { - @Override - public void onSubmit() { - // Handle file upload and reading here - try { - handleFileUpload(fileUploadField.getFileUpload()); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - }); - } - }); - -// Add the modal to the page - add(uploadModal); AmpAjaxLinkField importStructures = new AmpAjaxLinkField("importStructures", "Import Structures", "Import Structures") { @Override public void onClick(AjaxRequestTarget target) { - + modalWindow.show(target); // Show the modal when clicked } }; - - importStructures.getButton().add(new AttributeModifier("class", new Model("importStructures button_red_btm"))); add(importStructures); ExportExcelResourceReference resourceReference = new ExportExcelResourceReference(); CustomResourceLinkResourceLink downloadLink = new CustomResourceLinkResourceLink<>("downloadLink",resourceReference ); From 5e96f3f16e3e03de98c0ebe07a390b5837da06ff Mon Sep 17 00:00:00 2001 From: brianbrix Date: Fri, 4 Oct 2024 10:55:31 +0300 Subject: [PATCH 05/32] Ad import export structures buttons --- .../AmpStructuresFormSectionFeature.html | 7 ++- .../AmpStructuresFormSectionFeature.java | 54 ++++++++++--------- 2 files changed, 34 insertions(+), 27 deletions(-) diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html index 2ebf2bf651d..8d49116fb13 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html +++ b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html @@ -4,8 +4,11 @@ -
- + +
+ + +
Download diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java index 6b154517327..52190c0794a 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java +++ b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java @@ -7,47 +7,32 @@ import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.WorkbookFactory; -import org.apache.poi.xssf.usermodel.XSSFRow; -import org.apache.poi.xssf.usermodel.XSSFSheet; -import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.wicket.AttributeModifier; import org.apache.wicket.Component; import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior; import org.apache.wicket.behavior.AttributeAppender; -import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow; import org.apache.wicket.markup.html.TransparentWebMarkupContainer; -import org.apache.wicket.markup.html.WebMarkupContainer; import org.apache.wicket.markup.html.form.Button; +import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.markup.html.form.TextField; import org.apache.wicket.markup.html.form.upload.FileUpload; import org.apache.wicket.markup.html.form.upload.FileUploadField; -import org.apache.wicket.markup.html.link.ResourceLink; import org.apache.wicket.model.AbstractReadOnlyModel; import org.apache.wicket.model.IModel; import org.apache.wicket.model.Model; import org.apache.wicket.model.PropertyModel; -import org.apache.wicket.request.handler.resource.ResourceStreamRequestHandler; -import org.apache.wicket.request.http.WebResponse; -import org.apache.wicket.request.resource.ContentDisposition; -import org.apache.wicket.request.resource.ResourceReference; -import org.apache.wicket.util.resource.AbstractResourceStreamWriter; -import org.apache.wicket.util.resource.IResourceStream; -import org.apache.wicket.validation.validator.RangeValidator; +import org.apache.wicket.util.lang.Bytes; import org.dgfoundation.amp.onepager.OnePagerUtil; import org.dgfoundation.amp.onepager.components.ListEditorRemoveButton; -import org.dgfoundation.amp.onepager.components.ListItem; import org.dgfoundation.amp.onepager.components.PagingListEditor; import org.dgfoundation.amp.onepager.components.PagingListNavigator; import org.dgfoundation.amp.onepager.components.features.CustomResourceLinkResourceLink; import org.dgfoundation.amp.onepager.components.features.ExportExcelResourceReference; -import org.dgfoundation.amp.onepager.components.features.FileUploadModalPanel; -import org.dgfoundation.amp.onepager.components.features.tables.AmpLocationFormTableFeature; import org.dgfoundation.amp.onepager.components.fields.AmpAjaxLinkField; import org.dgfoundation.amp.onepager.components.fields.AmpTextAreaFieldPanel; import org.dgfoundation.amp.onepager.components.fields.AmpTextFieldPanel; import org.dgfoundation.amp.onepager.components.fields.LatAndLongValidator; -import org.dgfoundation.amp.onepager.components.upload.FileUploadPanel; import org.dgfoundation.amp.onepager.helper.structure.ColorData; import org.dgfoundation.amp.onepager.helper.structure.CoordinateData; import org.dgfoundation.amp.onepager.helper.structure.MapData; @@ -331,19 +316,38 @@ public void onClick(AjaxRequestTarget target) { addbutton.getButton().add(new AttributeModifier("class", new Model("addStructure button_green_btm"))); add(addbutton); - final ModalWindow modalWindow = new ModalWindow("modalWindow"); - add(modalWindow); - // Set the content of the modal window to the FileUploadModalPanel - modalWindow.setContent(new FileUploadModalPanel(modalWindow.getContentId(), modalWindow)); + final FileUploadField fileUploadField = new FileUploadField("fileUpload"); - AmpAjaxLinkField importStructures = new AmpAjaxLinkField("importStructures", "Import Structures", "Import Structures") { + // create the form + final Form form = new Form("form") + { + private static final long serialVersionUID = 1L; @Override - public void onClick(AjaxRequestTarget target) { - modalWindow.show(target); // Show the modal when clicked + protected void onSubmit() + { + // display uploaded info + FileUpload upload = fileUploadField.getFileUpload(); + if (upload == null) + { + logger.info("No file uploaded"); + } + else + { + logger.info("File-Name: " + upload.getClientFileName() + " File-Size: " + + Bytes.bytes(upload.getSize()).toString()); + } } }; - add(importStructures); + form.setMultiPart(true); // Enable file upload + form.setMaxSize(Bytes.megabytes(10)); + form.add(fileUploadField); + + + Button importStructures = new Button("importStructures"); + importStructures.setOutputMarkupId(true); + form.add(importStructures); + add(form); ExportExcelResourceReference resourceReference = new ExportExcelResourceReference(); CustomResourceLinkResourceLink downloadLink = new CustomResourceLinkResourceLink<>("downloadLink",resourceReference ); downloadLink.setOutputMarkupId(true); From 26fd0d7eefa79ac228aa7b69d0a482912c447d82 Mon Sep 17 00:00:00 2001 From: brianbrix Date: Fri, 4 Oct 2024 11:35:35 +0300 Subject: [PATCH 06/32] Ad import export structures buttons --- .../AmpStructuresFormSectionFeature.java | 62 ++++++++++++++++--- 1 file changed, 54 insertions(+), 8 deletions(-) diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java index 52190c0794a..ad5144fd678 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java +++ b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java @@ -5,8 +5,14 @@ package org.dgfoundation.amp.onepager.components.features.sections; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.WorkbookFactory; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.wicket.AttributeModifier; import org.apache.wicket.Component; import org.apache.wicket.ajax.AjaxRequestTarget; @@ -324,20 +330,43 @@ public void onClick(AjaxRequestTarget target) { { private static final long serialVersionUID = 1L; @Override - protected void onSubmit() - { + protected void onSubmit() { // display uploaded info FileUpload upload = fileUploadField.getFileUpload(); - if (upload == null) - { + if (upload == null) { logger.info("No file uploaded"); - } - else - { + } else { logger.info("File-Name: " + upload.getClientFileName() + " File-Size: " + - Bytes.bytes(upload.getSize()).toString()); + Bytes.bytes(upload.getSize())); + try { + XSSFWorkbook workbook = new XSSFWorkbook(upload.getInputStream()); + XSSFSheet sheet = workbook.getSheetAt(0); + Iterator rowIterator = sheet.iterator(); + rowIterator.next(); + + while (rowIterator.hasNext()) { + XSSFRow row = (XSSFRow) rowIterator.next(); + String title = getStringValueFromCell(row.getCell(0)); + String description = getStringValueFromCell(row.getCell(1)); + String latitude = getStringValueFromCell(row.getCell(2)); + String longitude = getStringValueFromCell(row.getCell(3)); + + AmpStructure stru = new AmpStructure(); + stru.setTitle(title); + stru.setDescription(description); + stru.setLatitude(latitude); + stru.setLongitude(longitude); + list.addItem(stru); + list.goToLastPage(); + } + + + } catch (IOException e) { + throw new RuntimeException(e); + } } } + }; form.setMultiPart(true); // Enable file upload form.setMaxSize(Bytes.megabytes(10)); @@ -370,6 +399,23 @@ public void onClick(AjaxRequestTarget target) { } + private static String getStringValueFromCell(Cell cell) { + if (cell == null) { + return null; + } + switch (cell.getCellType()) { + case Cell.CELL_TYPE_STRING: + return cell.getStringCellValue(); + case Cell.CELL_TYPE_NUMERIC: + return String.valueOf(cell.getNumericCellValue()); + case Cell.CELL_TYPE_BOOLEAN: + return String.valueOf(cell.getBooleanCellValue()); + case Cell.CELL_TYPE_FORMULA: + return cell.getCellFormula(); + default: + return null; + } + } public StructureData getDataFromStructureModel(IModel structureModel) { StructureData structureData = new StructureData(); From 8897dda4ace89598d08c05a1d4f78443c5e0536f Mon Sep 17 00:00:00 2001 From: brianbrix Date: Fri, 4 Oct 2024 22:29:16 +0300 Subject: [PATCH 07/32] Ad import export structures buttons --- .../AmpStructuresFormSectionFeature.html | 11 +- .../AmpStructuresFormSectionFeature.java | 109 ++++++++++++++++-- 2 files changed, 105 insertions(+), 15 deletions(-) diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html index 8d49116fb13..0eca8515640 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html +++ b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html @@ -3,21 +3,20 @@ - - +
- +
- + Download - + - + diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java index ad5144fd678..42491e25ef0 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java +++ b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java @@ -18,19 +18,26 @@ import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior; import org.apache.wicket.behavior.AttributeAppender; +import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow; import org.apache.wicket.markup.html.TransparentWebMarkupContainer; import org.apache.wicket.markup.html.form.Button; import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.markup.html.form.TextField; import org.apache.wicket.markup.html.form.upload.FileUpload; import org.apache.wicket.markup.html.form.upload.FileUploadField; +import org.apache.wicket.markup.html.link.ResourceLink; import org.apache.wicket.model.AbstractReadOnlyModel; import org.apache.wicket.model.IModel; import org.apache.wicket.model.Model; import org.apache.wicket.model.PropertyModel; +import org.apache.wicket.request.cycle.RequestCycle; +import org.apache.wicket.request.resource.AbstractResource; +import org.apache.wicket.request.resource.IResource; +import org.apache.wicket.request.resource.ResourceReference; import org.apache.wicket.util.lang.Bytes; import org.dgfoundation.amp.onepager.OnePagerUtil; import org.dgfoundation.amp.onepager.components.ListEditorRemoveButton; +import org.dgfoundation.amp.onepager.components.ListItem; import org.dgfoundation.amp.onepager.components.PagingListEditor; import org.dgfoundation.amp.onepager.components.PagingListNavigator; import org.dgfoundation.amp.onepager.components.features.CustomResourceLinkResourceLink; @@ -51,7 +58,9 @@ import org.digijava.module.categorymanager.util.CategoryConstants; import org.digijava.module.categorymanager.util.CategoryManagerUtil; +import javax.servlet.http.HttpServletResponse; import java.io.*; +import java.time.LocalDateTime; import java.util.*; public class AmpStructuresFormSectionFeature extends @@ -324,14 +333,13 @@ public void onClick(AjaxRequestTarget target) { final FileUploadField fileUploadField = new FileUploadField("fileUpload"); + fileUploadField.setOutputMarkupId(true); - // create the form final Form form = new Form("form") { private static final long serialVersionUID = 1L; @Override protected void onSubmit() { - // display uploaded info FileUpload upload = fileUploadField.getFileUpload(); if (upload == null) { logger.info("No file uploaded"); @@ -368,17 +376,56 @@ protected void onSubmit() { } }; - form.setMultiPart(true); // Enable file upload + form.setMultiPart(true); form.setMaxSize(Bytes.megabytes(10)); form.add(fileUploadField); Button importStructures = new Button("importStructures"); +// importStructures.add(new AttributeModifier("disabled", "true")); importStructures.setOutputMarkupId(true); form.add(importStructures); + fileUploadField.add(new AjaxFormComponentUpdatingBehavior("change") { + private static final long serialVersionUID = 1L; + + @Override + protected void onUpdate(AjaxRequestTarget target) { + importStructures.setEnabled(true); + importStructures.add(new AttributeModifier("disabled", (String) null)); // Enable the button + target.add(importStructures); + + } + }); + add(form); - ExportExcelResourceReference resourceReference = new ExportExcelResourceReference(); - CustomResourceLinkResourceLink downloadLink = new CustomResourceLinkResourceLink<>("downloadLink",resourceReference ); + + + ResourceReference resourceReference = new ResourceReference("exportData-"+ System.currentTimeMillis()) { + @Override + public IResource getResource() { + return new AbstractResource() { + @Override + protected ResourceResponse newResourceResponse(Attributes attributes) { + ResourceResponse response = new ResourceResponse(); + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setFileName("exported-structures-activity-"+am.getObject().getAmpId()+".xlsx"); + response.disableCaching(); + response.setWriteCallback(new WriteCallback() { + @Override + public void writeData(Attributes attributes) { + try (OutputStream out = attributes.getResponse().getOutputStream()) { + writeExcelFile(out, list); + } catch (IOException e) { + logger.error("Error writing data to file", e); + } + } + }); + return response; + } + }; + } + }; + ResourceLink downloadLink = new ResourceLink<>("downloadLink", resourceReference); downloadLink.setOutputMarkupId(true); add(downloadLink); @@ -386,13 +433,12 @@ protected void onSubmit() { @Override public void onClick(AjaxRequestTarget target) { logger.info("Preparing to download data"); - resourceReference.setList(list); - downloadLink.setReference(resourceReference); - // Trigger the non-AJAX file download String downloadLinkMarkupId = downloadLink.getMarkupId(); - target.appendJavaScript("setTimeout(function() { document.getElementById('" + downloadLinkMarkupId + "').click(); }, 100);"); + target.add(list.getParent()); + target.appendJavaScript("document.getElementById('" + downloadLinkMarkupId + "').click();"); } }; + add(exportStructures); exportStructures.getButton().add(new AttributeModifier("class", new Model("exportStructures button_blue_btm"))); add(exportStructures); @@ -417,6 +463,51 @@ private static String getStringValueFromCell(Cell cell) { } } + private void writeExcelFile(OutputStream out,PagingListEditor list) throws IOException { + try(XSSFWorkbook workbook = new XSSFWorkbook()) { + // Create Excel sheet + XSSFSheet sheet = workbook.createSheet("Structures"); + + // Create header row + XSSFRow headerRow = sheet.createRow(0); + headerRow.createCell(0).setCellValue("Title"); + headerRow.createCell(1).setCellValue("Description"); + headerRow.createCell(2).setCellValue("Latitude"); + headerRow.createCell(3).setCellValue("Longitude"); + + int rowIndex = 1; + for (Component child : list) { + if (child instanceof ListItem) { + ListItem listItem = (ListItem) child; + AmpStructure structure = listItem.getModelObject(); + + // Create a new row for each structure + XSSFRow row = sheet.createRow(rowIndex); + if (structure != null) { + createCellIfNotNull(row, 0, structure.getTitle()); + createCellIfNotNull(row, 1, structure.getDescription()); + createCellIfNotNull(row, 2, structure.getLatitude()); + createCellIfNotNull(row, 3, structure.getLongitude()); + } + rowIndex++; + } + } + + // Write workbook content to the output stream + workbook.write(out); + + // Respond with the written content + } catch (IOException e) { + logger.error("Error exporting data to Excel", e); + } + } + + private void createCellIfNotNull(XSSFRow row, int columnIndex, Object value) { + if (value != null) { + row.createCell(columnIndex).setCellValue(value.toString()); + } + } + public StructureData getDataFromStructureModel(IModel structureModel) { StructureData structureData = new StructureData(); AmpStructure structure = structureModel.getObject(); From 35e7f5587f84b0552172a32d87d0491eabe5f67a Mon Sep 17 00:00:00 2001 From: brianbrix Date: Sun, 6 Oct 2024 21:53:57 +0300 Subject: [PATCH 08/32] Add import export structures buttons --- .../features/sections/AmpStructuresFormSectionFeature.html | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html index 0eca8515640..2a722a42aed 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html +++ b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html @@ -1,19 +1,20 @@ - - - +

From d13e4a0142f1b9861dbcb0afa66a2680aea5fb04 Mon Sep 17 00:00:00 2001 From: brianbrix Date: Wed, 6 Nov 2024 14:30:21 +0300 Subject: [PATCH 10/32] GGW-369: Resolve project saving ajax issue --- amp/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/amp/pom.xml b/amp/pom.xml index 2be3156cdb3..8ae0d098824 100644 --- a/amp/pom.xml +++ b/amp/pom.xml @@ -7,7 +7,7 @@ war Aid Management Platform - 6.29.0 + 6.30.0 8.5.73 5.6.11 5.3.28 @@ -1762,4 +1762,4 @@ Development Gateway http://developmentgateway.org - \ No newline at end of file + From e35889cb133591c8b0b5b2b1d65836bdc857d294 Mon Sep 17 00:00:00 2001 From: brianbrix Date: Wed, 6 Nov 2024 14:52:54 +0300 Subject: [PATCH 11/32] GGW-369: Resolve project saving ajax issue --- .../amp/onepager/OnePagerApp.java | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/OnePagerApp.java b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/OnePagerApp.java index 551aa6d1370..9cab82dd787 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/OnePagerApp.java +++ b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/OnePagerApp.java @@ -41,7 +41,7 @@ * @author mihai */ public class OnePagerApp extends AuthenticatedWebApplication { - + public static boolean IS_DEVELOPMENT_MODE = false; private static Logger logger = Logger.getLogger(OnePagerApp.class); @@ -79,19 +79,19 @@ public void init() { //TODO:1.5 //TODO: /* - * - if (true) { + * + if (true) { ResourceMount.mountWicketResources("script", this); ResourceMount mount = new ResourceMount(); //.setResourceVersionProvider(new RevisionVersionProvider()); - - + + LinkedList csslist = new LinkedList(); //csslist.add(new ResourceSpec(YuiLib.class, "calendar/assets/skins/sam/calendar.css")); //csslist.add(new ResourceSpec(new ResourceReference("TEMPLATE/ampTemplate/css_2/amp-wicket.css"))); - - + + LinkedList jslist = new LinkedList(); jslist.add(new ResourceSpec(JQueryBehavior.class, JQueryBehavior.JQUERY_FILE_NAME)); //jslist.add(new ResourceSpec(AutoCompleteBehavior.class, "wicket-autocomplete.js")); @@ -99,8 +99,8 @@ public void init() { jslist.add(new ResourceSpec(IHeaderContributor.class, "wicket-event.js")); jslist.add(new ResourceSpec(AmpSubsectionFeaturePanel.class, "subsectionSlideToggle.js")); jslist.add(new ResourceSpec(AmpStructuresFormSectionFeature.class, "gisPopup.js")); -// jslist.add(new ResourceSpec(YuiLib.class, "yahoo/yahoo-min.js")); -// jslist.add(new ResourceSpec(YuiLib.class, "yahoodomevent/yahoo-dom-event.js")); +// jslist.add(new ResourceSpec(YuiLib.class, "yahoo/yahoo-min.js")); +// jslist.add(new ResourceSpec(YuiLib.class, "yahoodomevent/yahoo-dom-event.js")); // jslist.add(new ResourceSpec(YuiLib.class, "yuiloader.js")); //can't use the min version, because the normal one will be included too // jslist.add(new ResourceSpec(YuiLib.class, "calendar/calendar-min.js")); // jslist.add(new ResourceSpec(DatePicker.class, "wicket-date.js")); @@ -108,12 +108,12 @@ public void init() { jslist.add(new ResourceSpec(AmpAjaxBehavior.class, "translationsOnDocumentReady.js")); jslist.add(new ResourceSpec(AmpActivityFormFeature.class, "previewLogframe.js")); jslist.add(new ResourceSpec(AmpActivityFormFeature.class, "saveNavigationPanel.js")); - + mount.clone() .setPath("/style/all-23.css") .addResourceSpecs(csslist) .mount(this); - + mount.clone() .setPath("/style/all-2.js") .addResourceSpecs(jslist) @@ -221,14 +221,15 @@ protected WebResponse newWebResponse(WebRequest webRequest, HttpServletResponse return new ServletWebResponse((ServletWebRequest) webRequest, httpServletResponse) { @Override public void flush() { + // Add the X-Frame-Options header + getContainerResponse().addHeader("X-Frame-Options", "SAMEORIGIN"); try { getContainerResponse().flushBuffer(); } catch (SocketException e) { logger.warn("Socket exception encountered, ignoring", e); } catch (IOException e) { - // Socket Exception can be wrapped by a container specific exception. - // So we check the cause of the container exception - Throwable rootCause = null != e.getCause() ? e.getCause() : e; + // Check if the root cause is a SocketException + Throwable rootCause = (e.getCause() != null) ? e.getCause() : e; if (rootCause instanceof SocketException) { logger.warn("Socket exception encountered, ignoring.", rootCause); return; From b14ca23c88c3e6fd43687431247e57191468c502 Mon Sep 17 00:00:00 2001 From: brianbrix Date: Wed, 6 Nov 2024 15:07:23 +0300 Subject: [PATCH 12/32] GGW-369: Resolve project saving ajax issue --- .../src/org/dgfoundation/amp/onepager/OnePagerApp.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/OnePagerApp.java b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/OnePagerApp.java index 9cab82dd787..623da7c8065 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/OnePagerApp.java +++ b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/OnePagerApp.java @@ -218,11 +218,14 @@ public void setAuthenticationManager(AuthenticationManager authenticationManager @Override protected WebResponse newWebResponse(WebRequest webRequest, HttpServletResponse httpServletResponse) { + httpServletResponse.addHeader( "X-Frame-Options", "SAMEORIGIN" ); + logger.info("Headers"+ httpServletResponse.getHeaderNames()+httpServletResponse.getHeader("X-Frame-Options")); + return new ServletWebResponse((ServletWebRequest) webRequest, httpServletResponse) { + @Override public void flush() { // Add the X-Frame-Options header - getContainerResponse().addHeader("X-Frame-Options", "SAMEORIGIN"); try { getContainerResponse().flushBuffer(); } catch (SocketException e) { From 23f05c2da1386dce22b8fd19f76e6a200ab3c629 Mon Sep 17 00:00:00 2001 From: brianbrix Date: Wed, 6 Nov 2024 15:23:28 +0300 Subject: [PATCH 13/32] GGW-369: Resolve project saving ajax issue --- .../amp/onepager/OnePagerApp.java | 4 +-- .../amp/onepager/XFrameOptionsFilter.java | 30 +++++++++++++++++++ amp/WEB-INF/web.xml | 8 +++++ 3 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 amp/WEB-INF/src/org/dgfoundation/amp/onepager/XFrameOptionsFilter.java diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/OnePagerApp.java b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/OnePagerApp.java index 623da7c8065..903bff8ed32 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/OnePagerApp.java +++ b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/OnePagerApp.java @@ -73,6 +73,7 @@ public void init() { IS_DEVELOPMENT_MODE = true; } + //getResourceSettings().setStripJavaScriptCommentsAndWhitespace(true); //getResourceSettings().setAddLastModifiedTimeToResourceReferenceUrl(true); //TODO: @@ -218,9 +219,6 @@ public void setAuthenticationManager(AuthenticationManager authenticationManager @Override protected WebResponse newWebResponse(WebRequest webRequest, HttpServletResponse httpServletResponse) { - httpServletResponse.addHeader( "X-Frame-Options", "SAMEORIGIN" ); - logger.info("Headers"+ httpServletResponse.getHeaderNames()+httpServletResponse.getHeader("X-Frame-Options")); - return new ServletWebResponse((ServletWebRequest) webRequest, httpServletResponse) { @Override diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/XFrameOptionsFilter.java b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/XFrameOptionsFilter.java new file mode 100644 index 00000000000..5cf3e84017e --- /dev/null +++ b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/XFrameOptionsFilter.java @@ -0,0 +1,30 @@ +package org.dgfoundation.amp.onepager; + +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +public class XFrameOptionsFilter implements Filter { + @Override + public void init(FilterConfig filterConfig) throws ServletException { + // Initialization code if needed + } + + @Override + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException { + HttpServletResponse httpResponse = (HttpServletResponse) response; + httpResponse.setHeader("X-Frame-Options", "SAMEORIGIN"); // or "SAMEORIGIN" + chain.doFilter(request, response); + } + + @Override + public void destroy() { + // Cleanup code if needed + } +} diff --git a/amp/WEB-INF/web.xml b/amp/WEB-INF/web.xml index 2b6c2ee5a96..726c3d74c18 100644 --- a/amp/WEB-INF/web.xml +++ b/amp/WEB-INF/web.xml @@ -13,6 +13,14 @@ 5 + + XFrameOptionsFilter + org.dgfoundation.amp.onepager.XFrameOptionsFilter + + + XFrameOptionsFilter + /wicket/onepager/* + javamelody net.bull.javamelody.MonitoringFilter From b5c2f772dd72f20d0ea117f0866dabd3e86ed885 Mon Sep 17 00:00:00 2001 From: brianbrix Date: Wed, 6 Nov 2024 15:33:29 +0300 Subject: [PATCH 14/32] GGW-369: Resolve project saving ajax issue --- .../org/dgfoundation/amp/onepager/XFrameOptionsFilter.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/XFrameOptionsFilter.java b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/XFrameOptionsFilter.java index 5cf3e84017e..d8be1a1f19a 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/XFrameOptionsFilter.java +++ b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/XFrameOptionsFilter.java @@ -19,7 +19,10 @@ public void init(FilterConfig filterConfig) throws ServletException { public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletResponse httpResponse = (HttpServletResponse) response; - httpResponse.setHeader("X-Frame-Options", "SAMEORIGIN"); // or "SAMEORIGIN" + httpResponse.setHeader("Access-Control-Allow-Origin", "https://amp-ggw-pr-4349.stg.ampsite.net"); + httpResponse.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); + httpResponse.setHeader("Access-Control-Max-Age", "3600"); + httpResponse.setHeader("Access-Control-Allow-Headers", "x-requested-with"); chain.doFilter(request, response); } From cddc9f2219bae6bd9037aa01ed55831156951283 Mon Sep 17 00:00:00 2001 From: brianbrix Date: Wed, 6 Nov 2024 15:50:07 +0300 Subject: [PATCH 15/32] GGW-369: Resolve project saving ajax issue --- .../src/org/dgfoundation/amp/onepager/XFrameOptionsFilter.java | 1 + amp/WEB-INF/web.xml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/XFrameOptionsFilter.java b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/XFrameOptionsFilter.java index d8be1a1f19a..410e6df2e5a 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/XFrameOptionsFilter.java +++ b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/XFrameOptionsFilter.java @@ -23,6 +23,7 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha httpResponse.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); httpResponse.setHeader("Access-Control-Max-Age", "3600"); httpResponse.setHeader("Access-Control-Allow-Headers", "x-requested-with"); + httpResponse.setHeader("X-Frame-Options", "SAMEORIGIN"); chain.doFilter(request, response); } diff --git a/amp/WEB-INF/web.xml b/amp/WEB-INF/web.xml index 726c3d74c18..dd58e06a66d 100644 --- a/amp/WEB-INF/web.xml +++ b/amp/WEB-INF/web.xml @@ -19,7 +19,7 @@ XFrameOptionsFilter - /wicket/onepager/* + /wicket/* javamelody From a7d570d0e638eb5dcef6d0a7d5802262ac88227f Mon Sep 17 00:00:00 2001 From: brianbrix Date: Wed, 6 Nov 2024 16:39:13 +0300 Subject: [PATCH 16/32] GGW-369: Resolve project saving ajax issue --- .../amp/onepager/XFrameOptionsFilter.java | 5 +- .../features/AmpActivityFormFeature.java | 203 +++++++++--------- amp/WEB-INF/web.xml | 16 +- 3 files changed, 112 insertions(+), 112 deletions(-) diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/XFrameOptionsFilter.java b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/XFrameOptionsFilter.java index 410e6df2e5a..8f4463db1f4 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/XFrameOptionsFilter.java +++ b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/XFrameOptionsFilter.java @@ -19,10 +19,7 @@ public void init(FilterConfig filterConfig) throws ServletException { public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletResponse httpResponse = (HttpServletResponse) response; - httpResponse.setHeader("Access-Control-Allow-Origin", "https://amp-ggw-pr-4349.stg.ampsite.net"); - httpResponse.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); - httpResponse.setHeader("Access-Control-Max-Age", "3600"); - httpResponse.setHeader("Access-Control-Allow-Headers", "x-requested-with"); + httpResponse.setHeader("Access-Control-Allow-Origin", "*"); httpResponse.setHeader("X-Frame-Options", "SAMEORIGIN"); chain.doFilter(request, response); } diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/AmpActivityFormFeature.java b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/AmpActivityFormFeature.java index a8d4a74a264..fb2e50a7600 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/AmpActivityFormFeature.java +++ b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/AmpActivityFormFeature.java @@ -33,6 +33,7 @@ import org.apache.wicket.model.Model; import org.apache.wicket.model.PropertyModel; import org.apache.wicket.request.flow.RedirectToUrlException; +import org.apache.wicket.request.http.WebResponse; import org.apache.wicket.request.mapper.parameter.PageParameters; import org.apache.wicket.request.resource.PackageResourceReference; import org.apache.wicket.util.time.Duration; @@ -94,7 +95,7 @@ * @since Jun 7, 2011 */ public class AmpActivityFormFeature extends AmpFeaturePanel { - + private static final long serialVersionUID = 1L; protected Form activityForm; private static final Integer GO_TO_DESKTOP=1; @@ -116,13 +117,13 @@ public ListView getFeatureList() { TranslatorUtil.getTranslatedText("The sum of disbursements is greater than the sum of commitments"); private static final String EXPENDITURES_BIGGER_ERROR = TranslatorUtil.getTranslatedText("The sum of expenditures is greater than the sum of disbursements"); - + /** - * Toggles the validation of semantic validators. + * Toggles the validation of semantic validators. * @param enabled whether these validators are enabled * @param form the form to set the validators - * @param target + * @param target * @see AmpSemanticValidatorField * @see AmpSemanticValidator */ @@ -143,7 +144,7 @@ public void component(AmpPercentageTextField ifs, //target.add(ifs); } }); - + // visit all the semantic validator fields and enable/disable them form.visitChildren(AmpSemanticValidatorField.class, new IVisitor, Void>() { @@ -167,8 +168,8 @@ public void component(AmpSemanticValidatorField ifs, public void component( AmpIdentificationFormSectionFeature ifs, IVisit visit) { - toggleFormComponent (enabled,target,ifs,visit); - toggleFormRichTextComponent(enabled,target, ifs,visit); + toggleFormComponent (enabled,target,ifs,visit); + toggleFormRichTextComponent(enabled,target, ifs,visit); } }); @@ -200,16 +201,16 @@ public void component( IVisit visit) { /* Validator for date will make the date field mandatory only when there is an amount entered * in proposed project code field AMP-17234 - * Review to make is more readable + * Review to make is more readable */ AmpDatePickerFieldPanel proposedDate= null; - + //if it is saving as draft, disable required validator for proposed date if (!enabled) { proposedDate = (AmpDatePickerFieldPanel) component.get("funDate"); } //if proposed amount is not entered then, disable required validator for proposed Date - else if(component.getParent().getParent().getId().equalsIgnoreCase("funDate") && + else if(component.getParent().getParent().getId().equalsIgnoreCase("funDate") && component.getParent().getParent().getParent().get("amount").getDefaultModel().getObject()==null){ proposedDate = (AmpDatePickerFieldPanel)component.getParent().getParent(); } @@ -218,11 +219,11 @@ else if(component.getParent().getParent().getId().equalsIgnoreCase("funDate") && String js = String.format("$('#%s').change();",proposedDate.getDate().getMarkupId()); target.appendJavaScript(js); } - + } }); - - + + } private void toggleFormComponent( @@ -244,7 +245,7 @@ private void toggleFormComponent (boolean enabled, final AjaxRequestTarget targe AmpRequiredComponentContainer ifs, IVisit visit) { toggleFormComponent(enabled, target, ifs, visit, true); } - + private void toggleFormComponent (boolean enabled, final AjaxRequestTarget target, AmpRequiredComponentContainer ifs, IVisit visit, boolean stopVisit) { List > requiredComponents = ifs.getRequiredFormComponents(); @@ -267,41 +268,41 @@ private void toggleFormComponent (boolean enabled, final AjaxRequestTarget targe * @param id * @param am * @param fmName - * @param newActivity - * @param listModel + * @param newActivity + * @param listModel * @throws Exception */ public AmpActivityFormFeature(String id, final IModel am, String fmName, final boolean newActivity, AbstractReadOnlyModel> listModel) throws Exception { super(id, am, fmName, true); - + this.enabledFmButton.setVisible(false); this.visibleFmButton.setVisible(false); this.ignoreFmVisibility = true; this.ignoreFmButtonsVisibility = true; this.setVisible(true); - - activityForm=new Form("activityForm") { + + activityForm=new Form("activityForm") { @Override protected void onError() { super.onError(); } }; activityForm.setOutputMarkupId(true); - + String actNameStr = am.getObject().getName(); if (actNameStr != null && !actNameStr.trim().isEmpty()) { actNameStr = "(" + actNameStr + ")"; } Label activityName = new Label("activityName", actNameStr); add(activityName); - + final FeedbackPanel feedbackPanel = new FeedbackPanel("feedbackPanel"); feedbackPanel.setOutputMarkupPlaceholderTag(true); feedbackPanel.setOutputMarkupId(true); //this will be use to decorate all submit buttons AttributePrepender isSubmit = new AttributePrepender("data-is_submit", new Model("true"), ""); - + //do not show errors in this feedbacklabel (they will be shown for each component) int[] filteredErrorLevels = new int[]{FeedbackMessage.ERROR}; feedbackPanel.setFilter(new ErrorLevelsFeedbackMessageFilter(filteredErrorLevels)); @@ -382,8 +383,8 @@ public void onClick(AjaxRequestTarget target) { //add ajax submit button final AmpButtonField saveAndSubmit = new AmpButtonField("saveAndSubmit","Save and Submit", AmpFMTypes.MODULE, true) { - - + + @Override protected void onSubmit(final AjaxRequestTarget target, Form form) { processAndUpdateForm(true, am, form, target, this.getButton()); @@ -435,7 +436,7 @@ protected void onSubmit(final AjaxRequestTarget target, Form form) { //we only remove disable on buttons tagged as submit ones //target.appendJavaScript("enableButtons2();"); } - + @Override protected void onError(final AjaxRequestTarget target, Form form) { @@ -451,18 +452,18 @@ protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { generateEnableButtonsOnError(attributes); } }; - - - + + + AttributePrepender updateEditors = new AttributePrepender("onclick", new Model("window.onbeforeunload = null; for (instance in CKEDITOR.instances) CKEDITOR.instances[instance].updateElement();disableButton();"), ""); saveAndSubmit.getButton().add(isSubmit); - + AttributePrepender closeEditors = new AttributePrepender("onclick", new Model("$('a[data-is_close=true]:visible').click();"), ""); AttributePrepender clickMonEval = new AttributePrepender("onclick", new Model("$('.mon_eval_button:visible').click();"), ""); AttributePrepender closeDialogs = new AttributePrepender("onclick", new Model( "$('.ui-dialog-content').dialog('close');"), ""); - + saveAndSubmit.getButton().add(new AttributeModifier("class", new Model("sideMenuButtons"))); saveAndSubmit.getButton().add(updateEditors); saveAndSubmit.getButton().add(closeEditors); @@ -471,16 +472,16 @@ protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { saveAndSubmit.getButton().setDefaultFormProcessing(false); saveAndSubmit.setAffectedByFreezing(false); activityForm.add(saveAndSubmit); - + AmpAjaxLinkField rejectActivityLink = new AmpAjaxLinkField("saveReject", "Reject Activity", "Reject activity") { @Override protected void onClick(AjaxRequestTarget target) { } - + @Override protected void onBeforeRender() { super.onBeforeRender(); - + AmpAuthWebSession wicketSession = (AmpAuthWebSession) org.apache.wicket.Session.get(); AmpTeamMember ampCurrentMember = wicketSession.getAmpCurrentMember(); this.setVisible(ActivityUtil.canReject(ampCurrentMember, am.getObject().getDraft(), newActivity)); @@ -495,15 +496,17 @@ protected void onBeforeRender() { rejectActivityLink.getButton().add(new AttributeModifier("class", new Model<>("sideMenuButtons rejectButton"))); activityForm.add(rejectActivityLink); - + AmpAjaxLinkField saveAsDraft = new AmpAjaxLinkField("saveAsDraft", "Save as Draft", "Save as Draft") { @Override protected void onClick(AjaxRequestTarget target) { + WebResponse response = (WebResponse)getRequestCycle().getResponse(); + response.setHeader("Access-Control-Allow-Origin", "*"); } }; - + saveAsDraft.getButton().add(isSubmit); - + // saveAsDraft.getButton().add(new AttributeModifier("onclick", "showDraftPanel();disableButton();")); saveAsDraft.getButton().add(new AttributePrepender("onclick", new Model("showDraftPanel();disableButton();"), "")); saveAsDraft.getButton().add(closeEditors); @@ -523,7 +526,7 @@ public void renderHead(Component component, IHeaderResponse response) { response.render(JavaScriptHeaderItem.forReference(new PackageResourceReference(AmpActivityFormFeature.class, "enableDisableButtons.js"))); } }); - + final RadioGroup myDraftOpts = new RadioGroup("draftRedirectedGroup", new Model(GO_TO_DESKTOP)); Radio radioDesktop=new Radio("draftRedirectedDesktop", new Model(GO_TO_DESKTOP)); @@ -551,12 +554,12 @@ protected void onEvent(final AjaxRequestTarget target) { myDraftOpts.add(radioStay); activityForm.add(myDraftOpts); - + final AmpAjaxLinkField cancelLink = new AmpAjaxLinkField("saveAsDraftCanceld", "Cancel", "Cancel") { @Override protected void onClick(AjaxRequestTarget target) { // TODO Auto-generated method stub - + } }; cancelLink.getButton().add(new AttributeModifier("onclick", "hideDraftPanel();enableButtons2();")); @@ -573,7 +576,7 @@ protected void onSubmit(AjaxRequestTarget target, Form form) { onSaveAsDraft(am, feedbackPanel, redirected, new ActionButtonCancelLink(this, cancelLink), target, form); } - + @Override protected void onError(final AjaxRequestTarget target, Form form) { super.onError(target, form); @@ -596,13 +599,13 @@ protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { saveAsDraftAction.add(isSubmit); saveAsDraftAction.setAffectedByFreezing(false); activityForm.add(saveAsDraftAction); - + //text area for the message AmpTextAreaFieldPanel rejectMessage = new AmpTextAreaFieldPanel("rejectMessage", new PropertyModel(am,"rejectMessage"), "Reject Message", false); activityForm.add(rejectMessage); //buttons for the reject activity panel //cancelrejectActivity - + AmpAjaxLinkField cancelRejectActivity=new AmpAjaxLinkField("cancelRejectActivity", "Cancel Reject activity", "Cancel") { @Override protected void onClick(AjaxRequestTarget target) { @@ -614,8 +617,8 @@ protected void onClick(AjaxRequestTarget target) { cancelRejectActivity.setVisible(true); cancelRejectActivity.getButton().add(new AttributeModifier("class", new Model("sideMenuButtons"))); activityForm.add(cancelRejectActivity); - - + + AmpButtonField rejectActivityAction = new AmpButtonField("rejectActivityAction", "Reject Activity", AmpFMTypes.MODULE, true) { @Override protected void onSubmit(AjaxRequestTarget target, Form form) { @@ -627,7 +630,7 @@ protected void onError(final AjaxRequestTarget target, Form form) { super.onError(target, form); onErrorSaveAsDraftOrReject(feedbackPanel, target, form); } - + @Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { generateEnableButtonsOnError(attributes); @@ -639,13 +642,13 @@ protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { rejectActivityAction.getButton().add(new AttributePrepender("onclick", new Model("disableButton();"), "")); rejectActivityAction.getButton().add(updateEditors); rejectActivityAction.add(isSubmit); - activityForm.add(rejectActivityAction); - - - - - - + activityForm.add(rejectActivityAction); + + + + + + // this div will be "submitted" by the autoSaveTimer final WebMarkupContainer autoSaveDiv = new WebMarkupContainer( "autoSaveDiv"); @@ -663,8 +666,8 @@ protected void onSubmit(AjaxRequestTarget target) { op.getEditLockRefresher().setEnabled(false); if (op.getTimer() != null) { op.getTimer().stop(target); - } - + } + am.setObject(am.getObject()); toggleSemanticValidation(false, activityForm, target); // process the form for this request @@ -686,7 +689,7 @@ protected void onSubmit(AjaxRequestTarget target) { autoSaveTimer.restart(target); } } - + } @@ -703,7 +706,7 @@ public boolean getDefaultProcessing() { // will fire int autoSaveSeconds = Integer.parseInt(FeaturesUtil .getGlobalSettingValue(GlobalSettingsConstants.ACTIVITY_AUTO_SAVE_SECONDS)); - + autoSaveTimer = null; if (autoSaveSeconds != 0) { autoSaveTimer = new AbstractAjaxTimerBehavior( @@ -716,8 +719,8 @@ protected void onTimer(AjaxRequestTarget target) { op.getEditLockRefresher().setEnabled(false); if (op.getTimer() != null) { op.getTimer().stop(target); - } - //we disable the stop timer so it doesn't get called after its being processed + } + //we disable the stop timer so it doesn't get called after its being processed this.stop(target); target.appendJavaScript(String.format("$('#%s').click()", autoSaveDiv.getMarkupId())); @@ -748,7 +751,7 @@ protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { logframe.getButton().add(new AttributeModifier("class", true, new Model("sideMenuButtons"))); */ //activityForm.add(logframe); - + AmpButtonField preview = new AmpButtonField("preview", "Preview", AmpFMTypes.MODULE, true) { @Override protected void onSubmit(AjaxRequestTarget target, Form form) { @@ -762,7 +765,7 @@ protected void onSubmit(AjaxRequestTarget target, Form form) { + am.getObject().getAmpActivityId() + "~isPreview=1\");"); } } - + @Override protected void onError(AjaxRequestTarget target, Form form) { super.onError(target, form); @@ -784,7 +787,7 @@ protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { preview.getButton().add(isSubmit); preview.setAffectedByFreezing(false); activityForm.add(preview); - + featureList = new ListView("featureList", listModel) { private static final long serialVersionUID = 7218457979728871528L; @Override @@ -796,7 +799,7 @@ protected void populateItem(final ListItem item) { tmp.add(new AttributeModifier("style", "font-size: medium; font-style: bold; color: red; margin: 15px;")); item.add(tmp); } - + String activityFormOnePager = FeaturesUtil.getGlobalSettingValue( GlobalSettingsConstants.ACTIVITY_FORM_ONE_PAGER); if ("false".equals(activityFormOnePager)){ @@ -804,7 +807,7 @@ protected void populateItem(final ListItem item) { item.add(new AttributeModifier("style", "display: none;")); } } - + } }; featureList.setReuseItems(true); @@ -828,7 +831,7 @@ private void processAndUpdateForm(boolean notDraft, IModel a toggleSemanticValidation(notDraft, form, target); form.process(button); - + form.visitChildren(AmpAgreementItemPanel.class,new IVisitor() { @Override @@ -837,7 +840,7 @@ public void component(AmpAgreementItemPanel object, object.validateIsNewAgreementFormClosed(target); visit.dontGoDeeper(); } - + }); form.visitChildren(AbstractTextComponent.class, @@ -846,7 +849,7 @@ public void component(AmpAgreementItemPanel object, public void component(Component component, IVisit objectIVisit) { IModel model = component.getDefaultModel(); AbstractTextComponent atc = (AbstractTextComponent) component; - //logger.error(component.getParent().getId()); + //logger.error(component.getParent().getId()); boolean required = false; List validators = atc.getValidators(); for (IValidator validator : validators) { @@ -1026,7 +1029,7 @@ private double sumUp(Collection collection, int transactionType, Object parent){ return total; } - + protected void formSubmitErrorHandle(Form form, final AjaxRequestTarget target, FeedbackPanel feedbackPanel) { //once an error has happened if in tabsview we process the funding section to //highlight the tabs with errors @@ -1034,8 +1037,8 @@ protected void formSubmitErrorHandle(Form form, final AjaxRequestTarget targe showFundingTabsErrors(form, target); } // visit form children and add to the ajax request the invalid ones - - + + form.visitChildren(FormComponent.class, new IVisitor() { @Override public void component(FormComponent component, IVisit visit) { @@ -1092,7 +1095,7 @@ public void component(FormComponent component, IVisit visit) { protected void saveMethod(AjaxRequestTarget target, IModel am, FeedbackPanel feedbackPanel, boolean draft, Model redirected,boolean rejected) { - + AmpActivityModel a = (AmpActivityModel) am; AmpActivityVersion activity = am.getObject(); Long oldId = activity.getAmpActivityId(); @@ -1101,7 +1104,7 @@ protected void saveMethod(AjaxRequestTarget target, AmpAuthWebSession wicketSession = (AmpAuthWebSession)org.apache.wicket.Session.get(); long currentUserId = wicketSession.getCurrentMember().getMemberId(); activity.setChangeType(ChangeType.MANUAL.toString()); - + AmpTeamMember ampCurrentMember = wicketSession.getAmpCurrentMember(); @@ -1110,13 +1113,13 @@ protected void saveMethod(AjaxRequestTarget target, //Someone else has grabbed the lock ... maybe connection slow and lock refresh timed out throw new RedirectToUrlException(ActivityGatekeeper.buildRedirectLink(String.valueOf(a.getId()), currentUserId)); } - + ActivityUtil.saveActivity((AmpActivityModel) am, draft, rejected); info(TranslatorUtil.getTranslatedText("Activity saved successfully")); /* - * if activity created or created as draft + * if activity created or created as draft * and then saved the message should be sent to the list */ AmpActivityVersion newActivity=am.getObject(); @@ -1127,7 +1130,7 @@ protected void saveMethod(AjaxRequestTarget target, //if validation is off in team setup no messages should be generated String validation = DbUtil.getValidationFromTeamAppSettings(ampCurrentMember.getAmpTeam().getAmpTeamId()); - + if (activity.getDraft() != null && !activity.getDraft() && !(Constants.PROJECT_VALIDATION_OFF.equals(validation))) { if (ActivityUtil.isApproved(newActivity)) { @@ -1161,7 +1164,7 @@ protected void saveMethod(AjaxRequestTarget target, } p.set(1,actId); - //The folllogin exception will provide a redirection + //The folllogin exception will provide a redirection throw new RestartResponseException( new PageProvider( OnePager.class,p),RedirectPolicy.ALWAYS_REDIRECT); @@ -1213,29 +1216,29 @@ public CharSequence getFailureHandler(Component component) { }; attributes.getAjaxCallListeners().add(listener); } - + protected void onSaveAsDraft(final IModel am, final FeedbackPanel feedbackPanel, final Model redirected, final ActionButtonCancelLink actionButtonCancelLink, AjaxRequestTarget target, Form form) { - + target.appendJavaScript("hideDraftPanel();"); - + onSaveAsDraftOrReject(am, feedbackPanel, redirected, actionButtonCancelLink, target, form, false); } - + protected void onReject(final IModel am, final FeedbackPanel feedbackPanel, final Model redirected, final ActionButtonCancelLink actionButtonCancelLink, AjaxRequestTarget target, Form form) { - + target.appendJavaScript("hideRejectActivityPanel();"); - + onSaveAsDraftOrReject(am, feedbackPanel, redirected, actionButtonCancelLink, target, form, true); } - + /** * Method used from saveAsDraft and Reject activity(the only difference between them is that reject prior to saving * the activity changes the status of the activity and sends the messages if the user has chosen to - * + * * @param am * @param feedbackPanel * @param redirected @@ -1247,10 +1250,10 @@ protected void onSaveAsDraftOrReject(final IModel am, final final Model redirected, final ActionButtonCancelLink actionButtonCancelLink, AjaxRequestTarget target, Form form, boolean isRejected) { - + final AmpButtonField actionButton = actionButtonCancelLink.getActionButton(); final AmpAjaxLinkField cancelAction = actionButtonCancelLink.getCancelActionLink(); - + processAndUpdateForm(false, am, form, target, actionButton.getButton()); // only in the eventuality that the title field is valid (is not empty) we proceed with the real save! @@ -1261,12 +1264,12 @@ protected void onSaveAsDraftOrReject(final IModel am, final if (op.getTimer() != null) { op.getTimer().restart(target); } - + target.add(actionButton); target.add(cancelAction); - + onErrorSaveAsDraftOrReject(feedbackPanel, target, form); - + if (autoSaveTimer != null && autoSaveTimer.isStopped()) { autoSaveTimer.restart(target); } @@ -1274,12 +1277,12 @@ protected void onSaveAsDraftOrReject(final IModel am, final //if no error happend and we are rejecting we change the approval status to rejected // send a message to the creator of the activity saveMethod(target, am, feedbackPanel, true, redirected, isRejected); - + if (isRejected) { sendRejectMessage(am); } } - + target.appendJavaScript("enableButtons2();"); } @@ -1292,10 +1295,10 @@ private void sendRejectMessage(IModel activityModel) { AmpActivityVersion activity = activityModel.getObject(); String messageToSend = activity.getRejectMessage(); AmpTeamMember tmTo = activity.getActivityCreator(); - + AmpAuthWebSession wicketSession = (AmpAuthWebSession) org.apache.wicket.Session.get(); TeamMember tmFrom = wicketSession.getCurrentMember(); - + AmpMessage message = new AmpAlert(); String senderName; Long activityId; @@ -1305,24 +1308,24 @@ private void sendRejectMessage(IModel activityModel) { message.setName(TranslatorWorker.translateText("Activity Rejected")); message.setSenderType(MessageConstants.SENDER_TYPE_USER); message.setSenderId(tmFrom.getMemberId()); - + senderName = user.getFirstNames() + " " + user.getLastName() + "<" + user.getEmailUsedForNotification() + ">;" + tmFrom.getTeamName(); message.setSenderName(senderName); - + message.setRelatedActivityId(activityId); - + /*String fullModuleURL=RequestUtils.getFullModuleUrl(request);*/ String objUrl = "/aim/viewActivityPreview.do~activityId=" + activityId; message.setObjectURL(objUrl); - - + + message.setPriorityLevel(MessageConstants.PRIORITY_LEVEL_CRITICAL); if(messageToSend==null){ messageToSend=""; } message.setDescription(messageToSend); - + message.setCreationDate(new Date(System.currentTimeMillis())); message.setDraft(false); @@ -1332,7 +1335,7 @@ private void sendRejectMessage(IModel activityModel) { AmpMessageState state = new AmpMessageState(); state.setMessage(message); state.setSender(tmFrom.getMemberName() + ";" + tmFrom.getTeamName()); - + try { AmpMessageUtil.saveOrUpdateMessageState(state); AmpMessageUtil.createMessageState(message, tmTo); @@ -1340,7 +1343,7 @@ private void sendRejectMessage(IModel activityModel) { logger.error("Cannot create reject message", e); throw new RuntimeException(e); } - + message.addMessageReceiver(tmTo); AmpMessageUtil.saveOrUpdateMessage(message); diff --git a/amp/WEB-INF/web.xml b/amp/WEB-INF/web.xml index dd58e06a66d..10e20d1d745 100644 --- a/amp/WEB-INF/web.xml +++ b/amp/WEB-INF/web.xml @@ -13,14 +13,14 @@ 5 - - XFrameOptionsFilter - org.dgfoundation.amp.onepager.XFrameOptionsFilter - - - XFrameOptionsFilter - /wicket/* - + + + + + + + + javamelody net.bull.javamelody.MonitoringFilter From 64710e5f1cede1591b67e4daf53bc80bf168e34f Mon Sep 17 00:00:00 2001 From: brianbrix Date: Wed, 6 Nov 2024 19:40:49 +0300 Subject: [PATCH 17/32] GGW-369: Resolve project saving ajax issue --- .../AmpStructuresFormSectionFeature.html | 29 ++- .../AmpStructuresFormSectionFeature.java | 186 ++++++++++++------ 2 files changed, 155 insertions(+), 60 deletions(-) diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html index 942cb988eb6..9e2b3d18217 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html +++ b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html @@ -4,10 +4,31 @@ - From 26c05baec67ea1f42a2686de164f4aa7fc644b91 Mon Sep 17 00:00:00 2001 From: brianbrix Date: Thu, 7 Nov 2024 22:31:03 +0300 Subject: [PATCH 25/32] GGW-369: Structures section styling --- .../AmpStructuresFormSectionFeature.html | 12 +-- .../AmpStructuresFormSectionFeature.java | 81 +------------------ 2 files changed, 8 insertions(+), 85 deletions(-) diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html index a0921941d2a..f5e6ca9f966 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html +++ b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html @@ -7,23 +7,23 @@
+ +
+ Download
From 0c38bc1cc9ca6fc2ad09265fe1fe45e37f4637cd Mon Sep 17 00:00:00 2001 From: brianbrix Date: Tue, 8 Oct 2024 06:23:16 +0300 Subject: [PATCH 09/32] Import button color --- .../features/sections/AmpStructuresFormSectionFeature.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html index 2a722a42aed..942cb988eb6 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html +++ b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html @@ -6,12 +6,12 @@
- +
Download - +
-
- - -
+ + + + +
+
+ + + + + + + + +
+
+ +
+
+
+ +
+
+
+
Download diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java index 42491e25ef0..c706fb016ec 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java +++ b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java @@ -20,6 +20,7 @@ import org.apache.wicket.behavior.AttributeAppender; import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow; import org.apache.wicket.markup.html.TransparentWebMarkupContainer; +import org.apache.wicket.markup.html.WebMarkupContainer; import org.apache.wicket.markup.html.form.Button; import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.markup.html.form.TextField; @@ -35,6 +36,8 @@ import org.apache.wicket.request.resource.IResource; import org.apache.wicket.request.resource.ResourceReference; import org.apache.wicket.util.lang.Bytes; +import org.apache.wicket.util.upload.FileItem; +import org.dgfoundation.amp.onepager.OnePagerConst; import org.dgfoundation.amp.onepager.OnePagerUtil; import org.dgfoundation.amp.onepager.components.ListEditorRemoveButton; import org.dgfoundation.amp.onepager.components.ListItem; @@ -42,10 +45,9 @@ import org.dgfoundation.amp.onepager.components.PagingListNavigator; import org.dgfoundation.amp.onepager.components.features.CustomResourceLinkResourceLink; import org.dgfoundation.amp.onepager.components.features.ExportExcelResourceReference; -import org.dgfoundation.amp.onepager.components.fields.AmpAjaxLinkField; -import org.dgfoundation.amp.onepager.components.fields.AmpTextAreaFieldPanel; -import org.dgfoundation.amp.onepager.components.fields.AmpTextFieldPanel; -import org.dgfoundation.amp.onepager.components.fields.LatAndLongValidator; +import org.dgfoundation.amp.onepager.components.fields.*; +import org.dgfoundation.amp.onepager.components.upload.FileUploadPanel; +import org.dgfoundation.amp.onepager.helper.TemporaryActivityDocument; import org.dgfoundation.amp.onepager.helper.structure.ColorData; import org.dgfoundation.amp.onepager.helper.structure.CoordinateData; import org.dgfoundation.amp.onepager.helper.structure.MapData; @@ -57,6 +59,7 @@ import org.digijava.module.categorymanager.dbentity.AmpCategoryValue; import org.digijava.module.categorymanager.util.CategoryConstants; import org.digijava.module.categorymanager.util.CategoryManagerUtil; +import org.digijava.module.contentrepository.util.DocumentManagerUtil; import javax.servlet.http.HttpServletResponse; import java.io.*; @@ -332,74 +335,145 @@ public void onClick(AjaxRequestTarget target) { add(addbutton); - final FileUploadField fileUploadField = new FileUploadField("fileUpload"); - fileUploadField.setOutputMarkupId(true); +// final FileUploadField fileUploadField = new FileUploadField("fileUpload"); +// fileUploadField.setOutputMarkupId(true); +// +// final Form form = new Form("form") +// { +// private static final long serialVersionUID = 1L; +// @Override +// protected void onSubmit() { +// FileUpload upload = fileUploadField.getFileUpload(); +// if (upload == null) { +// logger.info("No file uploaded"); +// } else { +// logger.info("File-Name: " + upload.getClientFileName() + " File-Size: " + +// Bytes.bytes(upload.getSize())); +// try { +// XSSFWorkbook workbook = new XSSFWorkbook(upload.getInputStream()); +// XSSFSheet sheet = workbook.getSheetAt(0); +// Iterator rowIterator = sheet.iterator(); +// rowIterator.next(); +// +// while (rowIterator.hasNext()) { +// XSSFRow row = (XSSFRow) rowIterator.next(); +// String title = getStringValueFromCell(row.getCell(0)); +// String description = getStringValueFromCell(row.getCell(1)); +// String latitude = getStringValueFromCell(row.getCell(2)); +// String longitude = getStringValueFromCell(row.getCell(3)); +// +// AmpStructure stru = new AmpStructure(); +// stru.setTitle(title); +// stru.setDescription(description); +// stru.setLatitude(latitude); +// stru.setLongitude(longitude); +// list.addItem(stru); +// list.goToLastPage(); +// } +// +// +// } catch (IOException e) { +// throw new RuntimeException(e); +// } +// } +// } +// +// }; +// form.setMultiPart(true); +// form.setMaxSize(Bytes.megabytes(10)); +// form.add(fileUploadField); +// +// +// Button importStructures = new Button("importStructures"); +//// importStructures.add(new AttributeModifier("disabled", "true")); +// importStructures.setOutputMarkupId(true); +// form.add(importStructures); +// fileUploadField.add(new AjaxFormComponentUpdatingBehavior("change") { +// private static final long serialVersionUID = 1L; +// +// @Override +// protected void onUpdate(AjaxRequestTarget target) { +// importStructures.setEnabled(true); +// importStructures.add(new AttributeModifier("disabled", (String) null)); // Enable the button +// target.add(importStructures); +// +// } +// }); +// +// add(form); + + final Model fileItemModel = new Model(); + FileUploadPanel fileUpload = new FileUploadPanel("file",String.valueOf(am.getObject().getAmpActivityId()), fileItemModel); + final Form form = new Form("form") { + - final Form form = new Form("form") - { - private static final long serialVersionUID = 1L; @Override protected void onSubmit() { - FileUpload upload = fileUploadField.getFileUpload(); - if (upload == null) { - logger.info("No file uploaded"); - } else { - logger.info("File-Name: " + upload.getClientFileName() + " File-Size: " + - Bytes.bytes(upload.getSize())); - try { - XSSFWorkbook workbook = new XSSFWorkbook(upload.getInputStream()); - XSSFSheet sheet = workbook.getSheetAt(0); - Iterator rowIterator = sheet.iterator(); - rowIterator.next(); - - while (rowIterator.hasNext()) { - XSSFRow row = (XSSFRow) rowIterator.next(); - String title = getStringValueFromCell(row.getCell(0)); - String description = getStringValueFromCell(row.getCell(1)); - String latitude = getStringValueFromCell(row.getCell(2)); - String longitude = getStringValueFromCell(row.getCell(3)); - - AmpStructure stru = new AmpStructure(); - stru.setTitle(title); - stru.setDescription(description); - stru.setLatitude(latitude); - stru.setLongitude(longitude); - list.addItem(stru); - list.goToLastPage(); + if (fileItemModel.getObject() != null) { + FileUpload upload = new FileUpload(fileItemModel.getObject()); + if (upload == null) { + logger.info("No file uploaded"); + } else { + logger.info("File-Name: " + upload.getClientFileName() + " File-Size: " + + Bytes.bytes(upload.getSize())); + try { + XSSFWorkbook workbook = new XSSFWorkbook(upload.getInputStream()); + XSSFSheet sheet = workbook.getSheetAt(0); + Iterator rowIterator = sheet.iterator(); + rowIterator.next(); + + while (rowIterator.hasNext()) { + XSSFRow row = (XSSFRow) rowIterator.next(); + String title = getStringValueFromCell(row.getCell(0)); + String description = getStringValueFromCell(row.getCell(1)); + String latitude = getStringValueFromCell(row.getCell(2)); + String longitude = getStringValueFromCell(row.getCell(3)); + + AmpStructure stru = new AmpStructure(); + stru.setTitle(title); + stru.setDescription(description); + stru.setLatitude(latitude); + stru.setLongitude(longitude); + list.addItem(stru); + list.goToLastPage(); + fileItemModel.setObject(null); + } + } catch (Exception e) { + logger.error("Error reading excel file", e); } - - - } catch (IOException e) { - throw new RuntimeException(e); } } - } + } }; - form.setMultiPart(true); - form.setMaxSize(Bytes.megabytes(10)); - form.add(fileUploadField); - Button importStructures = new Button("importStructures"); -// importStructures.add(new AttributeModifier("disabled", "true")); - importStructures.setOutputMarkupId(true); - form.add(importStructures); - fileUploadField.add(new AjaxFormComponentUpdatingBehavior("change") { - private static final long serialVersionUID = 1L; + WebMarkupContainer rc = new WebMarkupContainer("resourcePanel"); +// rc.add(new AttributeModifier("id", getToggleId())); + rc.add(form); +// rc.add(name); + rc.add(fileUpload); + rc.setOutputMarkupId(true); + add(rc); + + form.add(fileUpload); + + // create the ajax button used to submit the form + org.dgfoundation.amp.onepager.components.fields.AmpButtonField submit = new AmpButtonField("ajaxSubmit", "Add", true){ @Override - protected void onUpdate(AjaxRequestTarget target) { - importStructures.setEnabled(true); - importStructures.add(new AttributeModifier("disabled", (String) null)); // Enable the button - target.add(importStructures); + protected void onSubmit(AjaxRequestTarget target, Form form) { + logger.info("Submitting form"); +// if (fileItemModel.getObject() != null) +// tmp.setFile(new FileUpload(fileItemModel.getObject())); + target.add(list); - } - }); - add(form); + } + }; + form.add(submit); ResourceReference resourceReference = new ResourceReference("exportData-"+ System.currentTimeMillis()) { @Override public IResource getResource() { From 4efac492b0a614304ac20435463f40ecfa655c84 Mon Sep 17 00:00:00 2001 From: brianbrix Date: Wed, 6 Nov 2024 19:51:28 +0300 Subject: [PATCH 18/32] GGW-369: Resolve project saving ajax issue --- .../features/sections/AmpStructuresFormSectionFeature.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html index 9e2b3d18217..329fd98a05d 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html +++ b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html @@ -8,7 +8,7 @@ -
+
From ac17a61c73b4a7b5bc7b3ba644e9eae9f624bd3f Mon Sep 17 00:00:00 2001 From: brianbrix Date: Wed, 6 Nov 2024 20:05:03 +0300 Subject: [PATCH 19/32] GGW-369: Resolve project saving ajax issue --- .../features/sections/AmpStructuresFormSectionFeature.html | 2 +- .../features/sections/AmpStructuresFormSectionFeature.java | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html index 329fd98a05d..135bfeb6930 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html +++ b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html @@ -21,7 +21,7 @@ diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java index c706fb016ec..15d948888fc 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java +++ b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java @@ -460,12 +460,10 @@ protected void onSubmit() { form.add(fileUpload); // create the ajax button used to submit the form - org.dgfoundation.amp.onepager.components.fields.AmpButtonField submit = new AmpButtonField("ajaxSubmit", "Add", true){ + org.dgfoundation.amp.onepager.components.fields.AmpButtonField submit = new AmpButtonField("ajaxSubmit", "Import Structures", true){ @Override protected void onSubmit(AjaxRequestTarget target, Form form) { logger.info("Submitting form"); -// if (fileItemModel.getObject() != null) -// tmp.setFile(new FileUpload(fileItemModel.getObject())); target.add(list); From a368cf53d50780bd159ba23815897711796b032a Mon Sep 17 00:00:00 2001 From: brianbrix Date: Wed, 6 Nov 2024 20:21:21 +0300 Subject: [PATCH 20/32] GGW-369: Resolve project saving ajax issue --- .../features/sections/AmpStructuresFormSectionFeature.html | 4 +--- .../features/sections/AmpStructuresFormSectionFeature.java | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html index 135bfeb6930..fa8b40768ea 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html +++ b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html @@ -21,9 +21,7 @@
-
+
-
- -
+
diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java index 15d948888fc..5f0511df9c5 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java +++ b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java @@ -459,8 +459,7 @@ protected void onSubmit() { form.add(fileUpload); - // create the ajax button used to submit the form - org.dgfoundation.amp.onepager.components.fields.AmpButtonField submit = new AmpButtonField("ajaxSubmit", "Import Structures", true){ + AmpButtonField submit = new AmpButtonField("ajaxSubmit", "Import Structures", true){ @Override protected void onSubmit(AjaxRequestTarget target, Form form) { logger.info("Submitting form"); From a925a5c21dc3ff93f2c5c83cfc3b084527cc209a Mon Sep 17 00:00:00 2001 From: brianbrix Date: Wed, 6 Nov 2024 20:21:34 +0300 Subject: [PATCH 21/32] GGW-369: Resolve project saving ajax issue --- .../features/sections/AmpStructuresFormSectionFeature.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html index fa8b40768ea..4624187d37c 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html +++ b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html @@ -10,7 +10,7 @@
- +
From 6bda7951832ed4948bb57c1f69b38715a346a216 Mon Sep 17 00:00:00 2001 From: brianbrix Date: Wed, 6 Nov 2024 20:32:12 +0300 Subject: [PATCH 22/32] GGW-369: Resolve project saving ajax issue --- .../AmpStructuresFormSectionFeature.java | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java index 5f0511df9c5..721e4d996cb 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java +++ b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java @@ -458,17 +458,18 @@ protected void onSubmit() { form.add(fileUpload); + Button submit = new Button("ajaxSubmit"); - AmpButtonField submit = new AmpButtonField("ajaxSubmit", "Import Structures", true){ - @Override - protected void onSubmit(AjaxRequestTarget target, Form form) { - logger.info("Submitting form"); - target.add(list); - - - - } - }; +// AmpButtonField submit = new AmpButtonField("ajaxSubmit", "Import Structures", true){ +// @Override +// protected void onSubmit(AjaxRequestTarget target, Form form) { +// logger.info("Submitting form"); +// target.add(list); +// +// +// +// } +// }; form.add(submit); ResourceReference resourceReference = new ResourceReference("exportData-"+ System.currentTimeMillis()) { From 964d3525c095effba88160a6385e9bcd408a431c Mon Sep 17 00:00:00 2001 From: brianbrix Date: Wed, 6 Nov 2024 20:41:47 +0300 Subject: [PATCH 23/32] GGW-369: Resolve project saving ajax issue --- .../features/sections/AmpStructuresFormSectionFeature.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html index 4624187d37c..e9320ea64a7 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html +++ b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html @@ -21,7 +21,7 @@
- +
From 82f28d04b22629af2ba9a7a4a72f6ad358067876 Mon Sep 17 00:00:00 2001 From: brianbrix Date: Wed, 6 Nov 2024 21:04:08 +0300 Subject: [PATCH 24/32] GGW-369: Resolve project saving ajax issue --- .../sections/AmpStructuresFormSectionFeature.html | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html index e9320ea64a7..a0921941d2a 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html +++ b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html @@ -4,13 +4,9 @@
- - - -
- +
@@ -27,8 +23,9 @@
+

+ Download
- +
-
- -
+
- +
+ +
-

+
Download diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java index 721e4d996cb..0a22a0eb265 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java +++ b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java @@ -335,72 +335,6 @@ public void onClick(AjaxRequestTarget target) { add(addbutton); -// final FileUploadField fileUploadField = new FileUploadField("fileUpload"); -// fileUploadField.setOutputMarkupId(true); -// -// final Form form = new Form("form") -// { -// private static final long serialVersionUID = 1L; -// @Override -// protected void onSubmit() { -// FileUpload upload = fileUploadField.getFileUpload(); -// if (upload == null) { -// logger.info("No file uploaded"); -// } else { -// logger.info("File-Name: " + upload.getClientFileName() + " File-Size: " + -// Bytes.bytes(upload.getSize())); -// try { -// XSSFWorkbook workbook = new XSSFWorkbook(upload.getInputStream()); -// XSSFSheet sheet = workbook.getSheetAt(0); -// Iterator rowIterator = sheet.iterator(); -// rowIterator.next(); -// -// while (rowIterator.hasNext()) { -// XSSFRow row = (XSSFRow) rowIterator.next(); -// String title = getStringValueFromCell(row.getCell(0)); -// String description = getStringValueFromCell(row.getCell(1)); -// String latitude = getStringValueFromCell(row.getCell(2)); -// String longitude = getStringValueFromCell(row.getCell(3)); -// -// AmpStructure stru = new AmpStructure(); -// stru.setTitle(title); -// stru.setDescription(description); -// stru.setLatitude(latitude); -// stru.setLongitude(longitude); -// list.addItem(stru); -// list.goToLastPage(); -// } -// -// -// } catch (IOException e) { -// throw new RuntimeException(e); -// } -// } -// } -// -// }; -// form.setMultiPart(true); -// form.setMaxSize(Bytes.megabytes(10)); -// form.add(fileUploadField); -// -// -// Button importStructures = new Button("importStructures"); -//// importStructures.add(new AttributeModifier("disabled", "true")); -// importStructures.setOutputMarkupId(true); -// form.add(importStructures); -// fileUploadField.add(new AjaxFormComponentUpdatingBehavior("change") { -// private static final long serialVersionUID = 1L; -// -// @Override -// protected void onUpdate(AjaxRequestTarget target) { -// importStructures.setEnabled(true); -// importStructures.add(new AttributeModifier("disabled", (String) null)); // Enable the button -// target.add(importStructures); -// -// } -// }); -// -// add(form); final Model fileItemModel = new Model(); FileUploadPanel fileUpload = new FileUploadPanel("file",String.valueOf(am.getObject().getAmpActivityId()), fileItemModel); @@ -449,9 +383,7 @@ protected void onSubmit() { WebMarkupContainer rc = new WebMarkupContainer("resourcePanel"); -// rc.add(new AttributeModifier("id", getToggleId())); rc.add(form); -// rc.add(name); rc.add(fileUpload); rc.setOutputMarkupId(true); add(rc); @@ -459,17 +391,8 @@ protected void onSubmit() { form.add(fileUpload); Button submit = new Button("ajaxSubmit"); + submit.add(new AttributeModifier("class", new Model("addStructure button_green_btm"))); -// AmpButtonField submit = new AmpButtonField("ajaxSubmit", "Import Structures", true){ -// @Override -// protected void onSubmit(AjaxRequestTarget target, Form form) { -// logger.info("Submitting form"); -// target.add(list); -// -// -// -// } -// }; form.add(submit); ResourceReference resourceReference = new ResourceReference("exportData-"+ System.currentTimeMillis()) { @@ -512,7 +435,7 @@ public void onClick(AjaxRequestTarget target) { }; add(exportStructures); - exportStructures.getButton().add(new AttributeModifier("class", new Model("exportStructures button_blue_btm"))); + exportStructures.getButton().add(new AttributeModifier("class", new Model("addStructure button_blue_btm"))); add(exportStructures); From 32b470bcfc8da1634d5ad5d328cad08d4c46c872 Mon Sep 17 00:00:00 2001 From: brianbrix Date: Thu, 7 Nov 2024 22:41:02 +0300 Subject: [PATCH 26/32] GGW-369: Structures section styling --- .../features/sections/AmpStructuresFormSectionFeature.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java index 0a22a0eb265..a0f550166ce 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java +++ b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java @@ -435,9 +435,6 @@ public void onClick(AjaxRequestTarget target) { }; add(exportStructures); - exportStructures.getButton().add(new AttributeModifier("class", new Model("addStructure button_blue_btm"))); - add(exportStructures); - } private static String getStringValueFromCell(Cell cell) { From b188988466f07043e661a9be0f5a45792f34bf40 Mon Sep 17 00:00:00 2001 From: brianbrix Date: Thu, 7 Nov 2024 22:55:41 +0300 Subject: [PATCH 27/32] GGW-369: Structures section styling --- .../features/sections/AmpStructuresFormSectionFeature.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html index f5e6ca9f966..57e025b3df3 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html +++ b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html @@ -6,7 +6,7 @@
- +
From 516e7668d412e25813bd79eed4c89a3e9ab0dfa4 Mon Sep 17 00:00:00 2001 From: brianbrix Date: Thu, 7 Nov 2024 23:30:51 +0300 Subject: [PATCH 28/32] GGW-369: Structures section styling --- .../sections/AmpStructuresFormSectionFeature.html | 2 +- .../sections/AmpStructuresFormSectionFeature.java | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html index 57e025b3df3..73b6a2cb2ed 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html +++ b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html @@ -9,7 +9,7 @@ diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java index a0f550166ce..3e33c0a926c 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java +++ b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java @@ -390,7 +390,14 @@ protected void onSubmit() { form.add(fileUpload); - Button submit = new Button("ajaxSubmit"); + AmpButtonField submit = new AmpButtonField("ajaxSubmit", "Add", true) { + + @Override + protected void onSubmit(AjaxRequestTarget target, Form form) { + // TODO: 07/11/2024 Add your code here + } + }; + submit.add(new AttributeModifier("class", new Model("addStructure button_green_btm"))); From 42d6ea9b64140bc445e98be4be20adf8fca883f2 Mon Sep 17 00:00:00 2001 From: brianbrix Date: Thu, 7 Nov 2024 23:55:59 +0300 Subject: [PATCH 29/32] GGW-369: Structures section styling --- .../sections/AmpStructuresFormSectionFeature.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java index 3e33c0a926c..d5596263cfd 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java +++ b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.java @@ -390,13 +390,7 @@ protected void onSubmit() { form.add(fileUpload); - AmpButtonField submit = new AmpButtonField("ajaxSubmit", "Add", true) { - - @Override - protected void onSubmit(AjaxRequestTarget target, Form form) { - // TODO: 07/11/2024 Add your code here - } - }; + Button submit = new Button("ajaxSubmit"); submit.add(new AttributeModifier("class", new Model("addStructure button_green_btm"))); From 4e3d3ed3942ad990807b62fe651d9e7ac83a4cf3 Mon Sep 17 00:00:00 2001 From: brianbrix Date: Thu, 7 Nov 2024 23:56:47 +0300 Subject: [PATCH 30/32] GGW-369: Structures section styling --- .../features/sections/AmpStructuresFormSectionFeature.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html index 73b6a2cb2ed..57e025b3df3 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html +++ b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html @@ -9,7 +9,7 @@
- +
From 7ca91096f9a666a62e1725ce02bf84e6b65eb237 Mon Sep 17 00:00:00 2001 From: Julian de Anquin Date: Mon, 11 Nov 2024 10:24:33 -0300 Subject: [PATCH 31/32] GGW-369 arrange colors --- .../features/sections/AmpStructuresFormSectionFeature.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html index 57e025b3df3..f6fe8c68366 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html +++ b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html @@ -9,7 +9,7 @@
- +
@@ -27,7 +27,7 @@
From bf2927a2b8443446cff63323051d479b7a1c5a32 Mon Sep 17 00:00:00 2001 From: Julian de Anquin Date: Mon, 11 Nov 2024 13:09:35 -0300 Subject: [PATCH 32/32] GGW-369 arrange colors --- .../features/sections/AmpStructuresFormSectionFeature.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html index f6fe8c68366..b4864f9ab94 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html +++ b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpStructuresFormSectionFeature.html @@ -27,7 +27,7 @@
- +
Download - +
Download - +