@lblod/ember-rdfa-editor-lblod-plugins 35.3.0 → 35.4.0-dev.227e3fda9666fa2f52270074003b8aeaf320a473
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/many-brooms-fetch.md +5 -0
- package/CHANGELOG.md +10 -0
- package/addon/components/roadsign-regulation-plugin/expanded-measure.gts +85 -15
- package/addon/components/roadsign-regulation-plugin/roadsigns-modal.gts +10 -0
- package/addon/components/roadsign-regulation-plugin/roadsigns-table.gts +3 -0
- package/addon/components/variable-plugin/marcode/insert.gts +1 -0
- package/addon/plugins/decision-plugin/actions/insert-article.ts +89 -46
- package/addon/plugins/roadsign-regulation-plugin/actions/insert-measure.ts +3 -0
- package/addon/plugins/variable-plugin/actions/create-codelist-variable.ts +7 -0
- package/addon/plugins/variable-plugin/utils/codelist-utils.ts +4 -0
- package/addon/plugins/variable-plugin/variables/codelist.ts +37 -27
- package/addon/utils/document-structure-utils.ts +17 -0
- package/declarations/addon/components/roadsign-regulation-plugin/expanded-measure.d.ts +22 -1
- package/declarations/addon/components/roadsign-regulation-plugin/roadsigns-modal.d.ts +2 -1
- package/declarations/addon/components/roadsign-regulation-plugin/roadsigns-table.d.ts +2 -0
- package/declarations/addon/plugins/decision-plugin/actions/insert-article.d.ts +1 -0
- package/declarations/addon/plugins/roadsign-regulation-plugin/actions/insert-measure.d.ts +2 -1
- package/declarations/addon/plugins/variable-plugin/actions/create-codelist-variable.d.ts +3 -1
- package/declarations/addon/utils/document-structure-utils.d.ts +6 -0
- package/package.json +6 -5
- package/translations/en-US.yaml +4 -0
- package/translations/nl-BE.yaml +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @lblod/ember-rdfa-editor-lblod-plugins
|
|
2
2
|
|
|
3
|
+
## 35.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#636](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/636) [`867383d`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/867383d8ee85dcf30ad7338cd80dc2c0802326c7) Thanks [@piemonkey](https://github.com/piemonkey)! - Use pointer functionality to link to make linking to codelist URIs possible
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#636](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/636) [`aeb74b2`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/aeb74b22f159f0297749e430093d90a54f5f34f6) Thanks [@piemonkey](https://github.com/piemonkey)! - Update to [v13.6.0](https://github.com/lblod/ember-rdfa-editor/releases/tag/%40lblod%2Fember-rdfa-editor%4013.6.0) of the editor
|
|
12
|
+
|
|
3
13
|
## 35.3.0
|
|
4
14
|
|
|
5
15
|
### Minor Changes
|
|
@@ -5,7 +5,6 @@ import { tracked } from '@glimmer/tracking';
|
|
|
5
5
|
import t from 'ember-intl/helpers/t';
|
|
6
6
|
import MeasurePreview from './measure-preview';
|
|
7
7
|
import AuRadioGroup from '@appuniversum/ember-appuniversum/components/au-radio-group';
|
|
8
|
-
import AuButtonGroup from '@appuniversum/ember-appuniversum/components/au-button-group';
|
|
9
8
|
import AuButton from '@appuniversum/ember-appuniversum/components/au-button';
|
|
10
9
|
import { MobilityMeasureConcept } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/roadsign-regulation-plugin/schemas/mobility-measure-concept';
|
|
11
10
|
import { action } from '@ember/object';
|
|
@@ -16,10 +15,15 @@ import {
|
|
|
16
15
|
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/roadsign-regulation-plugin/constants';
|
|
17
16
|
import { Task } from 'ember-concurrency';
|
|
18
17
|
import { isSome } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
|
|
18
|
+
import set from '@lblod/ember-rdfa-editor-lblod-plugins/helpers/set';
|
|
19
|
+
import { service } from '@ember/service';
|
|
20
|
+
import IntlService from 'ember-intl/services/intl';
|
|
21
|
+
import { PNode } from '@lblod/ember-rdfa-editor';
|
|
22
|
+
import PowerSelect from 'ember-power-select/components/power-select';
|
|
19
23
|
|
|
20
24
|
export type InsertMobilityMeasureTask = Task<
|
|
21
25
|
void,
|
|
22
|
-
[MobilityMeasureConcept, ZonalOrNot, boolean]
|
|
26
|
+
[MobilityMeasureConcept, ZonalOrNot, boolean, number?]
|
|
23
27
|
>;
|
|
24
28
|
type Signature = {
|
|
25
29
|
Args: {
|
|
@@ -27,12 +31,43 @@ type Signature = {
|
|
|
27
31
|
selectRow: (uri: string) => void;
|
|
28
32
|
insert: InsertMobilityMeasureTask;
|
|
29
33
|
endpoint: string;
|
|
34
|
+
articleNodes: PNode[];
|
|
30
35
|
};
|
|
31
36
|
};
|
|
32
37
|
|
|
38
|
+
type InsertPositionOption = {
|
|
39
|
+
label: string;
|
|
40
|
+
position: 'first' | 'last' | 'custom';
|
|
41
|
+
insertIndex?: number;
|
|
42
|
+
};
|
|
43
|
+
|
|
33
44
|
export default class ExpandedMeasure extends Component<Signature> {
|
|
45
|
+
@service declare intl: IntlService;
|
|
46
|
+
|
|
34
47
|
@tracked zonalityValue?: ZonalOrNot;
|
|
35
48
|
@tracked temporalValue?: boolean;
|
|
49
|
+
@tracked selectedInsertPosition: InsertPositionOption;
|
|
50
|
+
|
|
51
|
+
insertPositionOptionFirst: InsertPositionOption;
|
|
52
|
+
insertPositionOptionLast: InsertPositionOption;
|
|
53
|
+
|
|
54
|
+
constructor(owner: unknown, args: Signature['Args']) {
|
|
55
|
+
super(owner, args);
|
|
56
|
+
this.insertPositionOptionFirst = {
|
|
57
|
+
label: this.intl.t(
|
|
58
|
+
'editor-plugins.roadsign-regulation.expanded-measure.as-first-article',
|
|
59
|
+
),
|
|
60
|
+
position: 'first',
|
|
61
|
+
insertIndex: 0,
|
|
62
|
+
};
|
|
63
|
+
this.insertPositionOptionLast = {
|
|
64
|
+
label: this.intl.t(
|
|
65
|
+
'editor-plugins.roadsign-regulation.expanded-measure.as-last-article',
|
|
66
|
+
),
|
|
67
|
+
position: 'last',
|
|
68
|
+
};
|
|
69
|
+
this.selectedInsertPosition = this.insertPositionOptionLast;
|
|
70
|
+
}
|
|
36
71
|
|
|
37
72
|
get isPotentiallyZonal() {
|
|
38
73
|
return this.args.concept.zonality === ZONALITY_OPTIONS.POTENTIALLY_ZONAL;
|
|
@@ -41,6 +76,7 @@ export default class ExpandedMeasure extends Component<Signature> {
|
|
|
41
76
|
get insertButtonDisabled() {
|
|
42
77
|
return (
|
|
43
78
|
(this.isPotentiallyZonal && !this.zonalityValue) ||
|
|
79
|
+
this.args.insert.isRunning ||
|
|
44
80
|
(this.args.concept.variableSignage && !isSome(this.temporalValue))
|
|
45
81
|
);
|
|
46
82
|
}
|
|
@@ -57,11 +93,13 @@ export default class ExpandedMeasure extends Component<Signature> {
|
|
|
57
93
|
|
|
58
94
|
@action
|
|
59
95
|
insert() {
|
|
96
|
+
const { insertIndex } = this.selectedInsertPosition;
|
|
60
97
|
this.args.insert.perform(
|
|
61
98
|
this.args.concept,
|
|
62
99
|
// POTENTIALLY_ZONAL option is filtered out by requiring a zonalityValue to submit
|
|
63
100
|
(this.zonalityValue ?? this.args.concept.zonality) as ZonalOrNot,
|
|
64
101
|
this.temporalValue ?? false,
|
|
102
|
+
insertIndex,
|
|
65
103
|
);
|
|
66
104
|
}
|
|
67
105
|
|
|
@@ -70,6 +108,29 @@ export default class ExpandedMeasure extends Component<Signature> {
|
|
|
70
108
|
this.args.selectRow(this.args.concept.uri);
|
|
71
109
|
}
|
|
72
110
|
|
|
111
|
+
get articlesInDocument() {
|
|
112
|
+
return this.args.articleNodes;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
get insertPositionOptions() {
|
|
116
|
+
return [
|
|
117
|
+
this.insertPositionOptionLast,
|
|
118
|
+
this.insertPositionOptionFirst,
|
|
119
|
+
...this.articlesInDocument.slice(1).map((_, index) => ({
|
|
120
|
+
label: this.intl.t(
|
|
121
|
+
'editor-plugins.roadsign-regulation.expanded-measure.after-article-x',
|
|
122
|
+
{ articleNumber: index + 1 },
|
|
123
|
+
),
|
|
124
|
+
position: 'custom',
|
|
125
|
+
insertIndex: index + 1,
|
|
126
|
+
})),
|
|
127
|
+
];
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
get insertPositionDropdownTitle() {
|
|
131
|
+
return this.selectedInsertPosition?.label.toLowerCase();
|
|
132
|
+
}
|
|
133
|
+
|
|
73
134
|
<template>
|
|
74
135
|
<tr class='au-c-data-table__detail'>
|
|
75
136
|
<td colspan='5' class='au-o-flow au-o-flow--small'>
|
|
@@ -135,19 +196,28 @@ export default class ExpandedMeasure extends Component<Signature> {
|
|
|
135
196
|
</AuRadioGroup>
|
|
136
197
|
</div>
|
|
137
198
|
{{/if}}
|
|
138
|
-
<
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
</
|
|
199
|
+
<AuHeading @level='6' @skin='6'>
|
|
200
|
+
{{t
|
|
201
|
+
'editor-plugins.roadsign-regulation.expanded-measure.insert-position'
|
|
202
|
+
}}
|
|
203
|
+
</AuHeading>
|
|
204
|
+
<PowerSelect
|
|
205
|
+
class='au-u-1-5'
|
|
206
|
+
@allowClear={{false}}
|
|
207
|
+
@onChange={{set this 'selectedInsertPosition'}}
|
|
208
|
+
@selected={{this.selectedInsertPosition}}
|
|
209
|
+
@options={{this.insertPositionOptions}}
|
|
210
|
+
as |option|
|
|
211
|
+
>{{option.label}}</PowerSelect>
|
|
212
|
+
<AuButton
|
|
213
|
+
{{on 'click' this.insert}}
|
|
214
|
+
@skin='primary'
|
|
215
|
+
@loading={{@insert.isRunning}}
|
|
216
|
+
@loadingMessage={{t 'common.loading'}}
|
|
217
|
+
@disabled={{this.insertButtonDisabled}}
|
|
218
|
+
>
|
|
219
|
+
{{t 'common.insert'}}
|
|
220
|
+
</AuButton>
|
|
151
221
|
</td>
|
|
152
222
|
</tr>
|
|
153
223
|
</template>
|
|
@@ -41,6 +41,7 @@ import { Variable } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/roadsig
|
|
|
41
41
|
import { generateVariableInstanceUri } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/variable-plugin/utils/variable-helpers';
|
|
42
42
|
import { mapObject } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/map-object';
|
|
43
43
|
import { v4 as uuid } from 'uuid';
|
|
44
|
+
import { getArticleNodes } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/document-structure-utils';
|
|
44
45
|
|
|
45
46
|
type Option = {
|
|
46
47
|
uri: string;
|
|
@@ -319,6 +320,7 @@ export default class RoadsignsModal extends Component<Signature> {
|
|
|
319
320
|
concept: MobilityMeasureConcept,
|
|
320
321
|
zonality: ZonalOrNot,
|
|
321
322
|
temporal: boolean,
|
|
323
|
+
position?: number,
|
|
322
324
|
) => {
|
|
323
325
|
if (!this.decisionLocation) {
|
|
324
326
|
return;
|
|
@@ -355,6 +357,7 @@ export default class RoadsignsModal extends Component<Signature> {
|
|
|
355
357
|
decisionUri,
|
|
356
358
|
zonality,
|
|
357
359
|
temporal,
|
|
360
|
+
position,
|
|
358
361
|
})(this.controller.mainEditorState).transaction;
|
|
359
362
|
},
|
|
360
363
|
{ view: this.controller.mainEditorView },
|
|
@@ -386,6 +389,12 @@ export default class RoadsignsModal extends Component<Signature> {
|
|
|
386
389
|
this.pageNumber = pageNumber;
|
|
387
390
|
}
|
|
388
391
|
|
|
392
|
+
get articleNodes() {
|
|
393
|
+
return getArticleNodes(this.controller.mainEditorState).map(
|
|
394
|
+
(node) => node.node,
|
|
395
|
+
);
|
|
396
|
+
}
|
|
397
|
+
|
|
389
398
|
<template>
|
|
390
399
|
<AuModal
|
|
391
400
|
class='au-c-modal--flush'
|
|
@@ -516,6 +525,7 @@ export default class RoadsignsModal extends Component<Signature> {
|
|
|
516
525
|
@isLoading={{this.measureConceptsQuery.isRunning}}
|
|
517
526
|
@insert={{this.insertMeasure}}
|
|
518
527
|
@options={{@options}}
|
|
528
|
+
@articleNodes={{this.articleNodes}}
|
|
519
529
|
/>
|
|
520
530
|
{{#if this.measureConceptCount}}
|
|
521
531
|
{{#let
|
|
@@ -21,6 +21,7 @@ import { on } from '@ember/modifier';
|
|
|
21
21
|
import { fn } from '@ember/helper';
|
|
22
22
|
import { TRAFFIC_SIGNAL_CONCEPT_TYPES } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/roadsign-regulation-plugin/constants';
|
|
23
23
|
import removeZFromLabel from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/roadsign-regulation-plugin/helpers/removeZFromLabel';
|
|
24
|
+
import { PNode } from '@lblod/ember-rdfa-editor';
|
|
24
25
|
|
|
25
26
|
type Signature = {
|
|
26
27
|
Args: {
|
|
@@ -28,6 +29,7 @@ type Signature = {
|
|
|
28
29
|
content?: MobilityMeasureConcept[];
|
|
29
30
|
isLoading?: boolean;
|
|
30
31
|
insert: InsertMobilityMeasureTask;
|
|
32
|
+
articleNodes: PNode[];
|
|
31
33
|
};
|
|
32
34
|
};
|
|
33
35
|
|
|
@@ -163,6 +165,7 @@ export default class RoadSignsTable extends Component<Signature> {
|
|
|
163
165
|
@insert={{@insert}}
|
|
164
166
|
@selectRow={{this.selectRow}}
|
|
165
167
|
@endpoint={{@options.endpoint}}
|
|
168
|
+
@articleNodes={{@articleNodes}}
|
|
166
169
|
/>
|
|
167
170
|
{{/if}}
|
|
168
171
|
{{else}}
|
|
@@ -50,6 +50,7 @@ export default class MarcodeInsertComponent extends Component<Sig> {
|
|
|
50
50
|
// list in code instead of in the doc?
|
|
51
51
|
hardcodedOptionList: hardcodedMarcodeList,
|
|
52
52
|
label,
|
|
53
|
+
hasNonLiteralContents: true,
|
|
53
54
|
});
|
|
54
55
|
this.controller.doCommand(replaceSelectionWithAndSelectNode(node), {
|
|
55
56
|
view: this.controller.mainEditorView,
|
|
@@ -20,6 +20,7 @@ interface InsertArticleToDecisionArgs {
|
|
|
20
20
|
node: PNode;
|
|
21
21
|
decisionUri: string;
|
|
22
22
|
insertFreely?: false;
|
|
23
|
+
position?: number;
|
|
23
24
|
}
|
|
24
25
|
interface InsertArticleFreelyArgs {
|
|
25
26
|
node: PNode;
|
|
@@ -46,7 +47,7 @@ export function insertArticle(
|
|
|
46
47
|
};
|
|
47
48
|
}
|
|
48
49
|
|
|
49
|
-
const { decisionUri } = args;
|
|
50
|
+
const { decisionUri, position } = args;
|
|
50
51
|
const decision = getNodesBySubject(state, decisionUri)[0];
|
|
51
52
|
if (!decision) {
|
|
52
53
|
return {
|
|
@@ -55,56 +56,98 @@ export function insertArticle(
|
|
|
55
56
|
result: false,
|
|
56
57
|
};
|
|
57
58
|
}
|
|
59
|
+
|
|
58
60
|
const decisionResource = decision.value.attrs.subject;
|
|
59
61
|
const container = getOutgoingTriple(decision.value.attrs, PROV('value'));
|
|
60
|
-
if (container) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
},
|
|
76
|
-
}),
|
|
77
|
-
recalculateNumbers,
|
|
78
|
-
]);
|
|
79
|
-
|
|
80
|
-
const { result, transaction } = combiResult;
|
|
81
|
-
|
|
82
|
-
transaction.setSelection(
|
|
83
|
-
TextSelection.create(
|
|
84
|
-
transaction.doc,
|
|
85
|
-
insertLocation + 1,
|
|
86
|
-
insertLocation + node.nodeSize - 1,
|
|
87
|
-
),
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
transaction.scrollIntoView();
|
|
91
|
-
return {
|
|
92
|
-
initialState: state,
|
|
93
|
-
transaction,
|
|
94
|
-
result: result.every((ok) => ok),
|
|
95
|
-
};
|
|
96
|
-
} else {
|
|
97
|
-
return {
|
|
98
|
-
initialState: state,
|
|
99
|
-
transaction: state.tr,
|
|
100
|
-
result: false,
|
|
101
|
-
};
|
|
102
|
-
}
|
|
62
|
+
if (!container) {
|
|
63
|
+
return {
|
|
64
|
+
initialState: state,
|
|
65
|
+
transaction: state.tr,
|
|
66
|
+
result: false,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const location = findNodeByRdfaId(state.doc, container.object.value);
|
|
71
|
+
if (!location) {
|
|
72
|
+
return {
|
|
73
|
+
initialState: state,
|
|
74
|
+
transaction: state.tr,
|
|
75
|
+
result: false,
|
|
76
|
+
};
|
|
103
77
|
}
|
|
78
|
+
|
|
79
|
+
const insertLocation = resolveInsertLocation(location, position);
|
|
80
|
+
|
|
81
|
+
const factory = new SayDataFactory();
|
|
82
|
+
const tr = state.tr;
|
|
83
|
+
const combiResult = transactionCombinator(
|
|
84
|
+
state,
|
|
85
|
+
tr.replaceWith(insertLocation, insertLocation, node),
|
|
86
|
+
)([
|
|
87
|
+
addPropertyToNode({
|
|
88
|
+
resource: decisionResource,
|
|
89
|
+
property: {
|
|
90
|
+
predicate: ELI('has_part').full,
|
|
91
|
+
object: factory.resourceNode(node.attrs.subject),
|
|
92
|
+
},
|
|
93
|
+
}),
|
|
94
|
+
recalculateNumbers,
|
|
95
|
+
]);
|
|
96
|
+
|
|
97
|
+
const { result, transaction } = combiResult;
|
|
98
|
+
|
|
99
|
+
transaction.setSelection(
|
|
100
|
+
TextSelection.create(
|
|
101
|
+
transaction.doc,
|
|
102
|
+
insertLocation + 1,
|
|
103
|
+
insertLocation + node.nodeSize - 1,
|
|
104
|
+
),
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
transaction.scrollIntoView();
|
|
104
108
|
return {
|
|
105
109
|
initialState: state,
|
|
106
|
-
transaction
|
|
107
|
-
result:
|
|
110
|
+
transaction,
|
|
111
|
+
result: result.every((ok) => ok),
|
|
108
112
|
};
|
|
109
113
|
};
|
|
110
114
|
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Resolves the document position at which to insert a new article node
|
|
118
|
+
*
|
|
119
|
+
* - If `position` is undefined, insert at the end of the container.
|
|
120
|
+
* - If `position` is 0, insert before the first child.
|
|
121
|
+
* - If `position` >= childCount, insert after the last child (append).
|
|
122
|
+
* - Otherwise, insert before the child at that index.
|
|
123
|
+
*/
|
|
124
|
+
function resolveInsertLocation(
|
|
125
|
+
location: { pos: number; value: PNode },
|
|
126
|
+
position: number | undefined,
|
|
127
|
+
): number {
|
|
128
|
+
const containerNode = location.value;
|
|
129
|
+
|
|
130
|
+
if (position === undefined) {
|
|
131
|
+
return location.pos + containerNode.nodeSize - 1;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const childCount = containerNode.childCount;
|
|
135
|
+
|
|
136
|
+
if (position >= childCount) {
|
|
137
|
+
return location.pos + containerNode.nodeSize - 1;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
let offset = location.pos + 1; // +1 to step inside the container node
|
|
141
|
+
let articleIndex = 0;
|
|
142
|
+
for (const child of containerNode.children) {
|
|
143
|
+
if (articleIndex === position) {
|
|
144
|
+
return offset;
|
|
145
|
+
}
|
|
146
|
+
offset += child.nodeSize;
|
|
147
|
+
if (child.attrs.structureType === 'article') {
|
|
148
|
+
articleIndex += 1;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return location.pos + containerNode.nodeSize - 1;
|
|
153
|
+
}
|
|
@@ -60,6 +60,7 @@ type InsertMeasureArgs = {
|
|
|
60
60
|
variables: Record<string, VariableInstance & { __rdfaId: string }>;
|
|
61
61
|
templateString: string;
|
|
62
62
|
decisionUri: string;
|
|
63
|
+
position?: number;
|
|
63
64
|
articleUriGenerator?: () => string;
|
|
64
65
|
} & (
|
|
65
66
|
| {
|
|
@@ -78,6 +79,7 @@ export default function insertMeasure({
|
|
|
78
79
|
templateString,
|
|
79
80
|
articleUriGenerator,
|
|
80
81
|
decisionUri,
|
|
82
|
+
position,
|
|
81
83
|
...args
|
|
82
84
|
}: InsertMeasureArgs): TransactionMonad<boolean> {
|
|
83
85
|
return function (state: EditorState) {
|
|
@@ -230,6 +232,7 @@ export default function insertMeasure({
|
|
|
230
232
|
const initialTransaction = insertArticle({
|
|
231
233
|
node: articleNode,
|
|
232
234
|
decisionUri,
|
|
235
|
+
position,
|
|
233
236
|
})(state).transaction;
|
|
234
237
|
const resultingSelection = initialTransaction.selection;
|
|
235
238
|
const { transaction, result } = transactionCombinator(
|
|
@@ -30,6 +30,7 @@ export function createCodelistVariable(args: CreateCodelistVariableArgs) {
|
|
|
30
30
|
subject: args.value,
|
|
31
31
|
variableInstance: args.variableInstance,
|
|
32
32
|
text: args.valueLabel,
|
|
33
|
+
pointsToNode: args.__rdfaId,
|
|
33
34
|
});
|
|
34
35
|
return schema.nodes.codelist.create(attrs, [codelistOption]);
|
|
35
36
|
}
|
|
@@ -42,6 +43,7 @@ type CreateCodelistVariableAttrsArgs = {
|
|
|
42
43
|
source: string;
|
|
43
44
|
codelist: string;
|
|
44
45
|
hardcodedOptionList?: CodeListOption[];
|
|
46
|
+
hasNonLiteralContents?: boolean;
|
|
45
47
|
} & AllOrNone<{
|
|
46
48
|
variable: string;
|
|
47
49
|
variableInstance: string;
|
|
@@ -57,6 +59,7 @@ export function createCodelistVariableAttrs({
|
|
|
57
59
|
variable,
|
|
58
60
|
variableInstance,
|
|
59
61
|
hardcodedOptionList,
|
|
62
|
+
hasNonLiteralContents,
|
|
60
63
|
}: CreateCodelistVariableAttrsArgs) {
|
|
61
64
|
const externalTriples: FullTriple[] = [];
|
|
62
65
|
if (variable) {
|
|
@@ -90,6 +93,7 @@ export function createCodelistVariableAttrs({
|
|
|
90
93
|
variable,
|
|
91
94
|
variableInstance,
|
|
92
95
|
hardcodedOptionList,
|
|
96
|
+
hasNonLiteralContents: !!hasNonLiteralContents,
|
|
93
97
|
} as CodelistAttrs;
|
|
94
98
|
}
|
|
95
99
|
|
|
@@ -109,12 +113,14 @@ type CreateCodelistOptionNodeAttrsArgs = {
|
|
|
109
113
|
text: string;
|
|
110
114
|
value?: string;
|
|
111
115
|
variableInstance?: string;
|
|
116
|
+
pointsToNode?: string;
|
|
112
117
|
};
|
|
113
118
|
|
|
114
119
|
function createCodelistOptionNodeAttrs({
|
|
115
120
|
subject,
|
|
116
121
|
text,
|
|
117
122
|
variableInstance,
|
|
123
|
+
pointsToNode,
|
|
118
124
|
}: CreateCodelistOptionNodeAttrsArgs) {
|
|
119
125
|
const backlinks: IncomingTriple[] = [];
|
|
120
126
|
if (variableInstance) {
|
|
@@ -135,5 +141,6 @@ function createCodelistOptionNodeAttrs({
|
|
|
135
141
|
subject,
|
|
136
142
|
properties,
|
|
137
143
|
backlinks,
|
|
144
|
+
pointsToNode,
|
|
138
145
|
};
|
|
139
146
|
}
|
|
@@ -35,12 +35,16 @@ export function updateCodelistVariable(
|
|
|
35
35
|
const variableInstance = selectedCodelist.node.attrs['variableInstance'] as
|
|
36
36
|
| string
|
|
37
37
|
| undefined;
|
|
38
|
+
const pointerTarget = selectedCodelist.node.attrs['__rdfaId'] as
|
|
39
|
+
| string
|
|
40
|
+
| undefined;
|
|
38
41
|
const codelistOptionNodes = selectedOptions.map((option) =>
|
|
39
42
|
createCodelistOptionNode({
|
|
40
43
|
schema: controller.schema,
|
|
41
44
|
text: option.label,
|
|
42
45
|
subject: option.uri,
|
|
43
46
|
variableInstance,
|
|
47
|
+
pointsToNode: pointerTarget,
|
|
44
48
|
}),
|
|
45
49
|
);
|
|
46
50
|
const range = {
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
} from '@lblod/ember-rdfa-editor/utils/ember-node';
|
|
6
6
|
import {
|
|
7
7
|
DOMOutputSpec,
|
|
8
|
+
EditorState,
|
|
8
9
|
Fragment,
|
|
9
10
|
PNode,
|
|
10
11
|
Schema,
|
|
@@ -102,7 +103,7 @@ const parseDOM: TagParseRule[] = [
|
|
|
102
103
|
},
|
|
103
104
|
];
|
|
104
105
|
|
|
105
|
-
const toDOM = (node: PNode): DOMOutputSpec => {
|
|
106
|
+
const toDOM = (node: PNode, state?: EditorState): DOMOutputSpec => {
|
|
106
107
|
const {
|
|
107
108
|
label = 'codelist',
|
|
108
109
|
codelist,
|
|
@@ -119,30 +120,36 @@ const toDOM = (node: PNode): DOMOutputSpec => {
|
|
|
119
120
|
for (let i = 0; i < codelist_option_nodes.length; i++) {
|
|
120
121
|
const codelist_option_node = codelist_option_nodes[i];
|
|
121
122
|
contentArray.push(
|
|
122
|
-
unwrap(codelist_option_node.type.spec.toDOM)(
|
|
123
|
+
unwrap((codelist_option_node.type.spec as SayNodeSpec).toDOM)(
|
|
124
|
+
codelist_option_node,
|
|
125
|
+
state,
|
|
126
|
+
),
|
|
123
127
|
);
|
|
124
128
|
if (i !== codelist_option_nodes.length - 1) {
|
|
125
129
|
contentArray.push(', ');
|
|
126
130
|
}
|
|
127
131
|
}
|
|
128
|
-
return renderRdfaAware(
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
132
|
+
return renderRdfaAware(
|
|
133
|
+
{
|
|
134
|
+
renderable: node,
|
|
135
|
+
tag: 'span',
|
|
136
|
+
attrs: {
|
|
137
|
+
class: `${getClassnamesFromNode(node)}${className}`,
|
|
138
|
+
'data-say-variable': 'true',
|
|
139
|
+
'data-say-variable-type': 'codelist',
|
|
140
|
+
'data-say-node-version': '2',
|
|
141
|
+
'data-label': label as string | null,
|
|
142
|
+
'data-codelist': codelist as string,
|
|
143
|
+
'data-source': source as string,
|
|
144
|
+
'data-selection-style': selectionStyle as string,
|
|
145
|
+
'data-variable': variable as string,
|
|
146
|
+
'data-variable-instance': variableInstance as string,
|
|
147
|
+
'data-option-list': JSON.stringify(hardcodedOptionList),
|
|
148
|
+
},
|
|
149
|
+
contentArray: contentArray.length ? contentArray : [label],
|
|
143
150
|
},
|
|
144
|
-
|
|
145
|
-
|
|
151
|
+
state,
|
|
152
|
+
);
|
|
146
153
|
};
|
|
147
154
|
|
|
148
155
|
const emberNodeConfig: EmberNodeConfig = {
|
|
@@ -195,14 +202,17 @@ export const codelist_option: SayNodeSpec = {
|
|
|
195
202
|
attrs: {
|
|
196
203
|
...rdfaAttrSpec({ rdfaAware }),
|
|
197
204
|
},
|
|
198
|
-
toDOM: (node) => {
|
|
199
|
-
return renderRdfaAware(
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
205
|
+
toDOM: (node, state) => {
|
|
206
|
+
return renderRdfaAware(
|
|
207
|
+
{
|
|
208
|
+
renderable: node,
|
|
209
|
+
attrs: {
|
|
210
|
+
'data-say-type': 'codelist_option',
|
|
211
|
+
},
|
|
212
|
+
tag: 'span',
|
|
213
|
+
content: node.textContent,
|
|
203
214
|
},
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
});
|
|
215
|
+
state,
|
|
216
|
+
);
|
|
207
217
|
},
|
|
208
218
|
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { EditorState } from '@lblod/ember-rdfa-editor';
|
|
2
|
+
import { PNode } from '@lblod/ember-rdfa-editor';
|
|
3
|
+
|
|
4
|
+
export function getArticleNodes(state: EditorState) {
|
|
5
|
+
const articles: { node: PNode; pos: number }[] = [];
|
|
6
|
+
|
|
7
|
+
state.doc.descendants((node, pos) => {
|
|
8
|
+
if (node.attrs.structureType === 'article') {
|
|
9
|
+
articles.push({ node, pos });
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return true;
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
return articles;
|
|
17
|
+
}
|
|
@@ -2,10 +2,13 @@ import Component from '@glimmer/component';
|
|
|
2
2
|
import { MobilityMeasureConcept } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/roadsign-regulation-plugin/schemas/mobility-measure-concept';
|
|
3
3
|
import { ZonalOrNot } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/roadsign-regulation-plugin/constants';
|
|
4
4
|
import { Task } from 'ember-concurrency';
|
|
5
|
+
import IntlService from 'ember-intl/services/intl';
|
|
6
|
+
import { PNode } from '@lblod/ember-rdfa-editor';
|
|
5
7
|
export type InsertMobilityMeasureTask = Task<void, [
|
|
6
8
|
MobilityMeasureConcept,
|
|
7
9
|
ZonalOrNot,
|
|
8
|
-
boolean
|
|
10
|
+
boolean,
|
|
11
|
+
number?
|
|
9
12
|
]>;
|
|
10
13
|
type Signature = {
|
|
11
14
|
Args: {
|
|
@@ -13,16 +16,34 @@ type Signature = {
|
|
|
13
16
|
selectRow: (uri: string) => void;
|
|
14
17
|
insert: InsertMobilityMeasureTask;
|
|
15
18
|
endpoint: string;
|
|
19
|
+
articleNodes: PNode[];
|
|
16
20
|
};
|
|
17
21
|
};
|
|
22
|
+
type InsertPositionOption = {
|
|
23
|
+
label: string;
|
|
24
|
+
position: 'first' | 'last' | 'custom';
|
|
25
|
+
insertIndex?: number;
|
|
26
|
+
};
|
|
18
27
|
export default class ExpandedMeasure extends Component<Signature> {
|
|
28
|
+
intl: IntlService;
|
|
19
29
|
zonalityValue?: ZonalOrNot;
|
|
20
30
|
temporalValue?: boolean;
|
|
31
|
+
selectedInsertPosition: InsertPositionOption;
|
|
32
|
+
insertPositionOptionFirst: InsertPositionOption;
|
|
33
|
+
insertPositionOptionLast: InsertPositionOption;
|
|
34
|
+
constructor(owner: unknown, args: Signature['Args']);
|
|
21
35
|
get isPotentiallyZonal(): boolean;
|
|
22
36
|
get insertButtonDisabled(): boolean;
|
|
23
37
|
changeZonality(zonality: ZonalOrNot): void;
|
|
24
38
|
changeTemporality(temporality: 'true' | 'false'): void;
|
|
25
39
|
insert(): void;
|
|
26
40
|
unselectRow(): void;
|
|
41
|
+
get articlesInDocument(): PNode[];
|
|
42
|
+
get insertPositionOptions(): (InsertPositionOption | {
|
|
43
|
+
label: string;
|
|
44
|
+
position: string;
|
|
45
|
+
insertIndex: number;
|
|
46
|
+
})[];
|
|
47
|
+
get insertPositionDropdownTitle(): string;
|
|
27
48
|
}
|
|
28
49
|
export {};
|
|
@@ -134,10 +134,11 @@ export default class RoadsignsModal extends Component<Signature> {
|
|
|
134
134
|
}))[];
|
|
135
135
|
}[] | undefined;
|
|
136
136
|
get measureConceptCount(): number | undefined;
|
|
137
|
-
insertMeasure: import("ember-concurrency").TaskForAsyncTaskFunction<unknown, (concept: MobilityMeasureConcept, zonality: ZonalOrNot, temporal: boolean) => Promise<void>>;
|
|
137
|
+
insertMeasure: import("ember-concurrency").TaskForAsyncTaskFunction<unknown, (concept: MobilityMeasureConcept, zonality: ZonalOrNot, temporal: boolean, position?: number) => Promise<void>>;
|
|
138
138
|
resetPagination(): void;
|
|
139
139
|
goToPreviousPage(): void;
|
|
140
140
|
goToNextPage(): void;
|
|
141
141
|
goToPage(pageNumber: number): void;
|
|
142
|
+
get articleNodes(): import("prosemirror-model").Node[];
|
|
142
143
|
}
|
|
143
144
|
export {};
|
|
@@ -2,12 +2,14 @@ import Component from '@glimmer/component';
|
|
|
2
2
|
import { RoadsignRegulationPluginOptions } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/roadsign-regulation-plugin';
|
|
3
3
|
import { MobilityMeasureConcept } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/roadsign-regulation-plugin/schemas/mobility-measure-concept';
|
|
4
4
|
import { InsertMobilityMeasureTask } from './expanded-measure';
|
|
5
|
+
import { PNode } from '@lblod/ember-rdfa-editor';
|
|
5
6
|
type Signature = {
|
|
6
7
|
Args: {
|
|
7
8
|
options: RoadsignRegulationPluginOptions;
|
|
8
9
|
content?: MobilityMeasureConcept[];
|
|
9
10
|
isLoading?: boolean;
|
|
10
11
|
insert: InsertMobilityMeasureTask;
|
|
12
|
+
articleNodes: PNode[];
|
|
11
13
|
};
|
|
12
14
|
};
|
|
13
15
|
export default class RoadSignsTable extends Component<Signature> {
|
|
@@ -12,11 +12,12 @@ type InsertMeasureArgs = {
|
|
|
12
12
|
}>;
|
|
13
13
|
templateString: string;
|
|
14
14
|
decisionUri: string;
|
|
15
|
+
position?: number;
|
|
15
16
|
articleUriGenerator?: () => string;
|
|
16
17
|
} & ({
|
|
17
18
|
measureConcept: MobilityMeasureConcept;
|
|
18
19
|
} | {
|
|
19
20
|
measureDesign: MobilityMeasureDesign;
|
|
20
21
|
});
|
|
21
|
-
export default function insertMeasure({ arDesignUri, zonality, temporal, variables, templateString, articleUriGenerator, decisionUri, ...args }: InsertMeasureArgs): TransactionMonad<boolean>;
|
|
22
|
+
export default function insertMeasure({ arDesignUri, zonality, temporal, variables, templateString, articleUriGenerator, decisionUri, position, ...args }: InsertMeasureArgs): TransactionMonad<boolean>;
|
|
22
23
|
export {};
|
|
@@ -14,12 +14,13 @@ type CreateCodelistVariableAttrsArgs = {
|
|
|
14
14
|
source: string;
|
|
15
15
|
codelist: string;
|
|
16
16
|
hardcodedOptionList?: CodeListOption[];
|
|
17
|
+
hasNonLiteralContents?: boolean;
|
|
17
18
|
} & AllOrNone<{
|
|
18
19
|
variable: string;
|
|
19
20
|
variableInstance: string;
|
|
20
21
|
__rdfaId?: string;
|
|
21
22
|
}>;
|
|
22
|
-
export declare function createCodelistVariableAttrs({ selectionStyle, label, source, codelist, __rdfaId, variable, variableInstance, hardcodedOptionList, }: CreateCodelistVariableAttrsArgs): CodelistAttrs;
|
|
23
|
+
export declare function createCodelistVariableAttrs({ selectionStyle, label, source, codelist, __rdfaId, variable, variableInstance, hardcodedOptionList, hasNonLiteralContents, }: CreateCodelistVariableAttrsArgs): CodelistAttrs;
|
|
23
24
|
type CreateCodelistOptionNodeArgs = {
|
|
24
25
|
schema: Schema;
|
|
25
26
|
text: string;
|
|
@@ -30,5 +31,6 @@ type CreateCodelistOptionNodeAttrsArgs = {
|
|
|
30
31
|
text: string;
|
|
31
32
|
value?: string;
|
|
32
33
|
variableInstance?: string;
|
|
34
|
+
pointsToNode?: string;
|
|
33
35
|
};
|
|
34
36
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lblod/ember-rdfa-editor-lblod-plugins",
|
|
3
|
-
"version": "35.
|
|
3
|
+
"version": "35.4.0-dev.227e3fda9666fa2f52270074003b8aeaf320a473",
|
|
4
4
|
"description": "Ember addon providing lblod specific plugins for the ember-rdfa-editor",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon",
|
|
@@ -38,8 +38,9 @@
|
|
|
38
38
|
"lint:js": "eslint . --cache",
|
|
39
39
|
"lint:js:fix": "eslint . --fix",
|
|
40
40
|
"lint:prettier": "prettier --check .",
|
|
41
|
-
"lint:prettier:fix": "
|
|
41
|
+
"lint:prettier:fix": "pnpm format",
|
|
42
42
|
"lint:types": "glint",
|
|
43
|
+
"format": "prettier --write .",
|
|
43
44
|
"start": "concurrently -c \"auto\" -P \"pnpm:serve {@}\" \"pnpm:typecheck\" --",
|
|
44
45
|
"typecheck": "glint --watch --preserveWatchOutput",
|
|
45
46
|
"serve": "ember serve",
|
|
@@ -110,9 +111,8 @@
|
|
|
110
111
|
"@glint/environment-ember-loose": "^1.5.0",
|
|
111
112
|
"@glint/environment-ember-template-imports": "^1.5.0",
|
|
112
113
|
"@glint/template": "^1.5.0",
|
|
113
|
-
"@
|
|
114
|
-
"@
|
|
115
|
-
"@lblod/ember-rdfa-editor": "13.1.1",
|
|
114
|
+
"@lblod/ember-rdfa-editor": "13.6.0",
|
|
115
|
+
"@rdfjs/to-ntriples": "^3.0.1",
|
|
116
116
|
"@rdfjs/types": "^1.1.0",
|
|
117
117
|
"@release-it/keep-a-changelog": "^4.0.0",
|
|
118
118
|
"@tsconfig/ember": "^3.0.8",
|
|
@@ -207,6 +207,7 @@
|
|
|
207
207
|
"pnpm": {
|
|
208
208
|
"overrides": {
|
|
209
209
|
"babel-plugin-ember-template-compilation": "^2.2.5",
|
|
210
|
+
"@codemirror/state": "6.5.2",
|
|
210
211
|
"prosemirror-view": "^1.41.5"
|
|
211
212
|
}
|
|
212
213
|
},
|
package/translations/en-US.yaml
CHANGED
|
@@ -316,6 +316,10 @@ editor-plugins:
|
|
|
316
316
|
roadsign-regulation:
|
|
317
317
|
expanded-measure:
|
|
318
318
|
insert-measure: 'Insert measure:'
|
|
319
|
+
as-last-article: As first article
|
|
320
|
+
as-first-article: As last article
|
|
321
|
+
after-article-x: After article {articleNumber}
|
|
322
|
+
insert-position: 'Insertion position:'
|
|
319
323
|
select-zonality:
|
|
320
324
|
label: 'Select zonal validity:'
|
|
321
325
|
zonal: Zonal
|
package/translations/nl-BE.yaml
CHANGED
|
@@ -315,6 +315,10 @@ editor-plugins:
|
|
|
315
315
|
roadsign-regulation:
|
|
316
316
|
expanded-measure:
|
|
317
317
|
insert-measure: 'Voeg maatregel in:'
|
|
318
|
+
as-last-article: Als laatste artikel
|
|
319
|
+
as-first-article: Als eerste artikel
|
|
320
|
+
after-article-x: Na artikel {articleNumber}
|
|
321
|
+
insert-position: 'Invoegpositie:'
|
|
318
322
|
select-zonality:
|
|
319
323
|
label: 'Selecteer zonale geldigheid:'
|
|
320
324
|
zonal: Zonaal
|