commit 0b2d6e694df2e0a3d6e0eacd553817666468271f
Author: cagy <ml.cagy@seznam.cz>
Date:   Fri Apr 24 13:34:39 2020 +0200

    temp

diff --git a/src/main/java/vldc/aswi/web/controller/AssemblyController.java b/src/main/java/vldc/aswi/web/controller/AssemblyController.java
index 0a854e53..caaceb1b 100644
--- a/src/main/java/vldc/aswi/web/controller/AssemblyController.java
+++ b/src/main/java/vldc/aswi/web/controller/AssemblyController.java
@@ -70,4 +70,19 @@ System.out.println(assemblyID);
 
         return modelAndView;
     }
+
+
+    @GetMapping("/assembly_create")
+    public ModelAndView assemblyCreateIndex(@Valid @ModelAttribute("assemblyID") String id) {
+        ModelAndView modelAndView = new ModelAndView("assembly_edit");
+
+        ModelMap modelMap = modelAndView.getModelMap();
+
+        Assembly assembly = new Assembly();
+
+        modelMap.addAttribute("assemblies", assemblyManager.getAssemblies());
+        modelMap.addAttribute("assembly", assembly);
+
+        return modelAndView;
+    }
 }
diff --git a/src/main/webapp/WEB-INF/templates/assembly_edit.html b/src/main/webapp/WEB-INF/templates/assembly_edit.html
index a356a32a..05034b75 100644
--- a/src/main/webapp/WEB-INF/templates/assembly_edit.html
+++ b/src/main/webapp/WEB-INF/templates/assembly_edit.html
@@ -18,6 +18,12 @@
     <script type="text/javascript" src="js/jquery.js"></script>
     <script type="text/javascript" src="js/bootstrap.min.js"></script>
     <script type="text/javascript" src="js/bootstrap-select.min.js"></script>
+
+    <link href="//code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css" rel="stylesheet">
+
+    <script type="text/javascript" src="js/jquery.js"></script>
+    <script src="//code.jquery.com/jquery-1.11.1.js"></script>
+    <script src="//code.jquery.com/ui/1.11.1/jquery-ui.js"></script>
 </head>
 <body>
 <div id="test"></div>
@@ -64,7 +70,7 @@
       <button type="button" class="btn btn-success"><i class="fas fa-plus"></i> Přidat parametr</button>
     </div>
 
-    <div class="panel-group" id="accordion">
+    <div class="panel-group sort" id="accordion">
       <div class="panel panel-default">
 
         <div class="panel-heading">
@@ -98,10 +104,10 @@
                 <input type="text" class="form-control" id="name">
               </div>
             </div>
-            <div class="form-group row">
+            <div class="form-group row type-row">
               <label for="exampleFormControlSelect1" class="col-sm-2">Typ:</label>
               <div class="col-sm-10">
-                <select class="form-control" id="exampleFormControlSelect1">
+                <select class="form-control type-select">
                   <option>Text</option>
                   <option>Datum</option>
                   <option>Výčet</option>
@@ -181,10 +187,10 @@
                 <input type="text" class="form-control" id="name">
               </div>
             </div>
-            <div class="form-group row">
+            <div class="form-group row type-row">
               <label for="exampleFormControlSelect1" class="col-sm-2">Typ:</label>
               <div class="col-sm-10">
-                <select class="form-control" id="exampleFormControlSelect1">
+                <select class="form-control type-select">
                   <option>Text</option>
                   <option>Datum</option>
                   <option>Výčet</option>
@@ -263,13 +269,13 @@
                 <input type="text" class="form-control" id="name">
               </div>
             </div>
-            <div class="form-group row">
+            <div class="form-group row type-row">
               <label for="exampleFormControlSelect1" class="col-sm-2">Typ:</label>
               <div class="col-sm-10">
-                <select class="form-control" id="exampleFormControlSelect1">
-                  <option>Text</option>
-                  <option>Datum</option>
-                  <option>Výčet</option>
+                <select class="form-control type-select">
+                  <option value="1">Text</option>
+                  <option value="2">Datum</option>
+                  <option value="3">Výčet</option>
                 </select>
               </div>
             </div>
