@lblod/ember-rdfa-editor-lblod-plugins 8.2.1 → 8.3.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 (50) hide show
  1. package/.woodpecker/.test.yml +5 -0
  2. package/CHANGELOG.md +30 -1
  3. package/addon/components/citation-plugin/citations/search-modal.hbs +18 -41
  4. package/addon/components/citation-plugin/citations/search-modal.ts +0 -17
  5. package/addon/components/pagination/pagination-view.hbs +39 -0
  6. package/addon/components/roadsign-regulation-plugin/roadsigns-modal.ts +7 -1
  7. package/addon/components/snippet-plugin/helpers/alert-load-error.hbs +22 -0
  8. package/addon/components/snippet-plugin/helpers/alert-no-items.hbs +8 -0
  9. package/addon/components/snippet-plugin/search-modal.hbs +83 -0
  10. package/addon/components/snippet-plugin/search-modal.ts +97 -0
  11. package/addon/components/snippet-plugin/snippet-insert.hbs +17 -0
  12. package/addon/components/snippet-plugin/snippet-insert.ts +50 -0
  13. package/addon/components/snippet-plugin/snippets/snippet-list.hbs +12 -0
  14. package/addon/components/snippet-plugin/snippets/snippet-preview.hbs +27 -0
  15. package/addon/components/snippet-plugin/snippets/snippet-preview.ts +28 -0
  16. package/addon/helpers/pagination.ts +40 -0
  17. package/addon/plugins/citation-plugin/utils/vlaamse-codex.ts +4 -34
  18. package/addon/plugins/snippet-plugin/index.ts +27 -0
  19. package/addon/plugins/snippet-plugin/utils/fetch-data.ts +96 -0
  20. package/addon/plugins/variable-plugin/nodes.ts +15 -11
  21. package/addon/plugins/variable-plugin/utils/fetch-data.ts +6 -6
  22. package/addon/utils/sparql-helpers.ts +28 -6
  23. package/addon/utils/strings.ts +34 -0
  24. package/addon/utils/types.ts +3 -0
  25. package/app/components/pagination/pagination-view.js +1 -0
  26. package/app/components/snippet-plugin/helpers/alert-load-error.js +1 -0
  27. package/app/components/snippet-plugin/helpers/alert-no-items.js +1 -0
  28. package/app/components/snippet-plugin/search-modal.js +1 -0
  29. package/app/components/snippet-plugin/snippet-insert.js +1 -0
  30. package/app/components/snippet-plugin/snippets/snippet-list.js +1 -0
  31. package/app/components/snippet-plugin/snippets/snippet-preview.js +1 -0
  32. package/app/helpers/pagination.js +4 -0
  33. package/app/styles/snippet-plugin.scss +66 -0
  34. package/components/besluit-type-plugin/toolbar-dropdown.d.ts +1 -1
  35. package/components/citation-plugin/citations/search-modal.d.ts +0 -4
  36. package/components/snippet-plugin/search-modal.d.ts +22 -0
  37. package/components/snippet-plugin/snippet-insert.d.ts +16 -0
  38. package/components/snippet-plugin/snippets/snippet-preview.d.ts +14 -0
  39. package/helpers/pagination.d.ts +25 -0
  40. package/package.json +5 -5
  41. package/plugins/snippet-plugin/index.d.ts +16 -0
  42. package/plugins/snippet-plugin/utils/fetch-data.d.ts +18 -0
  43. package/plugins/table-of-contents-plugin/nodes/table-of-contents.d.ts +1 -1
  44. package/plugins/variable-plugin/nodes.d.ts +3 -3
  45. package/translations/en-US.yaml +23 -0
  46. package/translations/nl-BE.yaml +24 -1
  47. package/tsconfig.json +5 -13
  48. package/utils/sparql-helpers.d.ts +11 -4
  49. package/utils/strings.d.ts +2 -0
  50. package/utils/types.d.ts +2 -0
@@ -6,6 +6,7 @@ steps:
6
6
  - git diff -wb --name-only origin/master..HEAD | grep CHANGELOG.md
