@lblod/ember-rdfa-editor-lblod-plugins 5.0.0 → 6.0.0
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 +22 -2
- package/README.md +126 -70
- package/addon/components/address-plugin/insert.hbs +47 -0
- package/addon/components/address-plugin/insert.ts +100 -0
- package/addon/components/address-plugin/types.ts +26 -0
- package/addon/components/address-plugin/utils.ts +59 -0
- package/addon/components/besluit-type-plugin/toolbar-dropdown.ts +6 -5
- package/addon/components/{besluit-plugin/besluit-plugin-card.ts → decision-plugin/decision-plugin-card.ts} +22 -8
- package/addon/components/hover-tooltip.ts +15 -12
- package/addon/components/roadsign-regulation-plugin/measure-template.ts +5 -1
- package/addon/components/roadsign-regulation-plugin/roadsign-regulation-card.hbs +1 -1
- package/addon/components/roadsign-regulation-plugin/roadsigns-modal.hbs +1 -0
- package/addon/components/roadsign-regulation-plugin/roadsigns-modal.ts +24 -21
- package/addon/components/roadsign-regulation-plugin/roadsigns-table.ts +8 -11
- package/addon/components/table-of-contents-plugin/ember-nodes/table-of-contents.ts +16 -1
- package/addon/components/validation-plugin/validation-card.hbs +12 -0
- package/addon/components/validation-plugin/validation-card.ts +19 -0
- package/addon/components/validation-plugin/validation-item.hbs +2 -0
- package/addon/components/validation-plugin/validation-item.ts +55 -0
- package/addon/components/variable-plugin/template-variable-card.ts +8 -25
- package/addon/plugins/besluit-type-plugin/index.ts +3 -0
- package/addon/plugins/besluit-type-plugin/utils/fetchBesluitTypes.ts +1 -6
- package/addon/plugins/decision-plugin/commands/index.ts +4 -0
- package/addon/plugins/decision-plugin/commands/insert-article-container.ts +56 -0
- package/addon/plugins/decision-plugin/commands/insert-description.ts +53 -0
- package/addon/plugins/decision-plugin/commands/insert-motivation.ts +62 -0
- package/addon/plugins/decision-plugin/commands/insert-title.ts +54 -0
- package/addon/plugins/roadsign-regulation-plugin/index.ts +4 -0
- package/addon/plugins/standard-template-plugin/utils/nodes.ts +0 -1
- package/addon/plugins/table-of-contents-plugin/index.ts +2 -0
- package/addon/plugins/validation/README.md +84 -0
- package/addon/plugins/validation/index.ts +427 -0
- package/addon/plugins/validation/utils/transaction-complies-with-shapes.ts +28 -0
- package/addon/plugins/variable-plugin/index.ts +5 -0
- package/addon/services/roadsign-registry.ts +54 -50
- package/addon/utils/find-insertion-pos-in-ancestor-of-type.ts +35 -0
- package/app/components/{besluit-plugin/besluit-plugin-card.js → address-plugin/insert.js} +1 -1
- package/app/components/decision-plugin/decision-plugin-card.js +1 -0
- package/app/components/{besluit-plugin/besluit-context-card.js → validation-plugin/validation-card.js} +1 -1
- package/app/components/validation-plugin/validation-item.js +1 -0
- package/app/styles/address-plugin.scss +7 -0
- package/components/address-plugin/insert.d.ts +21 -0
- package/components/address-plugin/types.d.ts +25 -0
- package/components/address-plugin/utils.d.ts +9 -0
- package/components/besluit-type-plugin/toolbar-dropdown.d.ts +2 -0
- package/components/{besluit-plugin/besluit-plugin-card.d.ts → decision-plugin/decision-plugin-card.d.ts} +4 -1
- package/components/roadsign-regulation-plugin/measure-template.d.ts +2 -0
- package/components/roadsign-regulation-plugin/roadsigns-modal.d.ts +3 -0
- package/components/roadsign-regulation-plugin/roadsigns-table.d.ts +6 -1
- package/components/validation-plugin/validation-card.d.ts +13 -0
- package/components/validation-plugin/validation-item.d.ts +18 -0
- package/components/variable-plugin/template-variable-card.d.ts +2 -4
- package/package.json +1 -1
- package/plugins/besluit-type-plugin/index.d.ts +3 -0
- package/plugins/besluit-type-plugin/utils/fetchBesluitTypes.d.ts +1 -5
- package/plugins/decision-plugin/commands/index.d.ts +4 -0
- package/plugins/decision-plugin/commands/insert-article-container.d.ts +8 -0
- package/plugins/decision-plugin/commands/insert-description.d.ts +7 -0
- package/plugins/decision-plugin/commands/insert-motivation.d.ts +7 -0
- package/plugins/decision-plugin/commands/insert-title.d.ts +7 -0
- package/plugins/roadsign-regulation-plugin/index.d.ts +4 -0
- package/plugins/table-of-contents-plugin/index.d.ts +2 -0
- package/plugins/validation/index.d.ts +62 -0
- package/plugins/validation/utils/transaction-complies-with-shapes.d.ts +10 -0
- package/plugins/variable-plugin/index.d.ts +5 -0
- package/services/roadsign-registry.d.ts +7 -9
- package/translations/en-US.yaml +58 -47
- package/translations/nl-BE.yaml +18 -0
- package/utils/find-insertion-pos-in-ancestor-of-type.d.ts +11 -0
- package/addon/plugins/besluit-plugin/commands/index.ts +0 -1
- package/addon/plugins/besluit-plugin/commands/insert-title.ts +0 -43
- package/config/environment.js +0 -20
- package/plugins/besluit-plugin/commands/index.d.ts +0 -1
- package/plugins/besluit-plugin/commands/insert-title.d.ts +0 -3
- /package/addon/components/{besluit-plugin/besluit-plugin-card.hbs → decision-plugin/decision-plugin-card.hbs} +0 -0
- /package/addon/plugins/{besluit-plugin → decision-plugin}/utils/get-title-for-decision.ts +0 -0
- /package/plugins/{besluit-plugin → decision-plugin}/utils/get-title-for-decision.d.ts +0 -0
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { tracked } from '@glimmer/tracking';
|
|
2
2
|
import Component from '@glimmer/component';
|
|
3
3
|
import { action } from '@ember/object';
|
|
4
|
-
import { getOwner } from '@ember/application';
|
|
5
4
|
import { inject as service } from '@ember/service';
|
|
6
5
|
import {
|
|
7
6
|
addType,
|
|
@@ -17,6 +16,7 @@ import fetchBesluitTypes, {
|
|
|
17
16
|
import { findAncestorOfType } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/article-structure-plugin/utils/structure';
|
|
18
17
|
import { trackedFunction } from 'ember-resources/util/function';
|
|
19
18
|
import { unwrap } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
|
|
19
|
+
import { BesluitTypePluginOptions } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-type-plugin';
|
|
20
20
|
|
|
21
21
|
declare module 'ember__owner' {
|
|
22
22
|
export default interface Owner {
|
|
@@ -26,6 +26,7 @@ declare module 'ember__owner' {
|
|
|
26
26
|
|
|
27
27
|
type Args = {
|
|
28
28
|
controller: SayController;
|
|
29
|
+
options: BesluitTypePluginOptions;
|
|
29
30
|
};
|
|
30
31
|
|
|
31
32
|
export default class EditorPluginsToolbarDropdownComponent extends Component<Args> {
|
|
@@ -63,10 +64,10 @@ export default class EditorPluginsToolbarDropdownComponent extends Component<Arg
|
|
|
63
64
|
// eslint-disable-next-line @typescript-eslint/await-thenable
|
|
64
65
|
const bestuurseenheid = await this.currentSession.get('group');
|
|
65
66
|
const classificatie = await bestuurseenheid.get('classificatie');
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
const types = await fetchBesluitTypes(
|
|
68
|
+
classificatie.uri,
|
|
69
|
+
this.args.options.endpoint
|
|
70
|
+
);
|
|
70
71
|
return types;
|
|
71
72
|
});
|
|
72
73
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
2
|
import { action } from '@ember/object';
|
|
3
|
-
import { insertTitle } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/
|
|
3
|
+
import { insertTitle } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/decision-plugin/commands';
|
|
4
4
|
import { SayController } from '@lblod/ember-rdfa-editor';
|
|
5
5
|
import { inject as service } from '@ember/service';
|
|
6
6
|
import IntlService from 'ember-intl/services/intl';
|
|
@@ -9,8 +9,12 @@ type Args = {
|
|
|
9
9
|
controller: SayController;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated
|
|
14
|
+
*/
|
|
15
|
+
export default class DecisionPluginCard extends Component<Args> {
|
|
13
16
|
@service declare intl: IntlService;
|
|
17
|
+
|
|
14
18
|
get controller() {
|
|
15
19
|
return this.args.controller;
|
|
16
20
|
}
|
|
@@ -21,15 +25,25 @@ export default class BesluitPluginCardComponent extends Component<Args> {
|
|
|
21
25
|
|
|
22
26
|
@action
|
|
23
27
|
insertTitle() {
|
|
24
|
-
this.controller.doCommand(
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
this.controller.doCommand(
|
|
29
|
+
insertTitle({
|
|
30
|
+
placeholderText: this.intl.t('besluit-plugin.insert.decision-title'),
|
|
31
|
+
}),
|
|
32
|
+
{
|
|
33
|
+
view: this.controller.mainEditorView,
|
|
34
|
+
}
|
|
35
|
+
);
|
|
27
36
|
this.focus();
|
|
28
37
|
}
|
|
29
38
|
|
|
30
39
|
get canInsertTitle() {
|
|
31
|
-
return this.controller.checkCommand(
|
|
32
|
-
|
|
33
|
-
|
|
40
|
+
return this.controller.checkCommand(
|
|
41
|
+
insertTitle({
|
|
42
|
+
placeholderText: this.intl.t('besluit-plugin.insert.decision-title'),
|
|
43
|
+
}),
|
|
44
|
+
{
|
|
45
|
+
view: this.controller.mainEditorView,
|
|
46
|
+
}
|
|
47
|
+
);
|
|
34
48
|
}
|
|
35
49
|
}
|
|
@@ -7,18 +7,21 @@ interface Args {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export default class HoverTooltip extends Component<Args> {
|
|
10
|
-
hover = modifier(
|
|
11
|
-
element
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
10
|
+
hover = modifier(
|
|
11
|
+
(element) => {
|
|
12
|
+
element.addEventListener('mouseenter', this.showTooltip);
|
|
13
|
+
element.addEventListener('mouseleave', this.hideTooltip);
|
|
14
|
+
element.addEventListener('focus', this.showTooltip);
|
|
15
|
+
element.addEventListener('blur', this.hideTooltip);
|
|
16
|
+
return () => {
|
|
17
|
+
element.removeEventListener('mouseenter', this.showTooltip);
|
|
18
|
+
element.removeEventListener('mouseleave', this.hideTooltip);
|
|
19
|
+
element.removeEventListener('focus', this.showTooltip);
|
|
20
|
+
element.removeEventListener('blur', this.hideTooltip);
|
|
21
|
+
};
|
|
22
|
+
},
|
|
23
|
+
{ eager: false }
|
|
24
|
+
);
|
|
22
25
|
|
|
23
26
|
@tracked tooltipOpen = false;
|
|
24
27
|
|
|
@@ -9,21 +9,25 @@ type Args = {
|
|
|
9
9
|
template: string;
|
|
10
10
|
measure: string;
|
|
11
11
|
annotated: boolean;
|
|
12
|
+
endpoint: string;
|
|
12
13
|
};
|
|
13
14
|
export default class MeasureTemplateComponent extends Component<Args> {
|
|
14
15
|
@service declare roadsignRegistry: RoadsignRegistryService;
|
|
15
16
|
@tracked template = '';
|
|
17
|
+
endpoint: string;
|
|
16
18
|
|
|
17
19
|
constructor(parent: unknown, args: Args) {
|
|
18
20
|
super(parent, args);
|
|
19
21
|
this.template = this.args.template;
|
|
20
22
|
void this.fetchData.perform();
|
|
23
|
+
this.endpoint = this.args.endpoint;
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
fetchData = task(async () => {
|
|
24
27
|
const instructions =
|
|
25
28
|
await this.roadsignRegistry.getInstructionsForMeasure.perform(
|
|
26
|
-
this.args.measure
|
|
29
|
+
this.args.measure,
|
|
30
|
+
this.endpoint
|
|
27
31
|
);
|
|
28
32
|
const template = includeInstructions(
|
|
29
33
|
this.args.template,
|
|
@@ -9,4 +9,4 @@
|
|
|
9
9
|
Voeg mobiliteitsmaatregel in
|
|
10
10
|
</AuButton>
|
|
11
11
|
</AuList::Item>
|
|
12
|
-
<RoadsignRegulationPlugin::RoadsignsModal @modalOpen={{this.modalOpen}} @closeModal={{this.closeModal}} @controller={{@controller}}/>
|
|
12
|
+
<RoadsignRegulationPlugin::RoadsignsModal @modalOpen={{this.modalOpen}} @closeModal={{this.closeModal}} @controller={{@controller}} @options={{@options}}/>
|
|
@@ -2,7 +2,6 @@ import { action } from '@ember/object';
|
|
|
2
2
|
import Component from '@glimmer/component';
|
|
3
3
|
import { tracked } from '@glimmer/tracking';
|
|
4
4
|
import { task } from 'ember-concurrency';
|
|
5
|
-
import { getOwner } from '@ember/application';
|
|
6
5
|
import { v4 as uuid } from 'uuid';
|
|
7
6
|
import { inject as service } from '@ember/service';
|
|
8
7
|
import includeInstructions from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/roadsign-regulation-plugin/utils/includeInstructions';
|
|
@@ -20,6 +19,7 @@ import { besluitArticleStructure } from '@lblod/ember-rdfa-editor-lblod-plugins/
|
|
|
20
19
|
import IntlService from 'ember-intl/services/intl';
|
|
21
20
|
import { ProseParser } from '@lblod/ember-rdfa-editor';
|
|
22
21
|
import { unwrap } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
|
|
22
|
+
import { RoadsignRegulationPluginOptions } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/roadsign-regulation-plugin';
|
|
23
23
|
|
|
24
24
|
const PAGE_SIZE = 10;
|
|
25
25
|
const SIGN_TYPE_URI =
|
|
@@ -43,10 +43,12 @@ type Category = Option;
|
|
|
43
43
|
type Args = {
|
|
44
44
|
closeModal: () => void;
|
|
45
45
|
controller: SayController;
|
|
46
|
+
options: RoadsignRegulationPluginOptions;
|
|
46
47
|
};
|
|
47
48
|
|
|
48
49
|
export default class RoadsignRegulationCard extends Component<Args> {
|
|
49
50
|
endpoint: string;
|
|
51
|
+
imageBaseUrl: string;
|
|
50
52
|
|
|
51
53
|
pageSize = PAGE_SIZE;
|
|
52
54
|
@service declare roadsignRegistry: RoadsignRegistryService;
|
|
@@ -84,15 +86,10 @@ export default class RoadsignRegulationCard extends Component<Args> {
|
|
|
84
86
|
|
|
85
87
|
constructor(parent: unknown, args: Args) {
|
|
86
88
|
super(parent, args);
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
) as {
|
|
90
|
-
roadsignRegulationPlugin: {
|
|
91
|
-
endpoint: string;
|
|
92
|
-
};
|
|
93
|
-
};
|
|
94
|
-
this.endpoint = config.roadsignRegulationPlugin.endpoint;
|
|
89
|
+
this.endpoint = args.options.endpoint;
|
|
90
|
+
this.imageBaseUrl = args.options.imageBaseUrl;
|
|
95
91
|
this.search();
|
|
92
|
+
void this.roadsignRegistry.loadClassifications.perform(this.endpoint);
|
|
96
93
|
}
|
|
97
94
|
|
|
98
95
|
get schema() {
|
|
@@ -176,6 +173,7 @@ export default class RoadsignRegulationCard extends Component<Args> {
|
|
|
176
173
|
];
|
|
177
174
|
}
|
|
178
175
|
const codes = await this.roadsignRegistry.searchCode.perform(
|
|
176
|
+
this.endpoint,
|
|
179
177
|
undefined,
|
|
180
178
|
undefined,
|
|
181
179
|
undefined,
|
|
@@ -224,17 +222,21 @@ export default class RoadsignRegulationCard extends Component<Args> {
|
|
|
224
222
|
codes.push(this.selectedCode);
|
|
225
223
|
}
|
|
226
224
|
const { measures, count } =
|
|
227
|
-
await this.roadsignRegistry.fetchMeasures.perform(
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
? this.
|
|
235
|
-
: undefined,
|
|
236
|
-
|
|
237
|
-
|
|
225
|
+
await this.roadsignRegistry.fetchMeasures.perform(
|
|
226
|
+
this.endpoint,
|
|
227
|
+
this.imageBaseUrl,
|
|
228
|
+
{
|
|
229
|
+
zonality: this.zonalitySelected
|
|
230
|
+
? this.zonalitySelected.value
|
|
231
|
+
: undefined,
|
|
232
|
+
type: this.typeSelected ? this.typeSelected.value : undefined,
|
|
233
|
+
codes: codes.length ? codes.map((code) => code.value) : undefined,
|
|
234
|
+
category: this.categorySelected
|
|
235
|
+
? this.categorySelected.value
|
|
236
|
+
: undefined,
|
|
237
|
+
pageStart: this.pageStart,
|
|
238
|
+
}
|
|
239
|
+
);
|
|
238
240
|
this.tableData = measures;
|
|
239
241
|
this.count = count;
|
|
240
242
|
});
|
|
@@ -247,7 +249,8 @@ export default class RoadsignRegulationCard extends Component<Args> {
|
|
|
247
249
|
) {
|
|
248
250
|
const instructions =
|
|
249
251
|
await this.roadsignRegistry.fetchInstructionsForMeasure.perform(
|
|
250
|
-
measure.uri
|
|
252
|
+
measure.uri,
|
|
253
|
+
this.endpoint
|
|
251
254
|
);
|
|
252
255
|
const zonality = zonalityValue ? zonalityValue : measure.zonality;
|
|
253
256
|
const html = includeInstructions(
|
|
@@ -1,24 +1,21 @@
|
|
|
1
1
|
import { action } from '@ember/object';
|
|
2
2
|
import Component from '@glimmer/component';
|
|
3
3
|
import { tracked } from '@glimmer/tracking';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { SayController } from '@lblod/ember-rdfa-editor';
|
|
5
|
+
import { RoadsignRegulationPluginOptions } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/roadsign-regulation-plugin';
|
|
6
|
+
|
|
7
|
+
type Args = {
|
|
8
|
+
controller: SayController;
|
|
9
|
+
options: RoadsignRegulationPluginOptions;
|
|
10
|
+
};
|
|
6
11
|
|
|
7
|
-
type Args = Record<string, never>;
|
|
8
12
|
export default class RoadsignsTable extends Component<Args> {
|
|
9
13
|
@tracked selected?: string;
|
|
10
14
|
imageBaseUrl: string;
|
|
11
15
|
|
|
12
16
|
constructor(parent: unknown, args: Args) {
|
|
13
17
|
super(parent, args);
|
|
14
|
-
|
|
15
|
-
'config:environment'
|
|
16
|
-
) as {
|
|
17
|
-
roadsignRegulationPlugin: {
|
|
18
|
-
imageBaseUrl: string;
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
this.imageBaseUrl = config.roadsignRegulationPlugin.imageBaseUrl;
|
|
18
|
+
this.imageBaseUrl = args.options.imageBaseUrl;
|
|
22
19
|
}
|
|
23
20
|
|
|
24
21
|
@action
|
|
@@ -83,7 +83,22 @@ export default class TableOfContentsComponent extends Component<EmberNodeArgs> {
|
|
|
83
83
|
const selection = Selection.near(resolvedPos, 1);
|
|
84
84
|
if (selection) {
|
|
85
85
|
tr.setSelection(selection);
|
|
86
|
-
|
|
86
|
+
const coords = this.controller.mainEditorView.coordsAtPos(
|
|
87
|
+
selection.from
|
|
88
|
+
);
|
|
89
|
+
const config = this.config[0];
|
|
90
|
+
if (config.scrollContainer) {
|
|
91
|
+
const scrollContainer: HTMLElement = config.scrollContainer;
|
|
92
|
+
const alreadyScrolled = scrollContainer.scrollTop;
|
|
93
|
+
const MAGIC_NUMBER_TOPBAR_HEIGHT: number =
|
|
94
|
+
config.scrollingPadding ?? 150;
|
|
95
|
+
scrollContainer.scrollTo(
|
|
96
|
+
0,
|
|
97
|
+
coords.top + alreadyScrolled - MAGIC_NUMBER_TOPBAR_HEIGHT
|
|
98
|
+
);
|
|
99
|
+
} else {
|
|
100
|
+
tr.scrollIntoView();
|
|
101
|
+
}
|
|
87
102
|
}
|
|
88
103
|
return tr;
|
|
89
104
|
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{{#if this.shouldShow}}
|
|
2
|
+
<AuCard @shadow={{true}} @size="small" as |Card|>
|
|
3
|
+
<Card.header>
|
|
4
|
+
<AuHeading @level="2" @skin="4">{{@title}}</AuHeading>
|
|
5
|
+
</Card.header>
|
|
6
|
+
<Card.content>
|
|
7
|
+
{{#each this.results as |result|}}
|
|
8
|
+
<ValidationPlugin::ValidationItem @controller={{@controller}} @result={{result}}/>
|
|
9
|
+
{{/each}}
|
|
10
|
+
</Card.content>
|
|
11
|
+
</AuCard>
|
|
12
|
+
{{/if}}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { SayController } from '@lblod/ember-rdfa-editor';
|
|
3
|
+
import { ValidationReport } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/validation';
|
|
4
|
+
|
|
5
|
+
interface Args {
|
|
6
|
+
report: ValidationReport;
|
|
7
|
+
controller?: SayController;
|
|
8
|
+
title: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default class ValidationCardComponent extends Component<Args> {
|
|
12
|
+
get shouldShow() {
|
|
13
|
+
return !this.args.report.conforms;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
get results() {
|
|
17
|
+
return this.args.report.results ?? [];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { SayController } from '@lblod/ember-rdfa-editor';
|
|
3
|
+
import { ValidationResult } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/validation';
|
|
4
|
+
import { inject as service } from '@ember/service';
|
|
5
|
+
import IntlService from 'ember-intl/services/intl';
|
|
6
|
+
|
|
7
|
+
interface Args {
|
|
8
|
+
icon?: string;
|
|
9
|
+
result: ValidationResult;
|
|
10
|
+
|
|
11
|
+
controller?: SayController;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default class ValidationItem extends Component<Args> {
|
|
15
|
+
@service
|
|
16
|
+
declare intl: IntlService;
|
|
17
|
+
|
|
18
|
+
get result(): ValidationResult {
|
|
19
|
+
return this.args.result;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
get message(): string {
|
|
23
|
+
return this.result.message;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
get skin() {
|
|
27
|
+
switch (this.result.severity) {
|
|
28
|
+
case 'info':
|
|
29
|
+
return 'info';
|
|
30
|
+
case 'warning':
|
|
31
|
+
return 'warning';
|
|
32
|
+
case 'violation':
|
|
33
|
+
return 'error';
|
|
34
|
+
default:
|
|
35
|
+
return 'info';
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
get icon() {
|
|
40
|
+
switch (this.result.severity) {
|
|
41
|
+
case 'info':
|
|
42
|
+
return 'info-circle';
|
|
43
|
+
case 'warning':
|
|
44
|
+
return 'alert-triangle';
|
|
45
|
+
case 'violation':
|
|
46
|
+
return 'cross';
|
|
47
|
+
default:
|
|
48
|
+
return 'info-circle';
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
get controller() {
|
|
53
|
+
return this.args.controller;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
2
|
import { tracked } from '@glimmer/tracking';
|
|
3
3
|
import { action } from '@ember/object';
|
|
4
|
-
import { getOwner } from '@ember/application';
|
|
5
4
|
import { task } from 'ember-concurrency';
|
|
6
5
|
import { SayController } from '@lblod/ember-rdfa-editor';
|
|
7
6
|
import {
|
|
@@ -13,9 +12,11 @@ import { findParentNodeOfType } from '@curvenote/prosemirror-utils';
|
|
|
13
12
|
import { NodeSelection, PNode, ProseParser } from '@lblod/ember-rdfa-editor';
|
|
14
13
|
import { ZONAL_URI } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/roadsign-regulation-plugin/utils/constants';
|
|
15
14
|
import { unwrap } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
|
|
15
|
+
import { TemplateVariablePluginOptions } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/variable-plugin';
|
|
16
16
|
|
|
17
17
|
type Args = {
|
|
18
18
|
controller: SayController;
|
|
19
|
+
options: TemplateVariablePluginOptions;
|
|
19
20
|
};
|
|
20
21
|
export default class EditorPluginsTemplateVariableCardComponent extends Component<Args> {
|
|
21
22
|
@tracked variableOptions: CodeListOption[] = [];
|
|
@@ -24,26 +25,6 @@ export default class EditorPluginsTemplateVariableCardComponent extends Componen
|
|
|
24
25
|
@tracked showCard = false;
|
|
25
26
|
@tracked multiSelect = false;
|
|
26
27
|
mappingUri?: string;
|
|
27
|
-
zonalLocationCodelistUri: string;
|
|
28
|
-
endpoint: string;
|
|
29
|
-
nonZonalLocationCodelistUri: string;
|
|
30
|
-
|
|
31
|
-
constructor(parent: unknown, args: Args) {
|
|
32
|
-
super(parent, args);
|
|
33
|
-
const config = getOwner(this)?.resolveRegistration(
|
|
34
|
-
'config:environment'
|
|
35
|
-
) as {
|
|
36
|
-
templateVariablePlugin: {
|
|
37
|
-
zonalLocationCodelistUri: string;
|
|
38
|
-
endpoint: string;
|
|
39
|
-
nonZonalLocationCodelistUri: string;
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
const pluginConfig = config.templateVariablePlugin;
|
|
43
|
-
this.zonalLocationCodelistUri = pluginConfig.zonalLocationCodelistUri;
|
|
44
|
-
this.endpoint = pluginConfig.endpoint;
|
|
45
|
-
this.nonZonalLocationCodelistUri = pluginConfig.nonZonalLocationCodelistUri;
|
|
46
|
-
}
|
|
47
28
|
|
|
48
29
|
get controller() {
|
|
49
30
|
return this.args.controller;
|
|
@@ -107,13 +88,15 @@ export default class EditorPluginsTemplateVariableCardComponent extends Componen
|
|
|
107
88
|
const type = variable.node.attrs.type as string;
|
|
108
89
|
if (type === 'codelist') {
|
|
109
90
|
const source =
|
|
110
|
-
(variable.node.attrs.source as string | undefined) ??
|
|
91
|
+
(variable.node.attrs.source as string | undefined) ??
|
|
92
|
+
this.args.options.endpoint;
|
|
111
93
|
const codelistURI = variable.node.attrs.codelistResource as string;
|
|
112
94
|
void this.fetchCodeListOptions.perform(source, codelistURI);
|
|
113
95
|
this.showCard = true;
|
|
114
96
|
} else if (type === 'location') {
|
|
115
97
|
const source =
|
|
116
|
-
(variable.node.attrs.source as string | undefined) ??
|
|
98
|
+
(variable.node.attrs.source as string | undefined) ??
|
|
99
|
+
this.args.options.endpoint;
|
|
117
100
|
const roadSignRegulation = findParentNodeOfType(
|
|
118
101
|
this.controller.schema.nodes.roadsign_regulation
|
|
119
102
|
)(selection);
|
|
@@ -123,13 +106,13 @@ export default class EditorPluginsTemplateVariableCardComponent extends Componen
|
|
|
123
106
|
if (zonalityUri === ZONAL_URI) {
|
|
124
107
|
void this.fetchCodeListOptions.perform(
|
|
125
108
|
source,
|
|
126
|
-
this.zonalLocationCodelistUri,
|
|
109
|
+
this.args.options.zonalLocationCodelistUri,
|
|
127
110
|
true
|
|
128
111
|
);
|
|
129
112
|
} else {
|
|
130
113
|
void this.fetchCodeListOptions.perform(
|
|
131
114
|
source,
|
|
132
|
-
this.nonZonalLocationCodelistUri,
|
|
115
|
+
this.args.options.nonZonalLocationCodelistUri,
|
|
133
116
|
true
|
|
134
117
|
);
|
|
135
118
|
}
|
|
@@ -9,11 +9,7 @@ export type BesluitType = {
|
|
|
9
9
|
};
|
|
10
10
|
export default async function fetchBesluitTypes(
|
|
11
11
|
classificationUri: string,
|
|
12
|
-
|
|
13
|
-
besluitTypePlugin: {
|
|
14
|
-
endpoint: string;
|
|
15
|
-
};
|
|
16
|
-
}
|
|
12
|
+
endpoint: string
|
|
17
13
|
) {
|
|
18
14
|
const query = `
|
|
19
15
|
PREFIX conceptscheme: <https://data.vlaanderen.be/id/conceptscheme/>
|
|
@@ -54,7 +50,6 @@ export default async function fetchBesluitTypes(
|
|
|
54
50
|
const typeFetcher = new SparqlEndpointFetcher({
|
|
55
51
|
method: 'POST',
|
|
56
52
|
});
|
|
57
|
-
const endpoint = ENV.besluitTypePlugin.endpoint;
|
|
58
53
|
const bindingStream = await typeFetcher.fetchBindings(endpoint, query);
|
|
59
54
|
const validBesluitTriples: IBindings[] = [];
|
|
60
55
|
bindingStream.on('data', (triple: IBindings) => {
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { default as insertTitle } from './insert-title';
|
|
2
|
+
export { default as insertArticleContainer } from './insert-article-container';
|
|
3
|
+
export { default as insertDescription } from './insert-description';
|
|
4
|
+
export { default as insertMotivation } from './insert-motivation';
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Command,
|
|
3
|
+
EditorState,
|
|
4
|
+
NodeSelection,
|
|
5
|
+
Transaction,
|
|
6
|
+
} from '@lblod/ember-rdfa-editor';
|
|
7
|
+
import { v4 as uuid } from 'uuid';
|
|
8
|
+
import { besluitArticleStructure } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/standard-template-plugin/utils/nodes';
|
|
9
|
+
import IntlService from 'ember-intl/services/intl';
|
|
10
|
+
import { isNone } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
|
|
11
|
+
import { transactionCompliesWithShapes } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/validation/utils/transaction-complies-with-shapes';
|
|
12
|
+
import { findInsertionPosInAncestorOfType } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/find-insertion-pos-in-ancestor-of-type';
|
|
13
|
+
|
|
14
|
+
interface InsertArticleContainerArgs {
|
|
15
|
+
intl: IntlService;
|
|
16
|
+
validateShapes?: Set<string>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default function insertArticleContainer({
|
|
20
|
+
intl,
|
|
21
|
+
validateShapes,
|
|
22
|
+
}: InsertArticleContainerArgs): Command {
|
|
23
|
+
return function (state: EditorState, dispatch?: (tr: Transaction) => void) {
|
|
24
|
+
const { selection, schema } = state;
|
|
25
|
+
const nodeToInsert = schema.node(
|
|
26
|
+
'article_container',
|
|
27
|
+
{
|
|
28
|
+
__rdfaId: uuid(),
|
|
29
|
+
},
|
|
30
|
+
besluitArticleStructure.constructor({
|
|
31
|
+
schema,
|
|
32
|
+
intl,
|
|
33
|
+
}).node
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const insertionPos = findInsertionPosInAncestorOfType(
|
|
37
|
+
selection,
|
|
38
|
+
schema.nodes.besluit,
|
|
39
|
+
nodeToInsert
|
|
40
|
+
);
|
|
41
|
+
if (isNone(insertionPos)) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
const tr = state.tr;
|
|
45
|
+
tr.replaceRangeWith(insertionPos, insertionPos, nodeToInsert);
|
|
46
|
+
|
|
47
|
+
if (!transactionCompliesWithShapes(state, tr, validateShapes)) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
if (dispatch) {
|
|
51
|
+
tr.setSelection(NodeSelection.create(tr.doc, insertionPos + 4));
|
|
52
|
+
dispatch(tr.scrollIntoView());
|
|
53
|
+
}
|
|
54
|
+
return true;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EditorState,
|
|
3
|
+
NodeSelection,
|
|
4
|
+
Transaction,
|
|
5
|
+
} from '@lblod/ember-rdfa-editor';
|
|
6
|
+
import { v4 as uuid } from 'uuid';
|
|
7
|
+
import { isNone } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
|
|
8
|
+
import { transactionCompliesWithShapes } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/validation/utils/transaction-complies-with-shapes';
|
|
9
|
+
import { findInsertionPosInAncestorOfType } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/find-insertion-pos-in-ancestor-of-type';
|
|
10
|
+
|
|
11
|
+
interface InsertDescriptionArgs {
|
|
12
|
+
placeholderText: string;
|
|
13
|
+
validateShapes?: Set<string>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default function insertDescription({
|
|
17
|
+
placeholderText,
|
|
18
|
+
validateShapes,
|
|
19
|
+
}: InsertDescriptionArgs) {
|
|
20
|
+
return function (state: EditorState, dispatch?: (tr: Transaction) => void) {
|
|
21
|
+
const { selection, schema } = state;
|
|
22
|
+
const nodeToInsert = schema.node(
|
|
23
|
+
'description',
|
|
24
|
+
{ __rdfaId: uuid() },
|
|
25
|
+
schema.node(
|
|
26
|
+
'paragraph',
|
|
27
|
+
null,
|
|
28
|
+
schema.node('placeholder', {
|
|
29
|
+
placeholderText,
|
|
30
|
+
})
|
|
31
|
+
)
|
|
32
|
+
);
|
|
33
|
+
const insertionPos = findInsertionPosInAncestorOfType(
|
|
34
|
+
selection,
|
|
35
|
+
schema.nodes.besluit,
|
|
36
|
+
nodeToInsert
|
|
37
|
+
);
|
|
38
|
+
if (isNone(insertionPos)) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
const tr = state.tr;
|
|
42
|
+
|
|
43
|
+
tr.replaceRangeWith(insertionPos, insertionPos, nodeToInsert);
|
|
44
|
+
if (!transactionCompliesWithShapes(state, tr, validateShapes)) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
if (dispatch) {
|
|
48
|
+
tr.setSelection(NodeSelection.create(tr.doc, insertionPos + 2));
|
|
49
|
+
dispatch(tr.scrollIntoView());
|
|
50
|
+
}
|
|
51
|
+
return true;
|
|
52
|
+
};
|
|
53
|
+
}
|