@@ -277,48 +283,45 @@
             <div class="enum_box">
               Hodnoty:
               <div class="enum_values col-md-8">
-                <div class="input-action-box input-border-bottom">
-                  <input type="text" readonly class="form-control-plaintext" id="staticEmail" value="Doktorský">
-
-                  <span class="action-padding input-action-margin sort-icon">
-                    <i class="fas fa-sort"></i>
-                  </span>
-                  <span class="action-padding action-button input-action-margin">
-                    <a href=# class="action-link far fa-trash-alt"></a>
-                  </span>
+                  <div id="enum-wrapper">
+                    <div class="input-action-box input-border-bottom">
+                      <input type="text" readonly class="form-control-plaintext" value="Doktorský">
+
+                      <span class="action-padding input-action-margin sort-icon">
+                        <i class="fas fa-sort"></i>
+                      </span>
+                      <span class="action-padding action-button input-action-margin">
+                        <a href=# class="action-link far fa-trash-alt"></a>
+                      </span>
+                    </div>
+                    <div class="input-action-box input-border-bottom">
+                      <input type="text" readonly class="form-control-plaintext" value="Navazující">
+
+                      <span class="action-padding input-action-margin sort-icon">
+                        <i class="fas fa-sort"></i>
+                      </span>
+                      <span class="action-padding action-button input-action-margin">
+                        <a href=# class="action-link far fa-trash-alt"></a>
+                      </span>
+
+                    </div>
+                    <div class="input-action-box input-border-bottom">
+                      <input type="text" readonly class="form-control-plaintext" value="Bakalářský">
+
+                      <span class="action-padding input-action-margin sort-icon">
+                        <i class="fas fa-sort"></i>
+                      </span>
+                      <span class="action-padding action-button input-action-margin">
+                        <a href=# class="action-link far fa-trash-alt"></a>
+                      </span>
+                    </div>
                 </div>
-                <div class="input-action-box input-border-bottom">
-                  <input type="text" readonly class="form-control-plaintext" id="staticEmail" value="Navazující">
-
-                  <span class="action-padding input-action-margin sort-icon">
-                    <i class="fas fa-sort"></i>
-                  </span>
-                  <span class="action-padding action-button input-action-margin">
-                    <a href=# class="action-link far fa-trash-alt"></a>
-                  </span>
-
-                </div>
-                <div class="input-action-box input-border-bottom">
-                  <input type="text" readonly class="form-control-plaintext" id="staticEmail" value="Bakalářský">
-
-                  <span class="action-padding input-action-margin sort-icon">
-                    <i class="fas fa-sort"></i>
-                  </span>
-                  <span class="action-padding action-button input-action-margin">
-                    <a href=# class="action-link far fa-trash-alt"></a>
-                  </span>
-                </div>
-
                 <div class="form-group row form-add-item">
                   <div class="col-md-9">
-                    <input type="text" class="form-control" id="name">
+                    <input id="enum-input" type="text" class="form-control">
                   </div>
-                  <button type="submit" class="btn btn-primary mb-2">Přidat</button>
+                  <span id="enum-button" class="btn btn-primary mb-2">Přidat</span>
                 </div>
-
-
-
-
               </div>
             </div>
 
@@ -373,36 +376,30 @@
     <div class="box-header">
       <h3 class="box-title">Oprávnění</h3>
     </div>
-    <div class="input-action-box input-border-bottom">
-      <input type="text" readonly class="form-control-plaintext" id="staticEmail" value="Rektor">
-
-      <span class="action-padding input-action-margin sort-icon">
-        <i class="fas fa-sort"></i>
-      </span>
-      <span class="action-padding action-button input-action-margin">
-        <a href=# class="action-link far fa-trash-alt"></a>
-      </span>
-    </div>
-    <div class="input-action-box input-border-bottom">
-      <input type="text" readonly class="form-control-plaintext" id="staticEmail" value="Referentka">
-
-      <span class="action-padding input-action-margin sort-icon">
-        <i class="fas fa-sort"></i>
-      </span>
-      <span class="action-padding action-button input-action-margin">
-        <a href=# class="action-link far fa-trash-alt"></a>
-      </span>
+    <div id ="permission-wrapper">
+        <div class="input-action-box input-border-bottom input-row">
+            <input type="text" readonly class="form-control-plaintext permission-role" id="1" value="Rektor">
+            <span class="action-padding action-button input-action-margin">
+                <a href=# class="action-link far fa-trash-alt" onclick="removeRole(this);"></a>
+            </span>
+        </div>
+        <div class="input-action-box input-border-bottom input-row">
+            <input type="text" readonly class="form-control-plaintext permission-role" id="2" value="Referentka">
+            <span class="action-padding action-button input-action-margin">
+                <a href=# class="action-link far fa-trash-alt" onclick="removeRole(this);"></a>
+            </span>
+        </div>
     </div>
 
     <div class="form-group row form-add-item">
       <div class="col-md-9">
