anki/ts/ChangeNotetype/MapperRow.svelte
Damien Elmes 61e86cc29d new change notetype implementation for the frontend
- changes can now be undone
- the same field can now be mapped to multiple target fields, allowing
fields to be cloned
- the old Qt dialog has been removed
- the old col.models.change() API calls the new code, to avoid
breaking existing consumers. It requires the field map to always
be passed in, but that appears to have been the common case.
- closes #1175
2021-06-10 22:19:24 +10:00

37 lines
1.0 KiB
Svelte

<!--
Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="ts">
import type { ChangeNotetypeState, MapContext } from "./lib";
export let state: ChangeNotetypeState;
export let ctx: MapContext;
export let newIndex: number;
let info = state.info;
function onChange(evt: Event) {
const oldIdx = parseInt((evt.target as HTMLSelectElement).value, 10);
state.setOldIndex(ctx, newIndex, oldIdx);
}
</script>
<div class="row">
<div class="col">
<!-- svelte-ignore a11y-no-onchange -->
<select
value={$info.getOldIndex(ctx, newIndex)}
class="form-select"
on:change={onChange}
>
{#each $info.getOldNamesIncludingNothing(ctx) as name, idx}
<option value={idx}>{name}</option>
{/each}
</select>
</div>
<div class="col align-self-center">
{$info.getNewName(ctx, newIndex)}
</div>
</div>