Entries now have a finalize step to fill in defaults
This commit is contained in:
26
data.js
26
data.js
@@ -19,6 +19,11 @@ let steps = {
|
||||
result: {
|
||||
name: "",
|
||||
pronouns: ""
|
||||
},
|
||||
finalize: (result) => {
|
||||
if(result.name === "") {
|
||||
result.name = "SEM DOPLŇTE VAŠE JMÉNO";
|
||||
}
|
||||
}
|
||||
},
|
||||
collaborators: {
|
||||
@@ -29,6 +34,15 @@ let steps = {
|
||||
supervisor_name: "",
|
||||
has_consultant: false,
|
||||
consultant_name: ""
|
||||
},
|
||||
finalize: (result) => {
|
||||
if(result.supervisor_name === "") {
|
||||
result.supervisor_name = "SEM DOPLŇTE JMÉNO VEDOUCÍHO PRÁCE";
|
||||
}
|
||||
|
||||
if(result.consultant_name === "") {
|
||||
result.consultant_name = "SEM DOPLŇTE JMÉNO KONZULTANTA PRÁCE";
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
@@ -127,7 +141,13 @@ async function generate_zip() {
|
||||
for(const step_key in steps) {
|
||||
console.log(step_key);
|
||||
|
||||
for(const key in steps[step_key].result) {
|
||||
let result = steps[step_key].result;
|
||||
|
||||
if(steps[step_key].finalize) {
|
||||
steps[step_key].finalize(result);
|
||||
}
|
||||
|
||||
for(const key in result) {
|
||||
console.log("- " + key);
|
||||
|
||||
const search_condition = "<" + step_key + "." + key + ":";
|
||||
@@ -138,7 +158,7 @@ async function generate_zip() {
|
||||
|
||||
if(condition_end_pos >= 0) {
|
||||
const head = out.slice(0, condition_pos);
|
||||
const meat = steps[step_key].result[key] ? out.slice(condition_pos + search_condition.length, condition_pos + condition_end_pos) : "";
|
||||
const meat = result[key] ? out.slice(condition_pos + search_condition.length, condition_pos + condition_end_pos) : "";
|
||||
const tail = out.slice(condition_pos + condition_end_pos + 1);
|
||||
|
||||
out = head + meat + tail;
|
||||
@@ -150,7 +170,7 @@ async function generate_zip() {
|
||||
|
||||
if(replacement_pos >= 0) {
|
||||
const head = out.slice(0, replacement_pos);
|
||||
const meat = steps[step_key].result[key];
|
||||
const meat = result[key];
|
||||
const tail = out.slice(replacement_pos + search_replacement.length);
|
||||
|
||||
out = head + meat + tail;
|
||||
|
Reference in New Issue
Block a user