feat(editor): references dialog over the finding, view mode
A modal Dialog replaces the citations side sheet; families open it too (isCitable). The finding dialog shows only « Références citées » and « X références », also at zero; its edit form no longer carries reference_ids. A dirty form refusing « Aller à » or « Tout afficher » closes the clean references dialog first.
This commit is contained in:
1 parent
ff21b0315e
commit
abc781df52
29 files changed
+432
-858
No files matched your search
@@ -2,7 +2,7 @@ import type { ElementKey } from '@faunosteo/core-wasm/types'
|
||||
import { MAX_FINDING_PATH } from '../findings/tree'
|
||||
import {
|
||||
ANNOTATION_SECTIONS,
|
||||
isFindingNode,
|
||||
isCitable,
|
||||
sameView,
|
||||
type AnnotationSection,
|
||||
type EditorView,
|
||||
@@ -67,18 +67,18 @@ function sanitizeCreation(raw: unknown): EditorView['finding'] {
|
||||
return { create: { kind, parent: key } }
|
||||
}
|
||||
|
||||
/** The finding layer of a view: its dialog, with its citations sheet over it. */
|
||||
/** The finding layer of a view: its dialog, with its citations dialog over it. */
|
||||
function sanitizeFinding(raw: unknown, forms: boolean): EditorView['finding'] {
|
||||
if (!isRecord(raw)) return null
|
||||
if ('create' in raw) return forms ? sanitizeCreation(raw) : null
|
||||
const key = sanitizeKey(raw.key)
|
||||
if (!key) return null
|
||||
const sheet = raw.citations === true && isFindingNode(key)
|
||||
return { key, citations: sheet }
|
||||
const citations = raw.citations === true && isCitable(key)
|
||||
return { key, citations }
|
||||
}
|
||||
|
||||
/**
|
||||
* The reference dialog of a view: over the References tab, or over the citations sheet
|
||||
* The reference dialog of a view: over the References tab, or over the citations dialog
|
||||
* (the only other place that opens it). A form, so only read back where forms are kept;
|
||||
* whether the reference still exists is the dialog's own gone rule.
|
||||
*/
|
||||
@@ -88,17 +88,17 @@ function sanitizeReference(
|
||||
tab: unknown,
|
||||
): EditorView['reference'] {
|
||||
if (!isRecord(raw)) return null
|
||||
const sheet = !!finding && 'key' in finding && finding.citations
|
||||
const cited = !!finding && 'key' in finding && finding.citations
|
||||
if (raw.create === true) return tab === 'references' ? { create: true } : null
|
||||
const id = raw.edit
|
||||
if (!isId(id) || id === '') return null
|
||||
return tab === 'references' || sheet ? { edit: id } : null
|
||||
return tab === 'references' || cited ? { edit: id } : null
|
||||
}
|
||||
|
||||
/** The finding the References tab is filtered by: a finding node, on that tab only. */
|
||||
/** The element the References tab is filtered by: a family or a node, on that tab only. */
|
||||
function sanitizeFilter(raw: unknown, tab: unknown): ElementKey | null {
|
||||
const key = tab === 'references' ? sanitizeKey(raw) : null
|
||||
return key && isFindingNode(key) ? key : null
|
||||
return key && isCitable(key) ? key : null
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -166,13 +166,13 @@ export function ownedEntry(
|
||||
export const entryState = (entry: HistoryEntry) => ({ [ENTRY_KEY]: entry })
|
||||
|
||||
/**
|
||||
* Layers over the place: the finding dialog and the citations sheet over it, the
|
||||
* Layers over the place: the finding dialog and the citations dialog over it, the
|
||||
* reference dialog, each count one.
|
||||
*/
|
||||
export function layerCount(view: EditorView): number {
|
||||
const { finding } = view
|
||||
const sheet = finding && 'key' in finding && finding.citations
|
||||
return (finding ? 1 : 0) + (sheet ? 1 : 0) + (view.reference ? 1 : 0)
|
||||
const cited = finding && 'key' in finding && finding.citations
|
||||
return (finding ? 1 : 0) + (cited ? 1 : 0) + (view.reference ? 1 : 0)
|
||||
}
|
||||
|
||||
/** An Annotations section other than the drawing is a step over it, like a layer. */
|
||||
@@ -192,7 +192,7 @@ function isRemoval(top: EditorView, view: EditorView): boolean {
|
||||
/** What a changed view asks of the history. */
|
||||
export type HistoryWrite = 'none' | 'push' | 'replace' | 'back'
|
||||
|
||||
/** True when `view` shows the finding `key` (its dialog, with or without the sheet). */
|
||||
/** True when `view` shows the finding `key` (its dialog, with or without its citations). */
|
||||
export function showsFinding(view: EditorView, key: ElementKey): boolean {
|
||||
const { finding } = view
|
||||
const shown = finding && 'key' in finding ? finding.key : null
|
||||
|
||||
Reference in new issue
Block a user