2022-06-01 12:26:16 +02:00
|
|
|
<!--
|
|
|
|
Copyright: Ankitects Pty Ltd and contributors
|
|
|
|
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
-->
|
|
|
|
<script lang="ts">
|
|
|
|
import Spacer from "../components/Spacer.svelte";
|
|
|
|
import * as tr from "../lib/ftl";
|
|
|
|
import type { ImportExport } from "../lib/proto";
|
|
|
|
import type { ColumnOption } from "./lib";
|
|
|
|
import { getNotetypeFields } from "./lib";
|
|
|
|
import MapperRow from "./MapperRow.svelte";
|
|
|
|
|
|
|
|
export let columnOptions: ColumnOption[];
|
|
|
|
export let tagsColumn: number;
|
|
|
|
export let globalNotetype: ImportExport.CsvMetadata.MappedNotetype | null;
|
2022-08-07 17:01:25 +02:00
|
|
|
|
|
|
|
let lastNotetypeId: number | undefined = -1;
|
|
|
|
let fieldNamesPromise: Promise<string[]>;
|
|
|
|
|
|
|
|
$: if (globalNotetype?.id !== lastNotetypeId) {
|
|
|
|
lastNotetypeId = globalNotetype?.id;
|
|
|
|
fieldNamesPromise =
|
|
|
|
globalNotetype === null
|
|
|
|
? Promise.resolve([])
|
|
|
|
: getNotetypeFields(globalNotetype.id);
|
|
|
|
}
|
2022-06-01 12:26:16 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
{#if globalNotetype}
|
2022-08-07 17:01:25 +02:00
|
|
|
{#await fieldNamesPromise then fieldNames}
|
2022-06-01 12:26:16 +02:00
|
|
|
{#each fieldNames as label, idx}
|
|
|
|
<!-- first index is treated specially, because it must be assigned some column -->
|
|
|
|
<MapperRow
|
|
|
|
{label}
|
|
|
|
columnOptions={idx === 0 ? columnOptions.slice(1) : columnOptions}
|
|
|
|
bind:value={globalNotetype.fieldColumns[idx]}
|
|
|
|
/>
|
|
|
|
{/each}
|
|
|
|
{/await}
|
2022-06-09 02:28:01 +02:00
|
|
|
<Spacer --height="1.5rem" />
|
2022-06-01 12:26:16 +02:00
|
|
|
{/if}
|
|
|
|
<MapperRow label={tr.editingTags()} {columnOptions} bind:value={tagsColumn} />
|