add new block dialog to scheduler
This commit is contained in:
parent
b0c35eaa6d
commit
285180957a
29
layout.html
29
layout.html
@ -816,7 +816,36 @@
|
||||
const schedule_grid_click_handler = (e) => {
|
||||
e.preventDefault();
|
||||
// TODO: open dialog for add block
|
||||
const new_block_dialog = document.getElementById("new_block_dialog");
|
||||
const new_block_header = document.getElementById("new_block_dialog_header");
|
||||
const block_start_time = e.target.parentNode.firstElementChild.innerHTML;
|
||||
new_block_header.innerHTML = "New program block for " + block_start_time;
|
||||
|
||||
const new_block_close_button = document.getElementById("new_block_dialog_close_button");
|
||||
new_block_close_button.addEventListener("click", (event) => {
|
||||
event.preventDefault();
|
||||
new_block_dialog.close();
|
||||
});
|
||||
const new_block_save_button = document.getElementById("new_block_dialog_save_button");
|
||||
new_block_save_button.addEventListener("click", (event) => {
|
||||
event.preventDefault();
|
||||
const updateURL = "block.php";
|
||||
let data = new FormData(document.getElementById("new_block_dialog_form"));
|
||||
console.dir(data);
|
||||
fetch(updateURL, {
|
||||
method: "POST",
|
||||
body: data
|
||||
})
|
||||
.then((response) => {
|
||||
if (response.ok) {
|
||||
response.json().then((json) => {
|
||||
new_block_dialog.close();
|
||||
load_schedule(); // TODO: need to pass day here to keep working on the same schedule!
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
new_block_dialog.showModal();
|
||||
}
|
||||
|
||||
const schedule_block_click_handler = (e) => {
|
||||
|
Loading…
Reference in New Issue
Block a user