7
7
  when:
8
8
  event: pull_request
9
+ evaluate: 'not (CI_COMMIT_PULL_REQUEST_LABELS contains "dependabot")'
9
10
  install:
10
11
  image: danlynn/ember-cli:4.8.0
11
12
  commands:
@@ -26,6 +27,10 @@ steps:
26
27
  group: check
27
28
  commands:
28
29
  - ember test
30
+ precompile:
31
+ image: danlynn/ember-cli:4.8.0
32
+ commands:
33
+ - ember ts:precompile
29
34
 
30
35
 
31
36
  release:
package/CHANGELOG.md CHANGED
@@ -7,6 +7,32 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [8.3.0] - 2023-07-06
11
+ ### Added
12
+ - Insert the snippet
13
+
14
+ ### Added
15
+ - Addition of a precompile step to woodpecker PR check
16
+ ### Fixed
17
+ - fix type error due to bad tsconfig
18
+ ### Changed
19
+ - Woodpecker: do not run changelog-check when PR contains `dependabot` label
20
+ - Made the number variable also show placeholders
21
+ - Extract SPARQL query tools
22
+
23
+ ### Dependencies
24
+ - Bumps `@types/rdfjs__data-model` from 2.0.1 to 2.0.4
25
+ - Bumps `eslint-plugin-ember` from 11.4.6 to 11.9.0
26
+ - Bumps `@typescript-eslint/eslint-plugin` from 5.45.0 to 5.60.1
27
+ - Bumps `ember-velcro` to 2.1.0
28
+ - Bumps `@lblod/ember-rdfa-editor` to 4.0.0
29
+ - Bumps `ember-resources` from 5.6.2 to 6.1.1
30
+
31
+ ## [8.2.2] - 2023-06-28
32
+
33
+ ### Fixed
34
+ - Fix code filtering of roadsign regulation plugin
35
+
10
36
  ## [8.2.1] - 2023-06-28
11
37
  ### Fixed
12
38
  - GN-4200: Fixed bug with TOC scroll in GN and RB
@@ -54,6 +80,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
54
80
  ### Fixed
55
81
  - Change problematic type in citation that made it to break with new ember
56
82
 
83
+
57
84
  ## [8.0.0] - 2023-06-15
58
85
  ### Fixed
59
86
  - Bump `@lblod/ember-rdfa-editor` package to fix annotation not present for some structures
@@ -515,7 +542,7 @@ add onclick handler to pencil icon in variable plugin
515
542
 
516
543
  # Changelog
517
544
 
