@lblod/ember-rdfa-editor-lblod-plugins 28.1.0 → 28.2.0-dev.85da5ade4142e66d8c5423cd25ed0d291f1c2bad

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.
Files changed (36) hide show
  1. package/.changeset/hot-hats-wink.md +5 -0
  2. package/.changeset/selfish-singers-tan.md +5 -0
  3. package/.changeset/shiny-panthers-live.md +5 -0
  4. package/CHANGELOG.md +10 -0
  5. package/addon/components/besluit-type-plugin/besluit-type-form.gts +68 -0
  6. package/addon/components/besluit-type-plugin/besluit-type-select.gts +80 -0
  7. package/addon/components/besluit-type-plugin/toolbar-dropdown.gts +191 -0
  8. package/addon/components/location-plugin/map.gts +46 -3
  9. package/addon/plugins/besluit-type-plugin/utils/besluit-type-instances.ts +100 -0
  10. package/addon/plugins/besluit-type-plugin/utils/set-besluit-type.ts +57 -0
  11. package/addon/plugins/lpdc-plugin/index.ts +1 -1
  12. package/app/components/{location-plugin/insert-variable.js → besluit-type-plugin/besluit-type-form.js} +1 -1
  13. package/app/styles/location-plugin.scss +5 -0
  14. package/declarations/addon/components/besluit-type-plugin/besluit-type-form.d.ts +17 -0
  15. package/declarations/addon/components/besluit-type-plugin/besluit-type-select.d.ts +15 -8
  16. package/declarations/addon/components/besluit-type-plugin/toolbar-dropdown.d.ts +8 -28
  17. package/declarations/addon/plugins/besluit-type-plugin/utils/besluit-type-instances.d.ts +18 -0
  18. package/declarations/addon/plugins/besluit-type-plugin/utils/set-besluit-type.d.ts +4 -0
  19. package/declarations/addon/plugins/lpdc-plugin/index.d.ts +1 -1
  20. package/index.js +0 -4
  21. package/package.json +8 -3
  22. package/pnpm-lock.yaml +1543 -142
  23. package/translations/en-US.yaml +1 -0
  24. package/translations/nl-BE.yaml +1 -0
  25. package/types/ember-leaflet.d.ts +1 -0
  26. package/addon/components/besluit-type-plugin/besluit-type-select.hbs +0 -32
  27. package/addon/components/besluit-type-plugin/besluit-type-select.ts +0 -29
  28. package/addon/components/besluit-type-plugin/toolbar-dropdown.hbs +0 -102
  29. package/addon/components/besluit-type-plugin/toolbar-dropdown.ts +0 -223
  30. package/app/components/variable-plugin/autofilled/nodeview.js +0 -1
  31. package/app/components/variable-plugin/location/nodeview.js +0 -1
  32. package/app/models/instruction.js +0 -1
  33. package/app/models/measure.js +0 -1
  34. package/app/models/sign.js +0 -1
  35. package/app/services/roadsign-registry.js +0 -1
  36. package/webpack-config.js +0 -22
@@ -0,0 +1,5 @@
1
+ ---
2
+ '@lblod/ember-rdfa-editor-lblod-plugins': patch
3
+ ---
4
+
5
+ Bundle location plugin marker icons to avoid issues when bundling the code for embeddable
@@ -0,0 +1,5 @@
1
+ ---
2
+ '@lblod/ember-rdfa-editor-lblod-plugins': major
3
+ ---
4
+
5
+ Remove obsolete `webpack-config.js`. This config is solely needed for the tests, and is now inlined in the `ember-cli-build` file of the test-app
@@ -0,0 +1,5 @@
1
+ ---
2
+ '@lblod/ember-rdfa-editor-lblod-plugins': patch
3
+ ---
4
+
5
+ Update `ember-template-imports` to version 4.3.0 . This version unlocks `.gts`/`.gjs` sourcemaps.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @lblod/ember-rdfa-editor-lblod-plugins
2
2
 
