Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Form Editor Improvements #20

Draft
wants to merge 50 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
a2d70b4
testing
AlexthePear Feb 28, 2024
0051eb4
Merge branch 'main' into ap
AlexthePear Mar 21, 2024
bd7db62
Implemented Demo_form_editor to display editor components.
AlexthePear Mar 21, 2024
a602b35
Testing reactivity
AlexthePear Mar 26, 2024
3cc2108
- Created BaseEditor w/ slot at the end to
keillor Apr 1, 2024
c52dbe8
Finished Color Question
AlexthePear Apr 1, 2024
a9b9f1a
added exports and binds where I could
AlexthePear Apr 1, 2024
dd83299
did it for radio_group_question
AlexthePear Apr 1, 2024
e12a528
Added some slight styling
AlexthePear Apr 1, 2024
1159116
Added NumberQuestionInputEditor to render on demoFormEditor
AlexthePear Apr 1, 2024
cc1ffc4
minor improvements and re'form'atting
AlexthePear Apr 9, 2024
00c6ebe
Fixed Timezone
AlexthePear Apr 9, 2024
6e52537
added fieldset to color
keillor Apr 11, 2024
71648c0
TextQuestion
keillor Apr 11, 2024
26bdc86
created textarea w/ fieldset
keillor Apr 11, 2024
34b4d6b
added regular date question
keillor Apr 11, 2024
935563a
created date question
keillor Apr 11, 2024
86a8bab
created datetime editor
keillor Apr 11, 2024
a1a7200
added datetime to demo questions
keillor Apr 11, 2024
de0194e
added sample time question
keillor Apr 11, 2024
b523f15
more uncommented questions
keillor Apr 11, 2024
281e629
created time question input editor
keillor Apr 11, 2024
72ad826
fixed number input editor
keillor Apr 11, 2024
f44ffcd
Merge branch 'ap' into kj
AlexthePear Apr 11, 2024
686e133
Merge pull request #19 from acmcsufoss/kj
AlexthePear Apr 11, 2024
6d26cdb
make list input reactive
EthanThatOneKid Apr 12, 2024
b81d20c
install sortablejs
EthanThatOneKid Apr 12, 2024
0b402b1
wip
EthanThatOneKid Apr 12, 2024
276d87f
add `makeBlankQuestion` helper function
EthanThatOneKid Apr 12, 2024
f4207c2
Update list_input.svelte
EthanThatOneKid Apr 12, 2024
8fc254b
Merge branch 'sortable-moment' of https://github.com/acmcsufoss/form …
EthanThatOneKid Apr 12, 2024
2c0551e
fix svelte check errors
EthanThatOneKid Apr 12, 2024
8b00d82
WIP
AlexthePear Apr 12, 2024
e46e8f4
Fixed error with timezone_question_input still using data.defualt ins…
AlexthePear Apr 11, 2024
73e300a
left a note for delete_item.svelte
AlexthePear Apr 13, 2024
0f4ac5f
Added comment to list_input editor and some styling for question editor
AlexthePear Apr 13, 2024
b8fe977
wip
EthanThatOneKid Apr 18, 2024
3d19fc9
cringe
EthanThatOneKid Apr 18, 2024
9f88790
Fixed reactivity for list_input.svelte
AlexthePear Apr 18, 2024
b2c05c1
WIP: Select Question using ListInput
AlexthePear Apr 18, 2024
62e20c6
Fixed Select Question not having its option be reactive, WIP: Availab…
AlexthePear Apr 27, 2024
3f8ae5f
WIP
AlexthePear Apr 30, 2024
4f9b185
WIP: Tab-like system for question editors
AlexthePear Apr 30, 2024
bc6b054
Fixed issue with only having only allowing one tab open at a time for…
AlexthePear May 1, 2024
67e40e6
Created choice editor to help questions that have list of choices edi…
AlexthePear May 1, 2024
b3c1216
Did some slight styling changes
AlexthePear May 1, 2024
8b19dc4
allowed question_input to render TimezoneQuestionInput
AlexthePear May 2, 2024
851fe08
commented out extra QuestionInput "Shuffled"
AlexthePear May 2, 2024
67e9556
Minor styling tweaks
AlexthePear May 2, 2024
5edbecb
fixed choices errors
AlexthePear Oct 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added db.kv
Binary file not shown.
Binary file added db.kv-shm
Binary file not shown.
Binary file added db.kv-wal
Binary file not shown.
24 changes: 24 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"devDependencies": {
"@sveltejs/adapter-auto": "^2.0.0",
"@sveltejs/kit": "^1.20.4",
"@types/sortablejs": "^1.15.8",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"eslint": "^8.28.0",
Expand All @@ -33,6 +34,7 @@
"@deno/kv": "^0.7.0",
"discord-api-types": "^0.37.67",
"export-to-csv": "^1.2.2",
"sortablejs": "^1.15.2",
"ulid": "^2.3.0"
}
}
13 changes: 3 additions & 10 deletions src/lib/components/form/form.svelte
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<script lang="ts">
import type { User, Form } from '$lib/store';
import type * as db from '$lib/db';
import QuestionInput from '$lib/components/question_input/question_input.svelte';

