@lblod/ember-rdfa-editor-lblod-plugins 19.0.0 → 19.1.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.
Files changed (92) hide show
  1. package/.release-it.json +1 -1
  2. package/.woodpecker/.verify-pr.yml +6 -0
  3. package/CHANGELOG.md +10 -0
  4. package/README.md +21 -0
  5. package/addon/components/article-structure-plugin/article-structure-card.hbs +11 -6
  6. package/addon/components/article-structure-plugin/structure-card.hbs +50 -39
  7. package/addon/components/besluit-topic-plugin/besluit-topic-select.hbs +19 -0
  8. package/addon/components/besluit-topic-plugin/besluit-topic-select.ts +32 -0
  9. package/addon/components/besluit-topic-plugin/besluit-topic-toolbar-dropdown.hbs +93 -0
  10. package/addon/components/besluit-topic-plugin/besluit-topic-toolbar-dropdown.ts +151 -0
  11. package/addon/components/besluit-type-plugin/besluit-type-select.hbs +11 -8
  12. package/addon/components/citation-plugin/citation-card.hbs +1 -4
  13. package/addon/components/citation-plugin/citation-insert.hbs +1 -1
  14. package/addon/components/citation-plugin/citations/article-list.hbs +7 -3
  15. package/addon/components/citation-plugin/citations/article-preview.hbs +12 -8
  16. package/addon/components/citation-plugin/citations/legal-document-detail.hbs +75 -53
  17. package/addon/components/citation-plugin/citations/legal-document-list.hbs +8 -4
  18. package/addon/components/citation-plugin/citations/legal-document-preview.hbs +51 -41
  19. package/addon/components/citation-plugin/citations/search-modal.hbs +1 -1
  20. package/addon/components/confidentiality-plugin/toolbar.hbs +1 -1
  21. package/addon/components/decision-plugin/decision-plugin-card.hbs +42 -12
  22. package/addon/components/document-title-plugin/insert-title-card.hbs +4 -4
  23. package/addon/components/hover-tooltip.hbs +4 -1
  24. package/addon/components/import-snippet-plugin/card.hbs +25 -11
  25. package/addon/components/loading-alert.hbs +12 -12
  26. package/addon/components/roadsign-regulation-plugin/expanded-measure.hbs +37 -22
  27. package/addon/components/roadsign-regulation-plugin/measure-template.hbs +1 -1
  28. package/addon/components/roadsign-regulation-plugin/roadsign-regulation-card.hbs +11 -6
  29. package/addon/components/roadsign-regulation-plugin/roadsigns-modal.hbs +34 -26
  30. package/addon/components/roadsign-regulation-plugin/roadsigns-pagination.hbs +28 -11
  31. package/addon/components/roadsign-regulation-plugin/roadsigns-table.hbs +83 -55
  32. package/addon/components/snippet-plugin/search-modal.hbs +1 -1
  33. package/addon/components/snippet-plugin/snippet-insert.hbs +1 -1
  34. package/addon/components/snippet-plugin/snippet-list/snippet-list-modal.hbs +10 -2
  35. package/addon/components/snippet-plugin/snippet-list/snippet-list-view.hbs +24 -18
  36. package/addon/components/snippet-plugin/snippet-list-select-rdfa.hbs +5 -5
  37. package/addon/components/standard-template-plugin/card.hbs +9 -5
  38. package/addon/components/standard-template-plugin/template-provider.hbs +7 -5
  39. package/addon/components/table-of-contents-plugin/ember-nodes/outline.hbs +1 -1
  40. package/addon/components/table-of-contents-plugin/ember-nodes/table-of-contents.hbs +1 -1
  41. package/addon/components/template-comments-plugin/edit-card.hbs +4 -2
  42. package/addon/components/template-comments-plugin/insert.hbs +1 -1
  43. package/addon/components/template-comments-plugin/template-comment.hbs +3 -3
  44. package/addon/components/validation-plugin/validation-card.hbs +7 -4
  45. package/addon/components/validation-plugin/validation-item.hbs +7 -2
  46. package/addon/components/variable-plugin/address/edit.hbs +67 -34
  47. package/addon/components/variable-plugin/address/insert-variable.hbs +2 -2
  48. package/addon/components/variable-plugin/address/insert.hbs +6 -5
  49. package/addon/components/variable-plugin/codelist/edit.hbs +23 -10
  50. package/addon/components/variable-plugin/codelist/insert.hbs +2 -5
  51. package/addon/components/variable-plugin/date/date-time-picker.hbs +8 -7
  52. package/addon/components/variable-plugin/date/edit.hbs +49 -30
  53. package/addon/components/variable-plugin/date/help-modal.hbs +22 -19
  54. package/addon/components/variable-plugin/date/insert.hbs +6 -5
  55. package/addon/components/variable-plugin/date/nodeview.hbs +3 -3
  56. package/addon/components/variable-plugin/location/edit.hbs +23 -10
  57. package/addon/components/variable-plugin/location/insert.hbs +2 -2
  58. package/addon/components/variable-plugin/location/nodeview.hbs +7 -2
  59. package/addon/components/variable-plugin/number/insert.hbs +7 -7
  60. package/addon/components/variable-plugin/number/nodeview.hbs +5 -3
  61. package/addon/components/variable-plugin/text/insert.hbs +2 -2
  62. package/addon/components/variable-plugin/utils/label-input.hbs +1 -1
  63. package/addon/components/variable-plugin/variable/nodeview.hbs +7 -2
  64. package/addon/components/worship-plugin/administrative-unit-picker.hbs +2 -1
  65. package/addon/components/worship-plugin/list.hbs +1 -3
  66. package/addon/components/worship-plugin/search-modal.hbs +10 -10
  67. package/addon/components/worship-plugin/sortable-table-header.hbs +11 -5
  68. package/addon/plugins/besluit-topic-plugin/commands/update-besluit-topic-resource.ts +59 -0
  69. package/addon/plugins/besluit-topic-plugin/index.ts +3 -0
  70. package/addon/plugins/besluit-topic-plugin/utils/fetchBesluitTopics.ts +66 -0
  71. package/addon/plugins/besluit-topic-plugin/utils/helpers.ts +36 -0
  72. package/app/components/besluit-topic-plugin/besluit-topic-select.js +1 -0
  73. package/app/components/besluit-topic-plugin/besluit-topic-toolbar-dropdown.js +1 -0
  74. package/app/styles/besluit-plugin.scss +2 -2
  75. package/app/styles/citaten-plugin.scss +19 -16
  76. package/app/styles/confidentiality-plugin.scss +2 -2
  77. package/app/styles/document-title-plugin.scss +1 -1
  78. package/app/styles/snippet-plugin.scss +1 -1
  79. package/app/styles/variable-plugin.scss +5 -3
  80. package/declarations/addon/components/besluit-topic-plugin/besluit-topic-select.d.ts +12 -0
  81. package/declarations/addon/components/besluit-topic-plugin/besluit-topic-toolbar-dropdown.d.ts +28 -0
  82. package/declarations/addon/plugins/besluit-topic-plugin/commands/update-besluit-topic-resource.d.ts +8 -0
  83. package/declarations/addon/plugins/besluit-topic-plugin/index.d.ts +3 -0
  84. package/declarations/addon/plugins/besluit-topic-plugin/utils/fetchBesluitTopics.d.ts +16 -0
  85. package/declarations/addon/plugins/besluit-topic-plugin/utils/helpers.d.ts +4 -0
  86. package/package.json +3 -1
  87. package/translations/appuniversum/en-us.yaml +10 -10
  88. package/translations/appuniversum/nl-be.yaml +10 -10
  89. package/translations/en-US.yaml +18 -5
  90. package/translations/nl-BE.yaml +61 -52
  91. package/tsconfig.json +1 -1
  92. package/tsconfig.main.json +5 -16
