deckconfig->deckoptions
This commit is contained in:
parent
d6df6c0f89
commit
b485b8cbb9
@ -3,7 +3,7 @@ load("//ts:copy.bzl", "copy_files_into_group")
|
||||
_pages = [
|
||||
"graphs",
|
||||
"congrats",
|
||||
"deckconfig",
|
||||
"deckoptions",
|
||||
]
|
||||
|
||||
[copy_files_into_group(
|
||||
|
@ -32,7 +32,7 @@ class DeckOptionsDialog(QDialog):
|
||||
|
||||
self.web = AnkiWebView(title=self.TITLE)
|
||||
self.web.setVisible(False)
|
||||
self.web.load_ts_page("deckconfig")
|
||||
self.web.load_ts_page("deckoptions")
|
||||
layout = QVBoxLayout()
|
||||
layout.setContentsMargins(0, 0, 0, 0)
|
||||
layout.addWidget(self.web)
|
||||
@ -40,7 +40,7 @@ class DeckOptionsDialog(QDialog):
|
||||
|
||||
deck_id = self.mw.col.decks.get_current_id()
|
||||
self.web.eval(
|
||||
f"""const $deckOptions = anki.deckConfig(
|
||||
f"""const $deckOptions = anki.deckOptions(
|
||||
document.getElementById('main'), {deck_id});"""
|
||||
)
|
||||
gui_hooks.deck_options_did_load(self)
|
||||
|
@ -4,9 +4,9 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||
-->
|
||||
<script lang="ts">
|
||||
// import * as tr from "lib/i18n";
|
||||
import type { DeckConfigState } from "./lib";
|
||||
import type { DeckOptionsState } from "./lib";
|
||||
|
||||
export let state: DeckConfigState;
|
||||
export let state: DeckOptionsState;
|
||||
let components = state.addonComponents;
|
||||
</script>
|
||||
|
@ -8,7 +8,7 @@ load("//ts:compile_sass.bzl", "compile_sass")
|
||||
load("//ts:jest.bzl", "jest_test")
|
||||
|
||||
compile_sass(
|
||||
srcs = ["deckconfig-base.scss"],
|
||||
srcs = ["deckoptions-base.scss"],
|
||||
group = "base_css",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
@ -43,7 +43,7 @@ ts_library(
|
||||
name = "index",
|
||||
srcs = ["index.ts"],
|
||||
deps = [
|
||||
"DeckConfigPage",
|
||||
"DeckOptionsPage",
|
||||
"lib",
|
||||
"//ts/lib",
|
||||
"@npm//@popperjs",
|
||||
@ -59,7 +59,7 @@ ts_library(
|
||||
"steps.ts",
|
||||
"textInputModal.ts",
|
||||
],
|
||||
module_name = "deckconfig",
|
||||
module_name = "deckoptions",
|
||||
deps = [
|
||||
"TextInputModal",
|
||||
"//ts:image_module_support",
|
||||
@ -72,7 +72,7 @@ ts_library(
|
||||
)
|
||||
|
||||
esbuild(
|
||||
name = "deckconfig",
|
||||
name = "deckoptions",
|
||||
srcs = [
|
||||
"//ts:protobuf-shim.js",
|
||||
],
|
||||
@ -87,7 +87,7 @@ esbuild(
|
||||
external = [
|
||||
"protobufjs/light",
|
||||
],
|
||||
output_css = "deckconfig.css",
|
||||
output_css = "deckoptions.css",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"index",
|
||||
@ -100,7 +100,7 @@ esbuild(
|
||||
] + svelte_names,
|
||||
)
|
||||
|
||||
exports_files(["deckconfig.html"])
|
||||
exports_files(["deckoptions.html"])
|
||||
|
||||
# Tests
|
||||
################
|
@ -9,9 +9,9 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||
import LapseOptions from "./LapseOptions.svelte";
|
||||
import GeneralOptions from "./GeneralOptions.svelte";
|
||||
import Addons from "./Addons.svelte";
|
||||
import type { DeckConfigState } from "./lib";
|
||||
import type { DeckOptionsState } from "./lib";
|
||||
|
||||
export let state: DeckConfigState;
|
||||
export let state: DeckOptionsState;
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
@ -4,10 +4,10 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||
-->
|
||||
<script lang="ts">
|
||||
import * as tr from "lib/i18n";
|
||||
import type { DeckConfigState, ConfigListEntry } from "./lib";
|
||||
import type { DeckOptionsState, ConfigListEntry } from "./lib";
|
||||
import OptionsDropdown from "./OptionsDropdown.svelte";
|
||||
|
||||
export let state: DeckConfigState;
|
||||
export let state: DeckOptionsState;
|
||||
let configList = state.configList;
|
||||
|
||||
function configLabel(entry: ConfigListEntry): string {
|
@ -5,9 +5,9 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||
<script lang="ts">
|
||||
import * as tr from "lib/i18n";
|
||||
import SpinBox from "./SpinBox.svelte";
|
||||
import type { DeckConfigState } from "./lib";
|
||||
import type { DeckOptionsState } from "./lib";
|
||||
|
||||
export let state: DeckConfigState;
|
||||
export let state: DeckOptionsState;
|
||||
let config = state.currentConfig;
|
||||
let defaults = state.defaults;
|
||||
let parentLimits = state.parentLimits;
|
@ -5,13 +5,13 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||
<script lang="ts">
|
||||
import ConfigSelector from "./ConfigSelector.svelte";
|
||||
import ConfigEditor from "./ConfigEditor.svelte";
|
||||
import type { DeckConfigState } from "./lib";
|
||||
import type { DeckOptionsState } from "./lib";
|
||||
import { onMount, onDestroy } from "svelte";
|
||||
import { registerShortcut } from "lib/shortcuts";
|
||||
import type { Writable } from "svelte/store";
|
||||
import HtmlAddon from "./HtmlAddon.svelte";
|
||||
|
||||
export let state: DeckConfigState;
|
||||
export let state: DeckOptionsState;
|
||||
let addons = state.addonComponents;
|
||||
|
||||
export function auxData(): Writable<Record<string, unknown>> {
|
@ -6,9 +6,9 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||
import * as tr from "lib/i18n";
|
||||
import SpinBox from "./SpinBox.svelte";
|
||||
import CheckBox from "./CheckBox.svelte";
|
||||
import type { DeckConfigState } from "./lib";
|
||||
import type { DeckOptionsState } from "./lib";
|
||||
|
||||
export let state: DeckConfigState;
|
||||
export let state: DeckOptionsState;
|
||||
let config = state.currentConfig;
|
||||
let defaults = state.defaults;
|
||||
</script>
|
@ -8,9 +8,9 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||
import SpinBoxFloat from "./SpinBoxFloat.svelte";
|
||||
import StepsInput from "./StepsInput.svelte";
|
||||
import EnumSelector from "./EnumSelector.svelte";
|
||||
import type { DeckConfigState } from "./lib";
|
||||
import type { DeckOptionsState } from "./lib";
|
||||
|
||||
export let state: DeckConfigState;
|
||||
export let state: DeckOptionsState;
|
||||
let config = state.currentConfig;
|
||||
let defaults = state.defaults;
|
||||
|
@ -9,9 +9,9 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||
import CheckBox from "./CheckBox.svelte";
|
||||
import StepsInput from "./StepsInput.svelte";
|
||||
import EnumSelector from "./EnumSelector.svelte";
|
||||
import type { DeckConfigState } from "./lib";
|
||||
import type { DeckOptionsState } from "./lib";
|
||||
|
||||
export let state: DeckConfigState;
|
||||
export let state: DeckOptionsState;
|
||||
let config = state.currentConfig;
|
||||
let defaults = state.defaults;
|
||||
|
@ -5,9 +5,9 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||
<script lang="ts">
|
||||
import * as tr from "lib/i18n";
|
||||
import { textInputModal } from "./textInputModal";
|
||||
import type { DeckConfigState } from "./lib";
|
||||
import type { DeckOptionsState } from "./lib";
|
||||
|
||||
export let state: DeckConfigState;
|
||||
export let state: DeckOptionsState;
|
||||
|
||||
function addConfig(): void {
|
||||
textInputModal({
|
@ -7,9 +7,9 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||
import SpinBox from "./SpinBox.svelte";
|
||||
import SpinBoxFloat from "./SpinBoxFloat.svelte";
|
||||
import CheckBox from "./CheckBox.svelte";
|
||||
import type { DeckConfigState } from "./lib";
|
||||
import type { DeckOptionsState } from "./lib";
|
||||
|
||||
export let state: DeckConfigState;
|
||||
export let state: DeckOptionsState;
|
||||
let config = state.currentConfig;
|
||||
let defaults = state.defaults;
|
||||
</script>
|
@ -3,18 +3,18 @@
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" id="viewport" content="width=device-width" />
|
||||
<link href="deckconfig-base.css" rel="stylesheet" />
|
||||
<link href="deckconfig.css" rel="stylesheet" />
|
||||
<link href="deckoptions-base.css" rel="stylesheet" />
|
||||
<link href="deckoptions.css" rel="stylesheet" />
|
||||
<script src="../js/vendor/protobuf.min.js"></script>
|
||||
<script src="../js/vendor/bootstrap.bundle.min.js"></script>
|
||||
<script src="deckconfig.js"></script>
|
||||
<script src="deckoptions.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="main"></div>
|
||||
|
||||
<script>
|
||||
if (window.location.hash.startsWith("#test")) {
|
||||
anki.deckConfig(document.getElementById("main"), 1);
|
||||
anki.deckOptions(document.getElementById("main"), 1);
|
||||
}
|
||||
</script>
|
||||
</body>
|
@ -1,22 +1,22 @@
|
||||
// Copyright: Ankitects Pty Ltd and contributors
|
||||
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||
|
||||
import { getDeckConfigInfo, DeckConfigState } from "./lib";
|
||||
import { getDeckOptionsInfo, DeckOptionsState } from "./lib";
|
||||
import { setupI18n, ModuleName } from "lib/i18n";
|
||||
import { checkNightMode } from "lib/nightmode";
|
||||
import DeckConfigPage from "./DeckConfigPage.svelte";
|
||||
import DeckOptionsPage from "./DeckOptionsPage.svelte";
|
||||
|
||||
export async function deckConfig(
|
||||
export async function deckOptions(
|
||||
target: HTMLDivElement,
|
||||
deckId: number
|
||||
): Promise<DeckConfigPage> {
|
||||
): Promise<DeckOptionsPage> {
|
||||
checkNightMode();
|
||||
await setupI18n({
|
||||
modules: [ModuleName.SCHEDULING, ModuleName.ACTIONS, ModuleName.DECK_CONFIG],
|
||||
});
|
||||
const info = await getDeckConfigInfo(deckId);
|
||||
const state = new DeckConfigState(deckId, info);
|
||||
return new DeckConfigPage({
|
||||
const info = await getDeckOptionsInfo(deckId);
|
||||
const state = new DeckOptionsState(deckId, info);
|
||||
return new DeckOptionsPage({
|
||||
target,
|
||||
props: { state },
|
||||
});
|
@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
import * as pb from "lib/backend_proto";
|
||||
import { DeckConfigState } from "./lib";
|
||||
import { DeckOptionsState } from "./lib";
|
||||
import { get } from "svelte/store";
|
||||
|
||||
const exampleData = {
|
||||
@ -92,8 +92,8 @@ const exampleData = {
|
||||
},
|
||||
};
|
||||
|
||||
function startingState(): DeckConfigState {
|
||||
return new DeckConfigState(
|
||||
function startingState(): DeckOptionsState {
|
||||
return new DeckOptionsState(
|
||||
123,
|
||||
pb.BackendProto.DeckConfigsForUpdate.fromObject(exampleData)
|
||||
);
|
@ -12,7 +12,7 @@ import { isEqual, cloneDeep } from "lodash-es";
|
||||
import * as tr from "lib/i18n";
|
||||
import type { DynamicSvelteComponent } from "sveltelib/dynamicComponent";
|
||||
|
||||
export async function getDeckConfigInfo(
|
||||
export async function getDeckOptionsInfo(
|
||||
deckId: number
|
||||
): Promise<pb.BackendProto.DeckConfigsForUpdate> {
|
||||
return pb.BackendProto.DeckConfigsForUpdate.decode(
|
||||
@ -20,7 +20,7 @@ export async function getDeckConfigInfo(
|
||||
);
|
||||
}
|
||||
|
||||
export async function saveDeckConfig(
|
||||
export async function saveDeckOptions(
|
||||
input: pb.BackendProto.UpdateDeckConfigsIn
|
||||
): Promise<void> {
|
||||
const data: Uint8Array = pb.BackendProto.UpdateDeckConfigsIn.encode(input).finish();
|
||||
@ -28,7 +28,7 @@ export async function saveDeckConfig(
|
||||
return;
|
||||
}
|
||||
|
||||
export type DeckConfigId = number;
|
||||
export type DeckOptionsId = number;
|
||||
|
||||
export interface ConfigWithCount {
|
||||
config: pb.BackendProto.DeckConfig;
|
||||
@ -49,7 +49,7 @@ export interface ConfigListEntry {
|
||||
}
|
||||
|
||||
type ConfigInner = pb.BackendProto.DeckConfig.Config;
|
||||
export class DeckConfigState {
|
||||
export class DeckOptionsState {
|
||||
readonly currentConfig: Writable<ConfigInner>;
|
||||
readonly currentAuxData: Writable<Record<string, unknown>>;
|
||||
readonly configList: Readable<ConfigListEntry[]>;
|
||||
@ -63,8 +63,8 @@ export class DeckConfigState {
|
||||
private selectedIdx: number;
|
||||
private configListSetter!: (val: ConfigListEntry[]) => void;
|
||||
private parentLimitsSetter!: (val: ParentLimits) => void;
|
||||
private modifiedConfigs: Set<DeckConfigId> = new Set();
|
||||
private removedConfigs: DeckConfigId[] = [];
|
||||
private modifiedConfigs: Set<DeckOptionsId> = new Set();
|
||||
private removedConfigs: DeckOptionsId[] = [];
|
||||
private schemaModified: boolean;
|
||||
|
||||
constructor(targetDeckId: number, data: pb.BackendProto.DeckConfigsForUpdate) {
|
||||
@ -195,7 +195,7 @@ export class DeckConfigState {
|
||||
}
|
||||
|
||||
async save(applyToChildren: boolean): Promise<void> {
|
||||
await saveDeckConfig(this.dataForSaving(applyToChildren));
|
||||
await saveDeckOptions(this.dataForSaving(applyToChildren));
|
||||
}
|
||||
|
||||
private onCurrentConfigChanged(config: ConfigInner): void {
|
@ -48,7 +48,7 @@ def jest_test(deps, name = "jest", protobuf = False):
|
||||
deps = [
|
||||
name + "_lib",
|
||||
] + deps,
|
||||
# the code shaking saves close to a second off the deckconfig/lib.test.ts test
|
||||
# the code shaking saves close to a second off the deckoptions/lib.test.ts test
|
||||
minify = True,
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user