Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts" module>
import {Context} from 'runed';
import type {FieldId} from '$lib/entry-editor/field-data';
import type {FieldId} from '$lib/views/fields';
const fieldIdSymbol = Symbol('fw-lite-field-id');
class FieldRootState {
//require using the constructor when this type is used
Expand Down
40 changes: 0 additions & 40 deletions frontend/viewer/src/lib/entry-editor/field-data.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import {objectTemplateAreas, useCurrentView} from '$lib/views/view-service';
import {pt, vt} from '$lib/views/view-text';
import {t} from 'svelte-i18n-lingui';
import {fieldData, type FieldId} from '../field-data';
import {fieldData, type EntryFieldId} from '../../views/fields';
import {cn} from '$lib/utils';
import {useComplexFormTypes, usePublications, useWritingSystemService} from '$project/data';
import {MultiSelect, MultiWsInput, RichMultiWsInput} from '$lib/components/field-editors';
Expand All @@ -20,7 +20,7 @@
readonly?: boolean;
autofocus?: boolean;
modalMode?: boolean;
onchange?: (entry: IEntry, field: FieldId) => void;
onchange?: (entry: IEntry, field: EntryFieldId) => void;
publishInDescription?: Snippet;
}

Expand All @@ -40,14 +40,16 @@
const currentView = useCurrentView();
initSubjectContext(() => entry);

