From c7b148d8b8e29e1a75f8e8f59275aecd3dc263cf Mon Sep 17 00:00:00 2001 From: Mawoka Date: Wed, 20 Dec 2023 16:23:14 +0100 Subject: [PATCH] :sparkles: Closes #321 --- frontend/.eslintrc.cjs | 10 +- frontend/src/lib/editor/sidebar.svelte | 538 +++++++++++++++---------- frontend/src/lib/i18n/locales/en.json | 4 +- 3 files changed, 332 insertions(+), 220 deletions(-) diff --git a/frontend/.eslintrc.cjs b/frontend/.eslintrc.cjs index d91269f1..3aeb85a0 100644 --- a/frontend/.eslintrc.cjs +++ b/frontend/.eslintrc.cjs @@ -8,7 +8,15 @@ module.exports = { extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'], plugins: ['svelte3', '@typescript-eslint'], ignorePatterns: ['*.cjs'], - overrides: [{ files: ['*.svelte'], processor: 'svelte3/svelte3' }], + overrides: [ + { files: ['*.svelte'], processor: 'svelte3/svelte3' }, + { + files: ['*.*'], + rules: { + 'a11y-click-events-have-key-events': 'off' + } + } + ], rules: { 'no-unused-vars': ['error', { argsIgnorePattern: '^_' }], '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }] diff --git a/frontend/src/lib/editor/sidebar.svelte b/frontend/src/lib/editor/sidebar.svelte index 329c1e6c..b28d88aa 100644 --- a/frontend/src/lib/editor/sidebar.svelte +++ b/frontend/src/lib/editor/sidebar.svelte @@ -12,12 +12,16 @@ SPDX-License-Identifier: MPL-2.0 import { createTippy } from 'svelte-tippy'; import { getLocalization } from '$lib/i18n'; import AddNewQuestionPopup from '$lib/editor/AddNewQuestionPopup.svelte'; + import BrownButton from '$lib/components/buttons/brown.svelte'; + import { fade } from 'svelte/transition'; const { t } = getLocalization(); export let data: EditorData; export let selected_question = -1; + let reorder_mode = false; + const tippy = createTippy({ arrow: true, animation: 'perspective-subtle', @@ -35,7 +39,18 @@ SPDX-License-Identifier: MPL-2.0 answers: '' }; + const swapArrayElements = (arr, a: number, b: number) => { + let _arr = [...arr]; + let temp = _arr[a]; + _arr[a] = _arr[b]; + _arr[b] = temp; + return _arr; + }; + const setSelectedQuestion = (index: number): void => { + if (reorder_mode) { + return; + } selected_question = index; if (index === -1) { propertyCard.scrollIntoView({ @@ -54,60 +69,195 @@ SPDX-License-Identifier: MPL-2.0 });*/ -
-
setSelectedQuestion(-1)} - > -
-

+

+
+ (reorder_mode = !reorder_mode)} + >{#if reorder_mode}{$t('editor.disable_reorder')}{:else}{$t( + 'editor.enable_reorder' + )}{/if} - {#if data.title} - {@html data.title} - {:else} - {$t('editor.no_title')} - {/if} -

+
+
setSelectedQuestion(-1)} > -