850043b49b
* Make enum selector generic * Refactor ImportCsvPage to support tooltips * Improve csv import defaults * Unify import pages * Improve import page styling * Fix life cycle issue with import properties * Remove size constraints to fix scrollbar styling * Add help strings and urls to csv import page * Show ErrorPage on ImportPage error * Fix escaping of import path * Unify ImportPage and ImportLogPage * Apply suggestions from code review (dae) * Fix import progress * Fix preview overflowing container * Don't include <br> in FileIoErrors (dae) e.g. 500: Failed to read '/home/dae/foo2.csv':<br>stream did not contain valid UTF-8 I thought about using {@html ...} here, but that's a potential security issue, as the filename is not something we control.
55 lines
1.7 KiB
TypeScript
55 lines
1.7 KiB
TypeScript
// Copyright: Ankitects Pty Ltd and contributors
|
|
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
import {
|
|
CsvMetadata_Delimiter,
|
|
CsvMetadata_DupeResolution,
|
|
CsvMetadata_MatchScope,
|
|
} from "@tslib/anki/import_export_pb";
|
|
import * as tr from "@tslib/ftl";
|
|
import type { Choice } from "components/EnumSelector.svelte";
|
|
|
|
export function delimiterChoices(): Choice<CsvMetadata_Delimiter>[] {
|
|
return [
|
|
{
|
|
label: tr.importingTab(),
|
|
value: CsvMetadata_Delimiter.TAB,
|
|
},
|
|
{
|
|
label: tr.importingPipe(),
|
|
value: CsvMetadata_Delimiter.PIPE,
|
|
},
|
|
{
|
|
label: tr.importingSemicolon(),
|
|
value: CsvMetadata_Delimiter.SEMICOLON,
|
|
},
|
|
{
|
|
label: tr.importingColon(),
|
|
value: CsvMetadata_Delimiter.COLON,
|
|
},
|
|
{
|
|
label: tr.importingComma(),
|
|
value: CsvMetadata_Delimiter.COMMA,
|
|
},
|
|
{
|
|
label: tr.studyingSpace(),
|
|
value: CsvMetadata_Delimiter.SPACE,
|
|
},
|
|
];
|
|
}
|
|
|
|
export function dupeResolutionChoices(): Choice<CsvMetadata_DupeResolution>[] {
|
|
return [
|
|
{ label: tr.importingUpdate(), value: CsvMetadata_DupeResolution.UPDATE },
|
|
{ label: tr.importingPreserve(), value: CsvMetadata_DupeResolution.PRESERVE },
|
|
{ label: tr.importingDuplicate(), value: CsvMetadata_DupeResolution.DUPLICATE },
|
|
];
|
|
}
|
|
|
|
export function matchScopeChoices(): Choice<CsvMetadata_MatchScope>[] {
|
|
return [
|
|
{ label: tr.notetypesNotetype(), value: CsvMetadata_MatchScope.NOTETYPE },
|
|
{ label: tr.importingNotetypeAndDeck(), value: CsvMetadata_MatchScope.NOTETYPE_AND_DECK },
|
|
];
|
|
}
|