function onFieldChanged(field: FieldId) {
function onFieldChanged(field: EntryFieldId) {
onchange?.(entry, field);
}

const fields = $derived($currentView.fields.entry);
</script>

<Editor.SubGrid {...mergeProps(rest, { class: 'gap-2', style: { gridTemplateAreas: objectTemplateAreas($currentView, entry) } })}>
<Editor.Field.Root fieldId="lexemeForm" class={cn($currentView.fields.lexemeForm.show || 'hidden')}>
<Editor.Field.Title name={vt($t`Lexeme form`, $t`Word`)} helpId={fieldData.lexemeForm.helpId} />
<Editor.SubGrid {...mergeProps(rest, { class: 'gap-2', style: { gridTemplateAreas: objectTemplateAreas(fields) } })}>
<Editor.Field.Root fieldId="lexemeForm" class={cn(fields.lexemeForm.show || 'hidden')}>
<Editor.Field.Title name={vt($t`Lexeme form`, $t`Word`)} helpId={fieldData.entry.lexemeForm.helpId} />
<Editor.Field.Body subGrid>
<MultiWsInput
onchange={() => onFieldChanged('lexemeForm')}
Expand All @@ -58,8 +60,8 @@
</Editor.Field.Body>
</Editor.Field.Root>

<Editor.Field.Root fieldId="citationForm" class={cn($currentView.fields.citationForm.show || 'hidden')}>
<Editor.Field.Title name={vt($t`Citation form`, $t`Display as`)} helpId={fieldData.citationForm.helpId} />
<Editor.Field.Root fieldId="citationForm" class={cn(fields.citationForm.show || 'hidden')}>
<Editor.Field.Title name={vt($t`Citation form`, $t`Display as`)} helpId={fieldData.entry.citationForm.helpId} />
<Editor.Field.Body subGrid>
<MultiWsInput
onchange={() => onFieldChanged('citationForm')}
Expand All @@ -70,8 +72,8 @@
</Editor.Field.Root>

{#if !modalMode}
<Editor.Field.Root fieldId="complexForms" class={cn($currentView.fields.complexForms.show || 'hidden')}>
<Editor.Field.Title name={vt($t`Complex forms`, $t`Part of`)} helpId={fieldData.complexForms.helpId} />
<Editor.Field.Root fieldId="complexForms" class={cn(fields.complexForms.show || 'hidden')}>
<Editor.Field.Title name={vt($t`Complex forms`, $t`Part of`)} helpId={fieldData.entry.complexForms.helpId} />
<Editor.Field.Body>
<ComplexForms onchange={() => onFieldChanged('complexForms')}
bind:value={entry.complexForms}
Expand All @@ -80,8 +82,8 @@
</Editor.Field.Body>
</Editor.Field.Root>

<Editor.Field.Root fieldId="components" class={cn($currentView.fields.components.show || 'hidden')}>
<Editor.Field.Title name={$t`Components`} helpId={fieldData.components.helpId} />
<Editor.Field.Root fieldId="components" class={cn(fields.components.show || 'hidden')}>
<Editor.Field.Title name={$t`Components`} helpId={fieldData.entry.components.helpId} />
<Editor.Field.Body>
<ComplexFormComponents
onchange={() => onFieldChanged('components')}
Expand All @@ -91,8 +93,8 @@
</Editor.Field.Body>
</Editor.Field.Root>

<Editor.Field.Root fieldId="complexFormTypes" class={cn($currentView.fields.complexFormTypes.show || 'hidden')}>
<Editor.Field.Title name={vt($t`Complex form types`, $t`Uses components as`)} helpId={fieldData.complexFormTypes.helpId} />
<Editor.Field.Root fieldId="complexFormTypes" class={cn(fields.complexFormTypes.show || 'hidden')}>
<Editor.Field.Title name={vt($t`Complex form types`, $t`Uses components as`)} helpId={fieldData.entry.complexFormTypes.helpId} />
<Editor.Field.Body>
<MultiSelect
onchange={() => onFieldChanged('complexFormTypes')}
Expand All @@ -106,8 +108,8 @@
</Editor.Field.Root>
{/if}

<Editor.Field.Root fieldId="literalMeaning" class={cn($currentView.fields.literalMeaning.show || 'hidden')}>
<Editor.Field.Title name={vt($t`Literal meaning`)} helpId={fieldData.literalMeaning.helpId} />
<Editor.Field.Root fieldId="literalMeaning" class={cn(fields.literalMeaning.show || 'hidden')}>
<Editor.Field.Title name={vt($t`Literal meaning`)} helpId={fieldData.entry.literalMeaning.helpId} />
<Editor.Field.Body subGrid>
<RichMultiWsInput
onchange={() => onFieldChanged('literalMeaning')}
Expand All @@ -117,8 +119,8 @@
</Editor.Field.Body>
</Editor.Field.Root>

<Editor.Field.Root fieldId="note" class={cn($currentView.fields.note.show || 'hidden')}>
<Editor.Field.Title name={vt($t`Note`)} helpId={fieldData.note.helpId} />
<Editor.Field.Root fieldId="note" class={cn(fields.note.show || 'hidden')}>
<Editor.Field.Title name={vt($t`Note`)} helpId={fieldData.entry.note.helpId} />
<Editor.Field.Body subGrid>
<RichMultiWsInput
onchange={() => onFieldChanged('note')}
Expand All @@ -128,8 +130,8 @@
</Editor.Field.Body>
</Editor.Field.Root>

<Editor.Field.Root fieldId="publishIn" class={cn($currentView.fields.publishIn.show || 'hidden')}>
<Editor.Field.Title name={$t`Publish ${pt($t`Entry`, $t`Word`, $currentView)} in`} helpId={fieldData.publishIn.helpId} />
<Editor.Field.Root fieldId="publishIn" class={cn(fields.publishIn.show || 'hidden')}>
<Editor.Field.Title name={$t`Publish ${pt($t`Entry`, $t`Word`, $currentView)} in`} helpId={fieldData.entry.publishIn.helpId} />
<Editor.Field.Body>
<MultiSelect
onchange={() => onFieldChanged('publishIn')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import {objectTemplateAreas, useCurrentView} from '$lib/views/view-service';
import * as Editor from '$lib/components/editor';
import {asString, useWritingSystemService} from '$project/data';
import {fieldData, type FieldId} from '../field-data';
import {fieldData, type ExampleFieldId} from '../../views/fields';
import {cn, draftTranslation, isDraft} from '$lib/utils';
import {vt} from '$lib/views/view-text';
import {t} from 'svelte-i18n-lingui';
Expand All @@ -15,7 +15,7 @@
interface Props extends Omit<EditorSubGridProps, 'onchange'> {
example: IExampleSentence;
readonly?: boolean;
onchange?: (sense: IExampleSentence, field: FieldId) => void;
onchange?: (sense: IExampleSentence, field: ExampleFieldId) => void;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Misleading parameter name: sense should be example.

The onchange callback parameter is named sense but its type is IExampleSentence. This appears to be a copy-paste artifact from the sense editor.

Proposed fix
-    onchange?: (sense: IExampleSentence, field: ExampleFieldId) => void;
+    onchange?: (example: IExampleSentence, field: ExampleFieldId) => void;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
onchange?: (sense: IExampleSentence, field: ExampleFieldId) => void;
onchange?: (example: IExampleSentence, field: ExampleFieldId) => void;
🤖 Prompt for AI Agents
In
`@frontend/viewer/src/lib/entry-editor/object-editors/ExampleEditorPrimitive.svelte`
at line 18, The parameter name in the onchange callback is misleading: change
the first parameter name from sense to example in the signature "onchange?:
(sense: IExampleSentence, field: ExampleFieldId) => void;" so it reads something
like "onchange?: (example: IExampleSentence, field: ExampleFieldId) => void;"
(update any local references/usages in ExampleEditorPrimitive.svelte that refer
to the old name to match the new parameter name).

}

const {
Expand All @@ -29,14 +29,16 @@
const currentView = useCurrentView();
initSubjectContext(() => example);

function onFieldChanged(field: FieldId) {
function onFieldChanged(field: ExampleFieldId) {
onchange?.(example, field);
}

const fields = $derived($currentView.fields.example);
</script>

<Editor.SubGrid {...mergeProps(rest, { class: 'gap-2', style: { gridTemplateAreas: objectTemplateAreas($currentView, example) } })}>
<Editor.Field.Root fieldId="sentence" class={cn($currentView.fields.sentence.show || 'hidden')}>
<Editor.Field.Title name={vt($t`Sentence`)} helpId={fieldData.sentence.helpId} />
<Editor.SubGrid {...mergeProps(rest, { class: 'gap-2', style: { gridTemplateAreas: objectTemplateAreas(fields) } })}>
<Editor.Field.Root fieldId="sentence" class={cn(fields.sentence.show || 'hidden')}>
<Editor.Field.Title name={vt($t`Sentence`)} helpId={fieldData.example.sentence.helpId} />
<Editor.Field.Body subGrid>
<RichMultiWsInput
onchange={() => onFieldChanged('sentence')}
Expand All @@ -46,11 +48,11 @@
</Editor.Field.Body>
</Editor.Field.Root>

<Editor.Field.Root fieldId="translations" class={cn($currentView.fields.translations.show || 'hidden', 'space-y-2 items-center')}>
<Editor.Field.Root fieldId="translations" class={cn(fields.translations.show || 'hidden', 'space-y-2 items-center')}>
{#each (example.translations.length ? example.translations : [draftTranslation(example)]) as translation, i (translation.id)}
{@const title = example.translations.length > 1 ? vt($t`Translation ${i + 1}`) : vt($t`Translation`)}
<Editor.SubGrid class="items-baseline">
<Editor.Field.Title name={title} helpId={fieldData.translations.helpId}/>
<Editor.Field.Title name={title} helpId={fieldData.example.translations.helpId}/>
<Editor.Field.Body subGrid>
<RichMultiWsInput
onchange={(_, value) => {
Expand All @@ -68,8 +70,8 @@
</Editor.Field.Root>

{#if writingSystemService.defaultAnalysis}
<Editor.Field.Root fieldId="reference" class={cn($currentView.fields.reference.show || 'hidden')}>
<Editor.Field.Title name={vt($t`Reference`)} helpId={fieldData.reference.helpId} />
<Editor.Field.Root fieldId="reference" class={cn(fields.reference.show || 'hidden')}>
<Editor.Field.Title name={vt($t`Reference`)} helpId={fieldData.example.reference.helpId} />
<Editor.Field.Body>
<RichWsInput
onchange={() => onFieldChanged('reference')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
import {mergeProps} from 'bits-ui';
import type {Snippet} from 'svelte';
import {t} from 'svelte-i18n-lingui';
import {fieldData, type FieldId} from '../field-data';
import {fieldData, type SenseFieldId} from '../../views/fields';

interface Props extends Omit<EditorSubGridProps, 'onchange'> {
sense: ISense;
readonly?: boolean;
onchange?: (sense: ISense, field: FieldId) => void;
onchange?: (sense: ISense, field: SenseFieldId) => void;
partOfSpeechDescription?: Snippet;
semanticDomainsDescription?: Snippet;
};
Expand All @@ -35,14 +35,16 @@
const semanticDomains = useSemanticDomains();
const currentView = useCurrentView();
initSubjectContext(() => sense);
function onFieldChanged(field: FieldId) {
function onFieldChanged(field: SenseFieldId) {
onchange?.(sense, field);
}

const fields = $derived($currentView.fields.sense);
</script>

<Editor.SubGrid {...mergeProps(rest, { class: 'gap-2', style: { gridTemplateAreas: objectTemplateAreas($currentView, sense) } })}>
<Editor.Field.Root fieldId="gloss" class={cn($currentView.fields.gloss.show || 'hidden')}>
<Editor.Field.Title name={$t`Gloss`} helpId={fieldData.gloss.helpId} />
<Editor.SubGrid {...mergeProps(rest, { class: 'gap-2', style: { gridTemplateAreas: objectTemplateAreas(fields) } })}>
<Editor.Field.Root fieldId="gloss" class={cn(fields.gloss.show || 'hidden')}>
<Editor.Field.Title name={$t`Gloss`} helpId={fieldData.sense.gloss.helpId} />
<Editor.Field.Body subGrid>
<MultiWsInput
onchange={() => onFieldChanged('gloss')}
Expand All @@ -52,8 +54,8 @@
</Editor.Field.Body>
</Editor.Field.Root>

<Editor.Field.Root fieldId="definition" class={cn($currentView.fields.definition.show || 'hidden')}>
<Editor.Field.Title name={$t`Definition`} helpId={fieldData.definition.helpId} />
<Editor.Field.Root fieldId="definition" class={cn(fields.definition.show || 'hidden')}>
<Editor.Field.Title name={$t`Definition`} helpId={fieldData.sense.definition.helpId} />
<Editor.Field.Body subGrid>
<RichMultiWsInput
onchange={() => onFieldChanged('definition')}
Expand All @@ -63,8 +65,8 @@
</Editor.Field.Body>
</Editor.Field.Root>

<Editor.Field.Root fieldId="partOfSpeechId" class={cn($currentView.fields.partOfSpeechId.show || 'hidden')}>
<Editor.Field.Title name={vt($t`Grammatical info.`, $t`Part of speech`)} helpId={fieldData.partOfSpeechId.helpId}/>
<Editor.Field.Root fieldId="partOfSpeechId" class={cn(fields.partOfSpeechId.show || 'hidden')}>
<Editor.Field.Title name={vt($t`Grammatical info.`, $t`Part of speech`)} helpId={fieldData.sense.partOfSpeechId.helpId}/>
<Editor.Field.Body>
<Select
onchange={() => {
Expand All @@ -80,8 +82,8 @@
</Editor.Field.Body>
</Editor.Field.Root>

<Editor.Field.Root fieldId="semanticDomains" class={cn($currentView.fields.semanticDomains.show || 'hidden')}>
<Editor.Field.Title name={$t`Semantic domains`} helpId={fieldData.semanticDomains.helpId} />
<Editor.Field.Root fieldId="semanticDomains" class={cn(fields.semanticDomains.show || 'hidden')}>
<Editor.Field.Title name={$t`Semantic domains`} helpId={fieldData.sense.semanticDomains.helpId} />
<Editor.Field.Body>
<MultiSelect
onchange={() => onFieldChanged('semanticDomains')}
Expand Down
14 changes: 7 additions & 7 deletions frontend/viewer/src/lib/sandbox/EditorSandbox.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
import MultiSelect from '$lib/components/field-editors/multi-select.svelte';
import Select from '$lib/components/field-editors/select.svelte';
import LcmRichTextEditor from '$lib/components/lcm-rich-text-editor/lcm-rich-text-editor.svelte';
import { ResizablePaneGroup, ResizablePane, ResizableHandle } from '$lib/components/ui/resizable';
import { Switch } from '$lib/components/ui/switch';
import { Tabs, TabsList, TabsTrigger } from '$lib/components/ui/tabs';
import {ResizablePaneGroup, ResizablePane, ResizableHandle} from '$lib/components/ui/resizable';
import {Switch} from '$lib/components/ui/switch';
import {Tabs, TabsList, TabsTrigger} from '$lib/components/ui/tabs';
import {writingSystems} from '$project/demo/demo-entry-data';
import {type IMultiString} from '$lib/dotnet-types';
import {type IRichString} from '$lib/dotnet-types/generated-types/MiniLcm/Models/IRichString';
import { fieldData } from '$lib/entry-editor/field-data';
import {fieldData} from '$lib/views/fields';
import ViewPicker from '../../project/browse/EditorViewOptions.svelte';
import WsInput from '$lib/components/field-editors/ws-input.svelte';
import {vt} from '$lib/views/view-text';
Expand Down Expand Up @@ -131,7 +131,7 @@
<Editor.Field.Root>
<Editor.Field.Title
name="Semantic domains"
helpId={fieldData.semanticDomains.helpId}
helpId={fieldData.sense.semanticDomains.helpId}
/>
<Editor.Field.Body>
<MultiSelect
Expand All @@ -151,7 +151,7 @@
<Editor.Field.Root>
<Editor.Field.Title
name="Note"
helpId={fieldData.note.helpId}
helpId={fieldData.entry.note.helpId}
/>
<Editor.Field.Body>
<LcmRichTextEditor bind:value={entry.note} normalWs="en" readonly={editorReadonly} onchange={() => onChange('note')} />
Expand All @@ -160,7 +160,7 @@
<Editor.Field.Root>
<Editor.Field.Title
name={{lite: 'Part of speech', classic: 'Grammatical info'}}
helpId={fieldData.partOfSpeechId.helpId}
helpId={fieldData.sense.partOfSpeechId.helpId}
/>
<Editor.Field.Body>
<Select
Expand Down
2 changes: 1 addition & 1 deletion frontend/viewer/src/lib/sandbox/Sandbox.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import {Button, buttonVariants} from '$lib/components/ui/button';
import {Checkbox} from '$lib/components/ui/checkbox';
import {DotnetService, type IEntry, type ISense} from '$lib/dotnet-types';
import type {FieldId} from '$lib/entry-editor/field-data';
import type {FieldId} from '$lib/views/fields';
import SenseEditorPrimitive from '$lib/entry-editor/object-editors/SenseEditorPrimitive.svelte';
import {InMemoryDemoApi} from '$project/demo/in-memory-demo-api';
import {AppNotification} from '$lib/notifications/notifications';
Expand Down
Loading
Loading