From c3fc07ac20f5ae8aa839d3f48d5f4ec44092eab5 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Fri, 16 Apr 2021 23:29:21 +1000 Subject: [PATCH] more experimental updates to deck config screen - try out bootstrap modals - they're not perfect, but let's see how they go for now. Won't be hard to switch to bridge commands if required. - handle adding/renaming/removing - add a class to manage the state --- ts/deckconfig/BUILD.bazel | 47 +++++++- ts/deckconfig/ConfigEditor.svelte | 13 +-- ts/deckconfig/ConfigSelector.svelte | 28 +++-- ts/deckconfig/DeckConfigPage.svelte | 22 ++-- ts/deckconfig/GeneralOptions.svelte | 15 +-- ts/deckconfig/LapseOptions.svelte | 21 ++-- ts/deckconfig/NewOptions.svelte | 39 ++++--- ts/deckconfig/OptionsDropdown.svelte | 57 +++++++++- ts/deckconfig/ReviewOptions.svelte | 25 +++-- ts/deckconfig/TextInputModal.svelte | 93 ++++++++++++++++ ts/deckconfig/deckconfig-base.scss | 2 + ts/deckconfig/index.ts | 4 +- ts/deckconfig/lib.ts | 161 +++++++++++++++++++++++---- ts/deckconfig/textInputModal.ts | 23 ++++ ts/lib/BUILD.bazel | 1 - 15 files changed, 442 insertions(+), 109 deletions(-) create mode 100644 ts/deckconfig/TextInputModal.svelte create mode 100644 ts/deckconfig/textInputModal.ts diff --git a/ts/deckconfig/BUILD.bazel b/ts/deckconfig/BUILD.bazel index 48bc75add..7a5d4828b 100644 --- a/ts/deckconfig/BUILD.bazel +++ b/ts/deckconfig/BUILD.bazel @@ -5,10 +5,11 @@ load("//ts/svelte:svelte.bzl", "compile_svelte", "svelte", "svelte_check") load("//ts:esbuild.bzl", "esbuild") load("//ts:vendor.bzl", "copy_bootstrap_icons") load("//ts:compile_sass.bzl", "compile_sass") +load("@npm//jest-cli:index.bzl", "jest_test") compile_sass( - group = "base_css", srcs = ["deckconfig-base.scss"], + group = "base_css", visibility = ["//visibility:public"], deps = [ "//ts/sass:base_lib", @@ -24,6 +25,9 @@ svelte_names = [f.replace(".svelte", "") for f in svelte_files] compile_svelte( name = "svelte", srcs = svelte_files, + deps = [ + "@npm//@types/bootstrap", + ], ) copy_bootstrap_icons( @@ -50,12 +54,16 @@ ts_library( "icons.ts", "lib.ts", "steps.ts", + "textInputModal.ts", ], module_name = "deckconfig", deps = [ + "TextInputModal", "//ts:image_module_support", "//ts/lib", "//ts/lib:backend_proto", + "@npm//lodash-es", + "@npm//svelte", ], ) @@ -112,5 +120,40 @@ svelte_check( srcs = glob([ "*.ts", "*.svelte", - ]), + ]) + [ + "@npm//@types/bootstrap", + ], +) + +ts_library( + name = "test_lib", + srcs = glob(["*.test.ts"]), + tsconfig = "//ts:tsconfig.json", + deps = [ + ":lib", + "//ts/lib:backend_proto", + "@npm//@types/jest", + ], +) + +jest_test( + name = "test", + args = [ + "--no-cache", + "--no-watchman", + "--ci", + "--colors", + "--config", + "$(location //ts:jest.config.js)", + ], + data = [ + ":test_lib", + "//ts:jest.config.js", + "@npm//protobufjs", + ], + target_compatible_with = select({ + "@platforms//os:osx": [], + "@platforms//os:linux": [], + "//conditions:default": ["@platforms//os:linux"], + }), ) diff --git a/ts/deckconfig/ConfigEditor.svelte b/ts/deckconfig/ConfigEditor.svelte index a4ca85fa0..400f4d94a 100644 --- a/ts/deckconfig/ConfigEditor.svelte +++ b/ts/deckconfig/ConfigEditor.svelte @@ -3,14 +3,13 @@ Copyright: Ankitects Pty Ltd and contributors License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html -->
- - - - + + + +
diff --git a/ts/deckconfig/ConfigSelector.svelte b/ts/deckconfig/ConfigSelector.svelte index 52faf5219..990add066 100644 --- a/ts/deckconfig/ConfigSelector.svelte +++ b/ts/deckconfig/ConfigSelector.svelte @@ -4,16 +4,19 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html --> @@ -47,12 +50,15 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
- + {#each $configList as entry} + {/each} - +
diff --git a/ts/deckconfig/DeckConfigPage.svelte b/ts/deckconfig/DeckConfigPage.svelte index a6ae44078..84b181b50 100644 --- a/ts/deckconfig/DeckConfigPage.svelte +++ b/ts/deckconfig/DeckConfigPage.svelte @@ -3,24 +3,12 @@ Copyright: Ankitects Pty Ltd and contributors License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html --> + +
-
{tr.actionsOptionsFor({ val: state.deckName })}
+
{tr.actionsOptionsFor({ val: state.currentDeck.name })}
- + - +
diff --git a/ts/deckconfig/GeneralOptions.svelte b/ts/deckconfig/GeneralOptions.svelte index f91e93348..070c1fcd7 100644 --- a/ts/deckconfig/GeneralOptions.svelte +++ b/ts/deckconfig/GeneralOptions.svelte @@ -3,13 +3,14 @@ Copyright: Ankitects Pty Ltd and contributors License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html -->
@@ -21,23 +22,23 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html min={30} max={600} defaultValue={defaults.capAnswerTimeToSecs} - bind:value={config.capAnswerTimeToSecs} /> + bind:value={$config.capAnswerTimeToSecs} /> + bind:value={$config.showTimer} /> + bind:value={$config.disableAutoplay} /> + bind:value={$config.skipQuestionWhenReplayingAnswer} />
diff --git a/ts/deckconfig/LapseOptions.svelte b/ts/deckconfig/LapseOptions.svelte index 0c30a49dd..716a372da 100644 --- a/ts/deckconfig/LapseOptions.svelte +++ b/ts/deckconfig/LapseOptions.svelte @@ -3,15 +3,16 @@ Copyright: Ankitects Pty Ltd and contributors License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html --> @@ -23,8 +24,8 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html label="Relearning steps" subLabel="Relearning steps, separated by spaces." defaultValue={defaults.relearnSteps} - value={config.relearnSteps} - on:changed={(evt) => (config.relearnSteps = evt.detail.value)} /> + value={$config.relearnSteps} + on:changed={(evt) => ($config.relearnSteps = evt.detail.value)} /> (config.lapseMultiplier = evt.detail.value)} /> + value={$config.lapseMultiplier} + on:changed={(evt) => ($config.lapseMultiplier = evt.detail.value)} /> + bind:value={$config.minimumLapseInterval} /> + bind:value={$config.leechThreshold} /> + bind:value={$config.leechAction} /> diff --git a/ts/deckconfig/NewOptions.svelte b/ts/deckconfig/NewOptions.svelte index 077283685..1abb92a1b 100644 --- a/ts/deckconfig/NewOptions.svelte +++ b/ts/deckconfig/NewOptions.svelte @@ -3,16 +3,17 @@ Copyright: Ankitects Pty Ltd and contributors License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html -->
@@ -40,36 +44,37 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html subLabel="Learning steps, separated by spaces." warn={stepsExceedGraduatingInterval} defaultValue={defaults.learnSteps} - value={config.learnSteps} - on:changed={(evt) => (config.learnSteps = evt.detail.value)} /> + value={$config.learnSteps} + on:changed={(evt) => ($config.learnSteps = evt.detail.value)} /> + bind:value={$config.newCardOrder} /> + bind:value={$config.newPerDay} /> + bind:value={$config.graduatingIntervalGood} /> + bind:value={$config.graduatingIntervalEasy} /> (config.initialEase = evt.detail.value)} /> + value={$config.initialEase} + on:changed={(evt) => ($config.initialEase = evt.detail.value)} /> + bind:value={$config.buryNew} />
diff --git a/ts/deckconfig/OptionsDropdown.svelte b/ts/deckconfig/OptionsDropdown.svelte index 23d82d1b2..3dd6b7d59 100644 --- a/ts/deckconfig/OptionsDropdown.svelte +++ b/ts/deckconfig/OptionsDropdown.svelte @@ -2,6 +2,50 @@ Copyright: Ankitects Pty Ltd and contributors License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html --> + +