@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
|
@@ -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 CreateClassicLocationVariableArgs = {
|
|
@@ -28,11 +33,9 @@ export function createClassicLocationVariable(
|
|
|
28
33
|
}
|
|
29
34
|
|
|
30
35
|
type CreateClassicLocationVariableAttrsArgs = {
|
|
31
|
-
variable: string;
|
|
32
|
-
variableInstance: string;
|
|
33
36
|
label?: string;
|
|
34
37
|
source?: string;
|
|
35
|
-
};
|
|
38
|
+
} & AllOrNone<{ variable: string; variableInstance: string }>;
|
|
36
39
|
|
|
37
40
|
export function createClassicLocationVariableAttrs({
|
|
38
41
|
variable,
|
|
@@ -40,39 +43,44 @@ export function createClassicLocationVariableAttrs({
|
|
|
40
43
|
label,
|
|
41
44
|
source,
|
|
42
45
|
}: CreateClassicLocationVariableAttrsArgs) {
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
46
|
+
const externalTriples: FullTriple[] = [];
|
|
47
|
+
const backlinks: IncomingTriple[] = [];
|
|
48
|
+
if (variable) {
|
|
49
|
+
externalTriples.push(
|
|
50
|
+
{
|
|
51
|
+
subject: sayDataFactory.namedNode(variableInstance),
|
|
52
|
+
predicate: RDF('type').full,
|
|
53
|
+
object: sayDataFactory.namedNode(VARIABLES('VariableInstance').full),
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
subject: sayDataFactory.namedNode(variableInstance),
|
|
57
|
+
predicate: VARIABLES('instanceOf').full,
|
|
58
|
+
object: sayDataFactory.namedNode(variable),
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
subject: sayDataFactory.namedNode(variableInstance),
|
|
62
|
+
predicate: DCT('type').full,
|
|
63
|
+
object: sayDataFactory.literal('codelist'),
|
|
64
|
+
},
|
|
65
|
+
);
|
|
66
|
+
if (source) {
|
|
67
|
+
externalTriples.push({
|
|
68
|
+
subject: sayDataFactory.namedNode(variableInstance),
|
|
69
|
+
predicate: DCT('source').full,
|
|
70
|
+
object: sayDataFactory.namedNode(source),
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
backlinks.push({
|
|
74
|
+
subject: sayDataFactory.resourceNode(variableInstance),
|
|
57
75
|
predicate: RDF('value').full,
|
|
58
|
-
object: sayDataFactory.contentLiteral(),
|
|
59
|
-
},
|
|
60
|
-
];
|
|
61
|
-
if (label) {
|
|
62
|
-
properties.push({
|
|
63
|
-
predicate: DCT('title').full,
|
|
64
|
-
object: sayDataFactory.literal(label),
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
if (source) {
|
|
68
|
-
properties.push({
|
|
69
|
-
predicate: DCT('source').full,
|
|
70
|
-
object: sayDataFactory.namedNode(source),
|
|
71
76
|
});
|
|
72
77
|
}
|
|
73
78
|
return {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
79
|
+
rdfaNodeType: 'literal',
|
|
80
|
+
datatype: XSD('string').namedNode,
|
|
81
|
+
externalTriples,
|
|
82
|
+
backlinks,
|
|
83
|
+
label,
|
|
84
|
+
source,
|
|
77
85
|
};
|
|
78
86
|
}
|
|
@@ -4,8 +4,13 @@ import {
|
|
|
4
4
|
MOBILITEIT,
|
|
5
5
|
RDF,
|
|
6
6
|
VARIABLES,
|
|
7
|
+
XSD,
|
|
7
8
|
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
|
|
8
|
-
import {
|
|
9
|
+
import { AllOrNone } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/types';
|
|
10
|
+
import {
|
|
11
|
+
FullTriple,
|
|
12
|
+
IncomingTriple,
|
|
13
|
+
} from '@lblod/ember-rdfa-editor/core/rdfa-processor';
|
|
9
14
|
import { sayDataFactory } from '@lblod/ember-rdfa-editor/core/say-data-factory';
|
|
10
15
|
|
|
11
16
|
type CreateCodelistVariableArgs = {
|
|
@@ -27,13 +32,11 @@ export function createCodelistVariable(args: CreateCodelistVariableArgs) {
|
|
|
27
32
|
}
|
|
28
33
|
|
|
29
34
|
type CreateCodelistVariableAttrsArgs = {
|
|
30
|
-
variable: string;
|
|
31
|
-
variableInstance: string;
|
|
32
35
|
label?: string;
|
|
33
36
|
source?: string;
|
|
34
37
|
codelist?: string;
|
|
35
38
|
selectionStyle?: string;
|
|
36
|
-
};
|
|
39
|
+
} & AllOrNone<{ variable: string; variableInstance: string }>;
|
|
37
40
|
|
|
38
41
|
export function createCodelistVariableAttrs({
|
|
39
42
|
variable,
|
|
@@ -43,46 +46,54 @@ export function createCodelistVariableAttrs({
|
|
|
43
46
|
codelist,
|
|
44
47
|
selectionStyle,
|
|
45
48
|
}: CreateCodelistVariableAttrsArgs) {
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
49
|
+
const externalTriples: FullTriple[] = [];
|
|
50
|
+
const backlinks: IncomingTriple[] = [];
|
|
51
|
+
if (variable) {
|
|
52
|
+
externalTriples.push(
|
|
53
|
+
{
|
|
54
|
+
subject: sayDataFactory.namedNode(variableInstance),
|
|
55
|
+
predicate: RDF('type').full,
|
|
56
|
+
object: sayDataFactory.namedNode(VARIABLES('VariableInstance').full),
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
subject: sayDataFactory.namedNode(variableInstance),
|
|
60
|
+
predicate: VARIABLES('instanceOf').full,
|
|
61
|
+
object: sayDataFactory.namedNode(variable),
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
subject: sayDataFactory.namedNode(variableInstance),
|
|
65
|
+
predicate: DCT('type').full,
|
|
66
|
+
object: sayDataFactory.literal('codelist'),
|
|
67
|
+
},
|
|
68
|
+
);
|
|
69
|
+
if (codelist) {
|
|
70
|
+
externalTriples.push({
|
|
71
|
+
subject: sayDataFactory.namedNode(variableInstance),
|
|
72
|
+
predicate: MOBILITEIT('codelijst').full,
|
|
73
|
+
object: sayDataFactory.namedNode(codelist),
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
if (source) {
|
|
77
|
+
externalTriples.push({
|
|
78
|
+
subject: sayDataFactory.namedNode(variableInstance),
|
|
79
|
+
predicate: DCT('source').full,
|
|
80
|
+
object: sayDataFactory.namedNode(source),
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
backlinks.push({
|
|
84
|
+
subject: sayDataFactory.resourceNode(variableInstance),
|
|
60
85
|
predicate: RDF('value').full,
|
|
61
|
-
object: sayDataFactory.contentLiteral(),
|
|
62
|
-
},
|
|
63
|
-
];
|
|
64
|
-
if (label) {
|
|
65
|
-
properties.push({
|
|
66
|
-
predicate: DCT('title').full,
|
|
67
|
-
object: sayDataFactory.literal(label),
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
if (codelist) {
|
|
71
|
-
properties.push({
|
|
72
|
-
predicate: MOBILITEIT('codelijst').full,
|
|
73
|
-
object: sayDataFactory.namedNode(codelist),
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
if (source) {
|
|
77
|
-
properties.push({
|
|
78
|
-
predicate: DCT('source').full,
|
|
79
|
-
object: sayDataFactory.namedNode(source),
|
|
80
86
|
});
|
|
81
87
|
}
|
|
88
|
+
|
|
82
89
|
return {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
90
|
+
rdfaNodeType: 'literal',
|
|
91
|
+
datatype: XSD('string').namedNode,
|
|
92
|
+
externalTriples,
|
|
93
|
+
backlinks,
|
|
94
|
+
source,
|
|
95
|
+
codelist,
|
|
96
|
+
label,
|
|
86
97
|
selectionStyle,
|
|
87
98
|
};
|
|
88
99
|
}
|
|
@@ -5,8 +5,16 @@ import {
|
|
|
5
5
|
VARIABLES,
|
|
6
6
|
XSD,
|
|
7
7
|
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
|
|
8
|
-
import {
|
|
9
|
-
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';
|
|
13
|
+
import {
|
|
14
|
+
sayDataFactory,
|
|
15
|
+
SayNamedNode,
|
|
16
|
+
} from '@lblod/ember-rdfa-editor/core/say-data-factory';
|
|
17
|
+
import { formatContainsTime } from '../utils/date-helpers';
|
|
10
18
|
|
|
11
19
|
type CreateDateVariableArgs = {
|
|
12
20
|
schema: Schema;
|
|
@@ -19,60 +27,62 @@ export function createDateVariable(args: CreateDateVariableArgs) {
|
|
|
19
27
|
}
|
|
20
28
|
|
|
21
29
|
type CreateDateVariableAttrsArgs = {
|
|
22
|
-
variable: string;
|
|
23
|
-
variableInstance: string;
|
|
24
30
|
label?: string;
|
|
25
31
|
value?: string;
|
|
32
|
+
/** @deprecated the `onlyDate` attribute is no longer used. It has been superseded by the usage of `format` and `datatype` */
|
|
26
33
|
onlyDate?: boolean;
|
|
27
34
|
format?: string;
|
|
28
35
|
custom?: boolean;
|
|
29
36
|
customAllowed?: boolean;
|
|
30
|
-
};
|
|
37
|
+
} & AllOrNone<{ variable: string; variableInstance: string }>;
|
|
31
38
|
|
|
32
39
|
export function createDateVariableAttrs({
|
|
33
40
|
variable,
|
|
34
41
|
variableInstance,
|
|
35
42
|
label,
|
|
36
43
|
value,
|
|
37
|
-
onlyDate,
|
|
38
44
|
format,
|
|
39
45
|
custom,
|
|
40
46
|
customAllowed,
|
|
41
47
|
}: CreateDateVariableAttrsArgs) {
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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('date'),
|
|
66
|
+
},
|
|
67
|
+
);
|
|
68
|
+
backlinks.push({
|
|
69
|
+
subject: sayDataFactory.resourceNode(variableInstance),
|
|
64
70
|
predicate: RDF('value').full,
|
|
65
|
-
object: sayDataFactory.literal(
|
|
66
|
-
value,
|
|
67
|
-
onlyDate ? XSD('date').namedNode : XSD('dateTime').namedNode,
|
|
68
|
-
),
|
|
69
71
|
});
|
|
70
72
|
}
|
|
73
|
+
let datatype: SayNamedNode | undefined;
|
|
74
|
+
if (format) {
|
|
75
|
+
datatype = !formatContainsTime(format)
|
|
76
|
+
? XSD('date').namedNode
|
|
77
|
+
: XSD('dateTime').namedNode;
|
|
78
|
+
}
|
|
71
79
|
return {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
80
|
+
rdfaNodeType: 'literal',
|
|
81
|
+
datatype: datatype,
|
|
82
|
+
externalTriples,
|
|
83
|
+
backlinks,
|
|
84
|
+
label,
|
|
85
|
+
content: value,
|
|
76
86
|
format,
|
|
77
87
|
customAllowed,
|
|
78
88
|
custom,
|
|
@@ -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 CreateNumberVariableArgs = {
|
|
@@ -18,14 +23,15 @@ export function createNumberVariable(args: CreateNumberVariableArgs) {
|
|
|
18
23
|
}
|
|
19
24
|
|
|
20
25
|
type CreateNumberVariableAttrsArgs = {
|
|
21
|
-
variable: string;
|
|
22
|
-
variableInstance: string;
|
|
23
|
-
label?: string;
|
|
24
26
|
value?: string;
|
|
25
27
|
minimumValue?: number;
|
|
26
28
|
maximumValue?: number;
|
|
27
29
|
writtenNumber?: boolean;
|
|
28
|
-
|
|
30
|
+
label?: string;
|
|
31
|
+
} & AllOrNone<{
|
|
32
|
+
variable: string;
|
|
33
|
+
variableInstance: string;
|
|
34
|
+
}>;
|
|
29
35
|
|
|
30
36
|
export function createNumberVariableAttrs({
|
|
31
37
|
variable,
|
|
@@ -36,36 +42,38 @@ export function createNumberVariableAttrs({
|
|
|
36
42
|
maximumValue,
|
|
37
43
|
writtenNumber = false,
|
|
38
44
|
}: CreateNumberVariableAttrsArgs) {
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
45
|
+
const externalTriples: FullTriple[] = [];
|
|
46
|
+
const backlinks: IncomingTriple[] = [];
|
|
47
|
+
if (variable) {
|
|
48
|
+
externalTriples.push(
|
|
49
|
+
{
|
|
50
|
+
subject: sayDataFactory.namedNode(variableInstance),
|
|
51
|
+
predicate: RDF('type').full,
|
|
52
|
+
object: sayDataFactory.namedNode(VARIABLES('VariableInstance').full),
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
subject: sayDataFactory.namedNode(variableInstance),
|
|
56
|
+
predicate: VARIABLES('instanceOf').full,
|
|
57
|
+
object: sayDataFactory.namedNode(variable),
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
subject: sayDataFactory.namedNode(variableInstance),
|
|
61
|
+
predicate: DCT('type').full,
|
|
62
|
+
object: sayDataFactory.literal('number'),
|
|
63
|
+
},
|
|
64
|
+
);
|
|
65
|
+
backlinks.push({
|
|
66
|
+
subject: sayDataFactory.resourceNode(variableInstance),
|
|
61
67
|
predicate: RDF('value').full,
|
|
62
|
-
object: sayDataFactory.literal(value),
|
|
63
68
|
});
|
|
64
69
|
}
|
|
65
70
|
return {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
71
|
+
rdfaNodeType: 'literal',
|
|
72
|
+
datatype: XSD('number').namedNode,
|
|
73
|
+
label,
|
|
74
|
+
externalTriples,
|
|
75
|
+
backlinks,
|
|
76
|
+
content: value,
|
|
69
77
|
minimumValue,
|
|
70
78
|
maximumValue,
|
|
71
79
|
writtenNumber,
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Schema } from '@lblod/ember-rdfa-editor';
|
|
2
|
+
import { FOAF } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
|
|
3
|
+
import { OutgoingTriple } from '@lblod/ember-rdfa-editor/core/rdfa-processor';
|
|
4
|
+
import { sayDataFactory } from '@lblod/ember-rdfa-editor/core/say-data-factory';
|
|
5
|
+
import { Person } from '../variables';
|
|
6
|
+
|
|
7
|
+
type CreatePersonVariableArgs = {
|
|
8
|
+
schema: Schema;
|
|
9
|
+
} & CreatePersonVariableAttrsArgs;
|
|
10
|
+
|
|
11
|
+
export function createPersonVariable(args: CreatePersonVariableArgs) {
|
|
12
|
+
const { schema } = args;
|
|
13
|
+
return schema.nodes.person_variable.create(createPersonVariableAttrs(args));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
type CreatePersonVariableAttrsArgs = { label?: string; value?: Person };
|
|
17
|
+
|
|
18
|
+
export function createPersonVariableAttrs({
|
|
19
|
+
label,
|
|
20
|
+
value,
|
|
21
|
+
}: CreatePersonVariableAttrsArgs) {
|
|
22
|
+
const subject = value?.uri ?? null;
|
|
23
|
+
const properties: OutgoingTriple[] = value
|
|
24
|
+
? [
|
|
25
|
+
{
|
|
26
|
+
predicate: FOAF('givenName').full,
|
|
27
|
+
object: sayDataFactory.literal(value.firstName),
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
predicate: FOAF('familyName').full,
|
|
31
|
+
object: sayDataFactory.literal(value.lastName),
|
|
32
|
+
},
|
|
33
|
+
]
|
|
34
|
+
: [];
|
|
35
|
+
return {
|
|
36
|
+
rdfaNodeType: subject ? 'resource' : 'literal',
|
|
37
|
+
subject,
|
|
38
|
+
properties,
|
|
39
|
+
label,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
@@ -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 CreateTextVariableArgs = {
|
|
@@ -24,44 +29,46 @@ export function createTextVariable(args: CreateTextVariableArgs) {
|
|
|
24
29
|
);
|
|
25
30
|
}
|
|
26
31
|
|
|
27
|
-
type CreateTextVariableAttrsArgs = {
|
|
32
|
+
type CreateTextVariableAttrsArgs = { label?: string } & AllOrNone<{
|
|
28
33
|
variable: string;
|
|
29
34
|
variableInstance: string;
|
|
30
|
-
|
|
31
|
-
};
|
|
35
|
+
}>;
|
|
32
36
|
|
|
33
37
|
export function createTextVariableAttrs({
|
|
38
|
+
label,
|
|
34
39
|
variable,
|
|
35
40
|
variableInstance,
|
|
36
|
-
label,
|
|
37
41
|
}: CreateTextVariableAttrsArgs) {
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
42
|
+
const externalTriples: FullTriple[] = [];
|
|
43
|
+
const backlinks: IncomingTriple[] = [];
|
|
44
|
+
if (variable) {
|
|
45
|
+
externalTriples.push(
|
|
46
|
+
{
|
|
47
|
+
subject: sayDataFactory.namedNode(variableInstance),
|
|
48
|
+
predicate: RDF('type').full,
|
|
49
|
+
object: sayDataFactory.namedNode(VARIABLES('VariableInstance').full),
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
subject: sayDataFactory.namedNode(variableInstance),
|
|
53
|
+
predicate: VARIABLES('instanceOf').full,
|
|
54
|
+
object: sayDataFactory.namedNode(variable),
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
subject: sayDataFactory.namedNode(variableInstance),
|
|
58
|
+
predicate: DCT('type').full,
|
|
59
|
+
object: sayDataFactory.literal('text'),
|
|
60
|
+
},
|
|
61
|
+
);
|
|
62
|
+
backlinks.push({
|
|
63
|
+
subject: sayDataFactory.resourceNode(variableInstance),
|
|
52
64
|
predicate: RDF('value').full,
|
|
53
|
-
object: sayDataFactory.contentLiteral(),
|
|
54
|
-
},
|
|
55
|
-
];
|
|
56
|
-
if (label) {
|
|
57
|
-
properties.push({
|
|
58
|
-
predicate: DCT('title').full,
|
|
59
|
-
object: sayDataFactory.literal(label),
|
|
60
65
|
});
|
|
61
66
|
}
|
|
62
67
|
return {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
68
|
+
rdfaNodeType: 'literal',
|
|
69
|
+
datatype: XSD('string').namedNode,
|
|
70
|
+
label,
|
|
71
|
+
backlinks,
|
|
72
|
+
externalTriples,
|
|
66
73
|
};
|
|
67
74
|
}
|
|
@@ -1,12 +1,58 @@
|
|
|
1
1
|
import { Attrs } from '@lblod/ember-rdfa-editor';
|
|
2
2
|
import { generateVariableInstanceUri } from './variable-helpers';
|
|
3
|
+
import {
|
|
4
|
+
FullTriple,
|
|
5
|
+
IncomingTriple,
|
|
6
|
+
} from '@lblod/ember-rdfa-editor/core/rdfa-processor';
|
|
7
|
+
import { Option } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
|
|
8
|
+
import {
|
|
9
|
+
RDF,
|
|
10
|
+
VARIABLES,
|
|
11
|
+
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
|
|
12
|
+
import { sayDataFactory } from '@lblod/ember-rdfa-editor/core/say-data-factory';
|
|
3
13
|
|
|
4
|
-
export function recreateVariableUris(
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const templateMode = variableInstanceUri.includes(`--ref-uuid4-`);
|
|
9
|
-
attrs.subject = generateVariableInstanceUri({ templateMode });
|
|
14
|
+
export function recreateVariableUris(attrs: Attrs) {
|
|
15
|
+
const externalTriples = attrs.externalTriples as Option<FullTriple[]>;
|
|
16
|
+
if (!externalTriples || !externalTriples.length) {
|
|
17
|
+
return attrs;
|
|
10
18
|
}
|
|
11
|
-
|
|
19
|
+
const variableInstanceTriple = externalTriples.find(
|
|
20
|
+
(triple) =>
|
|
21
|
+
RDF('type').matches(triple.predicate) &&
|
|
22
|
+
VARIABLES('VariableInstance').matches(triple.object.value),
|
|
23
|
+
);
|
|
24
|
+
if (!variableInstanceTriple) {
|
|
25
|
+
return attrs;
|
|
26
|
+
}
|
|
27
|
+
const variableInstanceUri = variableInstanceTriple.subject.value;
|
|
28
|
+
const templateMode = variableInstanceUri.includes(`--ref-uuid4-`);
|
|
29
|
+
const newInstanceUri = generateVariableInstanceUri({ templateMode });
|
|
30
|
+
const newTriples = externalTriples.map((triple) => {
|
|
31
|
+
const newTriple = { ...triple };
|
|
32
|
+
if (triple.subject.value === variableInstanceUri) {
|
|
33
|
+
newTriple.subject = sayDataFactory.namedNode(newInstanceUri);
|
|
34
|
+
}
|
|
35
|
+
if (triple.object.value === variableInstanceUri) {
|
|
36
|
+
newTriple.object = sayDataFactory.namedNode(newInstanceUri);
|
|
37
|
+
}
|
|
38
|
+
return newTriple;
|
|
39
|
+
});
|
|
40
|
+
const backlinks = attrs.backlinks as Option<IncomingTriple[]>;
|
|
41
|
+
const newBacklinks = backlinks?.map((backlink) => {
|
|
42
|
+
const newBacklink = { ...backlink };
|
|
43
|
+
if (backlink.subject.value === variableInstanceUri) {
|
|
44
|
+
newBacklink.subject = sayDataFactory.resourceNode(newInstanceUri);
|
|
45
|
+
}
|
|
46
|
+
return newBacklink;
|
|
47
|
+
});
|
|
48
|
+
console.log({
|
|
49
|
+
...attrs,
|
|
50
|
+
externalTriples: newTriples,
|
|
51
|
+
backlinks: newBacklinks,
|
|
52
|
+
});
|
|
53
|
+
return {
|
|
54
|
+
...attrs,
|
|
55
|
+
externalTriples: newTriples,
|
|
56
|
+
backlinks: newBacklinks,
|
|
57
|
+
};
|
|
12
58
|
}
|