@lblod/ember-rdfa-editor-lblod-plugins 39.0.0 → 39.1.1-dev.25cb10062fc4dc92e211bd4921171c73222152ee

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 (66) hide show
  1. package/.changeset/forty-bottles-listen.md +5 -0
  2. package/.changeset/nervous-kids-agree.md +5 -0
  3. package/.woodpecker/.verify-pr.yml +7 -1
  4. package/CHANGELOG.md +20 -0
  5. package/addon/components/lmb-plugin/search-modal.gts +1 -1
  6. package/addon/components/location-plugin/edit.gts +4 -4
  7. package/addon/components/locked-placeholder-plugin/insert.gts +2 -2
  8. package/addon/components/mandatee-table-plugin/configure.gts +1 -1
  9. package/addon/components/placeholder-utils-plugin/edit.gts +1 -1
  10. package/addon/components/roadsign-regulation-plugin/roadsigns-modal.gts +1 -1
  11. package/addon/components/snippet-plugin/search-modal.gts +1 -1
  12. package/addon/components/snippet-plugin/snippet-list/snippet-list-modal.gts +269 -0
  13. package/addon/components/snippet-plugin/snippet-list/snippet-list-view.gts +130 -0
  14. package/addon/components/snippet-plugin/snippet-list/tag-selector.gts +60 -0
  15. package/addon/components/structure-plugin/control-card.gts +1 -1
  16. package/addon/components/variable-plugin/autofilled/edit.gts +1 -1
  17. package/addon/components/variable-plugin/autofilled/insert.gts +2 -2
  18. package/addon/components/variable-plugin/date/edit.gts +1 -1
  19. package/addon/components/variable-plugin/utils/label-input.gts +1 -1
  20. package/addon/helpers/in-array.ts +3 -9
  21. package/addon/plugins/decision-plugin/actions/insert-article.ts +2 -2
  22. package/addon/plugins/location-plugin/node.ts +4 -4
  23. package/addon/plugins/snippet-plugin/index.ts +18 -1
  24. package/addon/plugins/snippet-plugin/utils/fetch-data.ts +111 -18
  25. package/addon/plugins/variable-plugin/variables/address.ts +5 -4
  26. package/addon/plugins/variable-plugin/variables/date.ts +10 -3
  27. package/addon/plugins/variable-plugin/variables/number.ts +3 -1
  28. package/addon/plugins/variable-plugin/variables/person.ts +2 -1
  29. package/addon/utils/constants.ts +1 -1
  30. package/app/components/snippet-plugin/snippet-list/tag-selector.js +1 -0
  31. package/app/styles/snippet-plugin.scss +42 -1
  32. package/declarations/addon/components/lmb-plugin/search-modal.d.ts +1 -1
  33. package/declarations/addon/components/location-plugin/edit.d.ts +3 -3
  34. package/declarations/addon/components/locked-placeholder-plugin/insert.d.ts +2 -2
  35. package/declarations/addon/components/mandatee-table-plugin/configure.d.ts +1 -1
  36. package/declarations/addon/components/placeholder-utils-plugin/edit.d.ts +1 -1
  37. package/declarations/addon/components/roadsign-regulation-plugin/roadsigns-modal.d.ts +1 -1
  38. package/declarations/addon/components/snippet-plugin/search-modal.d.ts +1 -1
  39. package/declarations/addon/components/snippet-plugin/snippet-list/snippet-list-modal.d.ts +5 -1
  40. package/declarations/addon/components/snippet-plugin/snippet-list/snippet-list-view.d.ts +12 -8
  41. package/declarations/addon/components/snippet-plugin/snippet-list/tag-selector.d.ts +18 -0
  42. package/declarations/addon/components/structure-plugin/control-card.d.ts +1 -1
  43. package/declarations/addon/components/variable-plugin/autofilled/edit.d.ts +1 -1
  44. package/declarations/addon/components/variable-plugin/autofilled/insert.d.ts +2 -2
  45. package/declarations/addon/components/variable-plugin/date/edit.d.ts +1 -1
  46. package/declarations/addon/components/variable-plugin/utils/label-input.d.ts +1 -1
  47. package/declarations/addon/helpers/in-array.d.ts +1 -4
  48. package/declarations/addon/plugins/snippet-plugin/index.d.ts +9 -1
  49. package/declarations/addon/plugins/snippet-plugin/utils/fetch-data.d.ts +17 -2
  50. package/declarations/addon/utils/constants.d.ts +1 -1
  51. package/package.json +8 -11
  52. package/translations/en-US.yaml +10 -4
  53. package/translations/nl-BE.yaml +10 -4
  54. package/tsconfig.declarations.json +3 -7
  55. package/tsconfig.json +45 -7
  56. package/addon/components/snippet-plugin/snippet-list/snippet-list-modal.hbs +0 -63
  57. package/addon/components/snippet-plugin/snippet-list/snippet-list-modal.ts +0 -111
  58. package/addon/components/snippet-plugin/snippet-list/snippet-list-view.hbs +0 -66
  59. package/addon/components/snippet-plugin/snippet-list/snippet-list-view.ts +0 -57
  60. package/declarations/addon/components/citation-plugin/citations/article-list.d.ts +0 -1
  61. package/declarations/addon/components/citation-plugin/citations/legal-document-list.d.ts +0 -1
  62. package/declarations/addon/components/confidentiality-plugin/toolbar.d.ts +0 -1
  63. package/declarations/addon/components/table-of-contents-plugin/ember-nodes/outline.d.ts +0 -1
  64. package/declarations/addon/components/worship-plugin/list.d.ts +0 -1
  65. package/scripts/generate-type-declarations.sh +0 -16
  66. package/tsconfig.main.json +0 -51
