@lblod/ember-rdfa-editor-lblod-plugins 32.7.0 → 32.8.0-dev.ccd8888d1efc5ccdedb5c16e6a952e3a0892d760
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/tender-actors-shout.md +5 -0
- package/CHANGELOG.md +17 -0
- package/addon/components/besluit-topic-plugin/besluit-topic-toolbar-dropdown.ts +1 -1
- package/addon/components/besluit-type-plugin/toolbar-dropdown.gts +1 -1
- package/addon/components/decision-plugin/decision-plugin-card.gts +3 -2
- package/addon/components/decision-plugin/insert-article.gts +1 -1
- package/addon/components/document-validation-plugin/card.gts +130 -33
- package/addon/components/lpdc-plugin/lpdc-insert.ts +1 -1
- package/addon/components/roadsign-regulation-plugin/roadsign-regulation-card.gts +1 -1
- package/addon/components/roadsign-regulation-plugin/roadsigns-modal.gts +1 -1
- package/addon/plugins/besluit-type-plugin/utils/besluit-type-instances.ts +1 -1
- package/addon/plugins/besluit-type-plugin/utils/set-besluit-type.ts +1 -1
- package/addon/plugins/decision-plugin/commands/insert-article-container.ts +14 -1
- package/addon/plugins/decision-plugin/commands/insert-description.ts +9 -1
- package/addon/plugins/decision-plugin/commands/insert-motivation.ts +9 -1
- package/addon/plugins/decision-plugin/commands/insert-title.ts +9 -1
- package/addon/plugins/document-validation-plugin/common-fixes.ts +126 -0
- package/addon/plugins/document-validation-plugin/index.ts +61 -32
- package/addon/plugins/roadsign-regulation-plugin/actions/insert-measure.ts +4 -2
- package/addon/plugins/roadsign-regulation-plugin/constants.ts +3 -3
- package/addon/plugins/roadsign-regulation-plugin/nodes.ts +76 -2
- package/addon/plugins/roadsign-regulation-plugin/queries/road-sign-category.ts +1 -1
- package/addon/plugins/roadsign-regulation-plugin/queries/traffic-signal-concept.ts +5 -0
- package/addon/plugins/roadsign-regulation-plugin/schemas/traffic-signal-concept.ts +1 -0
- package/addon/plugins/structure-plugin/commands/move-structure.ts +6 -19
- package/addon/plugins/structure-plugin/monads/recalculate-structure-numbers.ts +3 -0
- package/addon/plugins/variable-plugin/utils/recreate-variable-uris.ts +0 -5
- package/addon/services/import-rdfa-snippet.ts +1 -5
- package/addon/{plugins/besluit-topic-plugin/utils/helpers.ts → utils/decision-utils.ts} +33 -9
- package/declarations/addon/components/document-validation-plugin/card.d.ts +51 -1
- package/declarations/addon/components/roadsign-regulation-plugin/roadsigns-modal.d.ts +2 -0
- package/declarations/addon/plugins/decision-plugin/commands/insert-article-container.d.ts +3 -1
- package/declarations/addon/plugins/document-validation-plugin/common-fixes.d.ts +6 -0
- package/declarations/addon/plugins/document-validation-plugin/index.d.ts +30 -6
- package/declarations/addon/plugins/roadsign-regulation-plugin/constants.d.ts +6 -6
- package/declarations/addon/plugins/roadsign-regulation-plugin/nodes.d.ts +6 -0
- package/declarations/addon/plugins/roadsign-regulation-plugin/queries/mobility-measure-concept.d.ts +1 -0
- package/declarations/addon/plugins/roadsign-regulation-plugin/queries/traffic-signal-concept.d.ts +2 -0
- package/declarations/addon/plugins/roadsign-regulation-plugin/schemas/mobility-measure-concept.d.ts +5 -0
- package/declarations/addon/plugins/roadsign-regulation-plugin/schemas/traffic-signal-concept.d.ts +3 -0
- package/declarations/addon/{plugins/besluit-topic-plugin/utils/helpers.d.ts → utils/decision-utils.d.ts} +5 -1
- package/package.json +3 -3
- package/pnpm-lock.yaml +17 -11
- package/translations/en-US.yaml +1 -0
- package/translations/nl-BE.yaml +1 -0
|
@@ -2,14 +2,17 @@ import factory from '@rdfjs/dataset';
|
|
|
2
2
|
import SHACLValidator from 'rdf-validate-shacl';
|
|
3
3
|
import { Parser as ParserN3 } from 'n3';
|
|
4
4
|
import { RdfaParser } from 'rdfa-streaming-parser';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
ProsePlugin,
|
|
7
|
+
PluginKey,
|
|
8
|
+
EditorView,
|
|
9
|
+
SayController,
|
|
10
|
+
} from '@lblod/ember-rdfa-editor';
|
|
6
11
|
import removeQuotes from '@lblod/ember-rdfa-editor-lblod-plugins/utils/remove-quotes';
|
|
7
12
|
import {
|
|
8
|
-
BlankNode,
|
|
9
13
|
DataFactory,
|
|
10
14
|
DatasetCore,
|
|
11
15
|
DatasetCoreFactory,
|
|
12
|
-
NamedNode,
|
|
13
16
|
Quad,
|
|
14
17
|
} from '@rdfjs/types';
|
|
15
18
|
import ValidationReport from 'rdf-validate-shacl/src/validation-report';
|
|
@@ -18,8 +21,34 @@ import { SayDataFactory } from '@lblod/ember-rdfa-editor/core/say-data-factory';
|
|
|
18
21
|
export const documentValidationPluginKey =
|
|
19
22
|
new PluginKey<DocumentValidationPluginState>('DOCUMENT_VALIDATION');
|
|
20
23
|
|
|
21
|
-
|
|
24
|
+
type Violation =
|
|
25
|
+
| {
|
|
26
|
+
action: (controller: SayController, report: ValidationReport) => void;
|
|
27
|
+
buttonTitle: string;
|
|
28
|
+
}
|
|
29
|
+
| {
|
|
30
|
+
helpText: string;
|
|
31
|
+
};
|
|
32
|
+
type Rule =
|
|
33
|
+
| {
|
|
34
|
+
shaclRule: string;
|
|
35
|
+
violations: {
|
|
36
|
+
[key: string]: Violation;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
| {
|
|
40
|
+
shaclRule: string;
|
|
41
|
+
action: (controller: SayController, report: ValidationReport) => void;
|
|
42
|
+
buttonTitle: string;
|
|
43
|
+
}
|
|
44
|
+
| {
|
|
45
|
+
shaclRule: string;
|
|
46
|
+
helpText: string;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export interface DocumentValidationPluginArgs {
|
|
22
50
|
documentShape: string;
|
|
51
|
+
rules: Rule[];
|
|
23
52
|
}
|
|
24
53
|
|
|
25
54
|
export type ShaclValidationReport = ValidationReport.ValidationReport<
|
|
@@ -27,17 +56,16 @@ export type ShaclValidationReport = ValidationReport.ValidationReport<
|
|
|
27
56
|
DatasetCoreFactory<Quad, Quad, DatasetCore<Quad, Quad>>
|
|
28
57
|
>;
|
|
29
58
|
|
|
59
|
+
type PropertyWithError = {
|
|
60
|
+
message: string;
|
|
61
|
+
subject: string | undefined;
|
|
62
|
+
shape: string;
|
|
63
|
+
constraint: string;
|
|
64
|
+
};
|
|
30
65
|
interface DocumentValidationResult {
|
|
31
66
|
report?: ValidationReport;
|
|
32
67
|
propertiesWithoutErrors: { message: string }[];
|
|
33
|
-
propertiesWithErrors:
|
|
34
|
-
| {
|
|
35
|
-
message: string;
|
|
36
|
-
subject: string | undefined;
|
|
37
|
-
}
|
|
38
|
-
// TODO get rid of this?
|
|
39
|
-
| undefined
|
|
40
|
-
)[];
|
|
68
|
+
propertiesWithErrors: PropertyWithError[];
|
|
41
69
|
}
|
|
42
70
|
export interface DocumentValidationTransactionMeta
|
|
43
71
|
extends DocumentValidationResult {
|
|
@@ -47,6 +75,7 @@ export interface DocumentValidationPluginState
|
|
|
47
75
|
extends DocumentValidationResult {
|
|
48
76
|
documentShape: string;
|
|
49
77
|
validationCallback: typeof validationCallback;
|
|
78
|
+
rules: Rule[];
|
|
50
79
|
}
|
|
51
80
|
|
|
52
81
|
export const documentValidationPlugin = (
|
|
@@ -61,6 +90,7 @@ export const documentValidationPlugin = (
|
|
|
61
90
|
documentShape: options.documentShape,
|
|
62
91
|
propertiesWithoutErrors: [],
|
|
63
92
|
propertiesWithErrors: [],
|
|
93
|
+
rules: options.rules,
|
|
64
94
|
};
|
|
65
95
|
},
|
|
66
96
|
apply(tr, state) {
|
|
@@ -107,31 +137,30 @@ async function validationCallback(view: EditorView, documentHtml: string) {
|
|
|
107
137
|
...shacl.match(undefined, propertyPred, undefined),
|
|
108
138
|
].map((quad: Quad) => quad.object);
|
|
109
139
|
|
|
110
|
-
const propertiesWithErrors: {
|
|
111
|
-
sourceShape: BlankNode | NamedNode<string>;
|
|
112
|
-
focusNode: BlankNode | NamedNode<string> | null;
|
|
113
|
-
}[] = [];
|
|
114
|
-
for (const r of report.results) {
|
|
115
|
-
const sourceShape = r.sourceShape;
|
|
116
|
-
if (sourceShape)
|
|
117
|
-
propertiesWithErrors.push({ sourceShape, focusNode: r.focusNode });
|
|
118
|
-
}
|
|
119
140
|
const errorMessagePred = sayFactory.namedNode(
|
|
120
141
|
'http://www.w3.org/ns/shacl#resultMessage',
|
|
121
142
|
);
|
|
122
|
-
const
|
|
123
|
-
|
|
143
|
+
const propertiesWithErrors: PropertyWithError[] = [];
|
|
144
|
+
for (const r of report.results) {
|
|
145
|
+
const sourceShape = r.sourceShape;
|
|
146
|
+
if (sourceShape) {
|
|
124
147
|
const match = shacl.match(sourceShape, errorMessagePred, undefined);
|
|
125
148
|
const message = [...match][0]?.object.value;
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
149
|
+
if (message) {
|
|
150
|
+
propertiesWithErrors.push({
|
|
151
|
+
message: removeQuotes(message),
|
|
152
|
+
subject: r.focusNode?.value,
|
|
153
|
+
shape: sourceShape.value,
|
|
154
|
+
constraint: r.sourceConstraintComponent?.value as string,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
131
160
|
const propertiesWithoutErrorsArray = propertyNodes.filter((propertyNode) =>
|
|
132
|
-
propertiesWithErrors.
|
|
133
|
-
|
|
134
|
-
|
|
161
|
+
propertiesWithErrors.every(
|
|
162
|
+
(propertyWithError) => propertyWithError.shape !== propertyNode.value,
|
|
163
|
+
),
|
|
135
164
|
);
|
|
136
165
|
|
|
137
166
|
const successMessagePred = sayFactory.namedNode(
|
|
@@ -149,7 +178,7 @@ async function validationCallback(view: EditorView, documentHtml: string) {
|
|
|
149
178
|
type: 'setNewReport',
|
|
150
179
|
report,
|
|
151
180
|
propertiesWithoutErrors,
|
|
152
|
-
propertiesWithErrors:
|
|
181
|
+
propertiesWithErrors: propertiesWithErrors,
|
|
153
182
|
});
|
|
154
183
|
transaction.setMeta('addToHistory', false);
|
|
155
184
|
view.dispatch(transaction);
|
|
@@ -241,12 +241,14 @@ function constructSignNode(
|
|
|
241
241
|
),
|
|
242
242
|
},
|
|
243
243
|
{
|
|
244
|
-
predicate:
|
|
244
|
+
predicate: PROV('wasDerivedFrom').full,
|
|
245
245
|
object: sayDataFactory.namedNode(signConcept.uri),
|
|
246
246
|
},
|
|
247
247
|
],
|
|
248
248
|
},
|
|
249
|
-
schema.text(
|
|
249
|
+
schema.text(
|
|
250
|
+
`${prefix} ${signConcept.regulatoryNotation || signConcept.code}${zonalityText}`,
|
|
251
|
+
),
|
|
250
252
|
);
|
|
251
253
|
return node;
|
|
252
254
|
}
|
|
@@ -23,9 +23,9 @@ export const TRAFFIC_SIGNAL_CONCEPT_TYPES = {
|
|
|
23
23
|
|
|
24
24
|
export const TRAFFIC_SIGNAL_TYPES = {
|
|
25
25
|
TRAFFIC_SIGNAL: MOBILITEIT('Verkeersteken').full,
|
|
26
|
-
ROAD_SIGN: MOBILITEIT('
|
|
27
|
-
TRAFFIC_LIGHT: MOBILITEIT('
|
|
28
|
-
ROAD_MARKING: MOBILITEIT('
|
|
26
|
+
ROAD_SIGN: MOBILITEIT('VerkeersbordVerkeersteken').full,
|
|
27
|
+
TRAFFIC_LIGHT: MOBILITEIT('VerkeerslichtVerkeersteken').full,
|
|
28
|
+
ROAD_MARKING: MOBILITEIT('WegmarkeringVerkeersteken').full,
|
|
29
29
|
} as const;
|
|
30
30
|
|
|
31
31
|
export const TRAFFIC_SIGNAL_TYPE_MAPPING = {
|
|
@@ -9,10 +9,25 @@ import {
|
|
|
9
9
|
EXT,
|
|
10
10
|
MOBILITEIT,
|
|
11
11
|
PROV,
|
|
12
|
+
RDF,
|
|
12
13
|
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
|
|
13
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
getOutgoingTriple,
|
|
16
|
+
hasOutgoingNamedNodeTriple,
|
|
17
|
+
hasRDFaAttribute,
|
|
18
|
+
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
|
|
14
19
|
import getClassnamesFromNode from '@lblod/ember-rdfa-editor/utils/get-classnames-from-node';
|
|
15
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
SayDataFactory,
|
|
22
|
+
sayDataFactory,
|
|
23
|
+
} from '@lblod/ember-rdfa-editor/core/say-data-factory';
|
|
24
|
+
import {
|
|
25
|
+
isResourceAttrs,
|
|
26
|
+
ModelMigration,
|
|
27
|
+
ModelMigrationGenerator,
|
|
28
|
+
} from '@lblod/ember-rdfa-editor/core/rdfa-types';
|
|
29
|
+
import { getRdfaContentElement } from '@lblod/ember-rdfa-editor/core/schema';
|
|
30
|
+
import { TRAFFIC_SIGNAL_TYPES } from './constants';
|
|
16
31
|
|
|
17
32
|
const CONTENT_SELECTOR = `div[property~='${
|
|
18
33
|
DCT('description').full
|
|
@@ -124,3 +139,62 @@ export const roadsign_regulation: NodeSpec = {
|
|
|
124
139
|
},
|
|
125
140
|
],
|
|
126
141
|
};
|
|
142
|
+
|
|
143
|
+
const replacements = [
|
|
144
|
+
[MOBILITEIT('Verkeersbord-Verkeersteken'), TRAFFIC_SIGNAL_TYPES.ROAD_SIGN],
|
|
145
|
+
[
|
|
146
|
+
MOBILITEIT('Verkeerslicht-Verkeersteken'),
|
|
147
|
+
TRAFFIC_SIGNAL_TYPES.TRAFFIC_LIGHT,
|
|
148
|
+
],
|
|
149
|
+
[MOBILITEIT('Wegmarkering-Verkeersteken'), TRAFFIC_SIGNAL_TYPES.ROAD_MARKING],
|
|
150
|
+
] as const;
|
|
151
|
+
/**
|
|
152
|
+
* Migrates documents from a data model featuring multiple nested inline_rdfa nodes to one that uses
|
|
153
|
+
* namedNodes to encode everything in one inline_rdfa
|
|
154
|
+
**/
|
|
155
|
+
export const trafficSignalMigration: ModelMigrationGenerator = (attrs) => {
|
|
156
|
+
const factory = new SayDataFactory();
|
|
157
|
+
for (const [source, replacement] of replacements) {
|
|
158
|
+
const conceptTriple = getOutgoingTriple(
|
|
159
|
+
attrs,
|
|
160
|
+
MOBILITEIT('heeftVerkeersbordconcept'),
|
|
161
|
+
);
|
|
162
|
+
if (
|
|
163
|
+
isResourceAttrs(attrs) &&
|
|
164
|
+
hasOutgoingNamedNodeTriple(attrs, RDF('type'), source) &&
|
|
165
|
+
conceptTriple
|
|
166
|
+
) {
|
|
167
|
+
return {
|
|
168
|
+
getAttrs: () => {
|
|
169
|
+
const conceptProp = {
|
|
170
|
+
predicate: PROV('wasDerivedFrom').full,
|
|
171
|
+
object: factory.namedNode(conceptTriple.object.value),
|
|
172
|
+
};
|
|
173
|
+
return {
|
|
174
|
+
...attrs,
|
|
175
|
+
properties: [
|
|
176
|
+
...(conceptProp ? [conceptProp] : []),
|
|
177
|
+
{
|
|
178
|
+
predicate: RDF('type').full,
|
|
179
|
+
object: sayDataFactory.namedNode(
|
|
180
|
+
TRAFFIC_SIGNAL_TYPES.TRAFFIC_SIGNAL,
|
|
181
|
+
),
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
predicate: RDF('type').full,
|
|
185
|
+
object: sayDataFactory.namedNode(replacement),
|
|
186
|
+
},
|
|
187
|
+
],
|
|
188
|
+
};
|
|
189
|
+
},
|
|
190
|
+
contentElement: (element) => {
|
|
191
|
+
const content = element.querySelector(
|
|
192
|
+
'[property="http://www.w3.org/2004/02/skos/core#prefLabel"]',
|
|
193
|
+
);
|
|
194
|
+
return getRdfaContentElement(content || element);
|
|
195
|
+
},
|
|
196
|
+
} satisfies ModelMigration;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return false;
|
|
200
|
+
};
|
|
@@ -29,7 +29,7 @@ export default async function queryRoadSignCategories(
|
|
|
29
29
|
?label
|
|
30
30
|
WHERE {
|
|
31
31
|
?uri a mobiliteit:Verkeersbordcategorie;
|
|
32
|
-
|
|
32
|
+
skos:prefLabel ?label.
|
|
33
33
|
|
|
34
34
|
${roadSignConceptUri ? `${sparqlEscapeUri(roadSignConceptUri)} dct:type ?uri` : ''}
|
|
35
35
|
}
|
|
@@ -35,6 +35,7 @@ export async function queryTrafficSignalConcepts(
|
|
|
35
35
|
?uri
|
|
36
36
|
?type
|
|
37
37
|
?code
|
|
38
|
+
?regulatoryNotation
|
|
38
39
|
?zonality
|
|
39
40
|
?image
|
|
40
41
|
?position
|
|
@@ -70,6 +71,10 @@ export async function queryTrafficSignalConcepts(
|
|
|
70
71
|
?uri ext:zonality ?zonality.
|
|
71
72
|
}
|
|
72
73
|
|
|
74
|
+
OPTIONAL {
|
|
75
|
+
?uri ext:regulatoryNotation ?regulatoryNotation.
|
|
76
|
+
}
|
|
77
|
+
|
|
73
78
|
VALUES ?type {
|
|
74
79
|
<https://data.vlaanderen.be/ns/mobiliteit#Verkeersbordconcept>
|
|
75
80
|
<https://data.vlaanderen.be/ns/mobiliteit#Wegmarkeringconcept>
|
|
@@ -8,14 +8,11 @@ import {
|
|
|
8
8
|
findNodePosDown,
|
|
9
9
|
findNodePosUp,
|
|
10
10
|
} from '@lblod/ember-rdfa-editor/utils/position-utils';
|
|
11
|
-
import { transactionCombinator } from '@lblod/ember-rdfa-editor/utils/transaction-utils';
|
|
12
11
|
import { findAncestorOfType } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/_private/find-ancestor';
|
|
13
12
|
import {
|
|
14
13
|
isNone,
|
|
15
14
|
unwrap,
|
|
16
15
|
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
|
|
17
|
-
import { recalculateNumbers } from '../monads/recalculate-structure-numbers';
|
|
18
|
-
import { regenerateRdfaLinks } from '../monads/regenerate-rdfa-links';
|
|
19
16
|
|
|
20
17
|
export function moveStructure(direction: 'up' | 'down'): Command {
|
|
21
18
|
return (state, dispatch) => {
|
|
@@ -53,23 +50,18 @@ export function moveStructure(direction: 'up' | 'down'): Command {
|
|
|
53
50
|
// previousStructurePos is the position right BEFORE the previous structure,
|
|
54
51
|
// so inserting there is correct
|
|
55
52
|
transaction.insert(previousStructurePos, node);
|
|
56
|
-
// after updating we have to recalculate the numbers
|
|
57
|
-
const { transaction: newTr } = transactionCombinator(
|
|
58
|
-
state,
|
|
59
|
-
transaction,
|
|
60
|
-
)([recalculateNumbers, regenerateRdfaLinks]);
|
|
61
53
|
|
|
62
54
|
// previousStructurePos should now point to the position right before our moved structure
|
|
63
55
|
// so we can simply add 1 to get the first position inside of it, and for the end
|
|
64
56
|
// we add the nodesize and subtract one
|
|
65
|
-
|
|
57
|
+
transaction.setSelection(
|
|
66
58
|
TextSelection.create(
|
|
67
|
-
|
|
59
|
+
transaction.doc,
|
|
68
60
|
previousStructurePos + 1,
|
|
69
61
|
previousStructurePos + node.nodeSize - 1,
|
|
70
62
|
),
|
|
71
63
|
);
|
|
72
|
-
dispatch(
|
|
64
|
+
dispatch(transaction);
|
|
73
65
|
}
|
|
74
66
|
return true;
|
|
75
67
|
}
|
|
@@ -107,21 +99,16 @@ export function moveStructure(direction: 'up' | 'down'): Command {
|
|
|
107
99
|
);
|
|
108
100
|
transaction.insert(insertPos, node);
|
|
109
101
|
|
|
110
|
-
const { transaction: newTr } = transactionCombinator(
|
|
111
|
-
state,
|
|
112
|
-
transaction,
|
|
113
|
-
)([recalculateNumbers, regenerateRdfaLinks]);
|
|
114
|
-
|
|
115
102
|
// since we've deleted something before the insert position, we have to map
|
|
116
103
|
// the positions through the transaction to find the moved node's new position
|
|
117
|
-
|
|
104
|
+
transaction.setSelection(
|
|
118
105
|
TextSelection.create(
|
|
119
|
-
|
|
106
|
+
transaction.doc,
|
|
120
107
|
insertPos + 1,
|
|
121
108
|
insertPos + node.nodeSize - 1,
|
|
122
109
|
),
|
|
123
110
|
);
|
|
124
|
-
dispatch(
|
|
111
|
+
dispatch(transaction);
|
|
125
112
|
}
|
|
126
113
|
|
|
127
114
|
return true;
|
|
@@ -135,11 +135,7 @@ export default class ImportRdfaSnippet extends Service {
|
|
|
135
135
|
.filter((triple) => triple.predicate === 'a')
|
|
136
136
|
.map((triple) => triple.object)
|
|
137
137
|
.filter((v, i, a) => a.indexOf(v) === i); //This filters only unique values
|
|
138
|
-
if (
|
|
139
|
-
types.includes(
|
|
140
|
-
'https://data.vlaanderen.be/ns/mobiliteit#Verkeersbord-Verkeersteken',
|
|
141
|
-
)
|
|
142
|
-
) {
|
|
138
|
+
if (types.includes('Verkeersteken')) {
|
|
143
139
|
return 'roadsign';
|
|
144
140
|
} else {
|
|
145
141
|
return 'generic';
|
|
@@ -7,6 +7,16 @@ import { hasOutgoingNamedNodeTriple } from '@lblod/ember-rdfa-editor-lblod-plugi
|
|
|
7
7
|
import { ElementPNode } from '@lblod/ember-rdfa-editor/plugins/datastore';
|
|
8
8
|
import { findAncestors } from '@lblod/ember-rdfa-editor/utils/position-utils';
|
|
9
9
|
|
|
10
|
+
export function getDecisionNodeLocation(controller: SayController) {
|
|
11
|
+
const besluitRange = getCurrentBesluitRange(controller);
|
|
12
|
+
if (!besluitRange) return;
|
|
13
|
+
const decisionNodeLocation = {
|
|
14
|
+
pos: besluitRange.from,
|
|
15
|
+
node: besluitRange.node,
|
|
16
|
+
};
|
|
17
|
+
return decisionNodeLocation;
|
|
18
|
+
}
|
|
19
|
+
|
|
10
20
|
export const getCurrentBesluitRange = (
|
|
11
21
|
controllerOrState: SayController | EditorState,
|
|
12
22
|
): ElementPNode | undefined => {
|
|
@@ -15,15 +25,29 @@ export const getCurrentBesluitRange = (
|
|
|
15
25
|
? controllerOrState.mainEditorState
|
|
16
26
|
: controllerOrState;
|
|
17
27
|
const selection = state.selection;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
let besluit;
|
|
29
|
+
if (
|
|
30
|
+
selection.$from.nodeAfter &&
|
|
31
|
+
hasOutgoingNamedNodeTriple(
|
|
32
|
+
selection.$from.nodeAfter.attrs,
|
|
33
|
+
RDF('type'),
|
|
34
|
+
BESLUIT('Besluit'),
|
|
35
|
+
)
|
|
36
|
+
) {
|
|
37
|
+
besluit = {
|
|
38
|
+
node: selection.$from.nodeAfter,
|
|
39
|
+
pos: selection.$from.pos,
|
|
40
|
+
};
|
|
41
|
+
} else {
|
|
42
|
+
besluit =
|
|
43
|
+
findAncestors(selection.$from, (node: PNode) => {
|
|
44
|
+
return hasOutgoingNamedNodeTriple(
|
|
45
|
+
node.attrs,
|
|
46
|
+
RDF('type'),
|
|
47
|
+
BESLUIT('Besluit'),
|
|
48
|
+
);
|
|
49
|
+
})[0] ?? null;
|
|
50
|
+
}
|
|
27
51
|
if (!besluit) {
|
|
28
52
|
return undefined;
|
|
29
53
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
2
|
import { SayController } from '@lblod/ember-rdfa-editor';
|
|
3
|
+
import ValidationReport from 'rdf-validate-shacl/src/validation-report';
|
|
3
4
|
interface Sig {
|
|
4
5
|
Args: {
|
|
5
6
|
controller: SayController;
|
|
@@ -9,14 +10,63 @@ export default class DocumentValidationPluginCard extends Component<Sig> {
|
|
|
9
10
|
get controller(): SayController;
|
|
10
11
|
get validationState(): import("@lblod/ember-rdfa-editor-lblod-plugins/plugins/document-validation-plugin").DocumentValidationPluginState | undefined;
|
|
11
12
|
get documentValidationErrors(): ({
|
|
13
|
+
rule: {
|
|
14
|
+
action: (controller: SayController, report: ValidationReport) => void;
|
|
15
|
+
buttonTitle: string;
|
|
16
|
+
} | {
|
|
17
|
+
helpText: string;
|
|
18
|
+
};
|
|
12
19
|
message: string;
|
|
13
20
|
subject: string | undefined;
|
|
14
|
-
|
|
21
|
+
shape: string;
|
|
22
|
+
constraint: string;
|
|
23
|
+
} | {
|
|
24
|
+
rule: {
|
|
25
|
+
shaclRule: string;
|
|
26
|
+
action: (controller: SayController, report: ValidationReport) => void;
|
|
27
|
+
buttonTitle: string;
|
|
28
|
+
} | {
|
|
29
|
+
shaclRule: string;
|
|
30
|
+
helpText: string;
|
|
31
|
+
} | undefined;
|
|
32
|
+
message: string;
|
|
33
|
+
subject: string | undefined;
|
|
34
|
+
shape: string;
|
|
35
|
+
constraint: string;
|
|
36
|
+
})[] | undefined;
|
|
15
37
|
get propertiesWithoutErrors(): {
|
|
16
38
|
message: string;
|
|
17
39
|
}[];
|
|
18
40
|
goToSubject: (subject: string) => void;
|
|
19
41
|
get status(): "not-run" | "no-matches" | "valid" | "invalid";
|
|
20
42
|
get isSuccesslike(): boolean;
|
|
43
|
+
doActionAndTriggerValidation: (action: (controller: SayController, report: ValidationReport) => void) => Promise<void>;
|
|
44
|
+
oldVal: typeof this.documentValidationErrors;
|
|
45
|
+
dedupeDocumentValidationErrors: (val: typeof this.documentValidationErrors) => ({
|
|
46
|
+
rule: {
|
|
47
|
+
action: (controller: SayController, report: ValidationReport) => void;
|
|
48
|
+
buttonTitle: string;
|
|
49
|
+
} | {
|
|
50
|
+
helpText: string;
|
|
51
|
+
};
|
|
52
|
+
message: string;
|
|
53
|
+
subject: string | undefined;
|
|
54
|
+
shape: string;
|
|
55
|
+
constraint: string;
|
|
56
|
+
} | {
|
|
57
|
+
rule: {
|
|
58
|
+
shaclRule: string;
|
|
59
|
+
action: (controller: SayController, report: ValidationReport) => void;
|
|
60
|
+
buttonTitle: string;
|
|
61
|
+
} | {
|
|
62
|
+
shaclRule: string;
|
|
63
|
+
helpText: string;
|
|
64
|
+
} | undefined;
|
|
65
|
+
message: string;
|
|
66
|
+
subject: string | undefined;
|
|
67
|
+
shape: string;
|
|
68
|
+
constraint: string;
|
|
69
|
+
})[] | undefined;
|
|
70
|
+
compareDocumentValidationErrors: (val1: typeof this.documentValidationErrors, val2: typeof this.documentValidationErrors) => boolean;
|
|
21
71
|
}
|
|
22
72
|
export {};
|
|
@@ -91,6 +91,7 @@ export default class RoadsignsModal extends Component<Signature> {
|
|
|
91
91
|
image: string;
|
|
92
92
|
uri: string;
|
|
93
93
|
position: number;
|
|
94
|
+
regulatoryNotation?: string | undefined;
|
|
94
95
|
zonality?: "http://lblod.data.gift/concepts/8f9367b2-c717-4be7-8833-4c75bbb4ae1f" | "http://lblod.data.gift/concepts/c81c6b96-736a-48cf-b003-6f5cc3dbc55d" | "http://lblod.data.gift/concepts/b651931b-923c-477c-8da9-fc7dd841fdcc" | undefined;
|
|
95
96
|
} & ({
|
|
96
97
|
type: "https://data.vlaanderen.be/ns/mobiliteit#Verkeersbordconcept";
|
|
@@ -119,6 +120,7 @@ export default class RoadsignsModal extends Component<Signature> {
|
|
|
119
120
|
image: string;
|
|
120
121
|
uri: string;
|
|
121
122
|
position: number;
|
|
123
|
+
regulatoryNotation?: string | undefined;
|
|
122
124
|
zonality?: "http://lblod.data.gift/concepts/8f9367b2-c717-4be7-8833-4c75bbb4ae1f" | "http://lblod.data.gift/concepts/c81c6b96-736a-48cf-b003-6f5cc3dbc55d" | "http://lblod.data.gift/concepts/b651931b-923c-477c-8da9-fc7dd841fdcc" | undefined;
|
|
123
125
|
} & ({
|
|
124
126
|
type: "https://data.vlaanderen.be/ns/mobiliteit#Verkeersbordconcept";
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { Command } from '@lblod/ember-rdfa-editor';
|
|
2
2
|
import IntlService from 'ember-intl/services/intl';
|
|
3
|
+
import { NodeWithPos } from '@curvenote/prosemirror-utils';
|
|
3
4
|
interface InsertArticleContainerArgs {
|
|
4
5
|
intl: IntlService;
|
|
5
6
|
decisionUri: string;
|
|
6
7
|
articleUriGenerator?: () => string;
|
|
8
|
+
decisionLocation: NodeWithPos;
|
|
7
9
|
}
|
|
8
|
-
export default function insertArticleContainer({ decisionUri, articleUriGenerator, }: InsertArticleContainerArgs): Command;
|
|
10
|
+
export default function insertArticleContainer({ decisionUri, articleUriGenerator, decisionLocation, }: InsertArticleContainerArgs): Command;
|
|
9
11
|
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SayController } from '@lblod/ember-rdfa-editor';
|
|
2
|
+
import IntlService from 'ember-intl/services/intl';
|
|
3
|
+
export declare function insertTitleAtCursor(controller: SayController, intl: IntlService): void;
|
|
4
|
+
export declare function insertDescriptionAtCursor(controller: SayController, intl: IntlService): void;
|
|
5
|
+
export declare function insertMotivationAtCursor(controller: SayController, intl: IntlService): void;
|
|
6
|
+
export declare function insertArticleContainerAtCursor(controller: SayController, intl: IntlService, articleUriGenerator?: () => string): void;
|
|
@@ -1,20 +1,43 @@
|
|
|
1
|
-
import { ProsePlugin, PluginKey, EditorView } from '@lblod/ember-rdfa-editor';
|
|
1
|
+
import { ProsePlugin, PluginKey, EditorView, SayController } from '@lblod/ember-rdfa-editor';
|
|
2
2
|
import { DataFactory, DatasetCore, DatasetCoreFactory, Quad } from '@rdfjs/types';
|
|
3
3
|
import ValidationReport from 'rdf-validate-shacl/src/validation-report';
|
|
4
4
|
export declare const documentValidationPluginKey: PluginKey<DocumentValidationPluginState>;
|
|
5
|
-
|
|
5
|
+
type Violation = {
|
|
6
|
+
action: (controller: SayController, report: ValidationReport) => void;
|
|
7
|
+
buttonTitle: string;
|
|
8
|
+
} | {
|
|
9
|
+
helpText: string;
|
|
10
|
+
};
|
|
11
|
+
type Rule = {
|
|
12
|
+
shaclRule: string;
|
|
13
|
+
violations: {
|
|
14
|
+
[key: string]: Violation;
|
|
15
|
+
};
|
|
16
|
+
} | {
|
|
17
|
+
shaclRule: string;
|
|
18
|
+
action: (controller: SayController, report: ValidationReport) => void;
|
|
19
|
+
buttonTitle: string;
|
|
20
|
+
} | {
|
|
21
|
+
shaclRule: string;
|
|
22
|
+
helpText: string;
|
|
23
|
+
};
|
|
24
|
+
export interface DocumentValidationPluginArgs {
|
|
6
25
|
documentShape: string;
|
|
26
|
+
rules: Rule[];
|
|
7
27
|
}
|
|
8
28
|
export type ShaclValidationReport = ValidationReport.ValidationReport<DataFactory<Quad, Quad> & DatasetCoreFactory<Quad, Quad, DatasetCore<Quad, Quad>>>;
|
|
29
|
+
type PropertyWithError = {
|
|
30
|
+
message: string;
|
|
31
|
+
subject: string | undefined;
|
|
32
|
+
shape: string;
|
|
33
|
+
constraint: string;
|
|
34
|
+
};
|
|
9
35
|
interface DocumentValidationResult {
|
|
10
36
|
report?: ValidationReport;
|
|
11
37
|
propertiesWithoutErrors: {
|
|
12
38
|
message: string;
|
|
13
39
|
}[];
|
|
14
|
-
propertiesWithErrors:
|
|
15
|
-
message: string;
|
|
16
|
-
subject: string | undefined;
|
|
17
|
-
} | undefined)[];
|
|
40
|
+
propertiesWithErrors: PropertyWithError[];
|
|
18
41
|
}
|
|
19
42
|
export interface DocumentValidationTransactionMeta extends DocumentValidationResult {
|
|
20
43
|
type: string;
|
|
@@ -22,6 +45,7 @@ export interface DocumentValidationTransactionMeta extends DocumentValidationRes
|
|
|
22
45
|
export interface DocumentValidationPluginState extends DocumentValidationResult {
|
|
23
46
|
documentShape: string;
|
|
24
47
|
validationCallback: typeof validationCallback;
|
|
48
|
+
rules: Rule[];
|
|
25
49
|
}
|
|
26
50
|
export declare const documentValidationPlugin: (options: DocumentValidationPluginArgs) => ProsePlugin<DocumentValidationPluginState>;
|
|
27
51
|
declare function validationCallback(view: EditorView, documentHtml: string): Promise<void>;
|
|
@@ -14,15 +14,15 @@ export declare const TRAFFIC_SIGNAL_CONCEPT_TYPES: {
|
|
|
14
14
|
};
|
|
15
15
|
export declare const TRAFFIC_SIGNAL_TYPES: {
|
|
16
16
|
readonly TRAFFIC_SIGNAL: "https://data.vlaanderen.be/ns/mobiliteit#Verkeersteken";
|
|
17
|
-
readonly ROAD_SIGN: "https://data.vlaanderen.be/ns/mobiliteit#
|
|
18
|
-
readonly TRAFFIC_LIGHT: "https://data.vlaanderen.be/ns/mobiliteit#
|
|
19
|
-
readonly ROAD_MARKING: "https://data.vlaanderen.be/ns/mobiliteit#
|
|
17
|
+
readonly ROAD_SIGN: "https://data.vlaanderen.be/ns/mobiliteit#VerkeersbordVerkeersteken";
|
|
18
|
+
readonly TRAFFIC_LIGHT: "https://data.vlaanderen.be/ns/mobiliteit#VerkeerslichtVerkeersteken";
|
|
19
|
+
readonly ROAD_MARKING: "https://data.vlaanderen.be/ns/mobiliteit#WegmarkeringVerkeersteken";
|
|
20
20
|
};
|
|
21
21
|
export declare const TRAFFIC_SIGNAL_TYPE_MAPPING: {
|
|
22
22
|
readonly "https://data.vlaanderen.be/ns/mobiliteit#Verkeerstekenconcept": "https://data.vlaanderen.be/ns/mobiliteit#Verkeersteken";
|
|
23
|
-
readonly "https://data.vlaanderen.be/ns/mobiliteit#Verkeersbordconcept": "https://data.vlaanderen.be/ns/mobiliteit#
|
|
24
|
-
readonly "https://data.vlaanderen.be/ns/mobiliteit#Verkeerslichtconcept": "https://data.vlaanderen.be/ns/mobiliteit#
|
|
25
|
-
readonly "https://data.vlaanderen.be/ns/mobiliteit#Wegmarkeringconcept": "https://data.vlaanderen.be/ns/mobiliteit#
|
|
23
|
+
readonly "https://data.vlaanderen.be/ns/mobiliteit#Verkeersbordconcept": "https://data.vlaanderen.be/ns/mobiliteit#VerkeersbordVerkeersteken";
|
|
24
|
+
readonly "https://data.vlaanderen.be/ns/mobiliteit#Verkeerslichtconcept": "https://data.vlaanderen.be/ns/mobiliteit#VerkeerslichtVerkeersteken";
|
|
25
|
+
readonly "https://data.vlaanderen.be/ns/mobiliteit#Wegmarkeringconcept": "https://data.vlaanderen.be/ns/mobiliteit#WegmarkeringVerkeersteken";
|
|
26
26
|
};
|
|
27
27
|
export declare const ROAD_SIGN_CATEGORIES: {
|
|
28
28
|
XXBORD: string;
|