Skip to content

Commit ec65b5c

Browse files
authored
Merge pull request #20 from acmcsufoss/sortable-moment
Form Editor Improvements
2 parents b97f5b9 + 53b4c78 commit ec65b5c

File tree

57 files changed

+1146
-162
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1146
-162
lines changed

.github/workflows/check.yaml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99

1010
jobs:
1111
check:
12+
name: Check
1213
runs-on: ubuntu-latest
1314

1415
strategy:
@@ -48,5 +49,21 @@ jobs:
4849
- name: Format
4950
run: npm run format && git diff --exit-code
5051

51-
- name: Lint
52+
lint:
53+
name: lint
54+
runs-on: ubuntu-latest
55+
56+
steps:
57+
- name: Checkout
58+
uses: actions/checkout@v3
59+
60+
- name: Setup Node
61+
uses: actions/setup-node@v3
62+
with:
63+
node-version: 21.x
64+
65+
- name: Install Dependencies
66+
run: npm ci
67+
68+
- name: Run Lint
5269
run: npm run lint && git diff --exit-code

db.kv

4 KB
Binary file not shown.

db.kv-shm

32 KB
Binary file not shown.

db.kv-wal

145 KB
Binary file not shown.

package-lock.json

Lines changed: 59 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"devDependencies": {
1616
"@sveltejs/adapter-auto": "^2.0.0",
1717
"@sveltejs/kit": "^1.20.4",
18+
"@types/sortablejs": "^1.15.8",
1819
"@typescript-eslint/eslint-plugin": "^6.0.0",
1920
"@typescript-eslint/parser": "^6.0.0",
2021
"eslint": "^8.28.0",
@@ -33,6 +34,8 @@
3334
"@deno/kv": "^0.7.0",
3435
"discord-api-types": "^0.37.67",
3536
"export-to-csv": "^1.2.2",
37+
"nanoid": "^5.1.0",
38+
"sortablejs": "^1.15.2",
3639
"ulid": "^2.3.0"
3740
}
3841
}

src/lib/components/form/form.svelte

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<script lang="ts">
2-
import type { User, Form } from '$lib/store';
2+
import type * as db from '$lib/db';
33
import QuestionInput from '$lib/components/question_input/question_input.svelte';
44
55
export let action = '';
66
export let method = 'POST';
7-
export let data: Form;
8-
export let user: User | undefined = undefined;
7+
export let data: db.Form;
8+
export let user: db.User | undefined = undefined;
99
1010
if (data.questions.shuffled) {
1111
data.questions.data = data.questions.data.sort(() => Math.random() - 0.5);
@@ -121,13 +121,6 @@
121121
font-weight: 400;
122122
}
123123
124-
:global(.Question-Header) {
125-
font-size: 13px;
126-
font-weight: bold;
127-
margin-bottom: 10px;
128-
font-family: 'Poppins';
129-
}
130-
131124
:global(.question) {
132125
padding: 20px 15px;
133126
width: calc(100% - 30px);

src/lib/components/form_editor/form_editor.svelte

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
11
<script lang="ts">
2-
import type { Form } from '$lib/store';
3-
import { QuestionType } from '$lib/form';
2+
import type { Form } from '$lib/form';
3+
import { QuestionType, type QuestionList } from '$lib/form';
44
import QuestionInput from '$lib/components/question_input/question_input.svelte';
55
import QuestionListEditor from './question_list_editor/question_list_editor.svelte';
66
77
export let action: string;
88
export let method: string;
99
export let value: Form;
1010
11+
var questions: QuestionList = value.questions;
1112
// TODO: Add discord data: channels, threads, guilds, roles.
13+
14+
// Uncalled function so commented out for now.
15+
// function addItem() {
16+
// questions.append();
17+
// }
18+
function handleSumbit(event: MouseEvent) {
19+
event.preventDefault();
20+
console.log(questions);
21+
}
1222
</script>
1323

1424
<form {action} {method}>
@@ -65,9 +75,8 @@
6575
bind:value={value.questions.shuffled}
6676
/>
6777

68-
<QuestionListEditor bind:value={value.questions} />
69-
70-
<button type="submit">Submit</button>
78+
<QuestionListEditor bind:value={questions} />
79+
<button type="submit" on:click={handleSumbit}>Submit</button>
7180
</form>
7281

7382
<style>
@@ -79,4 +88,38 @@
7988
margin: 0 auto;
8089
max-width: 400px;
8190
}
91+
:global(fieldset) {
92+
border: none;
93+
min-width: 0;
94+
margin: 10px;
95+
padding: 0px;
96+
max-width: calc(100% - 20px);
97+
width: 100%;
98+
display: block;
99+
}
100+
:global(legend) {
101+
font-size: 13px;
102+
font-weight: bold;
103+
margin-bottom: 10px;
104+
font-family: 'Poppins';
105+
}
106+
107+
:global(.question) {
108+
padding: 20px 15px;
109+
width: calc(100% - 30px);
110+
margin: 10px auto;
111+
background-color: #ffffff;
112+
border-radius: 10px;
113+
border-color: #c5c8c9;
114+
border-width: 0;
115+
border-style: solid;
116+
}
117+
118+
/* :global(label) {
119+
display: flex;
120+
} */
121+
122+
:global(input) {
123+
display: flex;
124+
}
82125
</style>
Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,52 @@
11
<script lang="ts">
2-
// import type { Question } from '$lib/form';
3-
// import QuestionInput from '$lib/components/form/question_input/question_input.svelte';
2+
import type { Question } from '$lib/form';
3+
import { QuestionType } from '$lib/form';
4+
import AvailabilityQuestionInputEditor from '$lib/components/questions/availability/availability_question_input_editor.svelte';
5+
import BooleanQuestionInputEditor from '$lib/components/questions/boolean/boolean_question_input_editor.svelte';
6+
import ColorQuestionInputEditor from '$lib/components/questions/color/color_question_input_editor.svelte';
7+
import DateQuestionInputEditor from '$lib/components/questions/date/date_question_input_editor.svelte';
8+
import DatetimeQuestionInputEditor from '$lib/components/questions/datetime/datetime_question_input_editor.svelte';
9+
import NumberQuestionInputEditor from '$lib/components/questions/number/number_question_input_editor.svelte';
10+
import RadioGroupQuestionInputEditor from '$lib/components/questions/radio_group/radio_group_question_input_editor.svelte';
11+
import SelectQuestionInputEditor from '$lib/components/questions/select/select_question_input_editor.svelte';
12+
import TextQuestionInputEditor from '$lib/components/questions/text/text_question_input_editor.svelte';
13+
import TextareaQuestionInputEditor from '$lib/components/questions/textarea/textarea_question_input_editor.svelte';
14+
import TimeQuestionInputEditor from '$lib/components/questions/time/time_question_input_editor.svelte';
415
5-
// export let value: Question;
16+
export var data: Question;
617
</script>
718