package/.release-it.json CHANGED
@@ -10,4 +10,4 @@
10
10
  "ignoreVersion": true,
11
11
  "allowSameVersion": true
12
12
  }
13
- }
13
+ }
@@ -16,6 +16,12 @@ steps:
16
16
  commands:
17
17
  - corepack enable
18
18
  - pnpm lint:hbs
19
+ lint-prettier:
20
+ image: node:20-slim
21
+ group: lint
22
+ commands:
23
+ - corepack enable
24
+ - pnpm lint:prettier
19
25
  test:
20
26
  image: danlynn/ember-cli:4.12.1
21
27
  commands:
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @lblod/ember-rdfa-editor-lblod-plugins
2
2
 
3
+ ## 19.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#426](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/426) [`cb28e40ae4a8b1bf1d2d792788a10986db77aec2`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/cb28e40ae4a8b1bf1d2d792788a10986db77aec2) Thanks [@dkozickis](https://github.com/dkozickis)! - GN-4692: Create a `besluit-topic` (decision topic) plugin
8
+
9
+ ### Patch Changes
10
+
11
+ - [#425](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/425) [`69da05460e79b8cb4a5601d9d5f4eae3026c4da3`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/69da05460e79b8cb4a5601d9d5f4eae3026c4da3) Thanks [@dkozickis](https://github.com/dkozickis)! - Apply Prettier to the codebase
12
+
3
13
  ## 19.0.0
4
14
 
5
15
  ### Major Changes
package/README.md CHANGED
@@ -224,6 +224,27 @@ You need to specify the endpoint from which the plugin will fetch the types in t
224
224
  }
