@myrmidon/cadmus-refs-asserted-ids 6.0.1 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +213 -133
- package/fesm2022/myrmidon-cadmus-refs-asserted-ids.mjs +428 -288
- package/fesm2022/myrmidon-cadmus-refs-asserted-ids.mjs.map +1 -1
- package/lib/asserted-composite-id/asserted-composite-id.component.d.ts +21 -24
- package/lib/asserted-composite-ids/asserted-composite-ids.component.d.ts +16 -17
- package/lib/asserted-id/asserted-id.component.d.ts +29 -15
- package/lib/asserted-ids/asserted-ids.component.d.ts +9 -17
- package/lib/pin-target-lookup/pin-target-lookup.component.d.ts +22 -22
- package/lib/scoped-pin-lookup/scoped-pin-lookup.component.d.ts +5 -3
- package/package.json +6 -5
package/README.md
CHANGED
|
@@ -1,50 +1,106 @@
|
|
|
1
1
|
# CadmusRefsAssertedIds
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
📦 `@myrmidon/cadmus-refs-asserted-ids`
|
|
4
|
+
|
|
5
|
+
This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 19.0.0.
|
|
4
6
|
|
|
5
7
|
- [CadmusRefsAssertedIds](#cadmusrefsassertedids)
|
|
6
|
-
- [
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
- [External IDs](#external-ids)
|
|
9
|
+
- [Internal IDs](#internal-ids)
|
|
10
|
+
- [ID Components](#id-components)
|
|
11
|
+
- [AssertedIdComponent](#assertedidcomponent)
|
|
12
|
+
- [Configuring Asserted ID](#configuring-asserted-id)
|
|
13
|
+
- [AssertedIdsComponent](#assertedidscomponent)
|
|
14
|
+
- [PinTargetLookupComponent](#pintargetlookupcomponent)
|
|
15
|
+
- [Configuring the Target ID Editor](#configuring-the-target-id-editor)
|
|
9
16
|
- [Asserted Composite ID](#asserted-composite-id)
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
- [Asserted Composite IDs](#asserted-composite-ids)
|
|
18
|
+
|
|
19
|
+
The asserted ID and asserted composite IDs bricks provide a way to include _external_ or _internal_ references to resource identifiers, whatever their type and origin. These components are the foundation for pin-based links in links part and links fragment types, as they provide both external and internal links, optionally accompanied by an assertion.
|
|
20
|
+
|
|
21
|
+
## External IDs
|
|
22
|
+
|
|
23
|
+
External IDs are provided by users, either manually or with the aid of lookup services. Cadmus already provides a set of builtin lookup providers for popular web APIs like VIAF, DBPedia, Geonames, and WHG, and you can add as many as you want.
|
|
24
|
+
|
|
25
|
+
At a minimum, an external ID is just a string representing an identifier. Usually this is globally unique, or it is unique only within the scope defined by its context. For instance, a DBPedia ID is a URI, which makes it a globally unique identifier; while the numeric ID assigned to an entity in a RDBMS is unique only in the scope of its table in that database.
|
|
26
|
+
|
|
27
|
+
According to their type and purpose, such IDs can thus be totally opaque for human users, like a number; or provide a hint about their target, like e.g. the URI for Marco Polo in DBPedia: <http://dbpedia.org/resource/Marco_Polo>.
|
|
16
28
|
|
|
17
|
-
|
|
29
|
+
So, in its most complete model an external ID has:
|
|
18
30
|
|
|
19
|
-
|
|
31
|
+
- a value for the ID itself, whether it's globally unique or not.
|
|
32
|
+
- a human-friendly label conventionally attached to the ID.
|
|
33
|
+
- an optional scope.
|
|
34
|
+
- an optional tag, which can be used to group or classify IDs in some way.
|
|
20
35
|
|
|
21
|
-
|
|
36
|
+
## Internal IDs
|
|
22
37
|
|
|
23
|
-
- a
|
|
24
|
-
- a _scope_, representing the context the ID originates from (e.g. an ontology, a repository, a website, etc.).
|
|
25
|
-
- an optional _tag_, used to group or classify the ID.
|
|
26
|
-
- an optional _assertion_, used to define the uncertainty level of the assignment of this ID to the context it applies to.
|
|
38
|
+
Internal IDs are human-friendly identifiers connected to any data in the Cadmus database. They can refer to an item as a whole, or to a specific part or fragment of it, or to a specific feature inside a part or fragment.
|
|
27
39
|
|
|
28
|
-
|
|
40
|
+
In most cases, human users prefer friendly identifiers, unique only in the context of their editing environment (which is what is present to the user's mind when entering data). These identifiers in Cadmus are named **EID**s (=_entity IDs_), and may be found scattered among parts or fragments via pins, or linked to whole items via a metadata part.
|
|
29
41
|
|
|
30
|
-
|
|
42
|
+
>Of course, all Cadmus data objects (items, parts and fragments) have their own globally unique identifier, which is an opaque GUID like `401267e7-282c-40e6-8f47-67be54382b07`. EIDs instead provide human-friendly identifiers, e.g. just like the IDs you type in a TEI document. Additionally, they can be used to target a specific feature inside a part or fragment, via search pins provided by it.
|
|
31
43
|
|
|
32
|
-
|
|
44
|
+
**Item EID**s are just human-friendly aliases used to refer to a Cadmus item as a whole. Whenever we want to assign a human-friendly ID to the _item_ itself, rather than referring to it by its GUID, the conventional method relies on the generic _metadata part_, which allows users entering any number of arbitrarily defined name=value pairs. So, a user might enter a pair like e.g. `eid=vat_lat_123`, and use it as the human friendly identifier for a manuscript item corresponding to Vat.Lat.123.
|
|
33
45
|
|
|
34
|
-
|
|
46
|
+
Ultimately, even an item EID, just like any other EID is just based on a **search pin**. In Cadmus, any part or fragment in an item provides any number of _search pins_, which essentially are name=value pairs, used for a simple search during editing.
|
|
35
47
|
|
|
36
|
-
|
|
48
|
+
Each pin name is unique only in the context of the part or fragment defining it, so that pin design is not constrained; yet, a pin can easily be turned into a globally unique identifier by adding to it other data.
|
|
37
49
|
|
|
38
|
-
For instance,
|
|
50
|
+
For instance, given that every part or fragment has its own globally unique ID, you can just prepend it to the pin name to get a globally unique internal ID pointing to a specific feature of a specific part or fragment. Thus, users just enter pins as arbitrary, easy to use strings, when entering data; but the general architecture also provides a way for making them globally unique.
|
|
39
51
|
|
|
40
|
-
|
|
52
|
+
>This is how the in-editor search is implemented, and a similar mechanism is also used when mapping entities from parts into a semantic graph (via mapping rules).
|
|
41
53
|
|
|
42
|
-
|
|
54
|
+
For instance, say a decorations part in a manuscript item collects a number of decorations; for each one, it might define an arbitrary EID (like e.g. `angel1`) used to identify it among the others, in the context of that part.
|
|
43
55
|
|
|
44
|
-
|
|
45
|
-
|
|
56
|
+
When filling the decorations part with data, users just ensure that this EID is unique in the context of the list they are editing; in other terms, no other decoration in that part will have `angel1` as its ID, while it might happen that `angel1` is used somewhere else in another part. Yet, should we be in need of a non-scoped, unique ID, we could easily build it by assembling together the EID with its part/item IDs, which by definition are globally unique (being GUIDs).
|
|
57
|
+
|
|
58
|
+
## ID Components
|
|
59
|
+
|
|
60
|
+
The asserted ID library provides a number of components which can be used to easily refer to the entities identified with external or internal IDs.
|
|
61
|
+
|
|
62
|
+
According to the scenario illustrated above, the basic requirements for ID components are:
|
|
63
|
+
|
|
64
|
+
- provide a general lookup mechanism for external and/or internal IDs.
|
|
65
|
+
- for internal IDs, be able to draw data _from parts or from items_, assuming the convention by which an item can be assigned an EID via its generic _metadata_ part; and provide a quick way to build a globally unique identifier from an EID. Optionally, a component can also allow users pick _the preferred combination_ of components which once assembled build a unique, yet human-friendly identifier.
|
|
66
|
+
|
|
67
|
+
>👉 The demo found in this workspace uses a [mock data service](../../../src/app/services/mock-item.service.ts) instead of the real one, which provides a minimal set of data and functions, just required for the components to function.
|
|
46
68
|
|
|
47
|
-
|
|
69
|
+
Various components from this library provide a different level of complexity, so you can pick the one which best fits your purposes; in general, the most powerful and versatile ID picker is represented by the [asserted composite ID](#asserted-composite-id), which can be used for both external and internal IDs, with full lookup support from lookup providers in either case.
|
|
70
|
+
|
|
71
|
+
## AssertedIdComponent
|
|
72
|
+
|
|
73
|
+
- 🔑 `AssertedIdComponent`
|
|
74
|
+
- 🚩 `cadmus-refs-asserted-id`
|
|
75
|
+
- ▶️ input:
|
|
76
|
+
- id (`AssertedId? | null`)
|
|
77
|
+
- external (`boolean?`)
|
|
78
|
+
- hasSubmit (`boolean?`)
|
|
79
|
+
- pinByTypeMode (`boolean?`)
|
|
80
|
+
- canSwitchMode (`boolean?`)
|
|
81
|
+
- canEditTarget (`boolean?`)
|
|
82
|
+
- defaultPartTypeKey (`string?|null`)
|
|
83
|
+
- lookupDefinitions (`IndexLookupDefinitions?`)
|
|
84
|
+
- internalDefault (`boolean?`): true to start a new ID as internal rather than external
|
|
85
|
+
- 📚 thesauri:
|
|
86
|
+
- `asserted-id-scopes` (idScopeEntries)
|
|
87
|
+
- `asserted-id-tags` (idTagEntries).
|
|
88
|
+
- `assertion-tags` (assTagEntries).
|
|
89
|
+
- `doc-reference-types` (refTypeEntries).
|
|
90
|
+
- `doc-reference-tags` (refTagEntries).
|
|
91
|
+
- 🔥 output:
|
|
92
|
+
- idChange (`AssertedId`)
|
|
93
|
+
- editorClose
|
|
94
|
+
- extMoreRequest (`RefLookupSetEvent`): the user requested more about the current external lookup source.
|
|
95
|
+
|
|
96
|
+
The asserted ID component allows editing a simple model representing a generic ID with an optional assertion. The ID has:
|
|
97
|
+
|
|
98
|
+
- **value**: the ID itself.
|
|
99
|
+
- **scope**: the context the ID originates from (e.g. an ontology, a repository, a website, etc.).
|
|
100
|
+
- an optional **tag**, used to group or classify the ID.
|
|
101
|
+
- an optional **assertion**, used to define the uncertainty level of the assignment of this ID to the context it applies to.
|
|
102
|
+
|
|
103
|
+
The asserted ID component provides an internal lookup mechanism based on data pins and metadata conventions. When users want to add an ID referring to some internal entity, either found in a part or corresponding to an item, he just has to pick the type of desired lookup (when more than a single lookup search definition is present), and type some characters to get the first N pins starting with these characters; he can then pick one from the list. Once a pin value is picked, the lookup control shows all the relevant data which can be used as components for the ID to build:
|
|
48
104
|
|
|
49
105
|
- the item GUID.
|
|
50
106
|
- the item title.
|
|
@@ -54,19 +110,19 @@ To this end, the asserted ID component provides an internal lookup mechanism bas
|
|
|
54
110
|
|
|
55
111
|
The user can then use buttons to append each of these components to the ID being built, and/or variously edit it. When he's ok with the ID, he can then use it as the reference ID being edited.
|
|
56
112
|
|
|
57
|
-
|
|
113
|
+
### Configuring Asserted ID
|
|
58
114
|
|
|
59
|
-
|
|
115
|
+
The asserted ID component internally uses a scoped pin lookup component (`ScopedPinLookupComponent`) to provide a list of pin-based searches with a lookup control. Whenever the user picks a pin value, he gets the details about its item and part, and item's metadata part, if any. He can then use these data to build a globally unique internal identifier by variously assembling these components.
|
|
60
116
|
|
|
61
|
-
|
|
117
|
+
You can use the scoped ID lookup control to add a pin-based lookup for any entity in your own UI:
|
|
62
118
|
|
|
63
|
-
(1) ensure to import
|
|
119
|
+
(1) ensure to import the component (`ScopedPinLookupComponent`).
|
|
64
120
|
|
|
65
121
|
(2) add a lookup control to your UI, like this:
|
|
66
122
|
|
|
67
123
|
```html
|
|
68
124
|
<!-- lookup -->
|
|
69
|
-
<cadmus-scoped-pin-lookup *ngIf="!noLookup" (idPick)="onIdPick($event)"
|
|
125
|
+
<cadmus-scoped-pin-lookup *ngIf="!noLookup" (idPick)="onIdPick($event)"/>
|
|
70
126
|
```
|
|
71
127
|
|
|
72
128
|
In this sample, my UI has a `noLookup` property which can be used to hide the lookup if not required:
|
|
@@ -109,116 +165,60 @@ export const INDEX_LOOKUP_DEFINITIONS: IndexLookupDefinitions = {
|
|
|
109
165
|
|
|
110
166
|
>Note that while pin name and type will not be displayed to the end user, the key of each definition will. Unless you have a single definition, the lookup component will display a dropdown list with all the available keys, so that the user can select the lookup's scope. So, use short, yet meaningful keys here, like in the above sample (`meta_eid`, `event_eid`).
|
|
111
167
|
|
|
112
|
-
##
|
|
113
|
-
|
|
114
|
-
This is the most complete ID reference. Each asserted composite ID has:
|
|
115
|
-
|
|
116
|
-
- a `target`, representing the pin-based target of the ID. The target model has these properties:
|
|
117
|
-
- a global ID, `gid`, built from the pin or manually defined;
|
|
118
|
-
- a human-friendly `label` for the target, built from the pin or manually defined;
|
|
119
|
-
- for internal links only:
|
|
120
|
-
- `itemId` for the item the pin derives from;
|
|
121
|
-
- when the pin derives from a part, an optional `partId`, `partTypeId`, `roleId`;
|
|
122
|
-
- the `name` and `value` of the pin.
|
|
123
|
-
- an optional `scope`, representing the context the ID originates from (e.g. an ontology, a repository, a website, etc.).
|
|
124
|
-
- an optional `tag`, eventually used to group or classify the ID.
|
|
125
|
-
- an optional `assertion`, eventually used to define the uncertainty level of the assignment of this ID to the context it applies to.
|
|
168
|
+
## AssertedIdsComponent
|
|
126
169
|
|
|
127
|
-
|
|
170
|
+
An editable list of asserted IDs.
|
|
128
171
|
|
|
129
|
-
|
|
172
|
+
- 🔑 `AssertedIdsComponent`
|
|
173
|
+
- 🚩 `cadmus-refs-asserted-ids`
|
|
174
|
+
- ▶️ input:
|
|
175
|
+
- ids (`AssertedId[]`)
|
|
176
|
+
- 📚 thesauri:
|
|
177
|
+
- `asserted-id-scopes` (idScopeEntries)
|
|
178
|
+
- `asserted-id-tags` (idTagEntries)
|
|
179
|
+
- `assertion-tags` (assTagEntries)
|
|
180
|
+
- `doc-reference-types` (refTypeEntries)
|
|
181
|
+
- `doc-reference-tags` (refTagEntries)
|
|
182
|
+
- 🔥 output:
|
|
183
|
+
- idsChange (`AssertedId[]`)
|
|
130
184
|
|
|
131
|
-
|
|
132
|
-
- the part type ID and pin name filter (i.e. the _index lookup definitions_) can be set from many sources:
|
|
133
|
-
1. directly from the consumer code by setting `lookupDefinitions`;
|
|
134
|
-
2. from injection, when (1) is not used;
|
|
135
|
-
3. from thesaurus `model-types`, when (2) is empty.
|
|
136
|
-
- set `pinByTypeMode` to true, to let the editor use in by-type mode instead of by-item;
|
|
137
|
-
- set `canSwitchMode` to true, to allow users switch between by-type and by-item modes;
|
|
138
|
-
- set `canEditTarget` to true, to allow users edit the link target GID and label also for internal pins, where they are automatically provided by pin lookup.
|
|
185
|
+
## PinTargetLookupComponent
|
|
139
186
|
|
|
140
|
-
|
|
187
|
+
- ▶️ input:
|
|
188
|
+
- target (`PinTarget? | null`)
|
|
189
|
+
- pinByTypeMode (`boolean?`)
|
|
190
|
+
- canSwitchMode (`boolean?`)
|
|
191
|
+
- canEditTarget (`boolean?`)
|
|
192
|
+
- defaultPartTypeKey (`string?|null`)
|
|
193
|
+
- lookupDefinitions (`IndexLookupDefinitions?`)
|
|
194
|
+
- extLookupConfigs (`RefLookupConfig[]`): the configurations of external lookup providers, if any.
|
|
195
|
+
- internalDefault (`boolean?`): true to start a new ID as internal rather than external
|
|
196
|
+
- 🔥 output:
|
|
197
|
+
- targetChange (`PinTarget`)
|
|
198
|
+
- editorClose
|
|
141
199
|
|
|
142
|
-
|
|
200
|
+
This component is used to edit an internal or external ID via lookup, and is the core of the [asserted composite ID](#asserted-composite-id) component:
|
|
143
201
|
|
|
144
|
-
|
|
202
|
+
- for **external** IDs, you can enter the ID and its human-friendly label manually, or get them from any number of lookup providers (e.g. VIAF, geonames, etc.).
|
|
145
203
|
|
|
146
|
-
-
|
|
147
|
-
- `AssertedCompositeIdComponent`, the editor for each single ID. This allows you to edit shared metadata (tag and scope), and specific properties for both external and internal ID.
|
|
148
|
-
- `PinTargetLookupComponent`, the editor for an internal ID, i.e. a link target based on pins lookup. This is the core of the editor's logic.
|
|
204
|
+
- for **internal** IDs, your lookup is based on search pins.
|
|
149
205
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
#### AssertedCompositeIdsComponent
|
|
153
|
-
|
|
154
|
-
- 📥 input:
|
|
155
|
-
- `ids` (`AssertedId[]`)
|
|
156
|
-
- `idScopeEntries` (`ThesaurusEntry[]?`): thesaurus `asserted-id-scopes`.
|
|
157
|
-
- `idTagEntries` (`ThesaurusEntry[]?`): thesaurus `asserted-id-tags`.
|
|
158
|
-
- `assTagEntries` (`ThesaurusEntry[]?`): thesaurus `assertion-tags`.
|
|
159
|
-
- `refTypeEntries` (`ThesaurusEntry[]?`): thesaurus `doc-reference-types`.
|
|
160
|
-
- `refTagEntries` (`ThesaurusEntry[]?`): thesaurus `doc-reference-tags`.
|
|
161
|
-
- `pinByTypeMode` (`boolean?`)
|
|
162
|
-
- `canSwitchMode` (`boolean?`)
|
|
163
|
-
- `canEditTarget` (`boolean?`)
|
|
164
|
-
- `defaultPartTypeKey` (`string?|null`)
|
|
165
|
-
- `lookupDefinitions` (`IndexLookupDefinitions?`)
|
|
166
|
-
- `internalDefault` (`boolean?`): true to start a new ID as internal rather than external
|
|
167
|
-
- ⚡ output:
|
|
168
|
-
- `idsChange` (`AssertedId[]`)
|
|
169
|
-
- `extMoreRequest` (`RefLookupSetEvent`): the user requested more about the current external lookup source.
|
|
206
|
+
- for **both** external and internal IDs, you can optionally specify a scope (usually defining the context of the ID, like VIAF or DBPedia, or your own Cadmus database) and a tag (an arbitrary string for grouping or tagging the ID in some way).
|
|
170
207
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
- 📥 input:
|
|
174
|
-
- `id` (`AssertedId? | null`)
|
|
175
|
-
- `idScopeEntries` (`ThesaurusEntry[]?`): thesaurus `asserted-id-scopes`.
|
|
176
|
-
- `idTagEntries` (`ThesaurusEntry[]?`): thesaurus `asserted-id-tags`.
|
|
177
|
-
- `assTagEntries` (`ThesaurusEntry[]?`): thesaurus `assertion-tags`.
|
|
178
|
-
- `refTypeEntries` (`ThesaurusEntry[]?`): thesaurus `doc-reference-types`.
|
|
179
|
-
- `refTagEntries` (`ThesaurusEntry[]?`): thesaurus `doc-reference-tags`.
|
|
180
|
-
- `external` (`boolean?`)
|
|
181
|
-
- `hasSubmit` (`boolean?`)
|
|
182
|
-
- `pinByTypeMode` (`boolean?`)
|
|
183
|
-
- `canSwitchMode` (`boolean?`)
|
|
184
|
-
- `canEditTarget` (`boolean?`)
|
|
185
|
-
- `defaultPartTypeKey` (`string?|null`)
|
|
186
|
-
- `lookupDefinitions` (`IndexLookupDefinitions?`)
|
|
187
|
-
- `internalDefault` (`boolean?`): true to start a new ID as internal rather than external
|
|
188
|
-
- ⚡ output:
|
|
189
|
-
- `idChange` (`AssertedId`)
|
|
190
|
-
- `editorClose`
|
|
191
|
-
- `extMoreRequest` (`RefLookupSetEvent`): the user requested more about the current external lookup source.
|
|
208
|
+
With thousands of parts/fragments providing dozens of pins, you quickly end up with a lot of them. So, to ease their lookup in this control, you can filter them. This component provides _two modes_ to get to a pin-based link target:
|
|
192
209
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
- 📥 input:
|
|
196
|
-
- `target` (`PinTarget? | null`)
|
|
197
|
-
- `pinByTypeMode` (`boolean?`)
|
|
198
|
-
- `canSwitchMode` (`boolean?`)
|
|
199
|
-
- `canEditTarget` (`boolean?`)
|
|
200
|
-
- `defaultPartTypeKey` (`string?|null`)
|
|
201
|
-
- `lookupDefinitions` (`IndexLookupDefinitions?`)
|
|
202
|
-
- `extLookupConfigs` (`RefLookupConfig[]`)
|
|
203
|
-
- `internalDefault` (`boolean?`): true to start a new ID as internal rather than external
|
|
204
|
-
- ⚡ output:
|
|
205
|
-
- `targetChange` (`PinTarget`)
|
|
206
|
-
- `editorClose`
|
|
207
|
-
|
|
208
|
-
### Target ID Editor
|
|
209
|
-
|
|
210
|
-
This component provides _two modes_ to get to a pin-based link target:
|
|
211
|
-
|
|
212
|
-
- **by item** (default mode): the user selects an item from a lookup list; then a part, from the list of the selected item's parts; and finally a pin, from a lookup list of pins filtered by that item's part. This essentially provides a way of selecting a pin from a restricted lookup set.
|
|
213
|
-
- **by type**: the user selects the part's type (or this is automatically pre-selected when only a single type is set), and then selects a pin from a lookup list of pins filtered by that part's type. The list of part types may come from several sources:
|
|
210
|
+
- **by item** (default mode): the user selects an item from a lookup list; then a part, from the list of the parts found in the selected item; and finally a pin, from a lookup list of pins filtered by that item's part. This essentially provides a way of selecting a pin from a restricted lookup set, by walking the data hierarchy from item to part/fragment and finally pin.
|
|
211
|
+
- **by type**: the user selects the part's type (this is automatically pre-selected when only a single type is set), and then selects a pin from a lookup list of pins filtered by that part's type. The list of part types may come from several sources:
|
|
214
212
|
- explicitly set via the component `lookupDefinitions` property;
|
|
215
213
|
- if this is not set, the lookup definitions will be got via injection when available;
|
|
216
214
|
- if the injected definitions are empty, the lookup definitions will be built from the `model-types` thesaurus;
|
|
217
215
|
- if this is not available either, the _by-type_ lookup will be disabled.
|
|
218
216
|
|
|
219
|
-
|
|
217
|
+
>Filtering by item essentially means filtering by an object instance: for instance a specific manuscript object. Filtering by type instead means filtering by pin class, as each part or fragment provides its own set of search pins, whose names are meaningful and unique only in their context.
|
|
220
218
|
|
|
221
|
-
|
|
219
|
+
In both cases, in the end the target ID model is the same; it's just the way the user selects the pin which changes. You can specify the mode for the component with `pinByTypeMode`, and control the possibility of switching between modes with `canSwitchMode`.
|
|
220
|
+
|
|
221
|
+
Once the user picks an internal pin, the target is automatically filled with data from the pin itself. Two values are calculated:
|
|
222
222
|
|
|
223
223
|
- `gid`, the global ID for the target is `P<part-id>/<pin-value>` when the pin is from a part; or `I<item-id>/<pin-value>` when it is from an item only.
|
|
224
224
|
- `label`, the human-friendly label for the target, is `<pin-value> | <item-title> (<part-type>[, <part-role>])`, where `<part-type>` is either the human-friendly name of the part type ID (as drawn from the `model-types` thesaurus), or the part type ID itself.
|
|
@@ -235,22 +235,21 @@ The user can then use buttons to append each of these components to the ID being
|
|
|
235
235
|
|
|
236
236
|
>👉 The demo found in this workspace uses a [mock data service](../../../src/app/services/mock-item.service.ts) instead of the real one, which provides a minimal set of data and functions, just required for the components to function.
|
|
237
237
|
|
|
238
|
-
###
|
|
238
|
+
### Configuring the Target ID Editor
|
|
239
239
|
|
|
240
|
-
|
|
240
|
+
You can configure the target ID editor to use any number of lookup providers:
|
|
241
241
|
|
|
242
|
-
(1) ensure to import
|
|
242
|
+
(1) ensure to import the `PinTargetLookupComponent` control in your component.
|
|
243
243
|
|
|
244
244
|
(2) add a lookup control to your UI, like this:
|
|
245
245
|
|
|
246
246
|
```html
|
|
247
247
|
<!-- lookup -->
|
|
248
248
|
<cadmus-pin-target-lookup [canSwitchMode]="true"
|
|
249
|
-
(targetChange)="onTargetChange($event)"
|
|
250
|
-
</cadmus-pin-target-lookup>
|
|
249
|
+
(targetChange)="onTargetChange($event)"/>
|
|
251
250
|
```
|
|
252
251
|
|
|
253
|
-
(3) specify the lookup definitions, either from
|
|
252
|
+
(3) specify the lookup definitions, either from binding, or via injection. In the latter case, in your app's `index-lookup-definitions.ts` file, add the required lookup definitions. Each definition has a conventional key, and is an object with part type ID for the lookup scope, and pin name, e.g.:
|
|
254
253
|
|
|
255
254
|
```ts
|
|
256
255
|
import { IndexLookupDefinitions } from '@myrmidon/cadmus-core';
|
|
@@ -275,3 +274,84 @@ export const INDEX_LOOKUP_DEFINITIONS: IndexLookupDefinitions = {
|
|
|
275
274
|
```
|
|
276
275
|
|
|
277
276
|
>Note that while pin name and type will not be displayed to the end user, the key of each definition will. Unless you have a single definition, the lookup component will display a dropdown list with all the available keys, so that the user can select the lookup's scope. So, use short, yet meaningful keys here, like in the above sample (`meta_eid`, `event_eid`).
|
|
277
|
+
|
|
278
|
+
## Asserted Composite ID
|
|
279
|
+
|
|
280
|
+
- 🔑 `AssertedCompositeIdComponent`
|
|
281
|
+
- 🚩 `cadmus-refs-asserted-composite-id`
|
|
282
|
+
- ▶️ input:
|
|
283
|
+
- ids (`AssertedId[]`)
|
|
284
|
+
- pinByTypeMode (`boolean?`)
|
|
285
|
+
- canSwitchMode (`boolean?`)
|
|
286
|
+
- canEditTarget (`boolean?`)
|
|
287
|
+
- defaultPartTypeKey (`string?|null`)
|
|
288
|
+
- lookupDefinitions (`IndexLookupDefinitions?`)
|
|
289
|
+
- internalDefault (`boolean?`): true to start a new ID as internal rather than external
|
|
290
|
+
- 📚 thesauri:
|
|
291
|
+
- `asserted-id-scopes` (idScopeEntries)
|
|
292
|
+
- `asserted-id-tags` (idTagEntries)
|
|
293
|
+
- `assertion-tags` (assTagEntries)
|
|
294
|
+
- `doc-reference-types` (refTypeEntries)
|
|
295
|
+
- `doc-reference-tags` (refTagEntries)
|
|
296
|
+
- ⚡ output:
|
|
297
|
+
- `idsChange` (`AssertedId[]`)
|
|
298
|
+
- `extMoreRequest` (`RefLookupSetEvent`): the user requested more about the current external lookup source.
|
|
299
|
+
|
|
300
|
+
This is the most complete ID reference, which can be used for both external and internal IDs, providing full lookup in either cases. Each asserted composite ID has:
|
|
301
|
+
|
|
302
|
+
- a `target`, representing the pin-based target of the ID. The target model has these properties:
|
|
303
|
+
- a global ID, `gid`, built from the pin or manually defined;
|
|
304
|
+
- a human-friendly `label` for the target, built from the pin or manually defined;
|
|
305
|
+
- for internal links only:
|
|
306
|
+
- `itemId` for the item the pin derives from;
|
|
307
|
+
- when the pin derives from a part, an optional `partId`, `partTypeId`, `roleId`;
|
|
308
|
+
- the `name` and `value` of the pin.
|
|
309
|
+
- an optional `scope`, representing the context the ID originates from (e.g. an ontology, a repository, a website, etc.).
|
|
310
|
+
- an optional `tag`, eventually used to group or classify the ID.
|
|
311
|
+
- an optional `assertion`, eventually used to define the uncertainty level of the assignment of this ID to the context it applies to.
|
|
312
|
+
|
|
313
|
+
When the ID is **external**, the only properties set for the target model are `gid` (=the ID) and `label`. You can easily distinguish between an external and internal ID by looking at a property like `name`, which is always present for internal IDs, and never present for external IDs.
|
|
314
|
+
|
|
315
|
+
There are different **options** to customize the lookup behavior:
|
|
316
|
+
|
|
317
|
+
- lookup pin without any filters, except for the always present part type ID and pin name (_by type_); or lookup pin with optional filters for the item and any of its parts (_by item_; this is the default).
|
|
318
|
+
- the part type ID and pin name filter (i.e. the _index lookup definitions_) can be set from many sources:
|
|
319
|
+
1. directly from the consumer code by setting `lookupDefinitions`;
|
|
320
|
+
2. from injection, when (1) is not used;
|
|
321
|
+
3. from thesaurus `model-types`, when (2) is empty.
|
|
322
|
+
- set `pinByTypeMode` to true, to let the editor use in by-type mode instead of by-item;
|
|
323
|
+
- set `canSwitchMode` to true, to allow users switch between by-type and by-item modes;
|
|
324
|
+
- set `canEditTarget` to true, to allow users edit the link target GID and label also for internal pins, where they are automatically provided by pin lookup.
|
|
325
|
+
|
|
326
|
+
These options can be variously combined to force users to use a specific behavior only; for instance, if you just want by-type lookup and automatic GID/label, set `pinByTypeMode` to true and `canSwitchMode` and `canEditTarget` to false.
|
|
327
|
+
|
|
328
|
+
Also, you can use any number of lookup components for external IDs. To globally configure all the asserted composite IDs components for this purpose, you can define (e.g. in your app's component constructor) an array of configuration objects keyed under `ASSERTED_COMPOSITE_ID_CONFIGS_KEY`.
|
|
329
|
+
|
|
330
|
+
Three components are used for this brick:
|
|
331
|
+
|
|
332
|
+
- `AssertedCompositeIdsComponent`, the top level editor for the list of IDs. This has buttons to add new internal/external IDs, and a list of existing IDs. Each existing ID has buttons for editing, moving, and deleting it. When editing, the `AssertedIdComponent` is used in an expansion panel.
|
|
333
|
+
- `AssertedCompositeIdComponent`, the editor for each single ID. This allows you to edit shared metadata (tag and scope), and specific properties for both external and internal ID.
|
|
334
|
+
- `PinTargetLookupComponent`, the editor for an internal ID, i.e. a link target based on pins lookup. This is the core of the editor's logic.
|
|
335
|
+
|
|
336
|
+
## Asserted Composite IDs
|
|
337
|
+
|
|
338
|
+
A collection of asserted composite IDs.
|
|
339
|
+
|
|
340
|
+
- 🔑 `AssertedCompositeIdsComponent`
|
|
341
|
+
- 🚩 `cadmus-refs-asserted-composite-ids`
|
|
342
|
+
- ▶️ input:
|
|
343
|
+
- ids (`AssertedId[]`)
|
|
344
|
+
- pinByTypeMode (`boolean?`)
|
|
345
|
+
- canSwitchMode (`boolean?`)
|
|
346
|
+
- canEditTarget (`boolean?`)
|
|
347
|
+
- defaultPartTypeKey (`string?|null`)
|
|
348
|
+
- lookupDefinitions (`IndexLookupDefinitions?`)
|
|
349
|
+
- internalDefault (`boolean?`): true to start a new ID as internal rather than external
|
|
350
|
+
- 📚 thesauri:
|
|
351
|
+
- `asserted-id-scopes` (idScopeEntries)
|
|
352
|
+
- `asserted-id-tags` (idTagEntries)
|
|
353
|
+
- `assertion-tags` (assTagEntries)
|
|
354
|
+
- `doc-reference-types` (refTypeEntries)
|
|
355
|
+
- `doc-reference-tags` (refTagEntries)
|
|
356
|
+
- ⚡ output:
|
|
357
|
+
- idsChange (`AssertedCompositeId[]`)
|