diff options
author | rstular <rok@stular.eu> | 2020-06-01 20:49:56 +0200 |
---|---|---|
committer | rstular <rok@stular.eu> | 2020-06-01 20:55:06 +0200 |
commit | 35b595f806f99ca18365d511ab820ab818da348d (patch) | |
tree | 353363f3883be5457cce00297f7bc1f6ef289056 /assets/js/gradings.js | |
parent | gsec bug fix (subject must not be null), UI fix (diff) | |
download | beziapp-35b595f806f99ca18365d511ab820ab818da348d.tar beziapp-35b595f806f99ca18365d511ab820ab818da348d.tar.gz beziapp-35b595f806f99ca18365d511ab820ab818da348d.tar.bz2 beziapp-35b595f806f99ca18365d511ab820ab818da348d.tar.lz beziapp-35b595f806f99ca18365d511ab820ab818da348d.tar.xz beziapp-35b595f806f99ca18365d511ab820ab818da348d.tar.zst beziapp-35b595f806f99ca18365d511ab820ab818da348d.zip |
Diffstat (limited to '')
-rw-r--r-- | assets/js/gradings.js | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/assets/js/gradings.js b/assets/js/gradings.js index a852337..bd664bb 100644 --- a/assets/js/gradings.js +++ b/assets/js/gradings.js @@ -131,6 +131,18 @@ function displayData() { calendar_obj.addEventSource(transformed_gradings); } +async function validateInputs() { + if ($("#input-grading-name").val() != null && $("#input-grading-name").val().length > 0) { + $("#btn-add-grading").removeAttr("disabled"); + $("#input-grading-name").addClass("valid"); + $("#input-grading-name").removeClass("invalid"); + } else { + $("#btn-add-grading").attr("disabled", "disabled"); + $("#input-grading-name").addClass("invalid"); + $("#input-grading-name").removeClass("valid"); + } +} + function gradingClickHandler(eventClickInfo) { let grading_id = parseInt(eventClickInfo.event.id); let grading_subject = gradings[grading_id]["subject"]; @@ -144,19 +156,19 @@ function gradingClickHandler(eventClickInfo) { M.Sidenav.getInstance(modal).open(); } - function setupPickers() { - // Setup pickers, todo (adding an event), to be stored in messages - var date_object = new Date(); - let elems = document.querySelectorAll('#datepicker-add'); - let options = { - autoClose: true, - format: "dd.mm.yyyy", - defaultDate: date_object, - setDefaultDate: true, - firstDay: 1 - } - instances = M.Datepicker.init(elems, options); +function setupPickers() { + // Setup pickers, todo (adding an event), to be stored in messages + var date_object = new Date(); + let elems = document.querySelectorAll('#datepicker-add'); + let options = { + autoClose: true, + format: "dd.mm.yyyy", + defaultDate: date_object, + setDefaultDate: true, + firstDay: 1 } + instances = M.Datepicker.init(elems, options); +} document.addEventListener("DOMContentLoaded", () => { @@ -176,14 +188,16 @@ document.addEventListener("DOMContentLoaded", () => { calendar_obj.render(); // Modal for adding gradings - setupPickers(); // todo (adding an event), to be stored in messages + setupPickers(); // TODO: Hook up submit logic // Setup modals const modal_elems = document.querySelectorAll('.modal'); const modal_options = { onOpenStart: () => { $("#fab-new").hide() }, onCloseEnd: () => { $("#fab-new").show() }, dismissible: false - }; + }; + $("#input-grading-name").on("blur", validateInputs); + $("#input-grading-description").on("blur", validateInputs); M.Modal.init(modal_elems, modal_options); loadGradings(true); |