225
225
  ```
226
226
 
227
+ ## besluit-topic-plugin
228
+
229
+ Plugin which allows a user to change the topic of a [besluit](https://data.vlaanderen.be/ns/besluit#Besluit).
230
+
231
+ This plugin needs to be added to the toolbar as a dropdown with the following syntax:
232
+
233
+ ```hbs
234
+ <BesluitTopicPlugin::BesluitTopicToolbarDropdown
235
+ @controller={{this.controller}}
236
+ @options={{this.config.besluitTopic}}
237
+ />
238
+ ```
239
+
240
+ You need to specify the endpoint from which the plugin will fetch the types in the config object
241
+
242
+ ```js
243
+ {
244
+ endpoint: 'https://data.vlaanderen.be/sparql',
245
+ }
246
+ ```
247
+
227
248
  ## decision-plugin
228
249
 
229
250
  This plugin provides some warnings to the user if the validation for a besluit fails, it need to be used with the validation plugin as it exports some validation rules for it.
@@ -1,11 +1,16 @@
1
1
  {{! @glint-nocheck: not typesafe yet }}
2
2
  <div>
3
3
  {{#each this.structureTypes as |structureType|}}
4
- <li class="au-c-list__item">
5
- <AuButton @icon={{this.AddIcon}} @iconAlignment="left" @skin="link" @disabled={{not (this.canInsertStructure structureType)}}
6
- {{on 'click' (fn this.insertStructure structureType)}}>
7
- {{t structureType.translations.insert}}
8
- </AuButton>
9
- </li>
4
+ <li class='au-c-list__item'>
5
+ <AuButton
6
+ @icon={{this.AddIcon}}
7
+ @iconAlignment='left'
8
+ @skin='link'
9
+ @disabled={{not (this.canInsertStructure structureType)}}
10
+ {{on 'click' (fn this.insertStructure structureType)}}
11
+ >
12
+ {{t structureType.translations.insert}}
13
+ </AuButton>
14
+ </li>
10
15
  {{/each}}
11
16
  </div>
@@ -1,28 +1,43 @@
1
1
  {{! @glint-nocheck: not typesafe yet }}
2
2
  {{#unless this.isOutsideStructure}}
3
- <AuCard @flex={{true}} @divided={{true}} @expandable={{false}} @shadow={{true}} @size="flush" as |c|>
4
- <c.header class="au-u-hidden-visually">
5
- <AuHeading @level="3" @skin="6">{{t "article-structure-plugin.title.structure-card"}}</AuHeading>
3
+ <AuCard
4
+ @flex={{true}}
5
+ @divided={{true}}
6
+ @expandable={{false}}
7
+ @shadow={{true}}
8
+ @size='flush'
9
+ as |c|
10
+ >
11
+ <c.header class='au-u-hidden-visually'>
12
+ <AuHeading @level='3' @skin='6'>{{t
13
+ 'article-structure-plugin.title.structure-card'
14
+ }}</AuHeading>
6
15
  </c.header>
7
- <c.content class="au-c-content--small">
8
- <AuList @divider={{true}} class="au-u-padding-top-tiny au-u-padding-bottom-tiny" as |Item|>
16
+ <c.content class='au-c-content--small'>
17
+ <AuList
18
+ @divider={{true}}
19
+ class='au-u-padding-top-tiny au-u-padding-bottom-tiny'
20
+ as |Item|
21
+ >
9
22
  <Item>
10
23
  <AuButton
11
24
  @icon={{this.ChevronUpIcon}}
12
- @iconAlignment="left"
13
- @skin="link"
25
+ @iconAlignment='left'
26
+ @skin='link'
14
27
  @disabled={{not this.canMoveUp}}
15
- {{on 'click' (fn this.moveStructure 'up')}}>
28
+ {{on 'click' (fn this.moveStructure 'up')}}
29
+ >
16
30
  {{t this.currentStructureType.translations.move.up}}
17
31
  </AuButton>
18
32
  </Item>
19
33
  <Item>
20
34
  <AuButton
21
35
  @icon={{this.ChevronDownIcon}}
22
- @iconAlignment="left"
23
- @skin="link"
36
+ @iconAlignment='left'
37
+ @skin='link'
24
38
  @disabled={{not this.canMoveDown}}
25
- {{on 'click' (fn this.moveStructure 'down')}}>
39
+ {{on 'click' (fn this.moveStructure 'down')}}
40
+ >
26
41
  {{t this.currentStructureType.translations.move.down}}
27
42
  </AuButton>
28
43
  </Item>
@@ -32,23 +47,20 @@
32
47
  <:hover as |hover|>
33
48
  <AuButton
34
49
  @icon={{this.BinIcon}}
35
- @iconAlignment="left"
36
- @skin="link"
50
+ @iconAlignment='left'
51
+ @skin='link'
37
52
  @alert={{true}}
38
53
  @disabled={{not this.canRemoveStructure}}
39
- aria-describedby="remove-tooltip"
54
+ aria-describedby='remove-tooltip'
40
55
  {{hover.velcroHook}}
41
56
  {{hover.handleHover}}
42
- {{on 'click' (fn this.removeStructure false)}}>
57
+ {{on 'click' (fn this.removeStructure false)}}
58
+ >
43
59
  {{this.remove}}
44
60
  </AuButton>
45
61
  </:hover>
46
62
  <:tooltip as |tooltip|>
47
- <AuPill
48
- id="remove-tooltip"
49
- role="tooltip"
50
- {{tooltip}}
51
- >
63
+ <AuPill id='remove-tooltip' role='tooltip' {{tooltip}}>
52
64
  {{t 'article-structure-plugin.remove.help-text'}}
53
65
  </AuPill>
54
66
  </:tooltip>
@@ -57,22 +69,19 @@
57
69
  <:hover as |hover|>
58
70
  <AuButton
59
71
  @icon={{this.BinIcon}}
60
- @iconAlignment="left"
61
- @skin="link"
62
- aria-describedby="remove-content-tooltip"
72
+ @iconAlignment='left'
73
+ @skin='link'
74
+ aria-describedby='remove-content-tooltip'
63
75
  @alert={{true}}
64
76
  {{hover.velcroHook}}
65
77
  {{hover.handleHover}}
66
- {{on 'click' (fn this.removeStructure true)}}>
78
+ {{on 'click' (fn this.removeStructure true)}}
79
+ >
67
80
  {{this.removeWithContent}}
68
81
  </AuButton>
69
82
  </:hover>
70
83
  <:tooltip as |tooltip|>
71
- <AuPill
72
- id="remove-content-tooltip"
73
- role="tooltip"
74
- {{tooltip}}
75
- >
84
+ <AuPill id='remove-content-tooltip' role='tooltip' {{tooltip}}>
76
85
  {{t 'article-structure-plugin.remove-with-content.help-text'}}
77
86
  </AuPill>
78
87
  </:tooltip>
@@ -81,7 +90,7 @@
81
90
  </AuButtonGroup>
82
91
  </Item>
83
92
  {{#if this.currentStructureType.getStartNumber}}
84
- <Item class="au-u-padding-left-small">
93
+ <Item class='au-u-padding-left-small'>
85
94
  <AuFormRow>
86
95
  {{#let (unique-id) as |id|}}
87
96
  <AuLabel for={{id}}>
@@ -90,25 +99,27 @@
90
99
  <AuInput
91
100
  id={{id}}
92
101
  value={{this.startNumberInputValue}}
93
- {{on "change" this.onStartNumberChange}}
94
- placeholder={{t 'article-structure-plugin.start-number.start-number'}}
95
- type="number"
96
- min="1"
102
+ {{on 'change' this.onStartNumberChange}}
103
+ placeholder={{t
104
+ 'article-structure-plugin.start-number.start-number'
105
+ }}
106
+ type='number'
107
+ min='1'
97
108
  />
98
109
  {{/let}}
99
110
  </AuFormRow>
100
111
  <AuButton
101
- @iconAlignment="left"
102
- class="au-u-margin-top-tiny"
112
+ @iconAlignment='left'
113
+ class='au-u-margin-top-tiny'
103
114
  {{on 'click' this.setStructureStartNumber}}
104
115
  >
105
116
  {{t 'article-structure-plugin.start-number.set'}}
106
117
  </AuButton>
107
118
  <AuButton
108
- @iconAlignment="left"
109
- @skin="secondary"
119
+ @iconAlignment='left'
120
+ @skin='secondary'
110
121
  @disabled={{not this.structureStartNumber}}
111
- class="au-u-margin-top-tiny"
122
+ class='au-u-margin-top-tiny'
112
123
  {{on 'click' this.resetStructureStartNumber}}
113
124
  >
114
125
  {{t 'article-structure-plugin.start-number.reset'}}
@@ -0,0 +1,19 @@
1
+ {{! @glint-nocheck: not typesafe yet }}
2
+ <div ...attributes>
3
+ <PowerSelectMultiple
4
+ @renderInPlace={{true}}
5
+ @searchEnabled={{true}}
6
+ @searchMessage={{t 'besluit-topic-plugin.search-message'}}
7
+ @noMatchesMessage={{t 'besluit-topic-plugin.no-matches-message'}}
8
+ @search={{this.search}}
9
+ @options={{this.besluitTopics}}
10
+ @selected={{@selected}}
11
+ @onChange={{@onchange}}
12
+ as |besluitTopic|
13
+ >
14
+ {{besluitTopic.label}}
15
+ </PowerSelectMultiple>
16
+ <p class='au-u-muted au-u-margin-tiny au-u-margin-bottom-small'>
17
+ {{@selected.definition}}
18
+ </p>
19
+ </div>
@@ -0,0 +1,32 @@
1
+ import Component from '@glimmer/component';
2
+ import { action } from '@ember/object';
3
+ import { tracked } from '@glimmer/tracking';
4
+ import { AlertTriangleIcon } from '@appuniversum/ember-appuniversum/components/icons/alert-triangle';
5
+ import { BesluitTopic } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-topic-plugin/utils/fetchBesluitTopics';
6
+
7
+ type Args = {
8
+ besluitTopics: BesluitTopic[];
9
+ };
10
+
11
+ export default class BesluitTopicSelectComponent extends Component<Args> {
12
+ AlertTriangleIcon = AlertTriangleIcon;
13
+
14
+ @tracked besluitTopics: BesluitTopic[] = [];
15
+
16
+ constructor(parent: unknown, args: Args) {
17
+ super(parent, args);
18
+
19
+ this.besluitTopics = this.args.besluitTopics.sort((a, b) =>
20
+ a.label > b.label ? 1 : -1,
21
+ );
22
+ }
23
+
24
+ @action
25
+ search(term: string) {
26
+ const lowerTerm = term.toLowerCase();
27
+
28
+ return this.args.besluitTopics.filter((besluitTopic) =>
29
+ besluitTopic.label.toLowerCase().includes(lowerTerm),
30
+ );
31
+ }
32
+ }
@@ -0,0 +1,93 @@
1
+ {{! @glint-nocheck: not typesafe yet }}
2
+ <div
3
+ {{did-update this.updateBesluitTopic @controller.mainEditorState}}
4
+ {{did-update this.updateBesluitTopic this.topics.value}}
5
+ >
6
+ {{#if this.showCard}}
7
+ {{#if this.topics.isError}}
8
+ <AuPill
9
+ @skin='error'
10
+ @icon={{this.CircleXIcon}}
11
+ @iconAlignment='left'
12
+ class='au-c-pill--link besluit-toolbar-pill'
13
+ {{on 'click' this.toggleCard}}
14
+ title={{t 'besluit-topic-plugin.insert-dt'}}
15
+ >
16
+ {{t 'besluit-topic-plugin.error-short'}}
17
+ </AuPill>
18
+ {{else}}
19
+ {{#if this.besluitTopicsSelected.length}}
20
+ <AuPill
21
+ @skin='link'
22
+ {{on 'click' this.toggleCard}}
23
+ title={{t 'besluit-topic-plugin.insert-dt'}}
24
+ >
25
+ {{t 'besluit-topic-plugin.dt'}}:
26
+ {{#if (gt this.besluitTopicsSelected.length 1)}}
27
+ {{t
28
+ 'besluit-topic-plugin.selected'
29
+ num=this.besluitTopicsSelected.length
30
+ }}
31
+ {{else}}
32
+ {{get this.besluitTopicsSelected '0.label'}}
33
+ {{/if}}
34
+ </AuPill>
35
+ {{else}}
36
+ <AuPill
37
+ @icon={{this.AlertTriangleIcon}}
38
+ @iconAlignment='left'
39
+ @skin='link'
40
+ {{on 'click' this.toggleCard}}
41
+ title={{t 'besluit-topic-plugin.insert-dt'}}
42
+ >
43
+ {{t 'besluit-topic-plugin.insert-dt'}}
44
+ </AuPill>
45
+ {{/if}}
46
+ {{/if}}
47
+ {{/if}}
48
+ {{#if this.cardExpanded}}
49
+ <AuModal
50
+ @title={{t 'besluit-topic-plugin.insert-dt'}}
51
+ @closeModal={{this.toggleCard}}
52
+ @modalOpen={{true}}
53
+ @size='default'
54
+ class='au-c-modal--overflow'
55
+ as |Modal|
56
+ >
57
+ <Modal.Body>
58
+ {{#if this.topics.isError}}
59
+ <AuAlert
60
+ @title={{t 'besluit-topic-plugin.error-title'}}
61
+ @skin='error'
62
+ @icon={{this.CrossIcon}}
63
+ >
64
+ <p>
65
+ {{t 'besluit-topic-plugin.error-first-body'}}
66
+ {{! template-lint-disable no-bare-strings }}
67
+ <AuLinkExternal
68
+ href='mailto:gelinktnotuleren@vlaanderen.be'
69
+ @icon={{this.MailIcon}}
70
+ @iconAlignment='left'
71
+ >
72
+ GelinktNotuleren@vlaanderen.be
73
+ </AuLinkExternal>
74
+ {{! template-lint-enable no-bare-strings }}
75
+ {{t 'besluit-topic-plugin.error-rest-body'}}
76
+ </p>
77
+ </AuAlert>
78
+ {{else}}
79
+ <BesluitTopicPlugin::BesluitTopicSelect
80
+ @besluitTopics={{this.topics.value}}
81
+ @onchange={{this.upsertBesluitTopic}}
82
+ @selected={{this.besluitTopicsSelected}}
83
+ />
84
+ {{/if}}
85
+ </Modal.Body>
86
+ <Modal.Footer>
87
+ <AuButton {{on 'click' this.toggleCard}}>{{t
88
+ 'besluit-topic-plugin.close-modal'
89
+ }}</AuButton>
90
+ </Modal.Footer>
91
+ </AuModal>
92
+ {{/if}}
93
+ </div>
@@ -0,0 +1,151 @@
1
+ import { tracked } from '@glimmer/tracking';
2
+ import Component from '@glimmer/component';
3
+ import { action } from '@ember/object';
4
+ import { SayController } from '@lblod/ember-rdfa-editor';
5
+ import { findAncestorOfType } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/article-structure-plugin/utils/structure';
6
+ import { trackedFunction } from 'ember-resources/util/function';
7
+ import { ELI } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
8
+ import { AlertTriangleIcon } from '@appuniversum/ember-appuniversum/components/icons/alert-triangle';
9
+ import { CrossIcon } from '@appuniversum/ember-appuniversum/components/icons/cross';
10
+ import { MailIcon } from '@appuniversum/ember-appuniversum/components/icons/mail';
11
+ import { BesluitTopicPluginOptions } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-topic-plugin';
12
+ import {
13
+ BesluitTopic,
14
+ fetchBesluitTopics,
15
+ } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-topic-plugin/utils/fetchBesluitTopics';
16
+ import {
17
+ getCurrentBesluitRange,
18
+ getCurrentBesluitURI,
19
+ } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-topic-plugin/utils/helpers';
20
+ import {
21
+ updateBesluitTopicResource,
22
+ ELI_SUBJECT,
23
+ } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-topic-plugin/commands/update-besluit-topic-resource';
24
+ import { getOutgoingTripleList } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
25
+
26
+ type Args = {
27
+ controller: SayController;
28
+ options: BesluitTopicPluginOptions;
29
+ };
30
+
31
+ export default class BesluitTopicToolbarDropdownComponent extends Component<Args> {
32
+ MailIcon = MailIcon;
33
+ CrossIcon = CrossIcon;
34
+ AlertTriangleIcon = AlertTriangleIcon;
35
+
36
+ /**
37
+ * Actual besluit topic selected
38
+ */
39
+ @tracked besluitTopicsSelected?: BesluitTopic[];
40
+ @tracked previousBesluitTopics?: string[];
41
+
42
+ @tracked cardExpanded = false;
43
+
44
+ get controller() {
45
+ return this.args.controller;
46
+ }
47
+
48
+ get doc() {
49
+ return this.controller.mainEditorState.doc;
50
+ }
51
+
52
+ topics = trackedFunction(this, async () => {
53
+ const result = await fetchBesluitTopics({
54
+ config: { endpoint: this.args.options.endpoint },
55
+ });
56
+
57
+ return result.topics;
58
+ });
59
+
60
+ findBesluitTopicsByUris(
61
+ uris: string[],
62
+ topics = this.topics.value,
63
+ ): BesluitTopic[] | undefined {
64
+ if (!uris.length || !topics) return;
65
+
66
+ return topics.filter((besluitTopic) => uris.includes(besluitTopic.uri));
67
+ }
68
+
69
+ @action
70
+ updateBesluitTopic() {
71
+ const currentBesluitURI = getCurrentBesluitURI(this.controller);
72
+
73
+ if (!currentBesluitURI || !this.topics.value) {
74
+ return;
75
+ }
76
+
77
+ const besluit = findAncestorOfType(
78
+ this.controller.mainEditorState.selection,
79
+ this.controller.schema.nodes['besluit'],
80
+ );
81
+
82
+ if (!besluit) {
83
+ console.warn(
84
+ `We have a besluit URI (${currentBesluitURI}), but can't find a besluit ancestor`,
85
+ );
86
+ return;
87
+ }
88
+
89
+ const outgoingBesluitTopics = getOutgoingTripleList(
90
+ besluit.node.attrs,
91
+ ELI(ELI_SUBJECT),
92
+ );
93
+
94
+ const besluitTopicsRelevant = outgoingBesluitTopics.filter(
95
+ (topic) =>
96
+ topic.object.termType === 'NamedNode' &&
97
+ topic.object.value.includes(
98
+ 'https://data.vlaanderen.be/id/concept/BesluitThema/',
99
+ ),
100
+ );
101
+
102
+ const outgoingUris = besluitTopicsRelevant.map(
103
+ (topic) => topic.object.value,
104
+ );
105
+
106
+ const besluitTopics = this.findBesluitTopicsByUris(outgoingUris);
107
+
108
+ if (besluitTopicsRelevant && besluitTopics) {
109
+ this.previousBesluitTopics = outgoingUris;
110
+
111
+ this.besluitTopicsSelected = besluitTopics;
112
+ } else {
113
+ this.besluitTopicsSelected = undefined;
114
+ }
115
+ }
116
+
117
+ get showCard() {
118
+ return !!getCurrentBesluitRange(this.controller);
119
+ }
120
+
121
+ @action
122
+ upsertBesluitTopic(selected: BesluitTopic[]) {
123
+ this.besluitTopicsSelected = selected;
124
+
125
+ const currentBesluitRange = getCurrentBesluitRange(this.controller);
126
+
127
+ const resource =
128
+ (currentBesluitRange &&
129
+ 'node' in currentBesluitRange &&
130
+ (currentBesluitRange.node.attrs.subject as string)) ||
131
+ undefined;
132
+
133
+ if (this.besluitTopicsSelected && resource) {
134
+ this.controller.doCommand(
135
+ updateBesluitTopicResource({
136
+ resource,
137
+ previousTopics: this.previousBesluitTopics,
138
+ newTopics: this.besluitTopicsSelected,
139
+ }),
140
+ {
141
+ view: this.args.controller.mainEditorView,
142
+ },
143
+ );
144
+ }
145
+ }
146
+
147
+ @action
148
+ toggleCard() {
149
+ this.cardExpanded = !this.cardExpanded;
150
+ }
151
+ }
@@ -3,12 +3,14 @@
3
3
  <PowerSelect
