@lblod/ember-rdfa-editor-lblod-plugins 7.1.0 → 8.0.1
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/CHANGELOG.md +32 -1
- package/README.md +12 -11
- package/addon/components/generic-rdfa-variable/insert-menu.hbs +30 -0
- package/addon/components/generic-rdfa-variable/insert-menu.ts +97 -0
- package/addon/components/rdfa-date-plugin/date.hbs +9 -0
- package/addon/components/rdfa-date-plugin/date.ts +55 -0
- package/addon/components/variable-plugin/insert-variable-card.hbs +19 -0
- package/addon/components/variable-plugin/insert-variable-card.ts +26 -5
- package/addon/components/variable-plugin/number-settings.hbs +31 -0
- package/addon/components/variable-plugin/template-variable-card.hbs +3 -0
- package/addon/components/variable-plugin/template-variable-card.ts +3 -0
- package/addon/components/variable-plugin/variable.hbs +7 -1
- package/addon/components/variable-plugin/variable.ts +39 -0
- package/addon/plugins/citation-plugin/utils/vlaamse-codex.ts +1 -2
- package/addon/plugins/rdfa-date-plugin/nodes/date.ts +150 -114
- package/addon/plugins/validation/README.md +1 -1
- package/addon/plugins/variable-plugin/nodes.ts +68 -3
- package/addon/plugins/variable-plugin/utils/constants.ts +29 -15
- package/addon/plugins/variable-plugin/utils/fetch-data.ts +9 -5
- package/app/components/generic-rdfa-variable/insert-menu.js +1 -0
- package/app/components/rdfa-date-plugin/date.js +1 -0
- package/app/components/variable-plugin/number-settings.js +1 -0
- package/app/styles/generic-rdfa-variable.scss +20 -0
- package/app/styles/variable-plugin.scss +31 -0
- package/components/generic-rdfa-variable/insert-menu.d.ts +17 -0
- package/components/rdfa-date-plugin/date.d.ts +16 -0
- package/components/variable-plugin/insert-variable-card.d.ts +4 -0
- package/components/variable-plugin/template-variable-card.d.ts +1 -0
- package/components/variable-plugin/variable.d.ts +11 -0
- package/package.json +8 -4
- package/plugins/citation-plugin/utils/vlaamse-codex.d.ts +2 -2
- package/plugins/rdfa-date-plugin/nodes/date.d.ts +2 -3
- package/plugins/variable-plugin/nodes.d.ts +22 -1
- package/plugins/variable-plugin/utils/constants.d.ts +11 -2
- package/translations/en-US.yaml +15 -0
- package/translations/nl-BE.yaml +15 -0
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
createEmberNodeSpec,
|
|
3
|
+
createEmberNodeView,
|
|
4
|
+
EmberNodeConfig,
|
|
5
|
+
} from '@lblod/ember-rdfa-editor/utils/ember-node';
|
|
2
6
|
import {
|
|
3
7
|
DCT,
|
|
4
8
|
EXT,
|
|
@@ -7,128 +11,160 @@ import {
|
|
|
7
11
|
import { hasRDFaAttribute } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
|
|
8
12
|
import { DateOptions } from '..';
|
|
9
13
|
import { formatDate, validateDateFormat } from '../utils';
|
|
14
|
+
import { PNode } from '@lblod/ember-rdfa-editor';
|
|
10
15
|
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
default: true,
|
|
25
|
-
},
|
|
26
|
-
custom: {
|
|
27
|
-
default: false,
|
|
28
|
-
},
|
|
16
|
+
const emberNodeConfig = (options: DateOptions): EmberNodeConfig => ({
|
|
17
|
+
name: 'date',
|
|
18
|
+
group: 'inline',
|
|
19
|
+
componentPath: 'rdfa-date-plugin/date',
|
|
20
|
+
inline: true,
|
|
21
|
+
selectable: true,
|
|
22
|
+
draggable: false,
|
|
23
|
+
atom: true,
|
|
24
|
+
defining: false,
|
|
25
|
+
options,
|
|
26
|
+
attrs: {
|
|
27
|
+
mappingResource: {
|
|
28
|
+
default: null,
|
|
29
29
|
},
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const { value, onlyDate, format } = node.attrs;
|
|
33
|
-
const humanReadableDate = value
|
|
34
|
-
? formatDate(new Date(value), format)
|
|
35
|
-
: onlyDate
|
|
36
|
-
? options.placeholder.insertDate
|
|
37
|
-
: options.placeholder.insertDateTime;
|
|
38
|
-
return humanReadableDate;
|
|
30
|
+
humanReadableDate: {
|
|
31
|
+
default: options.placeholder.insertDate,
|
|
39
32
|
},
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
['span', dateAttrs, humanReadableDate],
|
|
72
|
-
];
|
|
33
|
+
value: {},
|
|
34
|
+
format: {
|
|
35
|
+
default: options.formats[0].dateFormat,
|
|
36
|
+
},
|
|
37
|
+
onlyDate: {
|
|
38
|
+
default: true,
|
|
39
|
+
},
|
|
40
|
+
custom: {
|
|
41
|
+
default: false,
|
|
42
|
+
},
|
|
43
|
+
label: {
|
|
44
|
+
default: '',
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
leafText: (node: PNode) => {
|
|
48
|
+
const { value, onlyDate, format } = node.attrs;
|
|
49
|
+
const humanReadableDate = value
|
|
50
|
+
? formatDate(new Date(value), format)
|
|
51
|
+
: onlyDate
|
|
52
|
+
? options.placeholder.insertDate
|
|
53
|
+
: options.placeholder.insertDateTime;
|
|
54
|
+
return humanReadableDate;
|
|
55
|
+
},
|
|
56
|
+
toDOM: (node) => {
|
|
57
|
+
const { value, onlyDate, format, mappingResource, custom, label } =
|
|
58
|
+
node.attrs;
|
|
59
|
+
const datatype = onlyDate ? XSD('date') : XSD('dateTime');
|
|
60
|
+
let humanReadableDate: string;
|
|
61
|
+
if (value) {
|
|
62
|
+
if (validateDateFormat(format).type === 'ok') {
|
|
63
|
+
humanReadableDate = formatDate(new Date(value), format);
|
|
73
64
|
} else {
|
|
74
|
-
|
|
65
|
+
humanReadableDate = 'Ongeldig formaat';
|
|
75
66
|
}
|
|
67
|
+
} else {
|
|
68
|
+
humanReadableDate = (onlyDate as boolean)
|
|
69
|
+
? options.placeholder.insertDate
|
|
70
|
+
: options.placeholder.insertDateTime;
|
|
71
|
+
}
|
|
72
|
+
const dateAttrs = {
|
|
73
|
+
datatype: datatype.prefixed,
|
|
74
|
+
property: EXT('content').prefixed,
|
|
75
|
+
'data-format': format as string,
|
|
76
|
+
'data-custom': custom ? 'true' : 'false',
|
|
77
|
+
...(!!value && { content: value as string }),
|
|
78
|
+
};
|
|
79
|
+
if (mappingResource) {
|
|
80
|
+
return [
|
|
81
|
+
'span',
|
|
82
|
+
{
|
|
83
|
+
resource: mappingResource as string,
|
|
84
|
+
typeof: EXT('Mapping').prefixed,
|
|
85
|
+
class: 'date',
|
|
86
|
+
'data-label': label as string,
|
|
87
|
+
},
|
|
88
|
+
['span', { property: DCT('type').prefixed, content: 'date' }],
|
|
89
|
+
['span', dateAttrs, humanReadableDate],
|
|
90
|
+
];
|
|
91
|
+
} else {
|
|
92
|
+
return ['span', { class: 'date', ...dateAttrs }, humanReadableDate];
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
parseDOM: [
|
|
96
|
+
{
|
|
97
|
+
tag: 'span',
|
|
98
|
+
getAttrs: (node: HTMLElement) => {
|
|
99
|
+
if (
|
|
100
|
+
hasRDFaAttribute(node, 'datatype', XSD('date')) ||
|
|
101
|
+
hasRDFaAttribute(node, 'datatype', XSD('dateTime'))
|
|
102
|
+
) {
|
|
103
|
+
const onlyDate = hasRDFaAttribute(node, 'datatype', XSD('date'));
|
|
104
|
+
return {
|
|
105
|
+
value: node.getAttribute('content') ?? new Date().toISOString(),
|
|
106
|
+
onlyDate,
|
|
107
|
+
format: node.dataset.format,
|
|
108
|
+
custom: node.dataset.custom === 'true',
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
return false;
|
|
112
|
+
},
|
|
76
113
|
},
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
114
|
+
{
|
|
115
|
+
tag: 'span',
|
|
116
|
+
getAttrs: (node: HTMLElement) => {
|
|
117
|
+
if (hasRDFaAttribute(node, 'typeof', EXT('Mapping'))) {
|
|
118
|
+
const mappingResource = node.getAttribute('resource');
|
|
119
|
+
if (!mappingResource) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
const variableType = [...node.children]
|
|
123
|
+
.find((el) => hasRDFaAttribute(el, 'property', DCT('type')))
|
|
124
|
+
?.getAttribute('content');
|
|
125
|
+
const datatype = [...node.children]
|
|
126
|
+
.find((el) => hasRDFaAttribute(el, 'property', EXT('content')))
|
|
127
|
+
?.getAttribute('datatype');
|
|
128
|
+
if (variableType === 'date' && datatype) {
|
|
129
|
+
const onlyDate = !![...node.children].find((el) =>
|
|
130
|
+
hasRDFaAttribute(el, 'datatype', XSD('date'))
|
|
131
|
+
);
|
|
132
|
+
const dateNode = [...node.children].find((el) =>
|
|
133
|
+
hasRDFaAttribute(el, 'property', EXT('content'))
|
|
134
|
+
) as HTMLElement | undefined;
|
|
135
|
+
let humanReadableDate: string;
|
|
136
|
+
const value = dateNode?.getAttribute('content');
|
|
137
|
+
const format = dateNode?.dataset.format;
|
|
138
|
+
if (value && format) {
|
|
139
|
+
if (validateDateFormat(format).type === 'ok') {
|
|
140
|
+
humanReadableDate = formatDate(new Date(value), format);
|
|
141
|
+
} else {
|
|
142
|
+
humanReadableDate = 'Ongeldig formaat';
|
|
143
|
+
}
|
|
144
|
+
} else {
|
|
145
|
+
humanReadableDate = onlyDate
|
|
146
|
+
? options.placeholder.insertDate
|
|
147
|
+
: options.placeholder.insertDateTime;
|
|
148
|
+
}
|
|
149
|
+
const label = node.getAttribute('data-label') || variableType;
|
|
86
150
|
return {
|
|
87
|
-
|
|
151
|
+
mappingResource,
|
|
88
152
|
onlyDate,
|
|
89
|
-
|
|
90
|
-
|
|
153
|
+
humanReadableDate,
|
|
154
|
+
value: value,
|
|
155
|
+
format: format,
|
|
156
|
+
custom: dateNode?.dataset.custom === 'true',
|
|
157
|
+
label,
|
|
91
158
|
};
|
|
92
159
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
tag: 'span',
|
|
98
|
-
getAttrs: (node: HTMLElement) => {
|
|
99
|
-
if (hasRDFaAttribute(node, 'typeof', EXT('Mapping'))) {
|
|
100
|
-
const mappingResource = node.getAttribute('resource');
|
|
101
|
-
if (!mappingResource) {
|
|
102
|
-
return false;
|
|
103
|
-
}
|
|
104
|
-
const variableType = [...node.children]
|
|
105
|
-
.find((el) => hasRDFaAttribute(el, 'property', DCT('type')))
|
|
106
|
-
?.getAttribute('content');
|
|
107
|
-
const datatype = [...node.children]
|
|
108
|
-
.find((el) => hasRDFaAttribute(el, 'property', EXT('content')))
|
|
109
|
-
?.getAttribute('datatype');
|
|
110
|
-
if (variableType === 'date' && datatype) {
|
|
111
|
-
const onlyDate = !![...node.children].find((el) =>
|
|
112
|
-
hasRDFaAttribute(el, 'datatype', XSD('date'))
|
|
113
|
-
);
|
|
114
|
-
const dateNode = [...node.children].find((el) =>
|
|
115
|
-
hasRDFaAttribute(el, 'property', EXT('content'))
|
|
116
|
-
) as HTMLElement | undefined;
|
|
117
|
-
return {
|
|
118
|
-
mappingResource,
|
|
119
|
-
onlyDate,
|
|
120
|
-
value:
|
|
121
|
-
dateNode?.getAttribute('content') ?? new Date().toISOString(),
|
|
122
|
-
format: dateNode?.dataset.format,
|
|
123
|
-
custom: dateNode?.dataset.custom === 'true',
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
return false;
|
|
128
|
-
},
|
|
160
|
+
}
|
|
161
|
+
return false;
|
|
129
162
|
},
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
};
|
|
163
|
+
},
|
|
164
|
+
],
|
|
165
|
+
});
|
|
133
166
|
|
|
134
|
-
export
|
|
167
|
+
export const date = (options: DateOptions) =>
|
|
168
|
+
createEmberNodeSpec(emberNodeConfig(options));
|
|
169
|
+
export const dateView = (options: DateOptions) =>
|
|
170
|
+
createEmberNodeView(emberNodeConfig(options));
|
|
@@ -9,10 +9,55 @@ import {
|
|
|
9
9
|
EmberNodeConfig,
|
|
10
10
|
} from '@lblod/ember-rdfa-editor/utils/ember-node';
|
|
11
11
|
import { v4 as uuidv4 } from 'uuid';
|
|
12
|
+
import {
|
|
13
|
+
MAXIMUM_VALUE_HTML_ATTRIBUTE_KEY,
|
|
14
|
+
MAXIMUM_VALUE_PNODE_KEY,
|
|
15
|
+
MINIMUM_VALUE_HTML_ATTRIBUTE_KEY,
|
|
16
|
+
MINIMUM_VALUE_PNODE_KEY,
|
|
17
|
+
} from './utils/constants';
|
|
18
|
+
import { PNode } from '@lblod/ember-rdfa-editor';
|
|
12
19
|
|
|
13
|
-
const CONTENT_SELECTOR = `span[property~='${EXT('content').prefixed}'],
|
|
20
|
+
const CONTENT_SELECTOR = `span[property~='${EXT('content').prefixed}'],
|
|
14
21
|
span[property~='${EXT('content').full}']`;
|
|
15
22
|
|
|
23
|
+
export const getHTMLNodeExtraAttributes = ({
|
|
24
|
+
node,
|
|
25
|
+
type,
|
|
26
|
+
}: {
|
|
27
|
+
node: HTMLElement;
|
|
28
|
+
type: string;
|
|
29
|
+
}) => {
|
|
30
|
+
if (type === 'number') {
|
|
31
|
+
return {
|
|
32
|
+
[MINIMUM_VALUE_PNODE_KEY]:
|
|
33
|
+
node.getAttribute(MINIMUM_VALUE_HTML_ATTRIBUTE_KEY) ?? null,
|
|
34
|
+
[MAXIMUM_VALUE_PNODE_KEY]:
|
|
35
|
+
node.getAttribute(MAXIMUM_VALUE_HTML_ATTRIBUTE_KEY) ?? null,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return {};
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const getPNodeExtraAttributes = ({
|
|
43
|
+
node,
|
|
44
|
+
type,
|
|
45
|
+
}: {
|
|
46
|
+
node: PNode;
|
|
47
|
+
type: string;
|
|
48
|
+
}) => {
|
|
49
|
+
if (type === 'number') {
|
|
50
|
+
return {
|
|
51
|
+
[MINIMUM_VALUE_HTML_ATTRIBUTE_KEY]:
|
|
52
|
+
(node.attrs[MINIMUM_VALUE_PNODE_KEY] as string) ?? null,
|
|
53
|
+
[MAXIMUM_VALUE_HTML_ATTRIBUTE_KEY]:
|
|
54
|
+
(node.attrs[MAXIMUM_VALUE_PNODE_KEY] as string) ?? null,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return {};
|
|
59
|
+
};
|
|
60
|
+
|
|
16
61
|
const emberNodeConfig: EmberNodeConfig = {
|
|
17
62
|
name: 'variable',
|
|
18
63
|
componentPath: 'variable-plugin/variable',
|
|
@@ -39,6 +84,15 @@ const emberNodeConfig: EmberNodeConfig = {
|
|
|
39
84
|
datatype: {
|
|
40
85
|
default: null,
|
|
41
86
|
},
|
|
87
|
+
label: {
|
|
88
|
+
default: '',
|
|
89
|
+
},
|
|
90
|
+
minimumValue: {
|
|
91
|
+
default: null,
|
|
92
|
+
},
|
|
93
|
+
maximumValue: {
|
|
94
|
+
default: null,
|
|
95
|
+
},
|
|
42
96
|
},
|
|
43
97
|
toDOM: (node) => {
|
|
44
98
|
const {
|
|
@@ -48,12 +102,17 @@ const emberNodeConfig: EmberNodeConfig = {
|
|
|
48
102
|
type,
|
|
49
103
|
datatype,
|
|
50
104
|
source,
|
|
105
|
+
label,
|
|
51
106
|
} = node.attrs;
|
|
107
|
+
|
|
52
108
|
const sourceSpan = source
|
|
53
109
|
? [
|
|
54
110
|
[
|
|
55
111
|
'span',
|
|
56
|
-
{
|
|
112
|
+
{
|
|
113
|
+
property: DCT('source').prefixed,
|
|
114
|
+
resource: source as string,
|
|
115
|
+
},
|
|
57
116
|
],
|
|
58
117
|
]
|
|
59
118
|
: [];
|
|
@@ -73,6 +132,8 @@ const emberNodeConfig: EmberNodeConfig = {
|
|
|
73
132
|
{
|
|
74
133
|
resource: mappingResource as string,
|
|
75
134
|
typeof: EXT('Mapping').prefixed,
|
|
135
|
+
'data-label': label as string,
|
|
136
|
+
...getPNodeExtraAttributes({ node, type: type as string }),
|
|
76
137
|
},
|
|
77
138
|
[
|
|
78
139
|
'span',
|
|
@@ -115,10 +176,11 @@ const emberNodeConfig: EmberNodeConfig = {
|
|
|
115
176
|
const type = [...node.children]
|
|
116
177
|
.find((el) => hasRDFaAttribute(el, 'property', DCT('type')))
|
|
117
178
|
?.getAttribute('content');
|
|
179
|
+
const label = node.getAttribute('data-label') || type;
|
|
118
180
|
const datatype = [...node.children]
|
|
119
181
|
.find((el) => hasRDFaAttribute(el, 'property', EXT('content')))
|
|
120
182
|
?.getAttribute('datatype');
|
|
121
|
-
if (!mappingResource) {
|
|
183
|
+
if (!mappingResource || !type) {
|
|
122
184
|
return false;
|
|
123
185
|
}
|
|
124
186
|
return {
|
|
@@ -130,8 +192,11 @@ const emberNodeConfig: EmberNodeConfig = {
|
|
|
130
192
|
source,
|
|
131
193
|
type,
|
|
132
194
|
datatype,
|
|
195
|
+
label,
|
|
196
|
+
...getHTMLNodeExtraAttributes({ type, node }),
|
|
133
197
|
};
|
|
134
198
|
}
|
|
199
|
+
|
|
135
200
|
return false;
|
|
136
201
|
},
|
|
137
202
|
contentElement: CONTENT_SELECTOR,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PNode, Schema } from '@lblod/ember-rdfa-editor';
|
|
1
|
+
import { Attrs, PNode, Schema } from '@lblod/ember-rdfa-editor';
|
|
2
2
|
import { CodeList, fetchCodeListsByPublisher } from './fetch-data';
|
|
3
3
|
import { v4 as uuidv4 } from 'uuid';
|
|
4
4
|
import { XSD } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
|
|
@@ -10,17 +10,18 @@ export const MULTI_SELECT_CODELIST_TYPE =
|
|
|
10
10
|
export type VariableType = {
|
|
11
11
|
label: string;
|
|
12
12
|
fetchSubtypes?: (endpoint: string, publisher: string) => Promise<CodeList[]>;
|
|
13
|
-
constructor: (
|
|
14
|
-
schema: Schema
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
constructor: (props: {
|
|
14
|
+
schema: Schema;
|
|
15
|
+
label?: string;
|
|
16
|
+
attributes?: Attrs;
|
|
17
|
+
codelist?: CodeList;
|
|
18
|
+
}) => PNode;
|
|
18
19
|
};
|
|
19
20
|
|
|
20
21
|
export const DEFAULT_VARIABLE_TYPES: Record<string, VariableType> = {
|
|
21
22
|
text: {
|
|
22
23
|
label: 'text',
|
|
23
|
-
constructor: (schema) => {
|
|
24
|
+
constructor: ({ schema, label = 'text' }) => {
|
|
24
25
|
const mappingURI = `http://data.lblod.info/mappings/${uuidv4()}`;
|
|
25
26
|
const variableInstance = `http://data.lblod.info/variables/${uuidv4()}`;
|
|
26
27
|
return schema.node(
|
|
@@ -29,6 +30,7 @@ export const DEFAULT_VARIABLE_TYPES: Record<string, VariableType> = {
|
|
|
29
30
|
mappingResource: mappingURI,
|
|
30
31
|
variableInstance,
|
|
31
32
|
type: 'text',
|
|
33
|
+
label,
|
|
32
34
|
},
|
|
33
35
|
schema.node('placeholder', { placeholderText: 'text' })
|
|
34
36
|
);
|
|
@@ -36,9 +38,10 @@ export const DEFAULT_VARIABLE_TYPES: Record<string, VariableType> = {
|
|
|
36
38
|
},
|
|
37
39
|
number: {
|
|
38
40
|
label: 'number',
|
|
39
|
-
constructor: (schema) => {
|
|
41
|
+
constructor: ({ schema, attributes, label = 'number' }) => {
|
|
40
42
|
const mappingURI = `http://data.lblod.info/mappings/${uuidv4()}`;
|
|
41
43
|
const variableInstance = `http://data.lblod.info/variables/${uuidv4()}`;
|
|
44
|
+
|
|
42
45
|
return schema.node(
|
|
43
46
|
'variable',
|
|
44
47
|
{
|
|
@@ -46,6 +49,8 @@ export const DEFAULT_VARIABLE_TYPES: Record<string, VariableType> = {
|
|
|
46
49
|
variableInstance,
|
|
47
50
|
type: 'number',
|
|
48
51
|
datatype: XSD('integer').prefixed,
|
|
52
|
+
label,
|
|
53
|
+
...attributes,
|
|
49
54
|
},
|
|
50
55
|
schema.node('placeholder', { placeholderText: 'number' })
|
|
51
56
|
);
|
|
@@ -53,18 +58,19 @@ export const DEFAULT_VARIABLE_TYPES: Record<string, VariableType> = {
|
|
|
53
58
|
},
|
|
54
59
|
date: {
|
|
55
60
|
label: 'date',
|
|
56
|
-
constructor: (schema) => {
|
|
61
|
+
constructor: ({ schema, label = 'date' }) => {
|
|
57
62
|
return unwrap(
|
|
58
63
|
schema.nodes.date.createAndFill({
|
|
59
64
|
mappingResource: `http://data.lblod.info/mappings/${uuidv4()}`,
|
|
60
65
|
value: null,
|
|
66
|
+
label,
|
|
61
67
|
})
|
|
62
68
|
);
|
|
63
69
|
},
|
|
64
70
|
},
|
|
65
71
|
location: {
|
|
66
72
|
label: 'location',
|
|
67
|
-
constructor: (schema,
|
|
73
|
+
constructor: ({ schema, attributes, label = 'location' }) => {
|
|
68
74
|
const mappingURI = `http://data.lblod.info/mappings/${uuidv4()}`;
|
|
69
75
|
const variableInstance = `http://data.lblod.info/variables/${uuidv4()}`;
|
|
70
76
|
return schema.node(
|
|
@@ -73,7 +79,8 @@ export const DEFAULT_VARIABLE_TYPES: Record<string, VariableType> = {
|
|
|
73
79
|
type: 'location',
|
|
74
80
|
mappingResource: mappingURI,
|
|
75
81
|
variableInstance,
|
|
76
|
-
|
|
82
|
+
label,
|
|
83
|
+
...attributes,
|
|
77
84
|
},
|
|
78
85
|
schema.node('placeholder', {
|
|
79
86
|
placeholderText: 'location',
|
|
@@ -87,7 +94,7 @@ export const DEFAULT_VARIABLE_TYPES: Record<string, VariableType> = {
|
|
|
87
94
|
const codelists = fetchCodeListsByPublisher(endpoint, publisher);
|
|
88
95
|
return codelists;
|
|
89
96
|
},
|
|
90
|
-
constructor: (schema,
|
|
97
|
+
constructor: ({ schema, attributes, codelist, label }) => {
|
|
91
98
|
const mappingURI = `http://data.lblod.info/mappings/${uuidv4()}`;
|
|
92
99
|
const variableInstance = `http://data.lblod.info/variables/${uuidv4()}`;
|
|
93
100
|
return schema.node(
|
|
@@ -95,14 +102,21 @@ export const DEFAULT_VARIABLE_TYPES: Record<string, VariableType> = {
|
|
|
95
102
|
{
|
|
96
103
|
type: 'codelist',
|
|
97
104
|
mappingResource: mappingURI,
|
|
98
|
-
codelistResource:
|
|
105
|
+
codelistResource: codelist?.uri,
|
|
99
106
|
variableInstance,
|
|
100
|
-
|
|
107
|
+
label: label ?? codelist?.label,
|
|
108
|
+
...attributes,
|
|
101
109
|
},
|
|
102
110
|
schema.node('placeholder', {
|
|
103
|
-
placeholderText:
|
|
111
|
+
placeholderText: codelist?.label,
|
|
104
112
|
})
|
|
105
113
|
);
|
|
106
114
|
},
|
|
107
115
|
},
|
|
108
116
|
};
|
|
117
|
+
|
|
118
|
+
export const MINIMUM_VALUE_PNODE_KEY = 'minimumValue';
|
|
119
|
+
export const MAXIMUM_VALUE_PNODE_KEY = 'maximumValue';
|
|
120
|
+
|
|
121
|
+
export const MINIMUM_VALUE_HTML_ATTRIBUTE_KEY = 'data-minimum-value';
|
|
122
|
+
export const MAXIMUM_VALUE_HTML_ATTRIBUTE_KEY = 'data-maximum-value';
|
|
@@ -15,20 +15,24 @@ export type CodeListOption = {
|
|
|
15
15
|
|
|
16
16
|
function generateCodeListOptionsQuery(codelistUri: string): string {
|
|
17
17
|
const codeListOptionsQuery = `
|
|
18
|
-
PREFIX
|
|
18
|
+
PREFIX lblodMobiliteit: <http://data.lblod.info/vocabularies/mobiliteit/>
|
|
19
19
|
PREFIX dct: <http://purl.org/dc/terms/>
|
|
20
20
|
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
|
|
21
21
|
PREFIX schema: <http://schema.org/>
|
|
22
|
+
PREFIX ext: <http://mu.semte.ch/vocabularies/ext/>
|
|
22
23
|
SELECT DISTINCT * WHERE {
|
|
23
|
-
<${codelistUri}> a
|
|
24
|
+
<${codelistUri}> a lblodMobiliteit:Codelist.
|
|
24
25
|
?codelistOptions skos:inScheme <${codelistUri}>.
|
|
25
|
-
?codelistOptions skos:prefLabel ?
|
|
26
|
+
?codelistOptions skos:prefLabel ?value.
|
|
26
27
|
OPTIONAL {
|
|
27
28
|
?codelistOptions schema:position ?position .
|
|
28
29
|
}
|
|
29
30
|
OPTIONAL {
|
|
30
31
|
<${codelistUri}> dct:type ?type.
|
|
31
32
|
}
|
|
33
|
+
OPTIONAL {
|
|
34
|
+
?codelistOptions ext:summary ?label.
|
|
35
|
+
}
|
|
32
36
|
}
|
|
33
37
|
ORDER BY (!BOUND(?position)) ASC(?position)
|
|
34
38
|
`;
|
|
@@ -56,8 +60,8 @@ export async function fetchCodeListOptions(
|
|
|
56
60
|
function parseCodelistOptions(queryResult: QueryResult): CodeListOption[] {
|
|
57
61
|
const bindings = queryResult.results.bindings;
|
|
58
62
|
return bindings.map((binding) => ({
|
|
59
|
-
value: binding['
|
|
60
|
-
label: binding['label']?.value,
|
|
63
|
+
value: binding['value']?.value,
|
|
64
|
+
label: binding['label'] ? binding['label'].value : binding['value']?.value,
|
|
61
65
|
}));
|
|
62
66
|
}
|
|
63
67
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@lblod/ember-rdfa-editor-lblod-plugins/components/generic-rdfa-variable/insert-menu';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@lblod/ember-rdfa-editor-lblod-plugins/components/rdfa-date-plugin/date';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@lblod/ember-rdfa-editor-lblod-plugins/components/variable-plugin/number-settings';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
.generic-rdfa-variable-textarea-wrapper {
|
|
2
|
+
width: 100%;
|
|
3
|
+
height: 100%;
|
|
4
|
+
min-height: 150px;
|
|
5
|
+
display: flex;
|
|
6
|
+
|
|
7
|
+
overflow: visible;
|
|
8
|
+
|
|
9
|
+
.cm-editor {
|
|
10
|
+
width: 100%;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.generic-rdfa-plugin-modal {
|
|
15
|
+
overflow: visible;
|
|
16
|
+
|
|
17
|
+
.au-c-modal__body {
|
|
18
|
+
overflow: visible;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -55,6 +55,15 @@
|
|
|
55
55
|
word-wrap: break-word;
|
|
56
56
|
outline: 0px;
|
|
57
57
|
}
|
|
58
|
+
.label {
|
|
59
|
+
font-size: var(--au-base);
|
|
60
|
+
color: var(--au-blue-700);
|
|
61
|
+
user-select: none;
|
|
62
|
+
margin: 0.5rem;
|
|
63
|
+
}
|
|
64
|
+
.au-c-icon {
|
|
65
|
+
margin: 0;
|
|
66
|
+
}
|
|
58
67
|
}
|
|
59
68
|
}
|
|
60
69
|
|
|
@@ -68,3 +77,25 @@
|
|
|
68
77
|
}
|
|
69
78
|
}
|
|
70
79
|
}
|
|
80
|
+
|
|
81
|
+
.number-settings {
|
|
82
|
+
display: grid;
|
|
83
|
+
grid-template-columns: repeat(3, 1fr);
|
|
84
|
+
grid-template-rows: 1fr;
|
|
85
|
+
|
|
86
|
+
.to {
|
|
87
|
+
display: flex;
|
|
88
|
+
justify-content: center;
|
|
89
|
+
color: var(--au-gray-900);
|
|
90
|
+
|
|
91
|
+
span {
|
|
92
|
+
position: relative;
|
|
93
|
+
top: 33px;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// AuInput @type='number' overrides width to be 100px, we have to override it again
|
|
98
|
+
input[type='number'] {
|
|
99
|
+
width: 100%;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { SayController } from '@lblod/ember-rdfa-editor';
|
|
3
|
+
type Args = {
|
|
4
|
+
controller: SayController;
|
|
5
|
+
};
|
|
6
|
+
export default class GenericRdfaVariableInsertMenu extends Component<Args> {
|
|
7
|
+
modalOpen: boolean;
|
|
8
|
+
private htmlEditor?;
|
|
9
|
+
get controller(): SayController;
|
|
10
|
+
get schema(): import("prosemirror-model").Schema<any, any>;
|
|
11
|
+
showModal(): void;
|
|
12
|
+
closeModal(): void;
|
|
13
|
+
onCancel(): void;
|
|
14
|
+
setupHtmlEditor(element: HTMLElement): void;
|
|
15
|
+
onInsert(): void;
|
|
16
|
+
}
|
|
17
|
+
export {};
|