Added 'add task' functionality

This commit is contained in:
2023-07-29 19:25:37 +01:00
parent 453f62cfae
commit 75413b2c5e
3 changed files with 34 additions and 3 deletions

View File

@@ -60,4 +60,8 @@ pre {
padding: 0;
background: white;
border-radius: 0;
}
#taskCard {
margin-top: 45%;
}

View File

@@ -40,7 +40,18 @@
</div>
<div id="historyContent"></div>
</div>
<div id="addTask" class="screen" style="display: none;">Add Task</div>
<div id="addTask" class="screen" style="display: none;">
<article class="card" id="taskCard">
<header>
<h1>New task</h1> <br>
<label for="newTaskName">Task name</label>
<input type="text" id="newTaskName"> <br>
<label for="newTaskPoints">Task points</label>
<input type="number" id="newTaskPoints" min="1" max="5"> <br>
<input onclick="newTask()" value="Create" type="submit"> <br>
</header>
</article>
</div>
</div>
<div id="menu" class="flex three demo">
<div class="third" id="taskButton">
@@ -50,8 +61,8 @@
<span class="button" onclick="switchScreen('history')">History</span>
</div>
<div class="third" id="addButton">
<!-- <span class="button tooltip-top" onclick="switchScreen('add')" disabled data-tooltip="In construction">+ Task</span>-->
<span class="button tooltip-top" disabled data-tooltip="In construction">+ Task</span>
<span class="button tooltip-top" onclick="switchScreen('add')" >+ Task</span>
<!-- <span class="button tooltip-top" disabled data-tooltip="In construction">+ Task</span>-->
</div>
</div>
</div>

View File

@@ -155,4 +155,20 @@ async function switchScreen(button) {
} else if (button === "add") {
document.getElementById("addTask").setAttribute("style", "");
}
}
async function newTask() {
let points = document.getElementById(`newTaskPoints`).value;
let name = document.getElementById(`newTaskName`).value;
await fetch("/addTask", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
tid: 0,
name: name,
points: Number(points),
})
});
}