4
4
  @renderInPlace={{true}}
5
5
  @searchEnabled={{true}}
6
- @searchMessage={{t "besluit-type-plugin.search-message"}}
7
- @noMatchesMessage={{t "besluit-type-plugin.no-matches-message"}}
6
+ @searchMessage={{t 'besluit-type-plugin.search-message'}}
7
+ @noMatchesMessage={{t 'besluit-type-plugin.no-matches-message'}}
8
8
  @search={{this.search}}
9
9
  @options={{this.besluitTypes}}
10
10
  @selected={{@selected}}
11
- @onChange={{@onchange}} as |besluitType|>
11
+ @onChange={{@onchange}}
12
+ as |besluitType|
13
+ >
12
14
  {{besluitType.label}}
13
15
  </PowerSelect>
14
16
  <p class='au-u-muted au-u-margin-tiny au-u-margin-bottom-small'>
@@ -18,11 +20,12 @@
18
20
  {{#unless @selected}}
19
21
  <AuAlert
20
22
  @icon={{this.AlertTriangleIcon}}
21
- @title={{t "besluit-type-plugin.alert-title"}}
22
- @skin="warning"
23
- @size="small"
24
- class="au-u-margin-bottom-none au-u-margin-top-small">
25
- <p>{{t "besluit-type-plugin.alert-body"}}</p>
23
+ @title={{t 'besluit-type-plugin.alert-title'}}
24
+ @skin='warning'
25
+ @size='small'
26
+ class='au-u-margin-bottom-none au-u-margin-top-small'
27
+ >
28
+ <p>{{t 'besluit-type-plugin.alert-body'}}</p>
26
29
  </AuAlert>
27
30
  {{/unless}}
28
31
  {{/if}}
@@ -12,10 +12,7 @@
12
12
  this.documentText
13
13
  this.documentLegislationType
14
14
  }}