-        <select class="form-control " id="exampleFormControlSelect1">
-          <option>Rektor</option>
-          <option>Studijní oddělení</option>
-          <option>Strudenti</option>
+        <select class="form-control " id="permission-select" name="permission-select">
+          <option value="1">Rektor</option>
+          <option value="2">Studijní oddělení</option>
+          <option value="3">Strudenti</option>
         </select>
       </div>
-      <button type="submit" class="btn btn-primary mb-2">Přidat</button>
+      <span class="btn btn-primary mb-2" id="permission-button">Přidat</span>
     </div>
   </div>
 </div>
@@ -425,5 +422,187 @@
 </body>
 </html>
 <script type="text/javascript">
-$("select").selectpicker();
+
+    $(document).ready(function() {
+        $(".sort").sortable().disableSelection();
+        $("#enum-wrapper").sortable().disableSelection();
+
+        $('.type-select').on('change', function () {
+            if (this.value == 3)
+            {
+        console.log('a');
+                addEnum(this);
+            }
+            else
+            {
+                removeEnum(this);
+            }
+        });
+
+
+        $('.fa-trash-alt').click(function(event){
+            event.preventDefault();
+        });
+
+    });
+
+    $('#permission-button').on('click', function () {
+        var selectedRoleId = $('select[name=permission-select] option').filter(':selected').val();
+        var selectedRoleValue = $('select[name=permission-select] option').filter(':selected').text();
+
+        var addedRoles = $('.permission-role');
+
+        var roles = [];
+
+        // get assigned roles
+        addedRoles.each(function () {
+            roles.push($(this).attr('id'))
+        });
+
+        if (roles.includes(selectedRoleId))
+        {
+            return;
+        }
+
+        addPermissionRow(selectedRoleId, selectedRoleValue);
+
+    });
+
+
+    function addPermissionRow(id, value){
+
+        let row = document.createElement('div');
+        row.classList.add('input-action-box', 'input-border-bottom', 'permission-row');
+
+        let input = document.createElement('input');
+        input.type = 'text';
+        input.classList.add('form-control-plaintext', 'permission-role');
+        input.id = id;
+        input.value = value;
+        input.setAttribute('readonly', "true");
+
+        row.appendChild(input);
+
+        let actionButton = document.createElement('span');
+        actionButton.classList.add('action-padding', 'action-button', 'input-action-margin');
+
+        let deleteButton = document.createElement('a');
+        deleteButton.classList.add('action-link', 'far', 'fa-trash-alt');
+        deleteButton.setAttribute('onclick', 'removeRole(this);');
+        deleteButton.setAttribute('role', 'button');
+
+        actionButton.appendChild(deleteButton);
+        row.appendChild(actionButton);
+
+        document.getElementById('permission-wrapper').appendChild(row);
+
+    };
+
+    $('#enum-button').on('click', function () {
+        var value = $('#enum-input').val();
+        console.log('a');
+        addEnumRow(value);
+
+
+
+    });
+
+    function addEnumRow(value)
+    {
+      let row = document.createElement('div');
+      row.classList.add('input-action-box', 'input-border-bottom');
+
+
+      let input = document.createElement('input');
+      input.type = 'text';
+      input.classList.add('form-control-plaintext');
+      input.value = value;
+      input.setAttribute('readonly', "true");
+
+      row.appendChild(input);
+
+      let sortSpan = document.createElement('span');
+      sortSpan.classList.add('action-padding', 'input-action-margin', 'sort-icon');
+      sortSpan.innerHTML = "<i class=\"fas fa-sort\"></i>";
+
+      row.appendChild(sortSpan);
+
+      let deleteSpan = document.createElement('span');
+      deleteSpan.classList.add('action-padding', 'input-action-margin', 'action-button');
+
+      let deleteButton = document.createElement('a');
+      deleteButton.classList.add('action-link', 'far', 'fa-trash-alt');
+      deleteButton.setAttribute('onclick', 'removeEnum(this);');
+
+      deleteSpan.appendChild(deleteButton);
+
+      row.appendChild(deleteSpan);
+
+      document.getElementById('enum-wrapper').appendChild(row);
+
+    }
+
+
+    function removeRole (selectedField) {
+        selectedField.closest('.input-row').remove();
+    }
+
+
+    function addEnum(select)
+    {
+      console.log(select.parent());
+      let row = document.createElement('div');
+      row.classList.add('enum_box');
+      row.innerHTML = "Hodnoty:";
+
+      let values = document.createElement('div');
+      values.classList.add('enum_values', 'col-md-8');
+
+      let valuesWrapper = document.createElement('div');
+      valuesWrapper.id = "enum-wrapper";
+
+      values.appendChild(valuesWrapper);
+
+      let addButtonDiv = document.createElement('div');
+      addButtonDiv.classList.add('form-group', 'row', 'form-add-item');
+
+      let addInnerButton = document.createElement('div');
+      addInnerButton.classList.add('col-md-9');
+
+      let input = document.createElement('input');
+      input.type = 'text';
+      input.id = "enum-input";
+      input.classList.add('form-control');
+
+
+      let addButton = document.createElement('span');
+      addButton.classList.add('btn', 'btn-primary', 'mb-2');
+      addButton.innerHTML = 'Přidat';
+      addButton.id = "enum-button";
+
+      addInnerButton.appendChild(input);
+      addButtonDiv.appendChild(addInnerButton);
+      addButtonDiv.appendChild(addButton);
+
+      values.appendChild(addButtonDiv);
+      row.appendChild(values);
+
+      select.appendChild(row);
+
+      $(row).insertAfter($('.type-row'));
+
+      $('#enum-button').on('click', function () {
+        var value = $('#enum-input').val();
+        console.log('a');
+        addEnumRow(value);
+      });
+    }
+
+  
+    function removeEnum(select) {
+      $('.enum_box').remove();
+
+    }
+
 </script>
