commit 78a2184f68d8ea53db7e61e0eabee271233466ec
Author: cagy <ml.cagy@seznam.cz>
Date:   Wed May 20 17:45:05 2020 +0200

    re #8102 - indication submit button in post

diff --git a/src/main/java/vldc/aswi/web/controller/AssemblyController.java b/src/main/java/vldc/aswi/web/controller/AssemblyController.java
index 31258441..e0c53d89 100644
--- a/src/main/java/vldc/aswi/web/controller/AssemblyController.java
+++ b/src/main/java/vldc/aswi/web/controller/AssemblyController.java
@@ -142,6 +142,7 @@ public class AssemblyController extends BasicController {
 
         modelMap.addAttribute("configuration", configuration);
         modelMap.addAttribute("comparator", comparator);
+        modelMap.addAttribute("formAction", "/assembly?assemblyID=" + assembly.getId());
 
         return modelAndView;
     }
@@ -155,9 +156,38 @@ public class AssemblyController extends BasicController {
      * @return ModelAndView for assembly.
      */
     @PostMapping("/assembly")
-    public ModelAndView assemblyPost(@Valid Assembly assembly, BindingResult bindingResult, RedirectAttributes atts) {
-        ModelAndView modelAndView = new ModelAndView();
+    public ModelAndView assemblyPost(Assembly assembly,
+                                     BindingResult bindingResult,
+                                     RedirectAttributes atts,
+                                     @RequestParam("assemblyID") String id,
+                                     @RequestParam(required=false, value="generateTable") String generateTable,
+                                     @RequestParam(required=false, value="exportXls") String exportXls,
+                                     @RequestParam(required=false, value="exportPdf") String exportPdf,
+                                     @RequestParam(required=false, value="saveConfiguration") String saveConfiguration)
+    {
+        if (generateTable != null)
+        {
+            System.out.println("Generuj tabulku");
+        }
+        else if (exportXls != null)
+        {
+            System.out.println("Generuj XLS");
+        }
+        else if (exportPdf != null)
+        {
+            System.out.println("Generuj PDF");
+        }
+        else if (saveConfiguration != null)
+        {
+            System.out.println("ulož konfiguraci");
+        }
+
 
+
+        ModelAndView modelAndView = new ModelAndView("redirect:/assembly?assemblyID=" + id);
+
+        return modelAndView;
+/*
         ModelMap modelMap = modelAndView.getModelMap();
 
         long assemblyID = assembly.getId();
@@ -170,6 +200,8 @@ public class AssemblyController extends BasicController {
         modelMap.addAttribute("contingencyTableRows", this.sqlQueryManager.getContingencyTableRow(assembly2.getSQLQuery()));
 
         return modelAndView;
+
+ */
     }
 
     /**
diff --git a/src/main/java/vldc/aswi/web/controller/ConfigurationController.java b/src/main/java/vldc/aswi/web/controller/ConfigurationController.java
index 40a6c8bf..fb9c19a0 100644
--- a/src/main/java/vldc/aswi/web/controller/ConfigurationController.java
+++ b/src/main/java/vldc/aswi/web/controller/ConfigurationController.java
@@ -68,6 +68,7 @@ public class ConfigurationController extends BasicController{
 
         modelMap.addAttribute("configuration", configuration);
         modelMap.addAttribute("comparator", comparator);
+        modelMap.addAttribute("formAction", "/configuration?configurationID=" + configuration.getId());
 
         return modelAndView;
     }
@@ -80,8 +81,32 @@ public class ConfigurationController extends BasicController{
      * @return modelAndView with redirection
      */
     @PostMapping("/configuration")
-    public ModelAndView configurationPost(@Valid Configuration newConfiguration, BindingResult bindingResult,
-                                          @RequestParam("configurationID") String id) {
+    public ModelAndView configurationPost( Configuration newConfiguration,
+                                           BindingResult bindingResult,
+                                           @RequestParam("configurationID") String id,
+                                           @RequestParam(required=false, value="generateTable") String generateTable,
+                                           @RequestParam(required=false, value="exportXls") String exportXls,
+                                           @RequestParam(required=false, value="exportPdf") String exportPdf,
+                                           @RequestParam(required=false, value="saveConfiguration") String saveConfiguration)
+    {
+        if (generateTable != null)
+        {
+            System.out.println("Generuj tabulku");
+        }
+        else if (exportXls != null)
+        {
+            System.out.println("Generuj XLS");
+        }
+        else if (exportPdf != null)
+        {
+            System.out.println("Generuj PDF");
+        }
+        else if (saveConfiguration != null)
+        {
+            System.out.println("ulož konfiguraci");
+        }
+
+
         ModelAndView modelAndView = new ModelAndView();
 
         if (bindingResult.hasErrors()) {
diff --git a/src/main/webapp/WEB-INF/templates/assembly.html b/src/main/webapp/WEB-INF/templates/assembly.html
index 1c902e03..32170a5b 100644
--- a/src/main/webapp/WEB-INF/templates/assembly.html
+++ b/src/main/webapp/WEB-INF/templates/assembly.html
@@ -17,7 +17,7 @@
             <a href="/" class="btn btn-success mb-2">Zpět</a>
         </div>
 
-        <form th:object="${configuration}" method="post" th:action="@{/configuration(configurationID=${configuration.id})}">
+        <form th:object="${configuration}" method="post" th:action="@{${formAction}}">
             <input type="hidden" th:field="*{assembly.id}" th:value="${configuration.assembly?.getId()}"/>
             <div class="container box">
                 <div class="col-md-12">
@@ -193,15 +193,14 @@
                             <input type="text" required="required" class="form-control select-filter-input" th:field="${configuration.name}">
                         </div>
 
-                        <button type="submit" class="btn btn-success mb-2 template-input-submit">Uložit šablonu</button>
+                        <button type="submit" class="btn btn-success mb-2 template-input-submit" name="saveConfiguration">Uložit šablonu</button>
                     </div>
 
 
                     <div class="buttons-wrap">
-                        <button type="submit" class="btn btn-secondary mb-2 " name="generate-table">Vygenerovat tabulku
-                        </button>
-                        <button type="submit" class="btn btn-secondary mb-2 " name="export-xls">Export do XLS</button>
-                        <button type="submit" class="btn btn-secondary mb-2 " name="export-pdf">Export do PDF</button>
+                        <button type="submit" class="btn btn-secondary mb-2 " name="generateTable">Vygenerovat tabulku</button>
+                        <button type="submit" class="btn btn-secondary mb-2 " name="exportXls">Export do XLS</button>
+                        <button type="submit" class="btn btn-secondary mb-2 " name="exportPdf">Export do PDF</button>
                     </div>
                 </div>
             </div>