15
- {{did-update
16
- this.update
17
- this.activeDecoration
18
- }}
15
+ {{did-update this.update this.activeDecoration}}
19
16
  as |c|
20
17
  >
21
18
  <c.header>
@@ -1,5 +1,5 @@
1
1
  {{! @glint-nocheck: not typesafe yet }}
2
- <li class="au-c-list__item">
2
+ <li class='au-c-list__item'>
3
3
  <AuButton
4
4
  @icon={{this.AddIcon}}
5
5
  @iconAlignment='left'
@@ -1,13 +1,17 @@
1
1
  {{#if @articles.length}}
2
- <AuList @direction="vertical" @divider={{true}} as |Item|>
2
+ <AuList @direction='vertical' @divider={{true}} as |Item|>
3
3
  {{#each @articles as |article|}}
4
4
  <Item>
5
5
  <CitationPlugin::Citations::ArticlePreview
6
6
  @insertArticleCitation={{fn @insertArticleCitation article}}
7
- @article={{article}} />
7
+ @article={{article}}
8
+ />
8
9
  </Item>
9
10
  {{/each}}
10
11
  </AuList>
11
12
  {{else}}
12
- <Common::Search::AlertNoItems @fullSize={{@fullSize}} class={{if @fullSize "au-u-margin"}}/>
13
+ <Common::Search::AlertNoItems
14
+ @fullSize={{@fullSize}}
15
+ class={{if @fullSize 'au-u-margin'}}
16
+ />
13
17
  {{/if}}
@@ -1,17 +1,21 @@
1
1
  {{! @glint-nocheck: not typesafe yet }}
2
- <div class="au-u-margin" ...attributes>
3
- <AuHeading @level="3" @skin="5" class="au-u-margin-bottom-small">
4
- {{@article.number}} ({{@article.dateInForce}} - {{if @article.dateNoLongerInForce @article.dateNoLongerInForce "…"}})
2
+ <div class='au-u-margin' ...attributes>
3
+ <AuHeading @level='3' @skin='5' class='au-u-margin-bottom-small'>
4
+ {{@article.number}}
5
+ ({{@article.dateInForce}}
6
+ -
7
+ {{if @article.dateNoLongerInForce @article.dateNoLongerInForce '…'}})
5
8
  </AuHeading>
6
9
  <p>
7
10
  {{this.content}}
8
11
  </p>
9
12
  <AuButton
10
- @skin="primary"
13
+ @skin='primary'
11
14
  @icon={{this.PlusTextIcon}}
12
- @iconAlignment="left"
13
- class="au-u-margin-top-small"
14
- {{on "click" @insertArticleCitation}}>
15
- {{t "citaten-plugin.references.refer-article"}}
15
+ @iconAlignment='left'
16
+ class='au-u-margin-top-small'
17
+ {{on 'click' @insertArticleCitation}}
18
+ >
19
+ {{t 'citaten-plugin.references.refer-article'}}
16
20
  </AuButton>
17
21
  </div>