From 67ab36c1bb87196379153881afcd7e17aea421e2 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sun, 14 Jun 2020 20:03:51 +0200 Subject: Make state toggle when clicked. --- src/ws/munia.css | 5 +++-- src/ws/node.js | 2 +- src/ws/view.js | 29 +++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/ws/munia.css b/src/ws/munia.css index bfd63c7..bfc1823 100644 --- a/src/ws/munia.css +++ b/src/ws/munia.css @@ -10,7 +10,7 @@ body { cursor: default; - font-family: sans-serif; + font-family: helvetica, arial, sans-serif; font-size: 0.8em; } @@ -72,7 +72,8 @@ body padding-left: 5px; padding-right: 5px; background: transparent; - pointer-events: none; + pointer-events: auto; + cursor: pointer; } .node .description diff --git a/src/ws/node.js b/src/ws/node.js index 6e60b37..062f892 100644 --- a/src/ws/node.js +++ b/src/ws/node.js @@ -201,7 +201,7 @@ Node.prototype.create = function() this.state_element.setAttribute("onclick", "changeState(event)"); this.state_element.setAttribute("nodeid", this.id); this.state_element.setAttribute("class", "state"); - var txt_state = document.createTextNode(""); + var txt_state = document.createTextNode("todo"); this.state_element.appendChild(txt_state); this.data_element.appendChild(this.state_element); diff --git a/src/ws/view.js b/src/ws/view.js index 6c43dc8..aa4d9de 100644 --- a/src/ws/view.js +++ b/src/ws/view.js @@ -344,3 +344,32 @@ function collapse(e) node.element.classList.remove('collapsed'); } } + +function changeState(e) +{ + const idstr = e.target.parentElement.parentElement.id; + const node = findNodeFromString(idstr); + if(node == null) + { + return; // no node + } + + const id = idFromStr(e.target.parentElement.parentElement.id); + + switch(node.attributes["state"]) + { + case "in-progress": + update(id, "state", "blocked"); + break; + case "blocked": + update(id, "state", "done"); + break; + case "done": + update(id, "state", "todo"); + break; + default: + case "todo": + update(id, "state", "in-progress"); + break; + } +} -- cgit v1.2.3