export let action = '';
export let method = 'POST';
export let data: Form;
export let user: User | undefined = undefined;
export let data: db.Form;
export let user: db.User | undefined = undefined;

if (data.questions.shuffled) {
data.questions.data = data.questions.data.sort(() => Math.random() - 0.5);
Expand Down Expand Up @@ -121,13 +121,6 @@
font-weight: 400;
}

:global(.Question-Header) {
font-size: 13px;
font-weight: bold;
margin-bottom: 10px;
font-family: 'Poppins';
}

:global(.question) {
padding: 20px 15px;
width: calc(100% - 30px);
Expand Down
54 changes: 49 additions & 5 deletions src/lib/components/form_editor/form_editor.svelte
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
<script lang="ts">
import type { Form } from '$lib/store';
import { QuestionType } from '$lib/form';
import type { Form } from '$lib/form';
import { QuestionType, type QuestionList } from '$lib/form';
import QuestionInput from '$lib/components/question_input/question_input.svelte';
import QuestionListEditor from './question_list_editor/question_list_editor.svelte';
import BaseEditor from '../questions/base/base_editor.svelte';
import BooleanQuestionInputEditor from '../questions/boolean/boolean_question_input_editor.svelte';
import QuestionInputEditor from './question_input_editor/question_input_editor.svelte';

export let action: string;
export let method: string;
export let value: Form;

var questions: any = value.questions;
// TODO: Add discord data: channels, threads, guilds, roles.
function addItem() {
questions.append();
}
function handleSumbit(event: MouseEvent) {
event.preventDefault();
console.log(questions);
}
</script>

<form {action} {method}>
Expand Down Expand Up @@ -65,9 +76,8 @@
bind:value={value.questions.shuffled}
/>

<QuestionListEditor bind:value={value.questions} />

<button type="submit">Submit</button>
<QuestionListEditor bind:value={questions} />
<button type="submit" on:click={handleSumbit}>Submit</button>
</form>

<style>
Expand All @@ -79,4 +89,38 @@
margin: 0 auto;
max-width: 400px;
}
:global(fieldset) {
border: none;
min-width: 0;
margin: 10px;
padding: 0px;
max-width: calc(100% - 20px);
width: 100%;
display: block;
}
:global(legend) {
font-size: 13px;
font-weight: bold;
margin-bottom: 10px;
font-family: 'Poppins';
}

:global(.question) {
padding: 20px 15px;
width: calc(100% - 30px);
margin: 10px auto;
background-color: #ffffff;
border-radius: 10px;
border-color: #c5c8c9;
border-width: 0;
border-style: solid;
}

/* :global(label) {
display: flex;
} */

