diff --git a/data.js b/data.js index 5cebb22..a973dfb 100644 --- a/data.js +++ b/data.js @@ -69,6 +69,16 @@ let steps = { } } }, + assignment: { + title: "Jak vložit zadání?", + layout: assignment_layout, + result: { + format: "empty" + }, + finalize: (result) => { + result.include_pdf = result.format === "external"; + } + } } const faculties = { @@ -155,6 +165,15 @@ const pronouns_en = { } } +const assignment_formats = { + "empty": { + name: "Vložit do dokumentu prázdnou stránku.\nTuto stránku poté nahradíte podepsaným zadáním." + }, + "external": { + name: "Vložit do dokumentu zadání ve formě PDF." + } +} + const typst_header = `#import "template/template.typ": * #show: tultemplate2.with( @@ -166,8 +185,8 @@ const typst_header = `#import "template/template.typ": * author_pronouns: "{author_info.pronouns}", citations: "citations.bib", - assignment: "zadani.pdf" +> citations: "citations.bib" ) = Nadpis @@ -229,6 +248,10 @@ async function generate_zip() { out_zip.file("thesis.typ", generate_template()); + if(!steps.assignment.result.include_pdf) { + out_zip.remove("assignment.pdf"); + } + return await out_zip.generateAsync({ type: "blob" }); } diff --git a/ui.js b/ui.js index 4c814aa..ae170c1 100644 --- a/ui.js +++ b/ui.js @@ -136,6 +136,25 @@ async function collaborators_layout(content, result) { .finish()); } +async function assignment_layout(content, result) { + if(!Object.keys(assignment_formats).includes(result.format)) { + document.querySelector("#next-button").disabled = true; + } + + let buttons = new ButtonListBuilder(Object.keys(assignment_formats)) + .should_be_pressed((key) => result.format == key) + .modify((b, key) => b.class("wide").text(assignment_formats[key].name)) + .on_click((key) => { + result.format = key; + document.querySelector("#next-button").disabled = false; + }) + .finish(); + + for(const button of buttons) { + content.appendChild(button); + } +} + async function run() { startbutton.style.cursor = "auto"; startbutton.disabled = true;