+
diff --git a/src/main/webapp/WEB-INF/templates/index.html b/src/main/webapp/WEB-INF/templates/index.html
index efab95de..0e9c1c60 100644
--- a/src/main/webapp/WEB-INF/templates/index.html
+++ b/src/main/webapp/WEB-INF/templates/index.html
@@ -13,7 +13,6 @@
 	<link href="css/fontawesome.min.css" rel="stylesheet">
 	<link href="css/style.css" rel="stylesheet">
 
-
 </head>
 	<body>
 	<div id="test"></div>
@@ -42,9 +41,9 @@
 					<tr>
 						<td><a href=#>Vlastní šablona 2, Vlastní šablona 2, Vlastní šablona 2, Vlastní šablona 2</a></td>
 						<td class="center-cell">
-				  <span class="action-button">
-					<a href=# class="action-link far fa-trash-alt"></a>
-				  </span>
+						  <span class="action-button">
+							<a href=# class="action-link far fa-trash-alt"></a>
+						  </span>
 						</td>
 					</tr>
 					</tbody>
@@ -57,7 +56,7 @@
 				<h3 class="box-title">Seznam sestav</h3>
 			</div>
 			<div class="button-container">
-				<button type="button" class="btn btn-success"><i class="fas fa-plus"></i> Přidat novou sestavu</button>
+				<a th:href="@{/assembly_create}"><button type="button" class="btn btn-success"><i class="fas fa-plus"></i> Přidat novou sestavu</button></a>
 				<button type="button" class="btn btn-success align-right"><i class="fas fa-sort"></i> Upravit řazení</button>
 			</div>
 
