fix bug where new columns were not added to database immediately
authorAndrew Lorimer <andrew@lorimer.id.au>
Sat, 17 Aug 2019 04:37:21 +0000 (14:37 +1000)
committerAndrew Lorimer <andrew@lorimer.id.au>
Sat, 17 Aug 2019 04:37:21 +0000 (14:37 +1000)
admin.js
index 8fb45ffffeba1be76c138e89473b18448149fd12..2b82da75484393dec8d2f4e1f971cadb297d34a3 100644 (file)
--- a/admin.js
+++ b/admin.js
@@ -211,7 +211,7 @@ function closeEdit(editbtn) {
 
 function addCol() {
   var ul = document.createElement("ul");
-  ul.setAttribute("id", "new-category");
+  ul.setAttribute("id", "new");
   ul.setAttribute('draggable', 'true');
   ul.addEventListener('dragstart', dragStart, false);
   ul.addEventListener('dragenter', dragEnter, false);
@@ -229,14 +229,14 @@ function addCol() {
   ul.appendChild(title);
 
   var p = document.createElement("p");
-  p.innerText = "new-category";
+  p.innerText = "new";
   title.appendChild(p);
 
-  title.insertAdjacentHTML("beforeend", "<span class='add' id='add-new-category'>+</span>");
+  title.insertAdjacentHTML("beforeend", "<span class='add' id='add-new'>+</span>");
 
   rmbutton = document.createElement("span"); 
   rmbutton.setAttribute("class", "rmcol");
-  rmbutton.setAttribute("id", "rmcol-new-category");
+  rmbutton.setAttribute("id", "rmcol-new");
   rmbutton.innerText = "-";
   rmbutton.addEventListener('click', function(event){
     console.log("Deleting column " + this.parentNode.parentNode);
@@ -252,8 +252,9 @@ function addCol() {
   title.getElementsByClassName("add")[0].style.display = "flex";
   title.getElementsByTagName("p")[0].style.width = "calc(100% - 90px)";
   
-  listen(title.getElementsByClassName("add")[0]);
+  mainlist.push(["new"]);
   save();
+  listen(title.getElementsByClassName("add")[0]);
 }
 
 function listen(li) {
@@ -304,7 +305,7 @@ function addItem(caller, li) {
 
           newli.insertAdjacentHTML("beforeend", "<a href="+siteurl+">"+nme+"</a>");
           newli.insertAdjacentHTML("beforeend", rmspan[0]+columnToArray(ul).length.toString()+"-"+caller[1]+rmspan[1]);
-          document.getElementById(caller[1]).appendChild(newli);
+          document.getElementById(id).appendChild(newli);
           save();
           listen(newli);
         }