diff --git a/data.js b/data.js index 054ef60..ddab4c0 100644 --- a/data.js +++ b/data.js @@ -50,6 +50,29 @@ let steps = { } } }, + programme: { + title: "Který program studujete?", + layout: programme_layout, + result: { + faculty: "", // used for checking whether to clear + idx: -1 // -1 = none, 0+ = index into programmes[faculty] + }, + finalize: (result) => { + if(result.idx == -1) { + result.has_programme = false; + return + } + + let programme = programmes[steps.faculty.result.name][result.idx]; + + result.has_programme = true; + result.programme = programme.code + " " + ( + steps.language.result.lang == "cs" ? + programme.cs_name : + programme.en_name + ); + } + }, collaborators: { title: "Vedoucí práce", layout: collaborators_layout, @@ -185,6 +208,7 @@ const typst_header = `#import "template/template.typ": * author_pronouns: "{author_info.pronouns}", citations: "citations.bib" ) diff --git a/styles.css b/styles.css index c03ad46..31b4c2a 100644 --- a/styles.css +++ b/styles.css @@ -302,6 +302,21 @@ input[type="text"]:disabled { color: lightgray; } +select { + flex-grow: 0; + padding: 8px 16px; + + font-family: inherit; + font-size: 100%; + border: 1px var(--button-border-color) solid; + color: black; + background-color: var(--button-color); + border-radius: 8px; + + box-sizing: border-box; + width: 100%; +} + .zmp-logo { position: absolute; bottom: 20px; diff --git a/ui.js b/ui.js index ae170c1..edb592c 100644 --- a/ui.js +++ b/ui.js @@ -110,6 +110,29 @@ async function author_info_layout(content, result) { .finish()); } +async function programme_layout(content, result) { + let faculty = steps.faculty.result.name; + let programmes_faculty = programmes[faculty]; + let options = [ + [[-1, "(žádný)"]], + programmes_faculty.map((x, idx) => [ + idx, + "(" + x.title + ", " + x.form.slice(0, 4) + ".) " + x.cs_name + ]) + ].flat().map(x => new ElementBuilder("option") + .value(x[0]) + .text(x[1]) + .finish()); + + content.appendChild(new ElementBuilder("select") + .append_all(options) + .on_change(e => result.idx = +e.target.value) + .value(result.faculty != faculty ? -1 : result.idx) + .finish()); + + result.faculty = faculty; +} + async function collaborators_layout(content, result) { let supervisor_name = new TextInputBuilder(result, "supervisor_name") .placeholder("Jméno vedoucího práce (vč. titulů), příp. vedoucích") diff --git a/utils.js b/utils.js index 4d7c93b..d51a7a8 100644 --- a/utils.js +++ b/utils.js @@ -61,6 +61,11 @@ class ElementBuilder { return this; } + on_change(handler) { + this.element.onchange = handler; + return this; + } + for(fr) { this.element.htmlFor = fr; return this;