@@ -0,0 +1,5 @@
1
+ ---
2
+ '@lblod/ember-rdfa-editor-lblod-plugins': minor
3
+ ---
4
+
5
+ snippet-list plugin: introduce tag filtering
@@ -0,0 +1,5 @@
1
+ ---
2
+ '@lblod/ember-rdfa-editor-lblod-plugins': minor
3
+ ---
4
+
5
+ snippet-list plugin: move filtering options to separate sidebar
@@ -3,9 +3,15 @@ steps:
3
3
  image: node:22-slim
4
4
  commands:
5
5
  - npm config set ignore-scripts true
6
- - npm i -g corepack@0.35
7
6
  - corepack enable
8
7
  - pnpm i --frozen-lockfile
8
+ check-dev-packages:
9
+ image: node:22-slim
10
+ commands:
11
+ - corepack enable
12
+ - apt-get update
13
+ - apt-get install -y --no-install-recommends jq
14
+ - "pnpm list --json | jq -e '[ .. | .version? ] | map(select(. != null)) | map(test(\"dev\")) | any | not'"
9
15
  lint-js:
10
16
  image: node:22-slim
11
17
  group: lint
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @lblod/ember-rdfa-editor-lblod-plugins
2
2
 
3
+ ## 39.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#685](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/685) [`898d635`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/898d6357fe879e3ddd1df27655af07c7feea60df) Thanks [@elpoelma](https://github.com/elpoelma)! - classic `address` plugin: fix typo in `generiek` namespace
8
+
9
+ - [#680](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/680) [`e91e1bd`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/e91e1bd37cf6119b1dd403abeb61d0ff3ca275ad) Thanks [@lagartoverde](https://github.com/lagartoverde)! - `insert-article` command: fix article node selection to avoid prosemirror selection warning
10
+
11
+ ## 39.1.0
12
+
13
+ ### Minor Changes
14
+
15
+ - [#683](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/683) [`69858cb`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/69858cb1b537e7e7ed43adcd78bc858b21a5bab3) Thanks [@elpoelma](https://github.com/elpoelma)! - Move to glint v2
16
+
17
+ ### Patch Changes
18
+
19
+ - [#679](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/679) [`e08902b`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/e08902b088d4e649abe0f4396341e581d8949fa2) Thanks [@lagartoverde](https://github.com/lagartoverde)! - Fix variable serialization to include label
20
+
21
+ - [#684](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/684) [`9781fc2`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/9781fc21da2f4a1a1aece249ee207b0d0e8cc350) Thanks [@abeforgit](https://github.com/abeforgit)! - add ci check for dev-packages
22
+
3
23
  ## 39.0.0
4
24
 
5
25
  ### Major Changes
@@ -211,7 +211,7 @@ export default class SearchModal extends Component<Signature> {
211
211
  this.sort = sort;
212
212
  }
213
213
  @action
214
- setInputSearchText(event: InputEvent) {
214
+ setInputSearchText(event: Event) {
215
215
  assert(
216
216
  'inputSearchText must be bound to an input element',
217
217
  event.target instanceof HTMLInputElement,
@@ -340,18 +340,18 @@ export default class LocationPluginEditComponent extends Component<Signature> {
340
340
  }
341
341
 
342
342
  @action
343
- updateHousenumber(event: InputEvent) {
343
+ updateHousenumber(event: Event) {
344
344
  this.newHousenumber = (event.target as HTMLInputElement).value;
345
345
  this.newBusnumber = '';
346
346
  }
347
347
 
348
348
  @action
349
- updateBusnumber(event: InputEvent) {
349
+ updateBusnumber(event: Event) {
350
350
  this.newBusnumber = (event.target as HTMLInputElement).value;
351
351
  }
352
352
 
353
353
  @action
354
- updatePlaceName(event: InputEvent) {
354
+ updatePlaceName(event: Event) {
355
355
  this.args.setPlaceName((event.target as HTMLInputElement).value);
356
356
  }
357
357
 
@@ -434,7 +434,7 @@ export default class LocationPluginEditComponent extends Component<Signature> {
434
434
  @allowClear={{true}}
435
435
  @renderInPlace={{true}}
436
436
  @searchEnabled={{true}}
437
- @search={{perform this.searchMunicipality}}
437
+ @search={{this.searchMunicipality.perform}}
438
438
  @selected={{this.newMunicipality}}
439
439
  @onChange={{this.selectMunicipality}}
440
440
  as |municipality|
@@ -74,12 +74,12 @@ export default class LockedPlaceholderPluginInsert extends Component<Signature>
74
74
  }
75
75
 
76
76
  @action
77
- updateKey(event: InputEvent) {
77
+ updateKey(event: Event) {
78
78
  this.key = (event.target as HTMLInputElement).value;
79
79
  }
80
80
 
81
81
  @action
82
- updateLabel(event: InputEvent) {
82
+ updateLabel(event: Event) {
83
83
  this.label = (event.target as HTMLInputElement).value;
84
84
  }
85
85
 
@@ -62,7 +62,7 @@ export default class ConfigureMandateeTableComponent extends Component<Sig> {
62
62
  }
63
63
 
64
64
  @action
65
- updateNodeTitle(event: InputEvent) {
65
+ updateNodeTitle(event: Event) {
66
66
  this.updateAttribute('title', (event.target as HTMLInputElement).value);
67
67
  }
68
68
 
@@ -64,7 +64,7 @@ export default class PlaceholderUtilsEditCardComponent extends Component<Args> {
64
64
  get showCard() {
65
65
  return !!this.selectedPlaceholderNode;
66
66
  }
67
- updateLabelPlaceholder = (event: InputEvent) => {
67
+ updateLabelPlaceholder = (event: Event) => {
68
68
  this.placeholderLabel = (event.target as HTMLInputElement).value;
69
69
  };
70
70
  updatePlaceholder = () => {
@@ -152,7 +152,7 @@ export default class RoadsignsModal extends Component<Signature> {
152
152
  }
153
153
 
154
154
  @action
155
- handleSearch(event: InputEvent) {
155
+ handleSearch(event: Event) {
156
156
  this.searchQuery = (event.target as HTMLInputElement).value;
157
157
  this.resetPagination();
158
158
  }
@@ -67,7 +67,7 @@ export default class SnippetPluginSearchModalComponent extends Component<Args> {
67
67
  }
68
68
 
69
69
  @action
70
- setInputSearchText(event: InputEvent) {
70
+ setInputSearchText(event: Event) {
71
71
  assert(
72
72
  'inputSearchText must be bound to an input element',
73
73
  event.target instanceof HTMLInputElement,
@@ -0,0 +1,269 @@
1
+ import Component from '@glimmer/component';
2
+ import { action } from '@ember/object';
3
+ import { restartableTask, timeout } from 'ember-concurrency';
4
+ import { task as trackedTask } from 'reactiveweb/ember-concurrency';
5
+
6
+ import { tracked } from '@glimmer/tracking';
7
+
8
+ import {
9
+ fetchSnippetLists,
10
+ OrderBy,
11
+ } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin/utils/fetch-data';
12
+
13
+ import {
14
+ SnippetPluginConfig,
15
+ SnippetList,
16
+ Tag,
17
+ TaggableResourceType,
18
+ } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
19
+ import { localCopy, trackedReset } from 'tracked-toolbox';
20
+ import AuModal from '@appuniversum/ember-appuniversum/components/au-modal';
21
+ import t from 'ember-intl/helpers/t';
22
+ import AuMainContainer from '@appuniversum/ember-appuniversum/components/au-main-container';
23
+ import AlertLoadError from '@lblod/ember-rdfa-editor-lblod-plugins/components/common/search/alert-load-error';
24
+ import SnippetListView from './snippet-list-view';
25
+ import AuToolbar from '@appuniversum/ember-appuniversum/components/au-toolbar';
26
+ import AuCheckbox from '@appuniversum/ember-appuniversum/components/au-checkbox';
27
+ import AuButtonGroup from '@appuniversum/ember-appuniversum/components/au-button-group';
28
+ import AuButton from '@appuniversum/ember-appuniversum/components/au-button';
29
+ import { on } from '@ember/modifier';
30
+ import AuHeading from '@appuniversum/ember-appuniversum/components/au-heading';
31
+ import AuLabel from '@appuniversum/ember-appuniversum/components/au-label';
32
+ import AuNativeInput from '../../au-native-input';
33
+ import TagSelector from './tag-selector';
34
+ import { SAY } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
35
+ import { uniqueId } from '@ember/helper';
36
+ import AuFormRow from '@appuniversum/ember-appuniversum/components/au-form-row';
37
+ import { CrossIcon } from '@appuniversum/ember-appuniversum/components/icons/cross';
38
+
39
+ const TAGGABLE_RESOURCE_TYPES: TaggableResourceType[] = [
40
+ SAY('SnippetList').full,
41
+ ];
42
+ interface Signature {
43
+ Args: {
44
+ config: SnippetPluginConfig;
45
+ onSaveSnippetLists: (
46
+ lists: SnippetList[],
47
+ allowMultipleSnippets: boolean,
48
+ ) => void;
49
+ snippetListUris: string[] | undefined;
50
+ closeModal: () => void;
51
+ open: boolean;
52
+ allowMultipleSnippets?: boolean;
53
+ };
54
+ }
55
+
56
+ export default class SnippetListModalComponent extends Component<Signature> {
57
+ // Filtering
58
+ @tracked nameFilterText: string | null = null;
59
+ @tracked selectedTags: Tag[] = [];
60
+
61
+ // Sorting
62
+ @tracked sort: OrderBy = null;
63
+
64
+ // Display
65
+ @tracked error: unknown;
66
+
67
+ @trackedReset('args.snippetListUris')
68
+ snippetListUris: string[] = [...(this.args.snippetListUris ?? [])];
69
+
70
+ @localCopy('args.allowMultipleSnippets') allowMultipleSnippets = false;
71
+
72
+ @action
73
+ handleMultipleSnippetsCheckbox(checked: boolean) {
74
+ this.allowMultipleSnippets = checked;
75
+ }
76
+
77
+ setNameFilterText = (event: Event) => {
78
+ this.nameFilterText = (event.target as HTMLInputElement).value;
79
+ };
80
+
81
+ setSelectedTags = (tags: Tag[]) => {
82
+ this.selectedTags = tags;
83
+ };
84
+
85
+ resetFilters = () => {
86
+ this.nameFilterText = null;
87
+ this.selectedTags = [];
88
+ };
89
+
90
+ get config() {
91
+ return this.args.config;
92
+ }
93
+
94
+ @action
95
+ closeModal() {
96
+ this.allowMultipleSnippets = this.args.allowMultipleSnippets ?? false;
97
+ this.args.closeModal();
98
+ }
99
+
100
+ @action
101
+ saveAndClose() {
102
+ const snippetLists = this.snippetListResource.value?.filter((snippetList) =>
103
+ this.snippetListUris.includes(snippetList.uri),
104
+ );
105
+ this.args.onSaveSnippetLists(
106
+ snippetLists || [],
107
+ this.allowMultipleSnippets,
108
+ );
109
+ this.args.closeModal();
110
+ // Clear selection for next time
111
+ this.snippetListUris = [];
112
+ }
113
+
114
+ snippetListSearch = restartableTask(async () => {
115
+ await timeout(500);
116
+
117
+ const abortController = new AbortController();
118
+
119
+ try {
120
+ const queryResult = await fetchSnippetLists({
121
+ endpoint: this.args.config.endpoint,
122
+ abortSignal: abortController.signal,
123
+ filter: {
124
+ name: this.nameFilterText ?? undefined,
125
+ tags: this.selectedTags,
126
+ },
127
+ orderBy: this.sort,
128
+ });
129
+
130
+ return queryResult.results;
131
+ } catch (error) {
132
+ this.error = error;
133
+ return [];
134
+ } finally {
135
+ abortController.abort();
136
+ }
137
+ });
138
+
139
+ snippetListResource = trackedTask<SnippetList[]>(
140
+ this,
141
+ this.snippetListSearch,
142
+ () => [this.nameFilterText, this.selectedTags, this.sort],
143
+ );
144
+
145
+ @action
146
+ onChange(snippetListUris: string[]) {
147
+ this.snippetListUris = snippetListUris;
148
+ }
149
+
150
+ <template>
151
+ <AuModal
152
+ @modalOpen={{@open}}
153
+ @closeModal={{this.closeModal}}
154
+ @title={{t 'snippet-plugin.snippet-list.modal.title'}}
155
+ @size='large'
156
+ @padding='none'
157
+ as |modal|
158
+ >
159
+ <modal.Body>
160
+ <AuMainContainer class='say-snippet-list-overview' as |mc|>
161
+ <mc.sidebar class='say-snippet-list-overview__sidebar'>
162
+ <AuHeading @level='2' @skin='3'>
163
+ {{t 'snippet-plugin.snippet-list.modal.filter.title'}}
164
+ </AuHeading>
165
+ <form class='say-snippet-list-overview__form'>
166
+ <AuFormRow>
167
+ {{#let (uniqueId) as |id|}}
168
+ <AuLabel
169
+ for={{id}}
170
+ @inline={{false}}
171
+ @required={{false}}
172
+ @error={{false}}
173
+ @warning={{false}}
174
+ >{{t
175
+ 'snippet-plugin.snippet-list.modal.filter.name-filter.label'
176
+ }}</AuLabel>
177
+ <AuNativeInput
178
+ id={{id}}
179
+ @type='text'
180
+ @width='block'
181
+ @iconAlignment='right'
182
+ value={{this.nameFilterText}}
183
+ placeholder={{t
184
+ 'snippet-plugin.snippet-list.modal.filter.name-filter.placeholder'
185
+ }}
186
+ {{on 'input' this.setNameFilterText}}
187
+ />
188
+ {{/let}}
189
+ </AuFormRow>
190
+ <AuFormRow>
191
+ {{#let (uniqueId) as |id|}}
192
+ <AuLabel
193
+ for={{id}}
194
+ @inline={{false}}
195
+ @required={{false}}
196
+ @error={{false}}
197
+ @warning={{false}}
198
+ >{{t
199
+ 'snippet-plugin.snippet-list.modal.filter.tag-filter.label'
200
+ }}</AuLabel>
201
+ <TagSelector
202
+ id={{id}}
203
+ class='say-snippet-list-overview__tag-selector'
204
+ @endpoint={{this.config.endpoint}}
205
+ @onChange={{this.setSelectedTags}}
206
+ @selectedTags={{this.selectedTags}}
207
+ @taggableTypes={{TAGGABLE_RESOURCE_TYPES}}
208
+ />
209
+ {{/let}}
210
+ </AuFormRow>
211
+ <AuButton
212
+ class='say-snippet-list-overview__reset-filters-button'
213
+ @skin='naked'
214
+ @size='large'
215
+ @icon={{CrossIcon}}
216
+ {{on 'click' this.resetFilters}}
217
+ >{{t 'snippet-plugin.snippet-list.modal.filter.reset'}}</AuButton>
218
+ </form>
219
+ </mc.sidebar>
220
+ <mc.content class='say-snippet-list-overview__content'>
221
+ <div class='say-snippet-list-overview__table'>
222
+ {{#if this.error}}
223
+ <AlertLoadError
224
+ @error={{this.error}}
225
+ class='au-u-margin-top-none'
226
+ />
227
+ {{else}}
228
+ <SnippetListView
229
+ @snippetLists={{this.snippetListResource.value}}
230
+ @snippetListUris={{this.snippetListUris}}
231
+ @listNameFilter={{this.nameFilterText}}
232
+ @sort={{this.sort}}
233
+ @onChange={{this.onChange}}
234
+ @isLoading={{this.snippetListResource.isRunning}}
235
+ />
236
+ {{/if}}
237
+ </div>
238
+ <AuToolbar
239
+ @border='top'
240
+ @size='large'
241
+ @nowrap={{true}}
242
+ class='say-snippet-list-overview__footer au-u-flex--vertical-center'
243
+ as |Group|
244
+ >
245
+ <Group>
246
+ <AuCheckbox
247
+ @checked={{this.allowMultipleSnippets}}
248
+ @onChange={{this.handleMultipleSnippetsCheckbox}}
249
+ >
250
+ {{t 'snippet-plugin.snippet-list.modal.multi-snippet-toggle'}}
251
+ </AuCheckbox>
252
+ </Group>
253
+ <Group>
254
+ <AuButtonGroup>
255
+ <AuButton @skin='secondary' {{on 'click' this.closeModal}}>
256
+ {{t 'snippet-plugin.snippet-list.modal.button.cancel'}}
257
+ </AuButton>
258
+ <AuButton @skin='primary' {{on 'click' this.saveAndClose}}>
259
+ {{t 'snippet-plugin.snippet-list.modal.button.update'}}
260
+ </AuButton>
261
+ </AuButtonGroup>
262
+ </Group>
263
+ </AuToolbar>
264
+ </mc.content>
265
+ </AuMainContainer>
266
+ </modal.Body>
267
+ </AuModal>
268
+ </template>
269
+ }
@@ -0,0 +1,130 @@
1
+ import Component from '@glimmer/component';
2
+ import { action } from '@ember/object';
3
+ import { SnippetList } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
4
+ import AuDataTable from '@appuniversum/ember-appuniversum/components/au-data-table';
5
+ import AuDataTableThSortable from '@appuniversum/ember-appuniversum/components/au-data-table/th-sortable';
6
+ import AuCheckbox from '@appuniversum/ember-appuniversum/components/au-checkbox';
7
+ import { fn } from '@ember/helper';
8
+ import t from 'ember-intl/helpers/t';
9
+ import inArray from '@lblod/ember-rdfa-editor-lblod-plugins/helpers/in-array';
10
+ import { OrderBy } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin/utils/fetch-data';
11
+ import AuPill from '@appuniversum/ember-appuniversum/components/au-pill';
12
+ import { uniqueId } from '@ember/helper';
13
+
14
+ interface Signature {
15
+ Args: {
16
+ snippetLists?: SnippetList[] | null;
17
+ snippetListUris: string[];
18
+ listNameFilter: string | null;
19
+ isLoading: boolean;
20
+ onChange: (snippetListUris: string[]) => void;
21
+ sort: OrderBy;
22
+ };
23
+ }
24
+
25
+ export default class SnippetListView extends Component<Signature> {
26
+ @action
27
+ onChange(snippetUri: string, isSelected: boolean) {
28
+ if (isSelected) {
29
+ const newSnippetListUris = [...this.args.snippetListUris, snippetUri];
30
+
31
+ return this.args.onChange(newSnippetListUris);
32
+ }
33
+
34
+ const newSnippetListUris = this.args.snippetListUris.filter(
35
+ (uri) => uri !== snippetUri,
36
+ );
37
+
38
+ return this.args.onChange(newSnippetListUris);
39
+ }
40
+
41
+ @action
42
+ onClickRow(snippetList: SnippetList, event: Event) {
43
+ if (!(event.target instanceof HTMLElement)) {
44
+ return;
45
+ }
46
+
47
+ const target = event.target;
48
+
49
+ // Only trigger the action when clicking on a td or tr element
50
+ // This is to prevent the action from being triggered when clicking on a checkbox
51
+ if (target.tagName !== 'TD' && target.tagName !== 'TR') {
52
+ return;
53
+ }
54
+
55
+ const snippetListUri = snippetList.uri;
56
+
57
+ if (!snippetListUri) {
58
+ return;
59
+ }
60
+
61
+ const isSelected = this.args.snippetListUris.includes(snippetListUri);
62
+
63
+ this.onChange(snippetListUri, !isSelected);
64
+ }
65
+
66
+ get snippetLists() {
67
+ return this.args.snippetLists;
68
+ }
69
+
70
+ <template>
71
+ {{#let
72
+ (t 'snippet-plugin.snippet-list.modal.table.list')
73
+ (t 'snippet-plugin.snippet-list.modal.table.created')
74
+ (t 'snippet-plugin.snippet-list.modal.table.select')
75
+ (t 'snippet-plugin.snippet-list.modal.table.imported-resources')
76
+ (t 'snippet-plugin.snippet-list.modal.table.tags')
77
+ as |list created select imported tags|
78
+ }}
79
+ {{! @glint-expect-error au-data-table does not have type annotations yet }}
80
+ <AuDataTable
81
+ @content={{this.snippetLists}}
82
+ @isLoading={{@isLoading}}
83
+ @noDataMessage={{t 'common.search.no-results'}}
84
+ @sort={{@sort}}
85
+ @onClickRow={{this.onClickRow}}
86
+ @hidePagination={{true}}
87
+ as |t|
88
+ >
89
+ <t.content as |c|>
90
+ <c.header>
91
+ <th class='snippet-list-table-select-column'>{{select}}</th>
92
+ {{! @glint-expect-error au-data-table does not have type annotations yet }}
93
+ <AuDataTableThSortable
94
+ @field='label'
95
+ @label={{list}}
96
+ @currentSorting={{@sort}}
97
+ @class='data-table__header-title'
98
+ />
99
+ <th>{{imported}}</th>
100
+ <th>{{tags}}</th>
101
+ {{! @glint-expect-error au-data-table does not have type annotations yet }}
102
+ <AuDataTableThSortable
103
+ @field='createdOn'
104
+ @label={{created}}
105
+ @currentSorting={{@sort}}
106
+ @class='data-table__header-title snippet-list-table-created-column'
107
+ />
108
+ </c.header>
109
+ <c.body as |row|>
110
+ <td class='snippet-list-table-select-column'>
111
+ <AuCheckbox
112
+ id={{(uniqueId)}}
113
+ @onChange={{fn this.onChange row.uri}}
114
+ @checked={{inArray @snippetListUris row.uri}}
115
+ />
116
+ </td>
117
+ <td>{{row.label}}</td>
118
+ <td>{{row.importedResources}}</td>
119
+ <td>
120
+ {{#each row.tags as |tag|}}
121
+ <AuPill>{{tag.label}}</AuPill>
122
+ {{/each}}
123
+ </td>
124
+ <td class='snippet-list-table-created-column'>{{row.createdOn}}</td>
125
+ </c.body>
126
+ </t.content>
127
+ </AuDataTable>
128
+ {{/let}}
129
+ </template>
130
+ }
@@ -0,0 +1,60 @@
1
+ import Component from '@glimmer/component';
2
+ import { trackedFunction } from 'reactiveweb/function';
3
+ import { service } from '@ember/service';
4
+ import PowerSelectMultiple from 'ember-power-select/components/power-select-multiple';
5
+ import type IntlService from 'ember-intl/services/intl';
6
+ import {
7
+ Tag,
8
+ TaggableResourceType,
9
+ } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
10
+ import { fetchTags } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin/utils/fetch-data';
11
+ import t from 'ember-intl/helpers/t';
12
+
13
+ type Signature = {
14
+ Args: {
15
+ endpoint: string;
16
+ onChange: (tags: Tag[]) => void;
17
+ selectedTags?: Tag[];
18
+ taggableTypes?: TaggableResourceType[];
19
+ };
20
+ Element: HTMLElement;
21
+ };
22
+
23
+ export default class TagSelector extends Component<Signature> {
24
+ @service declare intl: IntlService;
25
+
26
+ tags = trackedFunction<Promise<Tag[]>>(this, async () => {
27
+ return fetchTags({
28
+ endpoint: this.args.endpoint,
29
+ filter: {
30
+ taggableTypes: this.args.taggableTypes,
31
+ },
32
+ });
33
+ });
34
+
35
+ changeSelection = (selectedTags: Tag[]) => {
36
+ this.args.onChange?.(
37
+ selectedTags.sort((tagA, tagB) => tagA.label.localeCompare(tagB.label)),
38
+ );
39
+ };
40
+
41
+ <template>
42
+ {{#if this.tags.value}}
43
+ <PowerSelectMultiple
44
+ @onChange={{this.changeSelection}}
45
+ @options={{this.tags.value}}
46
+ @searchEnabled={{true}}
47
+ @selected={{@selectedTags}}
48
+ @searchField='label'
49
+ @placeholder={{t
50
+ 'snippet-plugin.snippet-list.modal.filter.tag-filter.placeholder'
51
+ }}
52
+ class='template-tag-selector-powerselect'
53
+ ...attributes
54
+ as |tag|
55
+ >
56
+ {{tag.label}}
57
+ </PowerSelectMultiple>
58
+ {{/if}}
59
+ </template>
60
+ }
@@ -114,7 +114,7 @@ export default class StructureControlCardComponent extends Component<Sig> {
114
114
  },
115
115
  })
116
116
  startNumber: number | null = null;
117
- onStartNumberChange = (event: InputEvent) => {
117
+ onStartNumberChange = (event: Event) => {
118
118
  const target = event.target as HTMLInputElement;
119
119
  this.startNumber = parseInt(target.value);
120
120
  };
@@ -102,7 +102,7 @@ export default class AutoFilledVariableInsertComponent extends Component<Args> {
102
102
  }
103
103
 
104
104
  @action
105
- updateAutofillKey(event: InputEvent) {
105
+ updateAutofillKey(event: Event) {
106
106
  this.autofillKey = (event.target as HTMLInputElement).value;
107
107
  }
108
108
 
@@ -39,12 +39,12 @@ export default class AutoFilledVariableInsertComponent extends Component<Args> {
39
39
  }
40
40
 
41
41
  @action
42
- updateLabel(event: InputEvent) {
42
+ updateLabel(event: Event) {
43
43
  this.label = (event.target as HTMLInputElement).value;
44
44
  }
45
45
 
46
46
  @action
47
- updateAutofillKey(event: InputEvent) {
47
+ updateAutofillKey(event: Event) {
48
48
  this.autofillKey = (event.target as HTMLInputElement).value;
49
49
  }
50
50
 
@@ -301,7 +301,7 @@ export class DateEditComponent extends Component<Sig> {
301
301
  }
302
302
 
303
303
  @action
304
- setCustomDateFormat(event: InputEvent) {
304
+ setCustomDateFormat(event: Event) {
305
305
  const format = (event.target as HTMLInputElement).value;
306
306
 
307
307
  const pos = this.documentDatePos;
@@ -7,7 +7,7 @@ import { TemplateOnlyComponent } from '@ember/component/template-only';
7
7
  interface Sig {
8
8
  Args: {
9
9
  label: string;
10
- updateLabel: (event: InputEvent) => void;
10
+ updateLabel: (event: Event) => void;
11
11
  };
12
12
  }
13
13