Fix TextInputModal preset value
This commit is contained in:
parent
5cc6fc7d9b
commit
c074ca9159
@ -4,7 +4,10 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||||||
-->
|
-->
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import * as tr from "lib/i18n";
|
import * as tr from "lib/i18n";
|
||||||
|
import { getContext } from "svelte";
|
||||||
|
import { modalsKey } from "components/contextKeys";
|
||||||
import type { DeckOptionsState, ConfigListEntry } from "./lib";
|
import type { DeckOptionsState, ConfigListEntry } from "./lib";
|
||||||
|
import type Modal from "bootstrap/js/dist/modal";
|
||||||
|
|
||||||
import TextInputModal from "./TextInputModal.svelte";
|
import TextInputModal from "./TextInputModal.svelte";
|
||||||
import StickyBar from "components/StickyBar.svelte";
|
import StickyBar from "components/StickyBar.svelte";
|
||||||
@ -21,9 +24,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||||||
export let state: DeckOptionsState;
|
export let state: DeckOptionsState;
|
||||||
let configList = state.configList;
|
let configList = state.configList;
|
||||||
|
|
||||||
let addModalKey: string;
|
|
||||||
let renameModalKey: string;
|
|
||||||
|
|
||||||
function configLabel(entry: ConfigListEntry): string {
|
function configLabel(entry: ConfigListEntry): string {
|
||||||
const count = tr.deckConfigUsedByDecks({ decks: entry.useCount });
|
const count = tr.deckConfigUsedByDecks({ decks: entry.useCount });
|
||||||
return `${entry.name} (${count})`;
|
return `${entry.name} (${count})`;
|
||||||
@ -43,6 +43,21 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||||||
function onRenameConfig(text: string): void {
|
function onRenameConfig(text: string): void {
|
||||||
state.setCurrentName(text);
|
state.setCurrentName(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const modals = getContext<Map<string, Modal>>(modalsKey);
|
||||||
|
|
||||||
|
let addModalKey: string;
|
||||||
|
let renameModalKey: string;
|
||||||
|
let oldName = "";
|
||||||
|
|
||||||
|
function onAdd() {
|
||||||
|
modals.get(addModalKey)!.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
function onRename() {
|
||||||
|
oldName = state.getCurrentName();
|
||||||
|
modals.get(renameModalKey)!.show();
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<TextInputModal
|
<TextInputModal
|
||||||
@ -54,7 +69,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||||||
title="Rename Config"
|
title="Rename Config"
|
||||||
prompt="Name"
|
prompt="Name"
|
||||||
onOk={onRenameConfig}
|
onOk={onRenameConfig}
|
||||||
value={state.getCurrentName()}
|
value={oldName}
|
||||||
bind:modalKey={renameModalKey} />
|
bind:modalKey={renameModalKey} />
|
||||||
|
|
||||||
<StickyBar>
|
<StickyBar>
|
||||||
@ -77,7 +92,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||||||
</ButtonToolbarItem>
|
</ButtonToolbarItem>
|
||||||
|
|
||||||
<ButtonToolbarItem>
|
<ButtonToolbarItem>
|
||||||
<SaveButton {state} {addModalKey} {renameModalKey} />
|
<SaveButton {state} on:add={onAdd} on:rename={onRename} />
|
||||||
</ButtonToolbarItem>
|
</ButtonToolbarItem>
|
||||||
</ButtonToolbar>
|
</ButtonToolbar>
|
||||||
</WithTheming>
|
</WithTheming>
|
||||||
|
@ -4,10 +4,8 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||||||
-->
|
-->
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import * as tr from "lib/i18n";
|
import * as tr from "lib/i18n";
|
||||||
import { modalsKey } from "components/contextKeys";
|
import { createEventDispatcher } from "svelte";
|
||||||
import { getContext } from "svelte";
|
|
||||||
import type { DeckOptionsState } from "./lib";
|
import type { DeckOptionsState } from "./lib";
|
||||||
import type Modal from "bootstrap/js/dist/modal";
|
|
||||||
|
|
||||||
import ButtonGroup from "components/ButtonGroup.svelte";
|
import ButtonGroup from "components/ButtonGroup.svelte";
|
||||||
import ButtonGroupItem from "components/ButtonGroupItem.svelte";
|
import ButtonGroupItem from "components/ButtonGroupItem.svelte";
|
||||||
@ -18,9 +16,9 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||||||
import DropdownDivider from "components/DropdownDivider.svelte";
|
import DropdownDivider from "components/DropdownDivider.svelte";
|
||||||
import WithDropdownMenu from "components/WithDropdownMenu.svelte";
|
import WithDropdownMenu from "components/WithDropdownMenu.svelte";
|
||||||
|
|
||||||
export let state: DeckOptionsState;
|
const dispatch = createEventDispatcher();
|
||||||
|
|
||||||
const modals = getContext<Map<string, Modal>>(modalsKey);
|
export let state: DeckOptionsState;
|
||||||
|
|
||||||
function removeConfig(): void {
|
function removeConfig(): void {
|
||||||
// show pop-up after dropdown has gone away
|
// show pop-up after dropdown has gone away
|
||||||
@ -47,17 +45,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||||||
function save(applyToChildDecks: boolean): void {
|
function save(applyToChildDecks: boolean): void {
|
||||||
state.save(applyToChildDecks);
|
state.save(applyToChildDecks);
|
||||||
}
|
}
|
||||||
|
|
||||||
export let addModalKey: string;
|
|
||||||
export let renameModalKey: string;
|
|
||||||
|
|
||||||
function showAddModal() {
|
|
||||||
modals.get(addModalKey)!.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
function showRenameModal() {
|
|
||||||
modals.get(renameModalKey)!.show();
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ButtonGroup>
|
<ButtonGroup>
|
||||||
@ -69,8 +56,10 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||||||
<WithDropdownMenu let:createDropdown let:activateDropdown let:menuId>
|
<WithDropdownMenu let:createDropdown let:activateDropdown let:menuId>
|
||||||
<LabelButton on:mount={createDropdown} on:click={activateDropdown} />
|
<LabelButton on:mount={createDropdown} on:click={activateDropdown} />
|
||||||
<DropdownMenu id={menuId}>
|
<DropdownMenu id={menuId}>
|
||||||
<DropdownItem on:click={showAddModal}>Add Config</DropdownItem>
|
<DropdownItem on:click={() => dispatch('add')}>Add Config</DropdownItem>
|
||||||
<DropdownItem on:click={showRenameModal}>Rename Config</DropdownItem>
|
<DropdownItem on:click={() => dispatch('rename')}>
|
||||||
|
Rename Config
|
||||||
|
</DropdownItem>
|
||||||
<DropdownItem on:click={removeConfig}>Remove Config</DropdownItem>
|
<DropdownItem on:click={removeConfig}>Remove Config</DropdownItem>
|
||||||
<DropdownDivider />
|
<DropdownDivider />
|
||||||
<DropdownItem on:click={() => save(true)}>
|
<DropdownItem on:click={() => save(true)}>
|
||||||
|
@ -27,6 +27,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||||||
function onOkClicked(): void {
|
function onOkClicked(): void {
|
||||||
onOk(inputRef.value);
|
onOk(inputRef.value);
|
||||||
modal.hide();
|
modal.hide();
|
||||||
|
value = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
function onShown(): void {
|
function onShown(): void {
|
||||||
|
Loading…
Reference in New Issue
Block a user