:global(input) {
display: flex;
}
</style>
Original file line number Diff line number Diff line change
@@ -1,11 +1,52 @@
<script lang="ts">
// import type { Question } from '$lib/form';
// import QuestionInput from '$lib/components/form/question_input/question_input.svelte';
import { QuestionType } from '$lib/form';
import AvailabilityQuestionInputEditor from '$lib/components/questions/availability/availability_question_input_editor.svelte';
import BooleanQuestionInputEditor from '$lib/components/questions/boolean/boolean_question_input_editor.svelte';
import ColorQuestionInputEditor from '$lib/components/questions/color/color_question_input_editor.svelte';
import DateQuestionInputEditor from '$lib/components/questions/date/date_question_input_editor.svelte';
import DatetimeQuestionInputEditor from '$lib/components/questions/datetime/datetime_question_input_editor.svelte';
import NumberQuestionInputEditor from '$lib/components/questions/number/number_question_input_editor.svelte';
import RadioGroupQuestionInputEditor from '$lib/components/questions/radio_group/radio_group_question_input_editor.svelte';
import SelectQuestionInputEditor from '$lib/components/questions/select/select_question_input_editor.svelte';
import TextQuestionInputEditor from '$lib/components/questions/text/text_question_input_editor.svelte';
import TextareaQuestionInputEditor from '$lib/components/questions/textarea/textarea_question_input_editor.svelte';
import TimeQuestionInputEditor from '$lib/components/questions/time/time_question_input_editor.svelte';
import BooleanQuestionInput from '$lib/components/questions/boolean/boolean_question_input.svelte';

// export let value: Question;
export var data: any;
</script>

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

<!-- TODO: Make a new PR out of this current branch. -->

<!-- Uncomment finished questions to see if it renders -->
<div>
{#if data.type === QuestionType.BOOLEAN}
<BooleanQuestionInputEditor bind:data />
{:else if data.type === QuestionType.COLOR}
<ColorQuestionInputEditor bind:data />
{:else if data.type === QuestionType.NUMBER}
<NumberQuestionInputEditor bind:data />
{:else if data.type === QuestionType.TEXT}
<TextQuestionInputEditor bind:data />
{:else if data.type === QuestionType.TEXTAREA}
<TextareaQuestionInputEditor bind:data />
{:else if data.type === QuestionType.DATE}
<DateQuestionInputEditor bind:data />
{:else if data.type === QuestionType.DATETIME}
<DatetimeQuestionInputEditor bind:data />
{:else if data.type === QuestionType.TIME}
<TimeQuestionInputEditor bind:data />
{:else if data.type === QuestionType.RADIO_GROUP}
<RadioGroupQuestionInputEditor bind:data />
{:else if data.type === QuestionType.AVAILABILITY}
<AvailabilityQuestionInputEditor bind:data />
{:else if data.type === QuestionType.SELECT}
<SelectQuestionInputEditor bind:data />
{/if}
</div>

<style>
</style>
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<script lang="ts">
import { QuestionType } from '$lib/form';
import type { AddItemProps } from '$lib/components/list_input/list_input';
import { makeBlankQuestion } from './add_item';

export let addAction: AddItemProps['addAction'];

let type = QuestionType.TEXT;

function add() {
// TODO: Add a helper function to create a blank question object for each type.
addAction({ type });
function add(e: MouseEvent) {
e.preventDefault();
addAction(makeBlankQuestion(type));
}

// function makeDefault(type: QuestionType): Question {
Expand Down
10 changes: 10 additions & 0 deletions src/lib/components/form_editor/question_list_editor/add_item.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { QuestionBase, QuestionType } from '$lib/form';

export function makeBlankQuestion(type: QuestionType): QuestionBase {
return {
type,
name: '',
content: 'No content.',
required: false
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,14 @@
export let deleteAction: DeleteItemProps['deleteAction'];
</script>

<!-- TODO: stop this button from firing when the user hits the enter key -->
<!-- With the enter key still inactive its very easy to accidentally delete a question. -->
<!-- Some inputs may also use an enter such as text area if the user writes mutliple paragraphs -->
<button on:click={() => deleteAction()}>Delete</button>

<style>
button {
position: absolute;
transform: translateX(-120%) translateY(-250%);
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
export let value: QuestionList;
</script>

<QuestionInput
<!-- <QuestionInput
type={QuestionType.BOOLEAN}
name="shuffled"
content="Shuffled"
bind:value={value.shuffled}
/>
/> -->

<!-- TODO: Figure out how to handle indexed names for the items in the list if needed. -->

Expand Down
Loading
Loading