{#if record?.entity}
- {#if record.entityName === "Entry"}
+ {#if record.entityName === 'Entry'}
- {:else if record.entityName === "Sense"}
+ {:else if record.entityName === 'Sense'}
- {:else if record.entityName === "ExampleSentence"}
+ {:else if record.entityName === 'ExampleSentence'}
diff --git a/frontend/viewer/src/lib/i18n.ts b/frontend/viewer/src/lib/i18n.ts
index e71de67a9..da6db1ed5 100644
--- a/frontend/viewer/src/lib/i18n.ts
+++ b/frontend/viewer/src/lib/i18n.ts
@@ -1,8 +1,8 @@
-import type { FieldConfig, WellKnownFieldId } from './config-types';
+import type { WellKnownFieldId } from './config-types';
import type {FieldIds} from './entry-editor/field-data';
-type I18n = Record
& Record, string>;
+// type I18n = Record & Record, string>;
type I18nKey = FieldIds;
/**
* I18n type is used to specify which i18n group to use for a field. If empty, the default i18n is used.
diff --git a/frontend/viewer/src/lib/in-memory-api-service.ts b/frontend/viewer/src/lib/in-memory-api-service.ts
index 986e79379..d1021e179 100644
--- a/frontend/viewer/src/lib/in-memory-api-service.ts
+++ b/frontend/viewer/src/lib/in-memory-api-service.ts
@@ -1,4 +1,5 @@
-import type {
+/* eslint-disable @typescript-eslint/naming-convention */
+import type {
LexboxApiClient,
IEntry,
IExampleSentence,
@@ -13,11 +14,11 @@
} from './services/lexbox-api';
import {entries, projectName, writingSystems} from './entry-data';
-import {type WritingSystem} from './mini-lcm';
+import {pickWs, type WritingSystem} from './mini-lcm';
import {headword} from './utils';
import {applyPatch} from 'fast-json-patch';
-function filterEntries(entries: IEntry[], query: string) {
+function filterEntries(entries: IEntry[], query: string): IEntry[] {
return entries.filter(entry =>
[
...Object.values(entry.lexemeForm ?? {}),
@@ -31,8 +32,8 @@ function filterEntries(entries: IEntry[], query: string) {
export class InMemoryApiService implements LexboxApiClient {
GetPartsOfSpeech(): Promise {
return Promise.resolve([
- {id: 'noun', name: {en: 'noun'},},
- {id: 'verb', name: {en: 'verb'},}
+ {id: '86ff66f6-0774-407a-a0dc-3eeaf873daf7', name: {en: 'Verb'},},
+ {id: 'a8e41fd3-e343-4c7c-aa05-01ea3dd5cfb5', name: {en: 'Noun'},}
]);
}
@@ -54,7 +55,7 @@ export class InMemoryApiService implements LexboxApiClient {
private _entries = entries;
private _Entries(): IEntry[] {
- return JSON.parse(JSON.stringify(this._entries));
+ return JSON.parse(JSON.stringify(this._entries)) as IEntry[];
}
GetEntries(options: QueryOptions | undefined): Promise {
@@ -71,26 +72,24 @@ export class InMemoryApiService implements LexboxApiClient {
private ApplyQueryOptions(entries: IEntry[], options: QueryOptions | undefined): IEntry[] {
if (!options) return entries;
- let sortWs = options.order.writingSystem;
const defaultWs = writingSystems.vernacular[0].id;
- if (sortWs === 'default') sortWs = defaultWs;
if (options.exemplar?.value) {
- const lowerExemplar = options.exemplar?.value.toLowerCase();
- let ws = options.exemplar?.writingSystem;
- if (ws === 'default') ws = defaultWs;
+ const lowerExemplar = options.exemplar.value.toLowerCase();
+ const exemplarWs = pickWs(options.exemplar.writingSystem, defaultWs);
entries = entries.filter(entry =>
- (entry.citationForm[ws] ?? entry.lexemeForm[ws] ?? '')
+ (entry.citationForm[exemplarWs] ?? entry.lexemeForm[exemplarWs] ?? '')
?.toLocaleLowerCase()
?.startsWith(lowerExemplar));
}
+ const sortWs = pickWs(options.order.writingSystem, defaultWs);
return entries
.sort((e1, e2) => {
const v1 = headword(e1, sortWs);
const v2 = headword(e2, sortWs);
if (!v2) return -1;
if (!v1) return 1;
- let compare = v1.localeCompare(v2, sortWs);
+ const compare = v1.localeCompare(v2, sortWs);
if (compare !== 0) return compare;
return e1.id.localeCompare(e2.id);
})
@@ -155,11 +154,11 @@ export class InMemoryApiService implements LexboxApiClient {
return Promise.resolve();
}
- CreateWritingSystem(type: WritingSystemType, writingSystem: WritingSystem): Promise {
+ CreateWritingSystem(_type: WritingSystemType, _writingSystem: WritingSystem): Promise {
throw new Error('Method not implemented.');
}
- UpdateWritingSystem(wsId: string, type: WritingSystemType, update: JsonPatch): Promise {
+ UpdateWritingSystem(_wsId: string, _type: WritingSystemType, _update: JsonPatch): Promise {
throw new Error('Method not implemented.');
}
}
diff --git a/frontend/viewer/src/lib/layout/DictionaryEntryViewer.svelte b/frontend/viewer/src/lib/layout/DictionaryEntryViewer.svelte
index 3079f09a3..8cf46cbff 100644
--- a/frontend/viewer/src/lib/layout/DictionaryEntryViewer.svelte
+++ b/frontend/viewer/src/lib/layout/DictionaryEntryViewer.svelte
@@ -1,8 +1,8 @@
diff --git a/frontend/viewer/src/lib/mini-lcm/complex-form-component.ts b/frontend/viewer/src/lib/mini-lcm/complex-form-component.ts
index 6aee0e1a6..659fc0706 100644
--- a/frontend/viewer/src/lib/mini-lcm/complex-form-component.ts
+++ b/frontend/viewer/src/lib/mini-lcm/complex-form-component.ts
@@ -3,7 +3,7 @@
* Any changes made to this file can be lost when this file is regenerated.
*/
-import type { IComplexFormComponent } from "./i-complex-form-component";
+import type { IComplexFormComponent } from './i-complex-form-component';
export class ComplexFormComponent implements IComplexFormComponent {
constructor(id: string, complexFormEntryId: string, componentEntryId: string) {
diff --git a/frontend/viewer/src/lib/mini-lcm/i-complex-form-type.ts b/frontend/viewer/src/lib/mini-lcm/i-complex-form-type.ts
index aef9493a1..a03cc5c2a 100644
--- a/frontend/viewer/src/lib/mini-lcm/i-complex-form-type.ts
+++ b/frontend/viewer/src/lib/mini-lcm/i-complex-form-type.ts
@@ -1,4 +1,4 @@
-import type { IMultiString } from "./i-multi-string";
+import type { IMultiString } from './i-multi-string';
export interface IComplexFormType {
id: string;
diff --git a/frontend/viewer/src/lib/mini-lcm/query-options.ts b/frontend/viewer/src/lib/mini-lcm/query-options.ts
index b3f6255ee..cce249ec5 100644
--- a/frontend/viewer/src/lib/mini-lcm/query-options.ts
+++ b/frontend/viewer/src/lib/mini-lcm/query-options.ts
@@ -3,13 +3,19 @@
* Any changes made to this file can be lost when this file is regenerated.
*/
+type QueryWsId = Omit | 'default';
+
export interface QueryOptions {
order: {
field: 'headword',
- writingSystem: string | 'default',
+ writingSystem: QueryWsId,
ascending?: boolean
};
count: number;
offset: number;
- exemplar?: { value: string, writingSystem: string | 'default' };
+ exemplar?: { value: string, writingSystem: QueryWsId };
+}
+
+export function pickWs(ws: QueryWsId, defaultWs: string): string {
+ return ws === 'default' ? defaultWs : ws as string;
}
diff --git a/frontend/viewer/src/lib/notifications/NotificationOutlet.svelte b/frontend/viewer/src/lib/notifications/NotificationOutlet.svelte
index 46e0db57e..acdfaff52 100644
--- a/frontend/viewer/src/lib/notifications/NotificationOutlet.svelte
+++ b/frontend/viewer/src/lib/notifications/NotificationOutlet.svelte
@@ -14,7 +14,7 @@
{#each $notifications as notification}
-
+
{#if notification.type === 'success'}
diff --git a/frontend/viewer/src/lib/notifications/notifications.ts b/frontend/viewer/src/lib/notifications/notifications.ts
index 671c93741..39711b883 100644
--- a/frontend/viewer/src/lib/notifications/notifications.ts
+++ b/frontend/viewer/src/lib/notifications/notifications.ts
@@ -1,4 +1,4 @@
-import {writable, type Writable, type Readable, readonly} from 'svelte/store';
+import {writable, type Writable} from 'svelte/store';
interface NotificationAction {
label: string;
diff --git a/frontend/viewer/src/lib/parts-of-speech.ts b/frontend/viewer/src/lib/parts-of-speech.ts
index c31e96bd2..69a20fc02 100644
--- a/frontend/viewer/src/lib/parts-of-speech.ts
+++ b/frontend/viewer/src/lib/parts-of-speech.ts
@@ -9,6 +9,9 @@ export function usePartsOfSpeech(): Readable
{
partsOfSpeechStore = writable([], (set) => {
useLexboxApi().GetPartsOfSpeech().then(partsOfSpeech => {
set(partsOfSpeech);
+ }).catch(error => {
+ console.error('Failed to load parts of speech', error);
+ throw error;
});
});
}
diff --git a/frontend/viewer/src/lib/sandbox/Sandbox.svelte b/frontend/viewer/src/lib/sandbox/Sandbox.svelte
index 7b1640882..36ebe5cc9 100644
--- a/frontend/viewer/src/lib/sandbox/Sandbox.svelte
+++ b/frontend/viewer/src/lib/sandbox/Sandbox.svelte
@@ -3,30 +3,30 @@
import CrdtMultiOptionField from '../entry-editor/inputs/CrdtMultiOptionField.svelte';
const options = [
- { name: 'One', value: 1 },
- { name: 'Two', value: 2 },
- { name: 'Three', value: 3 },
- { name: 'Four', value: 4 },
+ { label: 'One', value: 1 },
+ { label: 'Two', value: 2 },
+ { label: 'Three', value: 3 },
+ { label: 'Four', value: 4 },
];
let value = [3];
- const crdtOptions:MenuOption[] = [
+ const crdtOptions: MenuOption[] = [
{value: 'a', label: 'Alpha'},
{value: 'b', label: 'Beta'},
{value: 'c', label: 'Charlie'},
];
- let crdtValue = [{id: 'a'}];
+ let crdtValue = ['a'];
-
(value = e.detail.value)}/>
+ (value = e.detail.value ?? [])}/>
selected: {value.join('|')}
- selected: {crdtValue.map(c => c.id).join('|')}
-
+ selected: {crdtValue.join('|')}
+
diff --git a/frontend/viewer/src/lib/search-bar/SearchBar.svelte b/frontend/viewer/src/lib/search-bar/SearchBar.svelte
index 2b57c4b28..eb8452621 100644
--- a/frontend/viewer/src/lib/search-bar/SearchBar.svelte
+++ b/frontend/viewer/src/lib/search-bar/SearchBar.svelte
@@ -1,6 +1,6 @@