518
- [unreleased]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v8.2.1...HEAD
545
+ [unreleased]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v8.3.0...HEAD
519
546
  [8.0.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v8.0.0...v8.0.1
520
547
  [8.0.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v7.1.0...v8.0.0
521
548
  [7.1.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v7.0.0...v7.1.0
@@ -531,6 +558,8 @@ add onclick handler to pencil icon in variable plugin
531
558
  [3.0.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v2.1.2...v3.0.0
532
559
  [2.1.2]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v2.1.1...v2.1.2
533
560
  [2.1.1]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v2.1.0...v2.1.1
561
+ [8.3.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v8.2.2...v8.3.0
562
+ [8.2.2]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v8.2.1...v8.2.2
534
563
  [8.2.1]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v8.2.0...v8.2.1
535
564
  [8.2.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v8.1.0...v8.2.0
536
565
  [8.1.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v8.0.1...v8.1.0
@@ -206,47 +206,24 @@
206
206
  {{/if}}
207
207
  {{/if}}
208
208
  {{#if this.decisionResource.value.length}}
209
- {{! Pagination in the footer of the dialog }}
210
- <div class='citaten--container-footer au-u-background-gray-100'>
211
- <AuToolbar @border='top' @size='large' @nowrap={{true}}>
212
- <div class='au-c-pagination'>
213
- <p>
214
- <span class='au-u-hidden-visually'>{{t
215
- 'citaten-plugin.search.results'
216
- }}</span>
217
- <strong>
218
- {{this.rangeStart}}
219
- -
220
- {{this.rangeEnd}}
221
- </strong>
222
- {{t 'citaten-plugin.pagination.of'}}
223
- {{this.totalCount}}
224
- </p>
225
- <div class='au-c-pagination__list-item'>
226
- {{#unless this.isFirstPage}}
227
- <AuButton
228
- @skin='link'
229
- @icon='nav-left'
230
- @iconAlignment='left'
231
- {{on 'click' this.previousPage}}
232
- >
233
- {{t 'citaten-plugin.pagination.previous'}}
234
- </AuButton>
235
- {{/unless}}
236
- {{#unless this.isLastPage}}
237
- <AuButton
238
- @skin='link'
239
- @icon='nav-right'
240
- @iconAlignment='right'
241
- {{on 'click' this.nextPage}}
242
- >
243
- {{t 'citaten-plugin.pagination.next'}}
244
- </AuButton>
245
- {{/unless}}
246
- </div>
247
- </div>
248
- </AuToolbar>
249
- </div>
209
+ {{#let
210
+ (pagination
211
+ page=this.pageNumber
212
+ pageSize=this.pageSize
213
+ count=this.totalCount
214
+ )
215
+ as |pg|
216
+ }}
217
+ <Pagination::PaginationView
218
+ @totalCount={{pg.count}}
219
+ @rangeStart={{pg.pageStart}}
220
+ @rangeEnd={{pg.pageEnd}}
221
+ @onNextPage={{this.nextPage}}
222
+ @onPreviousPage={{this.previousPage}}
223
+ @isFirstPage={{not pg.hasPreviousPage}}
224
+ @isLastPage={{not pg.hasNextPage}}
225
+ />
226
+ {{/let}}
250
227
  {{/if}}
251
228
  </mc.content>
252
229
  </AuMainContainer>
@@ -108,23 +108,6 @@ export default class EditorPluginsCitationsSearchModalComponent extends Componen
108
108
  return this.inputSearchText ?? this.text;
109
109
  }
110
110
 
111
- get rangeStart() {
112
- return this.pageNumber * this.pageSize + 1;
113
- }
114
-
115
- get rangeEnd() {
116
- const end = this.rangeStart + this.pageSize - 1;
117
- return end > this.totalCount ? this.totalCount : end;
118
- }
119
-
120
- get isFirstPage() {
121
- return this.pageNumber == 0;
122
- }
123
-
124
- get isLastPage() {
125
- return this.rangeEnd == this.totalCount;
126
- }
127
-
128
111
  resourceSearch = restartableTask(async () => {
129
112
  await timeout(500);
130
113
  this.error = null;
@@ -0,0 +1,39 @@
1
+ <div class='au-u-background-gray-100'>
2
+ <AuToolbar @border='top' @size='large' @nowrap={{true}}>
3
+ <div class='au-c-pagination'>
4
+ <p>
5
+ <span class='au-u-hidden-visually'>
6
+ {{t 'pagination.results'}}</span>
7
+ <strong>
8
+ {{@rangeStart}}
9
+ -
10
+ {{@rangeEnd}}
11
+ </strong>
12
+ {{t 'pagination.of'}}
13
+ {{@totalCount}}
14
+ </p>
15
+ <div class='au-u-flex'>
16
+ {{#unless @isFirstPage}}
17
+ <AuButton
18
+ @skin='link'
19
+ @icon='nav-left'
20
+ @iconAlignment='left'
21
+ {{on 'click' @onPreviousPage}}
22
+ >
23
+ {{t 'pagination.previous'}}
24
+ </AuButton>
25
+ {{/unless}}
26
+ {{#unless @isLastPage}}
27
+ <AuButton
28
+ @skin='link'
29
+ @icon='nav-right'
30
+ @iconAlignment='right'
31
+ {{on 'click' @onNextPage}}
32
+ >
33
+ {{t 'pagination.next'}}
34
+ </AuButton>
35
+ {{/unless}}
36
+ </div>
37
+ </div>
38
+ </AuToolbar>
39
+ </div>
@@ -156,11 +156,17 @@ export default class RoadsignRegulationCard extends Component<Args> {
156
156
  closeModal() {
157
157
  this.args.closeModal();
158
158
  }
159
+
159
160
  @action
160
161
  searchCodes(term: string) {
161
162
  const category = this.categorySelected?.value;
162
163
  const type = this.typeSelected?.value;
163
- return this.roadsignRegistry.searchCode.perform(term, category, type);
164
+ return this.roadsignRegistry.searchCode.perform(
165
+ this.endpoint,
166
+ term,
167
+ category,
168
+ type
169
+ );
164
170
  }
165
171
 
166
172
  async fetchCodeCombinations() {
@@ -0,0 +1,22 @@
1
+ <AuAlert
2
+ @title='{{t "snippet-plugin.modal.alert.error-title"}}'
3
+ @skin='error'
4
+ @icon='alert-triangle'
5
+ @closable={{false}}
6
+ class='au-u-margin au-u-margin-top-none'
7
+ ...attributes
8
+ >
9
+ <p>{{t 'snippet-plugin.modal.alert.error-intro'}}</p>
10
+ <code class='au-u-error snippet-modal--error-code'>{{@error}}</code>
11
+ <p>
12
+ {{t 'snippet-plugin.modal.alert.error-outro'}}
13
+ <AuLinkExternal
14
+ href='mailto:Gelinkt-Notuleren@vlaanderen.be'
15
+ @icon='mail'
16
+ @iconAlignment='left'
17
+ >
18
+ {{! template-lint-disable no-bare-strings }}
19
+ Gelinkt-Notuleren@vlaanderen.be
20
+ </AuLinkExternal>.
21
+ </p>
22
+ </AuAlert>
@@ -0,0 +1,8 @@
1
+ <AuAlert
2
+ @title={{t 'snippet-plugin.modal.alert.no-results'}}
3
+ @skin='warning'
4
+ @icon='cross'
5
+ @closable={{false}}
6
+ class='au-u-margin au-u-margin-top-none'
7
+ ...attributes
8
+ />
@@ -0,0 +1,83 @@
1
+ <AuModal
2
+ @modalOpen={{@open}}
3
+ @closeModal={{this.closeModal}}
4
+ @title={{t 'snippet-plugin.modal.title'}}
5
+ @size='large'
6
+ @padding='none'
7
+ as |modal|
8
+ >
9
+ <modal.Body>
10
+ <AuMainContainer class='snippet-modal--main-container' as |mc|>
11
+ <mc.sidebar>
12
+ <div class='au-c-sidebar'>
13
+ <div class='au-c-sidebar__content au-u-padding'>
14
+ <AuHeading @level='3' @skin='4' class='au-u-padding-bottom-small'>
15
+ {{t 'snippet-plugin.modal.search.title'}}
16
+ </AuHeading>
17
+ <AuLabel
18
+ class='au-margin-bottom-small'
19
+ for='searchTerm'
20
+ @inline={{false}}
21
+ @required={{false}}
22
+ @error={{false}}
23
+ @warning={{false}}
24
+ >
25
+ {{t 'snippet-plugin.modal.search.label'}}
26
+ </AuLabel>
27
+ <AuNativeInput
28
+ @type='text'
29
+ @width='block'
30
+ id='searchTerm'
31
+ value={{this.searchText}}
32
+ placeholder={{t 'snippet-plugin.modal.search.placeholder'}}
33
+ {{on 'input' this.setInputSearchText}}
34
+ />
35
+ </div>
36
+ </div>
37
+ </mc.sidebar>
38
+ <mc.content @scroll={{true}}>
39
+ <div class='au-u-padding-top snippet-modal--list-container'>
40
+ {{#if this.snippetsResource.isRunning}}
41
+ <div class='au-u-margin'>
42
+ <AuLoader @padding='large' />
43
+ <span class='au-u-hidden-visually'>
44
+ {{t 'snippet-plugin.alert.loading'}}
45
+ </span>
46
+ </div>
47
+ {{else}}
48
+ {{#if this.error}}
49
+ <SnippetPlugin::Helpers::AlertLoadError @error={{this.error}} />
50
+ {{else}}
51
+ {{#if this.snippetsResource.value.length}}
52
+ <SnippetPlugin::Snippets::SnippetList
53
+ @snippets={{this.snippetsResource.value}}
54
+ @onInsert={{@onInsert}}
55
+ />
56
+ {{else}}
57
+ <SnippetPlugin::Helpers::AlertNoItems />
58
+ {{/if}}
59
+ {{/if}}
60
+ {{/if}}
61
+ </div>
62
+ {{#if this.snippetsResource.value.length}}
63
+ {{#let
64
+ (pagination
65
+ page=this.pageNumber pageSize=this.pageSize count=this.totalCount
66
+ )
67
+ as |pg|
68
+ }}
69
+ <Pagination::PaginationView
70
+ @totalCount={{pg.count}}
71
+ @rangeStart={{pg.pageStart}}
72
+ @rangeEnd={{pg.pageEnd}}
73
+ @onNextPage={{this.nextPage}}
74
+ @onPreviousPage={{this.previousPage}}
75
+ @isFirstPage={{not pg.hasPreviousPage}}
76
+ @isLastPage={{not pg.hasNextPage}}
77
+ />
78
+ {{/let}}
79
+ {{/if}}
80
+ </mc.content>
81
+ </AuMainContainer>
82
+ </modal.Body>
83
+ </AuModal>
@@ -0,0 +1,97 @@
1
+ import Component from '@glimmer/component';
2
+ import { assert } from '@ember/debug';
3
+ import { action } from '@ember/object';
4
+ import { restartableTask, timeout } from 'ember-concurrency';
5
+ import { task as trackedTask } from 'ember-resources/util/ember-concurrency';
6
+
7
+ import { tracked } from '@glimmer/tracking';
8
+
9
+ import { fetchSnippets } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin/utils/fetch-data';
10
+ import { SnippetPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
11
+
12
+ interface Args {
13
+ config: SnippetPluginConfig;
14
+ closeModal: () => void;
15
+ }
16
+
17
+ export default class SnippetPluginSearchModalComponent extends Component<Args> {
18
+ // Filtering
19
+ @tracked inputSearchText: string | null = null;
20
+
21
+ // Display
22
+ @tracked error: unknown;
23
+
24
+ // Pagination
25
+ @tracked pageNumber = 0;
26
+ @tracked pageSize = 20;
27
+ @tracked totalCount = 0;
28
+
29
+ get config() {
30
+ return this.args.config;
31
+ }
32
+
33
+ get searchText() {
34
+ return this.inputSearchText;
35
+ }
36
+
37
+ @action
38
+ setInputSearchText(event: InputEvent) {
39
+ assert(
40
+ 'inputSearchText must be bound to an input element',
41
+ event.target instanceof HTMLInputElement
42
+ );
43
+
44
+ this.inputSearchText = event.target.value;
45
+ }
46
+
47
+ @action
48
+ async closeModal() {
49
+ await this.snippetsResource.cancel();
50
+ this.args.closeModal();
51
+ }
52
+
53
+ snippetsSearch = restartableTask(async () => {
54
+ await timeout(500);
55
+
56
+ const abortController = new AbortController();
57
+
58
+ try {
59
+ const queryResult = await fetchSnippets({
60
+ endpoint: this.args.config.endpoint,
61
+ abortSignal: abortController.signal,
62
+ filter: {
63
+ name: this.inputSearchText ?? undefined,
64
+ },
65
+ pagination: {
66
+ pageNumber: this.pageNumber,
67
+ pageSize: this.pageSize,
68
+ },
69
+ });
70
+
71
+ this.totalCount = queryResult.totalCount;
72
+
73
+ return queryResult.results;
74
+ } catch (error) {
75
+ this.error = error;
76
+ return [];
77
+ } finally {
78
+ abortController.abort();
79
+ }
80
+ });
81
+
82
+ snippetsResource = trackedTask(this, this.snippetsSearch, () => [
83
+ this.inputSearchText,
84
+ this.pageNumber,
85
+ this.pageSize,
86
+ ]);
87
+
88
+ @action
89
+ previousPage() {
90
+ --this.pageNumber;
91
+ }
92
+
93
+ @action
94
+ nextPage() {
95
+ ++this.pageNumber;
96
+ }
97
+ }
@@ -0,0 +1,17 @@
1
+ <AuList::Item>
2
+ <AuButton
3
+ @icon='add'
4
+ @iconAlignment='left'
5
+ @skin='link'
6
+ {{on 'click' this.openModal}}
7
+ >
8
+ {{t 'snippet-plugin.insert.title'}}
9
+ </AuButton>
10
+ </AuList::Item>
11
+
12
+ <SnippetPlugin::SearchModal
13
+ @open={{this.showModal}}
14
+ @closeModal={{this.closeModal}}
15
+ @config={{this.config}}
16
+ @onInsert={{this.onInsert}}
17
+ />
@@ -0,0 +1,50 @@
1
+ import { action } from '@ember/object';
2
+
3
+ import Component from '@glimmer/component';
4
+ import { tracked } from '@glimmer/tracking';
5
+
6
+ import { ProseParser, SayController } from '@lblod/ember-rdfa-editor';
7
+ import { SnippetPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
8
+
9
+ interface Args {
10
+ controller: SayController;
11
+ config: SnippetPluginConfig;
12
+ }
13
+
14
+ export default class SnippetInsertComponent extends Component<Args> {
15
+ @tracked showModal = false;
16
+
17
+ get controller() {
18
+ return this.args.controller;
19
+ }
20
+
21
+ get config() {
22
+ return this.args.config;
23
+ }
24
+
25
+ @action
26
+ openModal() {
27
+ this.controller.focus();
28
+ this.showModal = true;
29
+ }
30
+
31
+ @action
32
+ closeModal() {
33
+ this.showModal = false;
34
+ }
35
+
36
+ @action
37
+ onInsert(content: string) {
38
+ const domParser = new DOMParser();
39
+
40
+ this.closeModal();
41
+
42
+ this.controller.withTransaction((tr) => {
43
+ return tr.replaceSelectionWith(
44
+ ProseParser.fromSchema(this.controller.schema).parse(
45
+ domParser.parseFromString(content, 'text/html')
46
+ )
47
+ );
48
+ });
49
+ }
50
+ }
@@ -0,0 +1,12 @@
1
+ {{#if @snippets.length}}
2
+ <AuList @direction='vertical'>
3
+ {{#each @snippets as |snippet|}}
4
+ <AuList::Item>
5
+ <SnippetPlugin::Snippets::SnippetPreview
6
+ @snippet={{snippet}}
7
+ @onInsert={{@onInsert}}
8
+ />
9
+ </AuList::Item>
10
+ {{/each}}
11
+ </AuList>
12
+ {{/if}}
@@ -0,0 +1,27 @@
1
+ <div
2
+ class='snippet-preview--container au-c-panel au-u-margin-right'
3
+ ...attributes
4
+ >
5
+ <div
6
+ class='snippet-preview--article au-u-padding au-u-padding-right-large rdfa-annotations rdfa-annotations-highlight rdfa-annotations-hover'
7
+ >
8
+ <h3 class='snippet-preview--title au-u-margin-bottom'>
9
+ {{@snippet.title}}
10
+ </h3>
11
+ <div class="snippet-preview--editor-container">
12
+ <div class="say-container__main">
13
+ <div class="say-editor">
14
+ <div class="say-editor__inner say-content">
15
+ {{this.snippet.content}}
16
+ </div>
17
+ </div>
18
+ </div>
19
+ <div class="snippet-preview--editor-overlay"></div>
20
+ </div>
21
+ </div>
22
+ <div class='snippet-preview--button au-u-padding-small'>
23
+ <AuButton @skin='naked' {{on 'click' this.onInsert}}>
24
+ {{t 'snippet-plugin.modal.select'}}
25
+ </AuButton>
26
+ </div>
27
+ </div>
@@ -0,0 +1,28 @@
1
+ import { action } from '@ember/object';
2
+ import Component from '@glimmer/component';
3
+ import { tracked } from '@glimmer/tracking';
4
+
5
+ import { SayController } from '@lblod/ember-rdfa-editor';
6
+ import {
7
+ Snippet,
8
+ SnippetPluginConfig,
9
+ } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
10
+
11
+ interface Args {
12
+ config: SnippetPluginConfig;
13
+ snippet: Snippet;
14
+ onInsert: (content: string) => void;
15
+ }
16
+
17
+ export default class SnippetPreviewComponent extends Component<Args> {
18
+ @tracked controller?: SayController;
19
+
20
+ get snippet(): Snippet {
21
+ return this.args.snippet;
22
+ }
23
+
24
+ @action
25
+ onInsert() {
26
+ this.args.onInsert(this.args.snippet.content?.toHTML() ?? '');
27
+ }
28
+ }
@@ -0,0 +1,40 @@
1
+ import { helper } from '@ember/component/helper';
2
+
3
+ import { isSome } from '../utils/option';
4
+
5
+ interface PaginationArguments {
6
+ count: number;
7
+ pageSize: number;
8
+ page: number;
9
+ }
10
+
11
+ export function pagination({
12
+ page = 0,
13
+ count = 0,
14
+ pageSize = 20,
15
+ }: PaginationArguments) {
16
+ const totalPages = count / pageSize;
17
+ const pageStart = page * pageSize + 1;
18
+ const pageEnd = Math.min((page + 1) * pageSize, count);
19
+ const nextPage = page < totalPages - 1 ? page + 1 : null;
20
+ const previousPage = page > 0 ? page - 1 : null;
21
+ const hasPreviousPage = isSome(previousPage);
22
+ const hasNextPage = isSome(nextPage);
23
+
24
+ return {
25
+ count,
26
+ pageSize,
27
+ page,
28
+ totalPages,
29
+ pageStart,
30
+ pageEnd,
31
+ nextPage,
32
+ previousPage,
33
+ hasPreviousPage,
34
+ hasNextPage,
35
+ };
36
+ }
37
+
38
+ export default helper<unknown[], PaginationArguments>((_, named) =>
39
+ pagination(named)
40
+ );
@@ -1,9 +1,12 @@
1
1
  import { LEGISLATION_TYPE_CONCEPTS } from './legislation-types';
2
- import { warn } from '@ember/debug';
3
2
  import {
4
3
  Option,
5
4
  optionMapOr,
6
5
  } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
6
+ import {
7
+ dateValue,
8
+ escapeValue,
9
+ } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/strings';
7
10
 
8
11
  interface DecisionArgs {
9
12
  uri: string;
@@ -470,39 +473,6 @@ function cleanCaches() {
470
473
  fetchArticlesMemory.clear();
471
474
  }
472
475
 
473
- function escapeValue(value?: string) {
474
- if (value) {
475
- const shadowDomElement = document.createElement('textarea');
476
- shadowDomElement.innerHTML = value;
477
- return shadowDomElement.textContent;
478
- } else {
479
- return null;
480
- }
481
- }
482
-
483
- function dateValue(value?: string): string | null {
484
- if (value) {
485
- try {
486
- return new Intl.DateTimeFormat('nl-BE').format(
487
- new Date(Date.parse(value))
488
- );
489
- } catch (e) {
490
- let message: string;
491
- if (e instanceof Error) {
492
- message = e.message;
493
- } else {
494
- message = e as string;
495
- }
496
- warn(`Error parsing date ${value}: ${message}`, {
497
- id: 'date-parsing-error',
498
- });
499
- return null;
500
- }
501
- } else {
502
- return null;
503
- }
504
- }
505
-
506
476
  async function executeCountQuery({
507
477
  query,
508
478
  config,