fix(editor): plurals, trimmed names, default tab, parent drawing confirmation
This commit is contained in:
1 parent
b42c6ae844
commit
be4f468790
35 files changed
+385
-63
No files matched your search
@@ -137,14 +137,14 @@ export function annotationOf(
|
||||
return {
|
||||
...common,
|
||||
kind: 'detail_trigger',
|
||||
name: named ? { fr: form.fr, en: form.en } : null,
|
||||
name: named ? { fr: form.fr.trim(), en: form.en.trim() } : null,
|
||||
opens_view_id: form.opensViewId,
|
||||
}
|
||||
}
|
||||
return {
|
||||
...common,
|
||||
kind: pending.kind,
|
||||
name: { fr: form.fr, en: form.en },
|
||||
name: { fr: form.fr.trim(), en: form.en.trim() },
|
||||
finding_zone_id: orNull(form.zoneId),
|
||||
vertebral_region_code: orNull(form.regionCode),
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import { useT } from '@/i18n/useT'
|
||||
import { useLocaleStore } from '@/state/localeStore'
|
||||
import type { Locale } from '@/i18n/types'
|
||||
|
||||
/** `<key>_one` or `<key>_other` by the locale's plural rule (fr: 0 and 1 are singular). */
|
||||
export function pluralKey(locale: Locale, key: string, count: number): string {
|
||||
const category = new Intl.PluralRules(locale).select(count)
|
||||
return `${key}_${category === 'one' ? 'one' : 'other'}`
|
||||
}
|
||||
|
||||
/** A count phrase: picks the plural form of `key` and fills `{count}`. */
|
||||
export function usePlural(): (key: string, count: number) => string {
|
||||
const t = useT()
|
||||
const locale = useLocaleStore((s) => s.locale)
|
||||
return (key, count) =>
|
||||
t(pluralKey(locale, key, count)).replace('{count}', String(count))
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { ElementKey } from '@faunosteo/core-wasm/types'
|
||||
import type { ElementKey, PreviewState } from '@faunosteo/core-wasm/types'
|
||||
import type { FocusRequest } from './focusRequest'
|
||||
import { unmeasuredViews } from './issues'
|
||||
import type { TabTier } from './useViewport'
|
||||
|
||||
export const EDITOR_TABS = [
|
||||
@@ -28,6 +29,17 @@ export function tabsFor(tier: TabTier): {
|
||||
return { shown, more: EDITOR_TABS.filter((tab) => !shown.includes(tab)) }
|
||||
}
|
||||
|
||||
/**
|
||||
* The tab a version opens on: Annotations once a view can be annotated, Général while
|
||||
* there is nothing to annotate yet. A tier that does not list Général keeps Annotations.
|
||||
*/
|
||||
export function initialTab(state: PreviewState, tier: TabTier): EditorTabId {
|
||||
const unmeasured = unmeasuredViews(state)
|
||||
const measurable = state.document.views.some((v) => !unmeasured.has(v.id))
|
||||
const wanted = measurable ? 'annotations' : 'general'
|
||||
return SHOWN[tier].includes(wanted) ? wanted : 'annotations'
|
||||
}
|
||||
|
||||
/** Props of every tab body (Lots F-J fill them): read-only flag, tab jump, sheet reload. */
|
||||
export interface EditorTabProps {
|
||||
/** Not editable now: a mode that cannot save, or a recovery offer not answered yet. */
|
||||
|
||||
Reference in new issue
Block a user