@myrmidon/cadmus-part-general-ui
v20.0.2
Published
Cadmus - generic parts.
Readme
CadmusPartGeneralUi
- 📦
@myrmidon/cadmus-part-general-ui
This project was generated using Angular CLI version 19.0.0.
This library contains the components for editing general Cadmus parts and fragments.
Historical Events Part
- 🔑
it.vedph.historical-events - 🟢
HistoricalEventsPartComponent,HistoricalEventEditorComponent,RelatedEntityComponent
Each event has an ID, a type, an optional tag, description and note, any number of chronotopes, an optional assertion, and any number of related entities, each with a relation (e.g. father) and an entity ID.
Editor
The event editor has two tabs:
- general: ID, tag, description and note, side by side with the type when the editor is wide enough; and below, the chronotopes and the assertion. The tab label shows an error icon when any of its fields is invalid.
- related: the related entities, with their relation labels and entities. The tab label shows their count, and a warning icon when some relations do not fit the event type (see Relations): these entities are also marked in the list. While an entity is being edited, adding another is disabled, and a note below reminds that it is not yet saved.
The layout adapts to the width of the editor itself rather than to that of the window (CSS container queries), as the editor is usually nested in the part editor.
Settings
The editor gets its settings from the settings object of the profile, either under the part type ID (for all the historical events parts), or under the part type ID plus _ and a role ID (for the parts with that role only). Role-specific settings, when present, replace the global ones. With no settings, the editor behaves as it always did.
Settings (HistoricalEventsPartSettings) have these properties, all optional:
eventType(ThesOrTaxoSettings): how the event type is picked.relation(ThesOrTaxoSettings): how the relation of related entities is picked (see Relations).relationFilter(HistoricalEventRelationFilter): how relations are filtered by the event type (see Relations).
Both eventType and relation are settings for a ThesOrTaxoPicker (from @myrmidon/cadmus-ui-thestaxo), whose properties override the defaults:
mode:thesaurus(default),taxonomy, orunbound.source: the thesaurus ID (when not set, the thesaurus of the part is used:event-typesorevent-relations), or the taxonomy tree ID.thesaurusView:flat,tree, orauto(a tree only when entry IDs include dots). The default istreefor types andflatfor relations.hasTopNodeFilter: true (default) to show the top-level nodes filter in the taxonomy picker.canEditNode,canAddNode,canDeleteNode: whether users can edit, add or delete taxonomy nodes while picking. Default is false.
Taxonomy mode requires the TaxoStore API, whose base URL is set by taxoUrl in the app's env.js.
Event Type
By default, the type is picked from the event-types thesaurus, displayed as a tree. When this thesaurus is not available, the type is typed in a textbox. You can rather pick it from another thesaurus, or from a TaxoStore taxonomy (e.g. when types come from a rich LOD ontology), via eventType.
New events get the first thesaurus entry as their default type only in thesaurus mode.
Relations
By default, the relation of a related entity is picked from the event-relations thesaurus, displayed as a list, or typed when this thesaurus is not available. You can rather pick it from another thesaurus, or from a taxonomy, via relation.
When relations come from a thesaurus, they are filtered by the event type, so that only the relations fit for the type are available. The type ID is turned into a prefix, and only the relations whose ID starts with it are listed: e.g. type person.birth gives prefix person:birth:, which matches person:birth:father and person:birth:mother. The prefix is built by:
- splitting the type ID at each
typeSeparator(person.birth→person,birth); - removing
tailCutportions from its end. Also, when the last portion isparentSuffix(as inperson.job.-, the convention for parent entries), it is always removed; - joining the remaining portions with
relationSeparator, plus a finalrelationSeparator(person:birth:).
When no portion is left, relations are not filtered.
The relationFilter setting configures this behavior:
mode:prefix(default) to filter relations by the prefix built from the type, ornoneto always list all the relations. Usenonewhen type IDs and relation IDs do not share the same hierarchy, e.g. with types from a taxonomy whose keys do not follow this convention.typeSeparator: the separator between the portions of a type ID. Default is.. Set it according to the keys of your taxonomy, e.g./for keys likeperson/birth.relationSeparator: the separator between the portions of a relation ID. Default is:.tailCut: the number of portions to cut from the end of the type ID. Default is 0. For instance, with 1 the typeperson.job.bishopgives prefixperson:job:, so that all the jobs share the same relations. This replaces the deprecatedeventTypeTailCutinput of the event editor, which is still used whentailCutis not set.parentSuffix: the last portion of type IDs representing parent entries. Default is-; set to an empty string to disable.fallbackToAll: what to do when no relation matches the prefix: when false (default), no relation is listed, so it must be typed; when true, all the relations are listed.
The editor marks the related entities whose relation does not start with the current prefix, e.g. because the type was changed after adding them; with fallbackToAll, nothing is marked when no relation matches the prefix. Relations from a taxonomy are never filtered.
These functions are exported, so that you can reuse the same logic: resolveRelationFilter (merges a filter over DEFAULT_RELATION_FILTER), buildRelationPrefix, and filterRelationEntries.
Example
"settings": {
"it.vedph.historical-events": {
"eventType": {
"mode": "taxonomy",
"source": "event-types",
"canAddNode": true
},
"relationFilter": {
"fallbackToAll": true
}
},
"it.vedph.historical-events_bio": {
"eventType": {
"mode": "taxonomy",
"source": "bio-events"
},
"relation": {
"mode": "taxonomy",
"source": "bio-roles"
}
},
"it.vedph.historical-events_works": {
"relationFilter": {
"tailCut": 1
}
}
}Here:
- all the historical events parts pick their types from the
event-typestaxonomy, and their relations from theevent-relationsthesaurus, filtered by type; when no relation fits a type, all the relations are listed. - the parts with role
biopick types from thebio-eventstaxonomy, and relations from thebio-rolestaxonomy, with no filtering. As role-specific settings replace the global ones, they do not inheritcanAddNodenorfallbackToAll. - the parts with role
workspick types from theevent-typesthesaurus (the default, as global settings are replaced), filtering relations by the type without its last portion.