819
<!-- TODO: Reconcile changes made in
920
https://github.com/acmcsufoss/form/pull/new/question-input-editor -->
1021

1122
<!-- TODO: Make a new PR out of this current branch. -->
23+
24+
<!-- Uncomment finished questions to see if it renders -->
25+
<div>
26+
{#if data.type === QuestionType.BOOLEAN}
27+
<BooleanQuestionInputEditor bind:data />
28+
{:else if data.type === QuestionType.COLOR}
29+
<ColorQuestionInputEditor bind:data />
30+
{:else if data.type === QuestionType.NUMBER}
31+
<NumberQuestionInputEditor bind:data />
32+
{:else if data.type === QuestionType.TEXT}
33+
<TextQuestionInputEditor bind:data />
34+
{:else if data.type === QuestionType.TEXTAREA}
35+
<TextareaQuestionInputEditor bind:data />
36+
{:else if data.type === QuestionType.DATE}
37+
<DateQuestionInputEditor bind:data />
38+
{:else if data.type === QuestionType.DATETIME}
39+
<DatetimeQuestionInputEditor bind:data />
40+
{:else if data.type === QuestionType.TIME}
41+
<TimeQuestionInputEditor bind:data />
42+
{:else if data.type === QuestionType.RADIO_GROUP}
43+
<RadioGroupQuestionInputEditor bind:data />
44+
{:else if data.type === QuestionType.AVAILABILITY}
45+
<AvailabilityQuestionInputEditor bind:data />
46+
{:else if data.type === QuestionType.SELECT}
47+
<SelectQuestionInputEditor bind:data />
48+
{/if}
49+
</div>
50+
51+
<style>
52+
</style>

src/lib/components/form_editor/question_list_editor/add_item.svelte

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
<script lang="ts">
22
import { QuestionType } from '$lib/form';
33
import type { AddItemProps } from '$lib/components/list_input/list_input';
4+
import { makeBlankQuestion } from './add_item';
45
56
export let addAction: AddItemProps['addAction'];
67
78
let type = QuestionType.TEXT;
89
9-
function add() {
10-
// TODO: Add a helper function to create a blank question object for each type.
11-
addAction({ type });
10+
function add(e: MouseEvent) {
11+
e.preventDefault();
12+
addAction(makeBlankQuestion(type));
1213
}
1314
1415
// function makeDefault(type: QuestionType): Question {
@@ -31,4 +32,4 @@
3132
<option value={QuestionType.AVAILABILITY}>Availability</option>
3233
</select>
3334

34-
<button on:click={add}>Add</button>
35+
<button type="button" on:click={add}>Add</button>

0 commit comments

Comments
 (0)