3
+ ## 28.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#553](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/553) [`50831e0`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/50831e01cfa5d8101c72e8cc3d98b304a8b86646) Thanks [@piemonkey](https://github.com/piemonkey)! - Add re-usable component for selecting a decision type
8
+
9
+ ### Patch Changes
10
+
11
+ - [#553](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/553) [`03f4ce0`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/03f4ce0864550cfc947f8ff7504aeac8b0300ae9) Thanks [@piemonkey](https://github.com/piemonkey)! - Fix undo behaviour when changing decision type
12
+
3
13
  ## 28.1.0
4
14
 
5
15
  ### Minor Changes
@@ -0,0 +1,68 @@
1
+ import Component from '@glimmer/component';
2
+ import { type BesluitType } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-type-plugin/utils/fetchBesluitTypes';
3
+ import BesluitTypeSelect from '@lblod/ember-rdfa-editor-lblod-plugins/components/besluit-type-plugin/besluit-type-select';
4
+ import { type BesluitTypeInstance } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-type-plugin/utils/besluit-type-instances';
5
+
6
+ interface Sig {
7
+ Args: {
8
+ types: BesluitType[];
9
+ selectedType?: BesluitTypeInstance;
10
+ setType: (selected: BesluitTypeInstance) => void;
11
+ };
12
+ Element: HTMLDivElement;
13
+ }
14
+
15
+ export default class BesluitTypePluginBesluitTypeSelectComponent extends Component<Sig> {
16
+ updateParentType = (selected: BesluitType) => {
17
+ this.args.setType({ parent: selected });
18
+ };
19
+
20
+ updateSubType = (selected: BesluitType) => {
21
+ if (this.args.selectedType) {
22
+ this.args.setType({
23
+ parent: this.args.selectedType.parent,
24
+ subType: selected,
25
+ });
26
+ }
27
+ };
28
+
29
+ updateSubSubType = (selected: BesluitType) => {
30
+ if (this.args.selectedType) {
31
+ this.args.setType({
32
+ parent: this.args.selectedType.parent,
33
+ subType: this.args.selectedType.subType,
34
+ subSubType: selected,
35
+ });
36
+ }
37
+ };
38
+
39
+ <template>
40
+ <div ...attributes>
41
+ <BesluitTypeSelect
42
+ @fieldNameTranslation='besluit-type-plugin.dt'
43
+ @besluitTypes={{@types}}
44
+ @onchange={{this.updateParentType}}
45
+ @selected={{@selectedType.parent}}
46
+ @showWarningWhenEmpty={{false}}
47
+ />
48
+ {{#if @selectedType.parent.subTypes.length}}
49
+ <BesluitTypeSelect
50
+ @fieldNameTranslation='besluit-type-plugin.sub-type'
51
+ @besluitTypes={{@selectedType.parent.subTypes}}
52
+ @onchange={{this.updateSubType}}
53
+ @selected={{@selectedType.subType}}
54
+ @showWarningWhenEmpty={{true}}
55
+ />
56
+ {{/if}}
57
+ {{#if @selectedType.subType.subTypes.length}}
58
+ <BesluitTypeSelect
59
+ @fieldNameTranslation='besluit-type-plugin.sub-type'
60
+ @besluitTypes={{@selectedType.subType.subTypes}}
61
+ @onchange={{this.updateSubSubType}}
62
+ @selected={{@selectedType.subSubType}}
63
+ @showWarningWhenEmpty={{true}}
64
+ />
65
+ {{/if}}
66
+ </div>
67
+ </template>
68
+ }
@@ -0,0 +1,80 @@
1
+ import Component from '@glimmer/component';
2
+ import { tracked } from '@glimmer/tracking';
3
+ import t from 'ember-intl/helpers/t';
4
+ import PowerSelect from 'ember-power-select/components/power-select';
5
+ import { v4 as uuidv4 } from 'uuid';
6
+ import AuAlert from '@appuniversum/ember-appuniversum/components/au-alert';
7
+ import AuLabel from '@appuniversum/ember-appuniversum/components/au-label';
8
+ import { AlertTriangleIcon } from '@appuniversum/ember-appuniversum/components/icons/alert-triangle';
9
+ import { type BesluitType } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-type-plugin/utils/fetchBesluitTypes';
10
+
11
+ interface Sig {
12
+ Args: {
13
+ fieldNameTranslation: string;
14
+ besluitTypes: BesluitType[];
15
+ selected?: BesluitType;
16
+ showWarningWhenEmpty: boolean;
17
+ onchange: (selected: BesluitType) => void;
18
+ };
19
+ Element: HTMLDivElement;
20
+ }
21
+
22
+ export default class BesluitTypePluginBesluitTypeSelectComponent extends Component<Sig> {
23
+ @tracked besluitTypes;
24
+
25
+ constructor(parent: unknown, args: Sig['Args']) {
26
+ super(parent, args);
27
+ this.besluitTypes = this.args.besluitTypes.sort((a, b) =>
28
+ a.label > b.label ? 1 : -1,
29
+ );
30
+ }
31
+
32
+ get showWarning() {
33
+ return this.args.showWarningWhenEmpty && !this.args.selected;
34
+ }
35
+
36
+ search = (term: string) => {
37
+ const lowerTerm = term.toLowerCase();
38
+ return this.args.besluitTypes.filter((besluitType) =>
39
+ besluitType.label.toLowerCase().includes(lowerTerm),
40
+ );
41
+ };
42
+
43
+ <template>
44
+ <div ...attributes>
45
+ {{#let (uuidv4) as |id|}}
46
+ <AuLabel for={{id}}>
47
+ {{t @fieldNameTranslation}}
48
+ </AuLabel>
49
+ <PowerSelect
50
+ id={{id}}
51
+ @renderInPlace={{true}}
52
+ @searchEnabled={{true}}
53
+ @searchMessage={{t 'besluit-type-plugin.search-message'}}
54
+ @noMatchesMessage={{t 'besluit-type-plugin.no-matches-message'}}
55
+ @search={{this.search}}
56
+ @options={{this.besluitTypes}}
57
+ @selected={{@selected}}
58
+ @onChange={{@onchange}}
59
+ as |besluitType|
60
+ >
61
+ {{besluitType.label}}
62
+ </PowerSelect>
63
+ {{/let}}
64
+ <p class='au-u-muted au-u-margin-tiny au-u-margin-bottom-small'>
65
+ {{@selected.definition}}
66
+ </p>
67
+ {{#if this.showWarning}}
68
+ <AuAlert
69
+ @icon={{AlertTriangleIcon}}
70
+ @title={{t 'besluit-type-plugin.alert-title'}}
71
+ @skin='warning'
72
+ @size='small'
73
+ class='au-u-margin-bottom-none au-u-margin-top-small'
74
+ >
75
+ <p>{{t 'besluit-type-plugin.alert-body'}}</p>
76
+ </AuAlert>
77
+ {{/if}}
78
+ </div>
79
+ </template>
80
+ }
@@ -0,0 +1,191 @@
1
+ import { tracked } from '@glimmer/tracking';
2
+ import Component from '@glimmer/component';
3
+ import { on } from '@ember/modifier';
4
+ // eslint-disable-next-line ember/no-at-ember-render-modifiers
5
+ import didUpdate from '@ember/render-modifiers/modifiers/did-update';
6
+ import { trackedFunction } from 'reactiveweb/function';
7
+ import t from 'ember-intl/helpers/t';
8
+ import AuPill from '@appuniversum/ember-appuniversum/components/au-pill';
9
+ import AuModal from '@appuniversum/ember-appuniversum/components/au-modal';
10
+ import AuLinkExternal from '@appuniversum/ember-appuniversum/components/au-link-external';
11
+ import AuAlert from '@appuniversum/ember-appuniversum/components/au-alert';
12
+ import { AlertTriangleIcon } from '@appuniversum/ember-appuniversum/components/icons/alert-triangle';
13
+ import { CrossIcon } from '@appuniversum/ember-appuniversum/components/icons/cross';
14
+ import { MailIcon } from '@appuniversum/ember-appuniversum/components/icons/mail';
15
+ import { CircleXIcon } from '@appuniversum/ember-appuniversum/components/icons/circle-x';
16
+ import { SayController } from '@lblod/ember-rdfa-editor';
17
+ import fetchBesluitTypes from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-type-plugin/utils/fetchBesluitTypes';
18
+ import { BesluitTypePluginOptions } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-type-plugin';
19
+ import { getCurrentBesluitRange } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-topic-plugin/utils/helpers';
20
+ import {
21
+ BesluitTypeInstance,
22
+ checkBesluitTypeInstance,
23
+ mostSpecificBesluitType,
24
+ } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-type-plugin/utils/besluit-type-instances';
25
+ import BesluitTypeForm from '@lblod/ember-rdfa-editor-lblod-plugins/components/besluit-type-plugin/besluit-type-form';
26
+ import { setBesluitType } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-type-plugin/utils/set-besluit-type';
27
+
28
+ type Args = {
29
+ controller: SayController;
30
+ options: BesluitTypePluginOptions;
31
+ };
32
+
33
+ export default class EditorPluginsToolbarDropdownComponent extends Component<Args> {
34
+ @tracked selectedTypeInstance?: BesluitTypeInstance;
35
+ @tracked cardExpanded = false;
36
+
37
+ get controller() {
38
+ return this.args.controller;
39
+ }
40
+
41
+ types = trackedFunction(this, async () => {
42
+ const types = await fetchBesluitTypes(
43
+ this.args.options.classificatieUri,
44
+ this.args.options.endpoint,
45
+ );
46
+ return types;
47
+ });
48
+
49
+ get currentBesluitRange() {
50
+ return getCurrentBesluitRange(this.controller);
51
+ }
52
+
53
+ get showCard() {
54
+ return !!this.currentBesluitRange;
55
+ }
56
+
57
+ get selectedType() {
58
+ return (
59
+ this.selectedTypeInstance &&
60
+ mostSpecificBesluitType(this.selectedTypeInstance)
61
+ );
62
+ }
63
+
64
+ toggleCard = () => {
65
+ this.cardExpanded = !this.cardExpanded;
66
+ };
67
+
68
+ setType = (type: BesluitTypeInstance) => {
69
+ this.selectedTypeInstance = type;
70
+ this.insertIfValid();
71
+ };
72
+
73
+ updateBesluitTypes = () => {
74
+ if (!this.types.isFinished || !this.currentBesluitRange) {
75
+ return;
76
+ }
77
+ if (!this.types.value) {
78
+ console.warn('Request for besluit types failed');
79
+ return;
80
+ }
81
+ const typeInstance = checkBesluitTypeInstance(
82
+ this.controller.mainEditorState,
83
+ this.types.value,
84
+ );
85
+ if (typeInstance) {
86
+ this.selectedTypeInstance = typeInstance;
87
+ this.cardExpanded = false;
88
+ } else {
89
+ this.cardExpanded = true;
90
+ }
91
+ };
92
+
93
+ insertIfValid() {
94
+ this.controller.doCommand((state, dispatch) => {
95
+ if (!this.selectedTypeInstance || !dispatch) {
96
+ return false;
97
+ }
98
+ const { result, transaction } = setBesluitType(
99
+ state,
100
+ this.selectedTypeInstance,
101
+ );
102
+ if (result.every((ok) => ok)) {
103
+ dispatch(transaction);
104
+ return true;
105
+ }
106
+ return false;
107
+ });
108
+ }
109
+
110
+ <template>
111
+ <div
112
+ {{didUpdate this.updateBesluitTypes @controller.mainEditorState}}
113
+ {{didUpdate this.updateBesluitTypes this.types.value}}
114
+ >
115
+ {{#if this.showCard}}
116
+ {{#if this.types.isError}}
117
+ <AuPill
118
+ @skin='error'
119
+ @icon={{CircleXIcon}}
120
+ @iconAlignment='left'
121
+ class='au-c-pill--link besluit-toolbar-pill'
122
+ {{on 'click' this.toggleCard}}
123
+ title={{t 'besluit-type-plugin.insert-dt'}}
124
+ >
125
+ {{t 'besluit-type-plugin.error-short'}}
126
+ </AuPill>
127
+ {{else}}
128
+ {{#if this.selectedType.label}}
129
+ <AuPill
130
+ @skin='link'
131
+ {{on 'click' this.toggleCard}}
132
+ title={{t 'besluit-type-plugin.insert-dt'}}
133
+ >
134
+ {{t 'besluit-type-plugin.dt'}}:
135
+ {{this.selectedType.label}}
136
+ </AuPill>
137
+ {{else}}
138
+ <AuPill
139
+ @icon={{AlertTriangleIcon}}
140
+ @iconAlignment='left'
141
+ @skin='link'
142
+ {{on 'click' this.toggleCard}}
143
+ title={{t 'besluit-type-plugin.insert-dt'}}
144
+ >
145
+ {{t 'besluit-type-plugin.insert-dt'}}
146
+ </AuPill>
147
+ {{/if}}
148
+ {{/if}}
149
+ {{/if}}
150
+ {{#if this.cardExpanded}}
151
+ <AuModal
152
+ @title={{t 'besluit-type-plugin.insert-dt'}}
153
+ @closeModal={{this.toggleCard}}
154
+ @modalOpen={{true}}
155
+ class='au-c-modal--overflow'
156
+ as |Modal|
157
+ >
158
+ <Modal.Body>
159
+ {{#if this.types.isError}}
160
+ <AuAlert
161
+ @title={{t 'besluit-type-plugin.error-title'}}
162
+ @skin='error'
163
+ @icon={{CrossIcon}}
164
+ >
165
+ <p>
166
+ {{t 'besluit-type-plugin.error-first-body'}}
167
+ {{! template-lint-disable no-bare-strings }}
168
+ <AuLinkExternal
169
+ href='mailto:gelinktnotuleren@vlaanderen.be'
170
+ @icon={{MailIcon}}
171
+ @iconAlignment='left'
172
+ >
173
+ GelinktNotuleren@vlaanderen.be
174
+ </AuLinkExternal>
175
+ {{! template-lint-enable no-bare-strings }}
176
+ {{t 'besluit-type-plugin.error-rest-body'}}
177
+ </p>
178
+ </AuAlert>
179
+ {{else if this.types.value}}
180
+ <BesluitTypeForm
181
+ @types={{this.types.value}}
182
+ @selectedType={{this.selectedTypeInstance}}
183
+ @setType={{this.setType}}
184
+ />
185
+ {{/if}}
186
+ </Modal.Body>
187
+ </AuModal>
188
+ {{/if}}
189
+ </div>
190
+ </template>
191
+ }
@@ -6,6 +6,7 @@ import and from 'ember-truth-helpers/helpers/and';
6
6
  import eq from 'ember-truth-helpers/helpers/eq';
7
7
  import t from 'ember-intl/helpers/t';
8
8
  import {
9
+ Leaflet,
9
10
  LeafletMap,
10
11
  type LeafletMapSig,
11
12
  type LeafletMapStart,
@@ -20,6 +21,38 @@ import {
20
21
  type GlobalCoordinates,
21
22
  } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/location-plugin/utils/geo-helpers';
22
23
 
24
+ // Taken from Leaflet's default icon, with the viewbox tweaked (from 0 0 500 820), so that the icon
25
+ // is a whole number of pixels in size, to make positioning the point easy.
26
+ const ICON_HTML = `<svg viewBox="0 0 500 800" version="1.1" xmlns="http://www.w3.org/2000/svg" xml:space="preserve"
27
+ style="fill-rule: evenodd; clip-rule: evenodd; stroke-linecap: round;">
28
+ <defs>
29
+ <linearGradient x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(2.30025e-15,-37.566,37.566,2.30025e-15,416.455,540.999)" id="map-marker-38-f">
30
+ <stop offset="0" stop-color="rgb(18,111,198)"/>
31
+ <stop offset="1" stop-color="rgb(76,156,209)"/>
32
+ </linearGradient>
33
+ <linearGradient x1="0" y1="0" x2="1" y2="0"
34
+ gradientUnits="userSpaceOnUse"
35
+ gradientTransform="matrix(1.16666e-15,-19.053,19.053,1.16666e-15,414.482,522.486)"
36
+ id="map-marker-38-s">
37
+ <stop offset="0" stop-color="rgb(46,108,151)"/>
38
+ <stop offset="1" stop-color="rgb(56,131,183)"/>
39
+ </linearGradient>
40
+ </defs>
41
+ <g transform="matrix(19.5417,0,0,19.5417,-7889.1,-9807.44)">
42
+ <path fill="#FFFFFF" d="M421.2,515.5c0,2.6-2.1,4.7-4.7,4.7c-2.6,0-4.7-2.1-4.7-4.7c0-2.6,2.1-4.7,4.7-4.7 C419.1,510.8,421.2,512.9,421.2,515.5z"/>
43
+ <path d="M416.544,503.612C409.971,503.612 404.5,509.303 404.5,515.478C404.5,518.256 406.064,521.786 407.194,524.224L416.5,542.096L425.762,524.224C426.892,521.786 428.5,518.433 428.5,515.478C428.5,509.303 423.117,503.612 416.544,503.612ZM416.544,510.767C419.128,510.784 421.223,512.889 421.223,515.477C421.223,518.065 419.128,520.14 416.544,520.156C413.96,520.139 411.865,518.066 411.865,515.477C411.865,512.889 413.96,510.784 416.544,510.767Z" stroke-width="1.1px" fill="url(#map-marker-38-f)" stroke="url(#map-marker-38-s)"/>
44
+ </g>
45
+ </svg>`;
46
+ // We use Leaflet.divIcon directly, as passing arguments to the ember-leaflet helper seems to be
47
+ // broken
48
+ const MARKER_ICON = Leaflet.divIcon({
49
+ html: ICON_HTML,
50
+ // This prevents the default class from being applied, along with the default styling
51
+ className: '',
52
+ iconAnchor: [15, 48],
53
+ iconSize: [30, 48],
54
+ });
55
+
23
56
  export const SUPPORTED_LOCATION_TYPES = ['address', 'place', 'area'] as const;
24
57
  export type LocationType = (typeof SUPPORTED_LOCATION_TYPES)[number];
25
58
 
@@ -248,7 +281,11 @@ export default class LocationPluginMapComponent extends Component<Signature> {
248
281
  }
249
282
 
250
283
  <template>
251
- <div class='map-wrapper' ...attributes>
284
+ <div
285
+ class='map-wrapper
286
+ {{unless (eq @locationType "address") "map-cursor-pointer"}}'
287
+ ...attributes
288
+ >
252
289
  <MapWrapper
253
290
  @mapStart={{this.mapLocation}}
254
291
  @onClick={{this.onMapClick}}
@@ -259,7 +296,11 @@ export default class LocationPluginMapComponent extends Component<Signature> {
259
296
  @attribution={{MAP_TILE_ATTRIBUTION}}
260
297
  />
261
298
  {{#if (and @address (eq @locationType 'address') this.foundAddress)}}
262
- <layers.marker @location={{this.foundAddress}} as |marker|>
299
+ <layers.marker
300
+ @location={{this.foundAddress}}
301
+ @icon={{MARKER_ICON}}
302
+ as |marker|
303
+ >
263
304
  <marker.tooltip>
264
305
  {{@address.formatted}}
265
306
  </marker.tooltip>
@@ -269,6 +310,7 @@ export default class LocationPluginMapComponent extends Component<Signature> {
269
310
  <layers.marker
270
311
  @opacity={{if @location 0.3 1}}
271
312
  @location={{this.existingLocationCoords}}
313
+ @icon={{MARKER_ICON}}
272
314
  as |marker|
273
315
  >
274
316
  <marker.tooltip>
@@ -277,7 +319,7 @@ export default class LocationPluginMapComponent extends Component<Signature> {
277
319
  </layers.marker>
278
320
  {{/if}}
279
321
  {{#if (and @location (eq @locationType 'place'))}}
280
- <layers.marker @location={{@location.global}} />
322
+ <layers.marker @location={{@location.global}} @icon={{MARKER_ICON}} />
281
323
  {{/if}}
282
324
  {{#if (eq @locationType 'area')}}
283
325
  <layers.polyline @locations={{this.vertices}} />
@@ -285,6 +327,7 @@ export default class LocationPluginMapComponent extends Component<Signature> {
285
327
  <layers.marker
286
328
  @location={{vertex}}
287
329
  @onClick={{fn this.onVertexClick index}}
330
+ @icon={{MARKER_ICON}}
288
331
  as |marker|
289
332
  >
290
333
  {{#if (eq index 0)}}
@@ -0,0 +1,100 @@
1
+ import { type EditorState } from '@lblod/ember-rdfa-editor';
2
+ import { getOutgoingTripleList } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
3
+ import { getCurrentBesluitRange } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-topic-plugin/utils/helpers';
4
+ import { RDF } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
5
+ import { type BesluitType } from './fetchBesluitTypes';
6
+ import { type NamedNodeTriple } from '@lblod/ember-rdfa-editor/core/rdfa-processor';
7
+
8
+ export interface BesluitTypeInstance {
9
+ parent: BesluitType;
10
+ subType?: BesluitType;
11
+ subSubType?: BesluitType;
12
+ }
13
+
14
+ export function extractBesluitTypeUris(editorState: EditorState): string[] {
15
+ const besluitRange = getCurrentBesluitRange(editorState);
16
+ if (!besluitRange) {
17
+ return [];
18
+ }
19
+ return getOutgoingTripleList(besluitRange.node.attrs, RDF('type'))
20
+ .filter(
21
+ (type) =>
22
+ type.object.termType === 'NamedNode' &&
23
+ type.object.value.includes(
24
+ 'https://data.vlaanderen.be/id/concept/BesluitType/',
25
+ ),
26
+ )
27
+ .map((type: NamedNodeTriple) => type?.object.value);
28
+ }
29
+
30
+ /**
31
+ * Finds a decision type in the document and checks that it represents a valid decision type
32
+ * according to the list of types passed in.
33
+ */
34
+ export function checkBesluitTypeInstance(
35
+ editorState: EditorState,
36
+ types: BesluitType[],
37
+ ): BesluitTypeInstance | false {
38
+ const besluitTypes = extractBesluitTypeUris(editorState);
39
+
40
+ if (besluitTypes.length === 0) {
41
+ return false;
42
+ } else if (besluitTypes.length !== 1) {
43
+ console.warn(
44
+ "More than one decision type found for document, we don't support this and will just take the first one",
45
+ besluitTypes,
46
+ );
47
+ }
48
+ const typeHierarchy = findBesluitTypeHierarchy(types, besluitTypes[0]);
49
+
50
+ return (
51
+ !!typeHierarchy && {
52
+ parent: typeHierarchy[0],
53
+ subType: typeHierarchy[1],
54
+ subSubType: typeHierarchy[2],
55
+ }
56
+ );
57
+ }
58
+
59
+ function findBesluitTypeHierarchy(
60
+ types: BesluitType[],
61
+ uri: string,
62
+ ): BesluitType[] | undefined {
63
+ for (const type of types) {
64
+ if (type.uri === uri) {
65
+ return [type];
66
+ } else if (type.subTypes?.length) {
67
+ const subTypes = findBesluitTypeHierarchy(type.subTypes, uri);
68
+ if (subTypes) {
69
+ return [type, ...subTypes];
70
+ }
71
+ }
72
+ }
73
+ return;
74
+ }
75
+
76
+ /**
77
+ * Checks that the passed type instance has all of the necessary sub-types selected (and no more)
78
+ */
79
+ export function isValidTypeChoice({
80
+ parent,
81
+ subType,
82
+ subSubType,
83
+ }: BesluitTypeInstance) {
84
+ if (!parent.subTypes || parent.subTypes.length === 0) {
85
+ return !subType && !subSubType;
86
+ }
87
+ if (!subType) {
88
+ return false;
89
+ }
90
+ if (!subType.subTypes || subType.subTypes.length === 0) {
91
+ return !subSubType;
92
+ }
93
+ return !!subSubType;
94
+ }
95
+
96
+ export function mostSpecificBesluitType(
97
+ typeInstance: BesluitTypeInstance,
98
+ ): BesluitType {
99
+ return typeInstance.subSubType ?? typeInstance.subType ?? typeInstance.parent;
100
+ }
@@ -0,0 +1,57 @@
1
+ import { type EditorState } from '@lblod/ember-rdfa-editor';
2
+ import {
3
+ transactionCombinator,
4
+ type TransactionCombinatorResult,
5
+ } from '@lblod/ember-rdfa-editor/utils/transaction-utils';
6
+ import {
7
+ addPropertyToNode,
8
+ removePropertyFromNode,
9
+ } from '@lblod/ember-rdfa-editor/utils/rdfa-utils';
10
+ import { sayDataFactory } from '@lblod/ember-rdfa-editor/core/say-data-factory';
11
+ import { getCurrentBesluitURI } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-topic-plugin/utils/helpers';
12
+ import {
13
+ extractBesluitTypeUris,
14
+ isValidTypeChoice,
15
+ mostSpecificBesluitType,
16
+ type BesluitTypeInstance,
17
+ } from './besluit-type-instances';
18
+ import { RDF } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
19
+
20
+ export function setBesluitType(
21
+ initialState: EditorState,
22
+ typeInstance: BesluitTypeInstance,
23
+ ): TransactionCombinatorResult<boolean> {
24
+ const transaction = initialState.tr;
25
+
26
+ const resource = getCurrentBesluitURI(initialState);
27
+ if (!resource || !isValidTypeChoice(typeInstance)) {
28
+ return {
29
+ result: [false],
30
+ initialState,
31
+ transaction,
32
+ transactions: [transaction],
33
+ };
34
+ }
35
+ const existingTypeUris = extractBesluitTypeUris(initialState);
36
+ const monads = existingTypeUris.map((existingUri) => {
37
+ return removePropertyFromNode({
38
+ resource,
39
+ property: {
40
+ predicate: RDF('type').full,
41
+ object: sayDataFactory.namedNode(existingUri),
42
+ },
43
+ });
44
+ });
45
+ monads.push(
46
+ addPropertyToNode({
47
+ resource,
48
+ property: {
49
+ predicate: RDF('type').full,
50
+ object: sayDataFactory.namedNode(
51
+ mostSpecificBesluitType(typeInstance).uri,
52
+ ),
53
+ },
54
+ }),
55
+ );
56
+ return transactionCombinator<boolean>(initialState)(monads);
57
+ }
@@ -1,2 +1,2 @@
1
- export { type LpdcPluginConfig, LPDC } from './types';
1
+ export type { LpdcPluginConfig, LPDC } from './types';
2
2
  export { fetchLpdcs } from './api';
@@ -1 +1 @@
1
- export { default } from '@lblod/ember-rdfa-editor-lblod-plugins/components/location-plugin/insert-variable';
1
+ export { default } from '@lblod/ember-rdfa-editor-lblod-plugins/components/besluit-type-plugin/besluit-type-form';
@@ -21,6 +21,11 @@
21
21
  height: 100%;
22
22
  }
23
23
 
24
+ // Override the 'grab' cursor to 'pointer' so we can accurately pick points
25
+ .map-cursor-pointer > .leaflet-grab {
26
+ cursor: pointer;
27
+ }
28
+
24
29
  .leaflet-container {
25
30
  height: 100%;
26
31
  }
@@ -0,0 +1,17 @@
1
+ import Component from '@glimmer/component';
2
+ import { type BesluitType } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-type-plugin/utils/fetchBesluitTypes';
3
+ import { type BesluitTypeInstance } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-type-plugin/utils/besluit-type-instances';
4
+ interface Sig {
5
+ Args: {
6
+ types: BesluitType[];
7
+ selectedType?: BesluitTypeInstance;
8
+ setType: (selected: BesluitTypeInstance) => void;
9
+ };
10
+ Element: HTMLDivElement;
11
+ }
12
+ export default class BesluitTypePluginBesluitTypeSelectComponent extends Component<Sig> {
13
+ updateParentType: (selected: BesluitType) => void;
14
+ updateSubType: (selected: BesluitType) => void;
15
+ updateSubSubType: (selected: BesluitType) => void;
16
+ }
17
+ export {};