Skip to content

Commit c0431fa

Browse files
committed
Added nanoid and have questions generate a small unique id to fix issue with previewing question with the same name.
1 parent 0c484bf commit c0431fa

File tree

4 files changed

+44
-15
lines changed

4 files changed

+44
-15
lines changed

Diff for: package-lock.json

+35-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"@deno/kv": "^0.7.0",
3535
"discord-api-types": "^0.37.67",
3636
"export-to-csv": "^1.2.2",
37+
"nanoid": "^5.1.0",
3738
"sortablejs": "^1.15.2",
3839
"ulid": "^2.3.0"
3940
}

Diff for: src/lib/components/form_editor/question_list_editor/add_item.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,29 @@
11
import { QuestionType } from '$lib/form';
22
import type { Question } from '$lib/form/form';
3+
import { nanoid } from 'nanoid';
34

45
export function makeBlankQuestion(type: QuestionType): Question {
6+
const id = nanoid(5);
7+
58
switch (type) {
69
case QuestionType.RADIO_GROUP:
710
return {
811
type,
9-
name: '',
12+
name: id,
1013
content: 'No content.',
1114
choices: []
1215
};
1316
case QuestionType.SELECT:
1417
return {
1518
type,
16-
name: '',
19+
name: id,
1720
content: 'No content.',
1821
options: []
1922
};
2023
default:
2124
return {
2225
type,
23-
name: '',
26+
name: id,
2427
content: 'No content.'
2528
};
2629
}

Diff for: src/lib/components/questions/base/base_editor.svelte

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
</fieldset>
2828

2929
<fieldset>
30-
<legend>Internal Question</legend>
31-
<input type="text" bind:value={data.name} placeholder="Internal Question Name" />
30+
<legend>Question ID</legend>
31+
<input type="text" bind:value={data.name} placeholder="Question ID" />
3232
</fieldset>
3333

3434
<fieldset>

0 commit comments

Comments
 (0)