diff --git a/db.go b/db.go index c08f144..7148be4 100644 --- a/db.go +++ b/db.go @@ -99,7 +99,7 @@ CREATE TABLE IF NOT EXISTS survey_quests( title VARCHAR(255), description TEXT, placeholder VARCHAR(255), - kind ENUM('text', 'int', 'ucq', 'mcq') NOT NULL, + kind ENUM('text', 'int', 'ucq', 'mcq', 'list', 'list1', 'list2', 'list3', 'list4', 'list5', 'list6', 'list7', 'list8', 'list9') NOT NULL, FOREIGN KEY(id_survey) REFERENCES surveys(id_survey) ) DEFAULT CHARACTER SET = utf8 COLLATE = utf8_bin; `); err != nil { diff --git a/ui/src/components/ListInput.svelte b/ui/src/components/ListInput.svelte new file mode 100644 index 0000000..05dfa82 --- /dev/null +++ b/ui/src/components/ListInput.svelte @@ -0,0 +1,43 @@ + + +{#each mval as v, i} + { value = mval.join('\n').trim(); dispatch("change"); }} + on:blur={() => { if (kind == "list" && i == mval.length - 1 && mval[i] == "") { mval.pop(); mval = mval; } }} + > +{/each} +{#if kind == "list" && (mval.length == 0 || mval[mval.length-1] != "")} + { mval.push(""); mval = mval; tick().then(() => document.getElementById(qid + "l" + (mval.length-1)).focus()); }} + > +{/if} diff --git a/ui/src/components/QuestionForm.svelte b/ui/src/components/QuestionForm.svelte index 4c7472d..dc3a884 100644 --- a/ui/src/components/QuestionForm.svelte +++ b/ui/src/components/QuestionForm.svelte @@ -1,6 +1,7 @@