@lblod/ember-rdfa-editor-lblod-plugins 29.1.0 → 29.1.1-dev.4ca46ea39b10dedc794770fcf202fb89b6e0a16e
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/.changeset/brown-bats-watch-1.md +10 -0
- package/.changeset/brown-bats-watch-2.md +10 -0
- package/.changeset/brown-bats-watch-3.md +10 -0
- package/.changeset/brown-bats-watch-4.md +10 -0
- package/.changeset/brown-bats-watch-5.md +10 -0
- package/.changeset/brown-bats-watch-6.md +10 -0
- package/.changeset/brown-bats-watch-7.md +10 -0
- package/.changeset/brown-bats-watch-8.md +12 -0
- package/.changeset/friendly-suits-deliver.md +5 -0
- package/.changeset/hot-fans-promise.md +5 -0
- package/.changeset/plenty-spies-scream.md +5 -0
- package/.changeset/stupid-eels-eat.md +9 -0
- package/CHANGELOG.md +6 -0
- package/addon/components/lmb-plugin/insert.ts +4 -37
- package/addon/components/location-plugin/insert.gts +27 -5
- package/addon/components/variable-plugin/address/edit.ts +3 -0
- package/addon/components/variable-plugin/address/insert.ts +3 -0
- package/addon/components/variable-plugin/address/nodeview.ts +3 -0
- package/addon/components/variable-plugin/address/utils.ts +3 -0
- package/addon/components/variable-plugin/autofilled/edit.gts +2 -34
- package/addon/components/variable-plugin/autofilled/insert.gts +0 -8
- package/addon/components/variable-plugin/codelist/edit.ts +2 -9
- package/addon/components/variable-plugin/codelist/insert.ts +0 -8
- package/addon/components/variable-plugin/date/edit.ts +12 -33
- package/addon/components/variable-plugin/date/insert-variable.ts +0 -8
- package/addon/components/variable-plugin/date/insert.ts +0 -8
- package/addon/components/variable-plugin/date/nodeview.ts +4 -10
- package/addon/components/variable-plugin/location/edit.ts +1 -3
- package/addon/components/variable-plugin/location/insert.ts +0 -8
- package/addon/components/variable-plugin/number/insert.ts +0 -6
- package/addon/components/variable-plugin/number/nodeview.ts +4 -24
- package/addon/components/variable-plugin/person/edit.hbs +1 -1
- package/addon/components/variable-plugin/person/edit.ts +35 -11
- package/addon/components/variable-plugin/person/insert.ts +4 -37
- package/addon/components/variable-plugin/person/nodeview.ts +12 -13
- package/addon/components/variable-plugin/text/insert.ts +0 -11
- package/addon/models/electee.ts +2 -2
- package/addon/plugins/besluit-type-plugin/utils/fetchBesluitTypes.ts +9 -20
- package/addon/plugins/location-plugin/node.ts +26 -52
- package/addon/plugins/snippet-plugin/nodes/snippet.ts +1 -6
- package/addon/plugins/variable-plugin/actions/create-autofilled-variable.ts +34 -28
- package/addon/plugins/variable-plugin/actions/create-classic-location-variable.ts +42 -34
- package/addon/plugins/variable-plugin/actions/create-codelist-variable.ts +51 -40
- package/addon/plugins/variable-plugin/actions/create-date-variable.ts +46 -36
- package/addon/plugins/variable-plugin/actions/create-number-variable.ts +39 -31
- package/addon/plugins/variable-plugin/actions/create-person-variable.ts +41 -0
- package/addon/plugins/variable-plugin/actions/create-text-variable.ts +36 -29
- package/addon/plugins/variable-plugin/utils/recreate-variable-uris.ts +53 -7
- package/addon/plugins/variable-plugin/variables/autofilled.ts +57 -5
- package/addon/plugins/variable-plugin/variables/codelist.ts +66 -12
- package/addon/plugins/variable-plugin/variables/date.ts +72 -38
- package/addon/plugins/variable-plugin/variables/location.ts +56 -6
- package/addon/plugins/variable-plugin/variables/number.ts +69 -20
- package/addon/plugins/variable-plugin/variables/person.ts +44 -39
- package/addon/plugins/variable-plugin/variables/text.ts +46 -5
- package/declarations/addon/components/variable-plugin/address/edit.d.ts +3 -0
- package/declarations/addon/components/variable-plugin/address/insert.d.ts +3 -0
- package/declarations/addon/components/variable-plugin/address/nodeview.d.ts +3 -0
- package/declarations/addon/components/variable-plugin/address/utils.d.ts +3 -0
- package/declarations/addon/components/variable-plugin/autofilled/edit.d.ts +1 -1
- package/declarations/addon/components/variable-plugin/date/nodeview.d.ts +3 -2
- package/declarations/addon/components/variable-plugin/person/edit.d.ts +1 -1
- package/declarations/addon/components/variable-plugin/person/nodeview.d.ts +3 -4
- package/declarations/addon/models/electee.d.ts +2 -2
- package/declarations/addon/plugins/variable-plugin/actions/create-autofilled-variable.d.ts +10 -6
- package/declarations/addon/plugins/variable-plugin/actions/create-classic-location-variable.d.ts +11 -6
- package/declarations/addon/plugins/variable-plugin/actions/create-codelist-variable.d.ts +12 -6
- package/declarations/addon/plugins/variable-plugin/actions/create-date-variable.d.ts +14 -8
- package/declarations/addon/plugins/variable-plugin/actions/create-number-variable.d.ts +12 -7
- package/declarations/addon/plugins/variable-plugin/actions/create-person-variable.d.ts +18 -0
- package/declarations/addon/plugins/variable-plugin/actions/create-text-variable.d.ts +10 -6
- package/declarations/addon/plugins/variable-plugin/utils/recreate-variable-uris.d.ts +1 -3
- package/package.json +3 -4
- package/pnpm-lock.yaml +5 -98
- package/translations/en-US.yaml +1 -1
- package/translations/nl-BE.yaml +1 -1
|
@@ -8,10 +8,6 @@ import IntlService from 'ember-intl/services/intl';
|
|
|
8
8
|
import { modifier } from 'ember-modifier';
|
|
9
9
|
import { replaceSelectionWithAndSelectNode } from '@lblod/ember-rdfa-editor-lblod-plugins/commands';
|
|
10
10
|
import { createNumberVariable } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/variable-plugin/actions/create-number-variable';
|
|
11
|
-
import {
|
|
12
|
-
generateVariableInstanceUri,
|
|
13
|
-
generateVariableUri,
|
|
14
|
-
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/variable-plugin/utils/variable-helpers';
|
|
15
11
|
|
|
16
12
|
type Args = {
|
|
17
13
|
controller: SayController;
|
|
@@ -89,8 +85,6 @@ export default class NumberInsertComponent extends Component<Args> {
|
|
|
89
85
|
const label = this.label ?? defaultLabel;
|
|
90
86
|
const node = createNumberVariable({
|
|
91
87
|
schema: this.schema,
|
|
92
|
-
variable: generateVariableUri(),
|
|
93
|
-
variableInstance: generateVariableInstanceUri(),
|
|
94
88
|
maximumValue: isNumber(this.maximumValue)
|
|
95
89
|
? Number(this.maximumValue)
|
|
96
90
|
: undefined,
|
|
@@ -11,15 +11,9 @@ import intlService from 'ember-intl/services/intl';
|
|
|
11
11
|
import { localCopy } from 'tracked-toolbox';
|
|
12
12
|
import { isBlank } from '@ember/utils';
|
|
13
13
|
import { Velcro } from 'ember-velcro';
|
|
14
|
-
import { isRdfaAttrs } from '@lblod/ember-rdfa-editor/core/schema';
|
|
15
|
-
import { sayDataFactory } from '@lblod/ember-rdfa-editor/core/say-data-factory';
|
|
16
14
|
import { isNumber } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/strings';
|
|
17
15
|
import { numberToWords } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/variable-plugin/utils/number-to-words';
|
|
18
|
-
import {
|
|
19
|
-
DCT,
|
|
20
|
-
RDF,
|
|
21
|
-
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
|
|
22
|
-
import { getOutgoingTriple } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
|
|
16
|
+
import { Option } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
|
|
23
17
|
|
|
24
18
|
type Args = {
|
|
25
19
|
getPos: () => number | undefined;
|
|
@@ -58,7 +52,7 @@ export default class NumberNodeviewComponent extends Component<Args> {
|
|
|
58
52
|
}
|
|
59
53
|
|
|
60
54
|
get number(): string | null | undefined {
|
|
61
|
-
return
|
|
55
|
+
return this.node.attrs['content'] as Option<string>;
|
|
62
56
|
}
|
|
63
57
|
|
|
64
58
|
get formattedNumber() {
|
|
@@ -99,7 +93,7 @@ export default class NumberNodeviewComponent extends Component<Args> {
|
|
|
99
93
|
|
|
100
94
|
get label(): string | undefined {
|
|
101
95
|
if (this.inputNumber) return '';
|
|
102
|
-
return
|
|
96
|
+
return this.args.node.attrs['label'] as string | undefined;
|
|
103
97
|
}
|
|
104
98
|
|
|
105
99
|
@action onInputNumberChange(event: InputEvent) {
|
|
@@ -168,21 +162,7 @@ export default class NumberNodeviewComponent extends Component<Args> {
|
|
|
168
162
|
@action
|
|
169
163
|
validateAndSave() {
|
|
170
164
|
if (!this.errorMessage) {
|
|
171
|
-
|
|
172
|
-
const properties =
|
|
173
|
-
isRdfaAttrs(attrs) && attrs.rdfaNodeType === 'resource'
|
|
174
|
-
? attrs.properties
|
|
175
|
-
: [];
|
|
176
|
-
const newProperties = properties.filter((prop) => {
|
|
177
|
-
return !RDF('value').matches(prop.predicate);
|
|
178
|
-
});
|
|
179
|
-
if (this.inputNumber) {
|
|
180
|
-
newProperties.push({
|
|
181
|
-
predicate: RDF('value').full,
|
|
182
|
-
object: sayDataFactory.literal(this.inputNumber),
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
this.args.updateAttribute('properties', newProperties);
|
|
165
|
+
this.args.updateAttribute('content', this.inputNumber);
|
|
186
166
|
}
|
|
187
167
|
}
|
|
188
168
|
}
|
|
@@ -5,7 +5,14 @@ import { NodeSelection } from '@lblod/ember-rdfa-editor';
|
|
|
5
5
|
import { tracked } from '@glimmer/tracking';
|
|
6
6
|
import { LmbPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/lmb-plugin';
|
|
7
7
|
import Electee from '@lblod/ember-rdfa-editor-lblod-plugins/models/electee';
|
|
8
|
-
import {
|
|
8
|
+
import { unwrap } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
|
|
9
|
+
import { transactionCombinator } from '@lblod/ember-rdfa-editor/utils/transaction-utils';
|
|
10
|
+
import {
|
|
11
|
+
addPropertyToNode,
|
|
12
|
+
updateSubject,
|
|
13
|
+
} from '@lblod/ember-rdfa-editor/plugins/rdfa-info/utils';
|
|
14
|
+
import { FOAF } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
|
|
15
|
+
import { sayDataFactory } from '@lblod/ember-rdfa-editor/core/say-data-factory';
|
|
9
16
|
|
|
10
17
|
type Args = {
|
|
11
18
|
controller: SayController;
|
|
@@ -59,16 +66,33 @@ export default class PersonEditComponent extends Component<Args> {
|
|
|
59
66
|
this.showModal = false;
|
|
60
67
|
}
|
|
61
68
|
@action
|
|
62
|
-
|
|
63
|
-
const personNode = this.selectedPersonNode
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
onUpdate(electee: Electee) {
|
|
70
|
+
const personNode = unwrap(this.selectedPersonNode);
|
|
71
|
+
this.controller.withTransaction(() => {
|
|
72
|
+
return transactionCombinator(this.controller.activeEditorState)([
|
|
73
|
+
updateSubject({
|
|
74
|
+
pos: personNode.pos,
|
|
75
|
+
targetSubject: electee.uri,
|
|
76
|
+
keepBacklinks: true,
|
|
77
|
+
keepProperties: false,
|
|
78
|
+
keepExternalTriples: true,
|
|
79
|
+
}),
|
|
80
|
+
addPropertyToNode({
|
|
81
|
+
resource: electee.uri,
|
|
82
|
+
property: {
|
|
83
|
+
predicate: FOAF('givenName').full,
|
|
84
|
+
object: sayDataFactory.literal(electee.firstName),
|
|
85
|
+
},
|
|
86
|
+
}),
|
|
87
|
+
addPropertyToNode({
|
|
88
|
+
resource: electee.uri,
|
|
89
|
+
property: {
|
|
90
|
+
predicate: FOAF('familyName').full,
|
|
91
|
+
object: sayDataFactory.literal(electee.lastName),
|
|
92
|
+
},
|
|
93
|
+
}),
|
|
94
|
+
]).transaction;
|
|
95
|
+
});
|
|
72
96
|
this.closeModal();
|
|
73
97
|
}
|
|
74
98
|
}
|
|
@@ -3,15 +3,9 @@ import { tracked } from '@glimmer/tracking';
|
|
|
3
3
|
import { action } from '@ember/object';
|
|
4
4
|
import { service } from '@ember/service';
|
|
5
5
|
import { type SayController } from '@lblod/ember-rdfa-editor';
|
|
6
|
-
import { sayDataFactory } from '@lblod/ember-rdfa-editor/core/say-data-factory';
|
|
7
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
8
6
|
import IntlService from 'ember-intl/services/intl';
|
|
9
|
-
import {
|
|
10
|
-
DCT,
|
|
11
|
-
EXT,
|
|
12
|
-
RDF,
|
|
13
|
-
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
|
|
14
7
|
import { replaceSelectionWithAndSelectNode } from '@lblod/ember-rdfa-editor-lblod-plugins/commands';
|
|
8
|
+
import { createPersonVariable } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/variable-plugin/actions/create-person-variable';
|
|
15
9
|
|
|
16
10
|
type Args = {
|
|
17
11
|
controller: SayController;
|
|
@@ -41,41 +35,14 @@ export default class PersonVariableInsertComponent extends Component<Args> {
|
|
|
41
35
|
|
|
42
36
|
@action
|
|
43
37
|
insert() {
|
|
44
|
-
const mappingSubject = `http://data.lblod.info/mappings/${
|
|
45
|
-
this.args.templateMode ? '--ref-uuid4-' : ''
|
|
46
|
-
}${uuidv4()}`;
|
|
47
|
-
const variableInstance = `http://data.lblod.info/variables/${
|
|
48
|
-
this.args.templateMode ? '--ref-uuid4-' : ''
|
|
49
|
-
}${uuidv4()}`;
|
|
50
|
-
const variableId = uuidv4();
|
|
51
|
-
|
|
52
38
|
const placeholder = this.intl.t('variable.person.label', {
|
|
53
39
|
locale: this.documentLanguage,
|
|
54
40
|
});
|
|
55
41
|
|
|
56
42
|
const label = this.label ?? placeholder;
|
|
57
|
-
const node =
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
__rdfaId: variableId,
|
|
61
|
-
properties: [
|
|
62
|
-
{
|
|
63
|
-
predicate: RDF('type').full,
|
|
64
|
-
object: sayDataFactory.namedNode(EXT('Mapping').full),
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
predicate: EXT('instance').full,
|
|
68
|
-
object: sayDataFactory.namedNode(variableInstance),
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
predicate: EXT('label').full,
|
|
72
|
-
object: sayDataFactory.literal(label),
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
predicate: DCT('type').full,
|
|
76
|
-
object: sayDataFactory.literal('person'),
|
|
77
|
-
},
|
|
78
|
-
],
|
|
43
|
+
const node = createPersonVariable({
|
|
44
|
+
schema: this.controller.schema,
|
|
45
|
+
label,
|
|
79
46
|
});
|
|
80
47
|
|
|
81
48
|
this.label = undefined;
|
|
@@ -2,8 +2,7 @@ import Component from '@glimmer/component';
|
|
|
2
2
|
|
|
3
3
|
import { PNode, SayController } from '@lblod/ember-rdfa-editor';
|
|
4
4
|
import { getOutgoingTriple } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
|
|
5
|
-
import {
|
|
6
|
-
import { Person } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/variable-plugin/variables';
|
|
5
|
+
import { FOAF } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
|
|
7
6
|
|
|
8
7
|
type Args = {
|
|
9
8
|
getPos: () => number | undefined;
|
|
@@ -20,24 +19,24 @@ export default class PersonNodeviewComponent extends Component<Args> {
|
|
|
20
19
|
return this.args.node;
|
|
21
20
|
}
|
|
22
21
|
|
|
23
|
-
get
|
|
24
|
-
|
|
22
|
+
get firstName() {
|
|
23
|
+
const firstName = getOutgoingTriple(this.node.attrs, FOAF('givenName'))
|
|
24
|
+
?.object.value;
|
|
25
|
+
return firstName;
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
get
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
get lastName() {
|
|
29
|
+
const lastName = getOutgoingTriple(this.node.attrs, FOAF('familyName'))
|
|
30
|
+
?.object.value;
|
|
31
|
+
return lastName;
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
get filled() {
|
|
33
|
-
return
|
|
35
|
+
return Boolean(this.node.attrs['subject']);
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
get content() {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
} else {
|
|
40
|
-
return this.label;
|
|
41
|
-
}
|
|
39
|
+
const fullName = [this.firstName, this.lastName].filter(Boolean).join(' ');
|
|
40
|
+
return fullName || this.node.attrs['label'];
|
|
42
41
|
}
|
|
43
42
|
}
|
|
@@ -6,10 +6,6 @@ import { type SayController } from '@lblod/ember-rdfa-editor';
|
|
|
6
6
|
import IntlService from 'ember-intl/services/intl';
|
|
7
7
|
import { replaceSelectionWithAndSelectNode } from '@lblod/ember-rdfa-editor-lblod-plugins/commands';
|
|
8
8
|
import { createTextVariable } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/variable-plugin/actions/create-text-variable';
|
|
9
|
-
import {
|
|
10
|
-
generateVariableInstanceUri,
|
|
11
|
-
generateVariableUri,
|
|
12
|
-
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/variable-plugin/utils/variable-helpers';
|
|
13
9
|
|
|
14
10
|
type Args = {
|
|
15
11
|
controller: SayController;
|
|
@@ -39,11 +35,6 @@ export default class TextVariableInsertComponent extends Component<Args> {
|
|
|
39
35
|
|
|
40
36
|
@action
|
|
41
37
|
insert() {
|
|
42
|
-
const variable = generateVariableUri();
|
|
43
|
-
const variableInstance = generateVariableInstanceUri({
|
|
44
|
-
templateMode: this.args.templateMode,
|
|
45
|
-
});
|
|
46
|
-
|
|
47
38
|
const placeholder = this.intl.t('variable.text.label', {
|
|
48
39
|
locale: this.documentLanguage,
|
|
49
40
|
});
|
|
@@ -51,8 +42,6 @@ export default class TextVariableInsertComponent extends Component<Args> {
|
|
|
51
42
|
const label = this.label ?? placeholder;
|
|
52
43
|
const node = createTextVariable({
|
|
53
44
|
schema: this.schema,
|
|
54
|
-
variable,
|
|
55
|
-
variableInstance,
|
|
56
45
|
label,
|
|
57
46
|
});
|
|
58
47
|
|
package/addon/models/electee.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Term } from '@rdfjs/types';
|
|
2
2
|
import { unwrap } from '../utils/option';
|
|
3
3
|
|
|
4
4
|
export default class Electee {
|
|
@@ -8,7 +8,7 @@ export default class Electee {
|
|
|
8
8
|
readonly lastName: string,
|
|
9
9
|
readonly kandidatenlijst?: string,
|
|
10
10
|
) {}
|
|
11
|
-
static fromBinding(binding:
|
|
11
|
+
static fromBinding(binding: Record<string, Term>) {
|
|
12
12
|
const uri = unwrap(binding['person'].value);
|
|
13
13
|
const firstName = unwrap(binding['firstName'].value);
|
|
14
14
|
const lastName = unwrap(binding['lastName'].value);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { executeQuery } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/sparql-helpers';
|
|
2
|
+
import { Term } from '@rdfjs/types';
|
|
2
3
|
|
|
3
4
|
export type BesluitType = {
|
|
4
5
|
uri: string;
|
|
@@ -47,28 +48,16 @@ export default async function fetchBesluitTypes(
|
|
|
47
48
|
}
|
|
48
49
|
}
|
|
49
50
|
`;
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
});
|
|
53
|
-
const bindingStream = await typeFetcher.fetchBindings(endpoint, query);
|
|
54
|
-
const validBesluitTriples: IBindings[] = [];
|
|
55
|
-
bindingStream.on('data', (triple: IBindings) => {
|
|
56
|
-
validBesluitTriples.push(triple);
|
|
57
|
-
});
|
|
58
|
-
return new Promise<IBindings[]>((resolve, reject) => {
|
|
59
|
-
bindingStream.on('error', reject);
|
|
60
|
-
bindingStream.on('end', () => {
|
|
61
|
-
resolve(validBesluitTriples);
|
|
62
|
-
});
|
|
63
|
-
}).then(quadsToBesluitTypeObjects);
|
|
51
|
+
const bindings = (await executeQuery({ query, endpoint })).results.bindings;
|
|
52
|
+
return bindingsToBesluitTypeObjects(bindings);
|
|
64
53
|
}
|
|
65
54
|
|
|
66
|
-
function
|
|
55
|
+
function bindingsToBesluitTypeObjects(bindings: Record<string, Term>[]) {
|
|
67
56
|
const besluitTypes = new Map<string, BesluitType>();
|
|
68
|
-
|
|
69
|
-
const subject =
|
|
70
|
-
const predicate =
|
|
71
|
-
const object =
|
|
57
|
+
bindings.forEach((binding) => {
|
|
58
|
+
const subject = binding['s'];
|
|
59
|
+
const predicate = binding['p'];
|
|
60
|
+
const object = binding['o'];
|
|
72
61
|
const existing =
|
|
73
62
|
besluitTypes.get(subject.value) ||
|
|
74
63
|
({
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
2
1
|
import type { ComponentLike } from '@glint/template';
|
|
3
2
|
import {
|
|
4
3
|
createEmberNodeSpec,
|
|
@@ -11,15 +10,12 @@ import {
|
|
|
11
10
|
PNode,
|
|
12
11
|
TagParseRule,
|
|
13
12
|
} from '@lblod/ember-rdfa-editor';
|
|
14
|
-
import { sayDataFactory } from '@lblod/ember-rdfa-editor/core/say-data-factory';
|
|
15
13
|
import {
|
|
16
14
|
getRdfaAttrs,
|
|
17
15
|
rdfaAttrSpec,
|
|
18
16
|
renderRdfaAware,
|
|
19
17
|
} from '@lblod/ember-rdfa-editor/core/schema';
|
|
20
18
|
import {
|
|
21
|
-
ADRES,
|
|
22
|
-
DCT,
|
|
23
19
|
EXT,
|
|
24
20
|
LOCN,
|
|
25
21
|
RDF,
|
|
@@ -27,8 +23,6 @@ import {
|
|
|
27
23
|
import {
|
|
28
24
|
hasRdfaVariableType,
|
|
29
25
|
isVariable,
|
|
30
|
-
parseLabel,
|
|
31
|
-
parseVariableInstance,
|
|
32
26
|
parseVariableType,
|
|
33
27
|
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/variable-attribute-parsers';
|
|
34
28
|
import {
|
|
@@ -46,7 +40,6 @@ import {
|
|
|
46
40
|
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/location-plugin/utils/geo-helpers';
|
|
47
41
|
import { findChildWithRdfaAttribute } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
|
|
48
42
|
import { NodeContentsUtils } from './node-contents';
|
|
49
|
-
import { recreateVariableUris } from '../variable-plugin/utils/recreate-variable-uris';
|
|
50
43
|
import { OutgoingTriple } from '@lblod/ember-rdfa-editor/core/rdfa-processor';
|
|
51
44
|
|
|
52
45
|
export interface LocationPluginConfig {
|
|
@@ -72,19 +65,19 @@ const parseDOM = (config: LocationPluginConfig): TagParseRule[] => {
|
|
|
72
65
|
if (attrs.rdfaNodeType !== 'resource') {
|
|
73
66
|
return false;
|
|
74
67
|
}
|
|
68
|
+
|
|
69
|
+
// Do not parse if using old 'variable style'
|
|
70
|
+
if (hasOutgoingNamedNodeTriple(attrs, RDF('type'), EXT('Mapping'))) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
75
73
|
if (contentContainer) {
|
|
76
74
|
const location =
|
|
77
75
|
nodeContentsUtils.address.parse(contentContainer.children[0]) ||
|
|
78
76
|
nodeContentsUtils.place.parse(contentContainer.children[0]) ||
|
|
79
77
|
nodeContentsUtils.area.parse(contentContainer.children[0]);
|
|
80
78
|
if (location) {
|
|
81
|
-
//
|
|
82
|
-
|
|
83
|
-
const properties = attrs.properties?.filter(
|
|
84
|
-
(prop) =>
|
|
85
|
-
!ADRES('verwijstNaar').matches(prop.predicate) ||
|
|
86
|
-
prop.object.termType === 'NamedNode',
|
|
87
|
-
);
|
|
79
|
+
// Ignore the properties for now, we handle these ourselves
|
|
80
|
+
const properties: OutgoingTriple[] = [];
|
|
88
81
|
return {
|
|
89
82
|
...attrs,
|
|
90
83
|
properties,
|
|
@@ -114,11 +107,6 @@ const parseDOM = (config: LocationPluginConfig): TagParseRule[] => {
|
|
|
114
107
|
if (attrs.rdfaNodeType !== 'resource') {
|
|
115
108
|
return false;
|
|
116
109
|
}
|
|
117
|
-
// Filter out properties with content predicate,
|
|
118
|
-
// as we handle this ourselves with the `value` attribute
|
|
119
|
-
attrs.properties = attrs.properties.filter((prop) => {
|
|
120
|
-
return !EXT('content').matches(prop.predicate);
|
|
121
|
-
});
|
|
122
110
|
|
|
123
111
|
const addressNode = [...dataContainer.children].find((el) =>
|
|
124
112
|
hasRDFaAttribute(el, 'property', EXT('content')),
|
|
@@ -137,11 +125,18 @@ const parseDOM = (config: LocationPluginConfig): TagParseRule[] => {
|
|
|
137
125
|
nodeContentsUtils.area.parse(placeNode);
|
|
138
126
|
}
|
|
139
127
|
}
|
|
128
|
+
const value =
|
|
129
|
+
location ??
|
|
130
|
+
nodeContentsUtils.address.parseOld(addressNode || dataContainer);
|
|
131
|
+
if (!value) {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
140
134
|
return {
|
|
141
|
-
|
|
142
|
-
value
|
|
143
|
-
|
|
144
|
-
|
|
135
|
+
rdfaNodeType: 'resource',
|
|
136
|
+
subject: value.uri,
|
|
137
|
+
value,
|
|
138
|
+
backlinks: [],
|
|
139
|
+
properties: [],
|
|
145
140
|
};
|
|
146
141
|
}
|
|
147
142
|
return false;
|
|
@@ -156,8 +151,6 @@ const parseDOM = (config: LocationPluginConfig): TagParseRule[] => {
|
|
|
156
151
|
if (!mappingResource) {
|
|
157
152
|
return false;
|
|
158
153
|
}
|
|
159
|
-
const variableInstance = parseVariableInstance(node);
|
|
160
|
-
const label = parseLabel(node);
|
|
161
154
|
|
|
162
155
|
const addressNode = [...node.children].find((el) =>
|
|
163
156
|
hasRDFaAttribute(el, 'property', EXT('content')),
|
|
@@ -166,36 +159,18 @@ const parseDOM = (config: LocationPluginConfig): TagParseRule[] => {
|
|
|
166
159
|
return false;
|
|
167
160
|
}
|
|
168
161
|
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
},
|
|
174
|
-
{
|
|
175
|
-
predicate: EXT('instance').full,
|
|
176
|
-
object: sayDataFactory.namedNode(
|
|
177
|
-
variableInstance ??
|
|
178
|
-
`http://data.lblod.info/variables/${uuidv4()}`,
|
|
179
|
-
),
|
|
180
|
-
},
|
|
181
|
-
{
|
|
182
|
-
predicate: DCT('type').full,
|
|
183
|
-
object: sayDataFactory.literal('address'),
|
|
184
|
-
},
|
|
185
|
-
];
|
|
186
|
-
if (label) {
|
|
187
|
-
properties.push({
|
|
188
|
-
predicate: EXT('label').full,
|
|
189
|
-
object: sayDataFactory.literal(label),
|
|
190
|
-
});
|
|
162
|
+
const value = nodeContentsUtils.address.parseOld(addressNode);
|
|
163
|
+
|
|
164
|
+
if (!value) {
|
|
165
|
+
return false;
|
|
191
166
|
}
|
|
192
167
|
|
|
193
168
|
return {
|
|
194
|
-
value: nodeContentsUtils.address.parseOld(addressNode),
|
|
195
|
-
subject: mappingResource,
|
|
196
169
|
rdfaNodeType: 'resource',
|
|
197
|
-
|
|
198
|
-
|
|
170
|
+
subject: value.uri,
|
|
171
|
+
value,
|
|
172
|
+
properties: [],
|
|
173
|
+
backlinks: [],
|
|
199
174
|
};
|
|
200
175
|
}
|
|
201
176
|
|
|
@@ -246,7 +221,6 @@ const emberNodeConfig = (config: LocationPluginConfig): EmberNodeConfig => ({
|
|
|
246
221
|
group: 'inline variable',
|
|
247
222
|
atom: true,
|
|
248
223
|
editable: true,
|
|
249
|
-
recreateUriFunction: recreateVariableUris,
|
|
250
224
|
draggable: false,
|
|
251
225
|
needsFFKludge: true,
|
|
252
226
|
selectable: true,
|
|
@@ -52,12 +52,7 @@ function outgoingFromBacklink(
|
|
|
52
52
|
} else {
|
|
53
53
|
return {
|
|
54
54
|
predicate: backlink.predicate,
|
|
55
|
-
object: sayDataFactory.literalNode(
|
|
56
|
-
attrs.__rdfaId,
|
|
57
|
-
('language' in backlink.subject && backlink.subject.language) ||
|
|
58
|
-
('datatype' in backlink.subject && backlink.subject.datatype) ||
|
|
59
|
-
'',
|
|
60
|
-
),
|
|
55
|
+
object: sayDataFactory.literalNode(attrs.__rdfaId),
|
|
61
56
|
};
|
|
62
57
|
}
|
|
63
58
|
}
|
|
@@ -3,8 +3,13 @@ import {
|
|
|
3
3
|
DCT,
|
|
4
4
|
RDF,
|
|
5
5
|
VARIABLES,
|
|
6
|
+
XSD,
|
|
6
7
|
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
|
|
7
|
-
import {
|
|
8
|
+
import { AllOrNone } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/types';
|
|
9
|
+
import {
|
|
10
|
+
FullTriple,
|
|
11
|
+
IncomingTriple,
|
|
12
|
+
} from '@lblod/ember-rdfa-editor/core/rdfa-processor';
|
|
8
13
|
import { sayDataFactory } from '@lblod/ember-rdfa-editor/core/say-data-factory';
|
|
9
14
|
|
|
10
15
|
type CreateAutofilledVariableArgs = {
|
|
@@ -26,13 +31,11 @@ export function createAutofilledVariable(args: CreateAutofilledVariableArgs) {
|
|
|
26
31
|
}
|
|
27
32
|
|
|
28
33
|
type CreateAutofilledVariableAttrsArgs = {
|
|
29
|
-
variable: string;
|
|
30
|
-
variableInstance: string;
|
|
31
34
|
label?: string;
|
|
32
35
|
autofillKey?: string;
|
|
33
36
|
convertToString?: boolean;
|
|
34
37
|
initialized?: boolean;
|
|
35
|
-
};
|
|
38
|
+
} & AllOrNone<{ variable: string; variableInstance: string }>;
|
|
36
39
|
|
|
37
40
|
export function createAutofilledVariableAttrs({
|
|
38
41
|
variable,
|
|
@@ -42,34 +45,37 @@ export function createAutofilledVariableAttrs({
|
|
|
42
45
|
convertToString,
|
|
43
46
|
initialized,
|
|
44
47
|
}: CreateAutofilledVariableAttrsArgs) {
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
48
|
+
const externalTriples: FullTriple[] = [];
|
|
49
|
+
const backlinks: IncomingTriple[] = [];
|
|
50
|
+
if (variable) {
|
|
51
|
+
externalTriples.push(
|
|
52
|
+
{
|
|
53
|
+
subject: sayDataFactory.namedNode(variableInstance),
|
|
54
|
+
predicate: RDF('type').full,
|
|
55
|
+
object: sayDataFactory.namedNode(VARIABLES('VariableInstance').full),
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
subject: sayDataFactory.namedNode(variableInstance),
|
|
59
|
+
predicate: VARIABLES('instanceOf').full,
|
|
60
|
+
object: sayDataFactory.namedNode(variable),
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
subject: sayDataFactory.namedNode(variableInstance),
|
|
64
|
+
predicate: DCT('type').full,
|
|
65
|
+
object: sayDataFactory.literal('autofilled'),
|
|
66
|
+
},
|
|
67
|
+
);
|
|
68
|
+
backlinks.push({
|
|
69
|
+
subject: sayDataFactory.resourceNode(variableInstance),
|
|
59
70
|
predicate: RDF('value').full,
|
|
60
|
-
object: sayDataFactory.contentLiteral(),
|
|
61
|
-
},
|
|
62
|
-
];
|
|
63
|
-
if (label) {
|
|
64
|
-
properties.push({
|
|
65
|
-
predicate: DCT('title').full,
|
|
66
|
-
object: sayDataFactory.literal(label),
|
|
67
71
|
});
|
|
68
72
|
}
|
|
69
73
|
return {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
74
|
+
rdfaNodeType: 'literal',
|
|
75
|
+
datatype: XSD('string').namedNode,
|
|
76
|
+
backlinks,
|
|
77
|
+
label,
|
|
78
|
+
externalTriples,
|
|
73
79
|
autofillKey,
|
|
74
80
|
convertToString,
|
|
75
81
|
initialized,
|