@lblod/ember-rdfa-editor-lblod-plugins 39.1.2 → 39.2.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 (32) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/addon/components/common/tags/collapsible-tag-list.gts +149 -0
  3. package/addon/components/common/tags/tag-selector.gts +117 -0
  4. package/addon/components/snippet-plugin/snippet-insert-placeholder.gts +10 -8
  5. package/addon/components/snippet-plugin/snippet-list/snippet-list-modal.gts +278 -0
  6. package/addon/components/snippet-plugin/snippet-list/snippet-list-view.gts +130 -0
  7. package/addon/components/snippet-plugin/snippet-list-select.gts +10 -9
  8. package/addon/helpers/in-array.ts +3 -9
  9. package/addon/plugins/common/tags/queries.ts +64 -0
  10. package/addon/plugins/common/tags/types.ts +12 -0
  11. package/addon/plugins/snippet-plugin/index.ts +11 -1
  12. package/addon/plugins/snippet-plugin/utils/fetch-data.ts +48 -17
  13. package/app/components/common/tags/collapsible-tag-list.js +1 -0
  14. package/app/components/common/tags/tag-selector.js +1 -0
  15. package/app/styles/common/tags.scss +61 -0
  16. package/app/styles/snippet-plugin.scss +44 -1
  17. package/declarations/addon/components/common/tags/collapsible-tag-list.d.ts +26 -0
  18. package/declarations/addon/components/common/tags/tag-selector.d.ts +31 -0
  19. package/declarations/addon/components/snippet-plugin/snippet-list/snippet-list-modal.d.ts +6 -0
  20. package/declarations/addon/components/snippet-plugin/snippet-list/snippet-list-view.d.ts +12 -8
  21. package/declarations/addon/helpers/in-array.d.ts +1 -4
  22. package/declarations/addon/plugins/common/tags/queries.d.ts +12 -0
  23. package/declarations/addon/plugins/common/tags/types.d.ts +9 -0
  24. package/declarations/addon/plugins/snippet-plugin/index.d.ts +4 -1
  25. package/declarations/addon/plugins/snippet-plugin/utils/fetch-data.d.ts +7 -1
  26. package/package.json +1 -1
  27. package/translations/en-US.yaml +16 -4
  28. package/translations/nl-BE.yaml +16 -4
  29. package/addon/components/snippet-plugin/snippet-list/snippet-list-modal.hbs +0 -63
  30. package/addon/components/snippet-plugin/snippet-list/snippet-list-modal.ts +0 -111
  31. package/addon/components/snippet-plugin/snippet-list/snippet-list-view.hbs +0 -66
  32. package/addon/components/snippet-plugin/snippet-list/snippet-list-view.ts +0 -57
@@ -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 { uniqueId } from '@ember/helper';
12
+ import CollapsibleTagList from '@lblod/ember-rdfa-editor-lblod-plugins/components/common/tags/collapsible-tag-list';
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
+ {{#if row.tags.length}}
121
+ <CollapsibleTagList @tags={{row.tags}} />
122
+ {{/if}}
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
+ }
@@ -96,15 +96,16 @@ export default class SnippetListSelect extends Component<Signature> {
96
96
  >
97
97
  {{t 'snippet-plugin.snippet-list.open-modal'}}
98
98
  </AuButton>
99
-
100
- <SnippetListModal
101
- @config={{@config}}
102
- @snippetListUris={{this.snippetListUris}}
103
- @onSaveSnippetLists={{this.onSaveSnippetLists}}
104
- @allowMultipleSnippets={{this.allowMultipleSnippets}}
105
- @open={{this.showModal}}
106
- @closeModal={{this.closeModal}}
107
- />
99
+ {{#if this.showModal}}
100
+ <SnippetListModal
101
+ @config={{@config}}
102
+ @snippetListUris={{this.snippetListUris}}
103
+ @onSaveSnippetLists={{this.onSaveSnippetLists}}
104
+ @allowMultipleSnippets={{this.allowMultipleSnippets}}
105
+ @open={{true}}
106
+ @closeModal={{this.closeModal}}
107
+ />
108
+ {{/if}}
108
109
  {{/if}}
109
110
  </template>
110
111
  }
@@ -1,13 +1,7 @@
1
- import { helper } from '@ember/component/helper';
2
-
3
- type PositionalParams = [array: unknown[], needle: unknown];
4
-
5
- export function inArray([theArray, needle]: PositionalParams) {
6
- if (!Array.isArray(theArray)) {
1
+ export default function inArray(arr: unknown[], needle: unknown) {
2
+ if (!Array.isArray(arr)) {
7
3
  return false;
8
4
  }
9
5
 
10
- return theArray.includes(needle);
6
+ return arr.includes(needle);
11
7
  }
12
-
13
- export default helper<PositionalParams>(inArray);
@@ -0,0 +1,64 @@
1
+ import {
2
+ executeQuery,
3
+ sparqlEscapeString,
4
+ sparqlEscapeUri,
5
+ type BindingObject,
6
+ } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/sparql-helpers';
7
+ import type { TaggableResourceType, TagWithUri } from './types';
8
+ import type { Option } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
9
+
10
+ type TagFilter = {
11
+ searchTerm?: Option<string>;
12
+ taggableTypes?: TaggableResourceType[];
13
+ };
14
+ const buildTagsQuery = ({ searchTerm, taggableTypes }: TagFilter) => {
15
+ return /* sparql */ `
16
+ PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
17
+ PREFIX say: <https://say.data.gift/ns/>
18
+ PREFIX gn: <http://data.lblod.info/vocabularies/gelinktnotuleren/>
19
+ PREFIX ext: <http://mu.semte.ch/vocabularies/ext/>
20
+
21
+ SELECT DISTINCT ?uri ?value WHERE {
22
+ ?uri a gn:Tag;
23
+ skos:prefLabel ?value.
24
+ ${
25
+ taggableTypes && taggableTypes.length
26
+ ? `
27
+ FILTER EXISTS {
28
+ ?usedBy a ?usedByType.
29
+ VALUES ?usedByType {
30
+ ${taggableTypes.map((t) => sparqlEscapeUri(t)).join('\n')}
31
+ }
32
+ ?usedBy ext:hasTag ?uri.
33
+ }
34
+ `
35
+ : ''
36
+ }
37
+ ${searchTerm ? `FILTER(CONTAINS(?value, ${sparqlEscapeString(searchTerm)}))` : ''}
38
+ }
39
+ ORDER BY ?value
40
+ `;
41
+ };
42
+
43
+ export const fetchTags = async ({
44
+ endpoint,
45
+ abortSignal,
46
+ filter,
47
+ }: {
48
+ endpoint: string;
49
+ abortSignal?: AbortSignal;
50
+ filter: TagFilter;
51
+ }): Promise<TagWithUri[]> => {
52
+ const queryResult = await executeQuery<
53
+ BindingObject<{ uri: string; value: string }>
54
+ >({
55
+ endpoint,
56
+ query: buildTagsQuery(filter),
57
+ abortSignal,
58
+ });
59
+
60
+ return queryResult.results.bindings.map((binding) => ({
61
+ uri: binding.uri.value,
62
+ value: binding.value.value,
63
+ }));
64
+ };
@@ -0,0 +1,12 @@
1
+ import { SAY } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
2
+
3
+ export type Tag = {
4
+ value: string;
5
+ };
6
+
7
+ export type TagWithUri = Tag & {
8
+ uri: string;
9
+ };
10
+
11
+ const SNIPPET_LIST_TYPE = SAY('SnippetList').full;
12
+ export type TaggableResourceType = typeof SNIPPET_LIST_TYPE;
@@ -1,6 +1,7 @@
1
1
  import { PreviewableDocument } from '@lblod/ember-rdfa-editor-lblod-plugins/components/common/documents/types';
2
2
  import { type Option } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
3
3
  import { dateValue } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/strings';
4
+ import type { Tag } from '../common/tags/types';
4
5
 
5
6
  export const DEFAULT_CONTENT_STRING = 'block+';
6
7
 
@@ -43,6 +44,7 @@ export type SnippetListArgs = {
43
44
  label: string;
44
45
  createdOn: string;
45
46
  importedResources: string[];
47
+ tags: Tag[];
46
48
  };
47
49
 
48
50
  export class SnippetList {
@@ -50,11 +52,19 @@ export class SnippetList {
50
52
  label: string;
51
53
  createdOn: string | null;
52
54
  importedResources: string[];
55
+ tags: Tag[];
53
56
 
54
- constructor({ uri, label, createdOn, importedResources }: SnippetListArgs) {
57
+ constructor({
58
+ uri,
59
+ label,
60
+ createdOn,
61
+ importedResources,
62
+ tags,
63
+ }: SnippetListArgs) {
55
64
  this.uri = uri;
56
65
  this.label = label;
57
66
  this.createdOn = dateValue(createdOn);
58
67
  this.importedResources = importedResources;
68
+ this.tags = tags;
59
69
  }
60
70
  }
@@ -6,8 +6,12 @@ import {
6
6
  sparqlEscapeUri,
7
7
  } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/sparql-helpers';
8
8
  import { Snippet, SnippetList, SnippetListArgs } from '../index';
9
+ import type { TagWithUri } from '../../common/tags/types';
9
10
 
10
- export type SnippetFilter = { name?: string; snippetListUris?: string[] };
11
+ export type SnippetFilter = {
12
+ name?: string;
13
+ snippetListUris?: string[];
14
+ };
11
15
  export type OrderBy =
12
16
  | 'label'
13
17
  | 'created-on'
@@ -134,23 +138,43 @@ const buildOrderByString = (orderBy: OrderBy) => {
134
138
  }
135
139
  };
136
140
 
141
+ type SnippetListFilter = {
142
+ name?: string;
143
+ tags?: TagWithUri[];
144
+ };
145
+
137
146
  const buildSnippetListFetchQuery = ({
138
- filter: { name },
147
+ filter: { name, tags },
139
148
  orderBy,
140
149
  }: {
141
- filter: SnippetFilter;
150
+ filter: SnippetListFilter;
142
151
  orderBy: OrderBy;
143
152
  }) => {
144
153
  return /* sparql */ `
145
154
  PREFIX pav: <http://purl.org/pav/>
146
155
  PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
147
156
  PREFIX say: <https://say.data.gift/ns/>
157
+ PREFIX ext: <http://mu.semte.ch/vocabularies/ext/>
148
158
 
149
- SELECT (?snippetLists as ?uri) ?label ?createdOn ?importedResources WHERE {
150
- ?snippetLists a say:SnippetList;
159
+ SELECT DISTINCT ?uri ?label ?createdOn ?importedResource ?tagUri ?tagValue WHERE {
160
+ ?uri a say:SnippetList;
151
161
  skos:prefLabel ?label;
152
162
  pav:createdOn ?createdOn.
153
- OPTIONAL { ?snippetLists say:snippetImportedResource ?importedResources . }
163
+ OPTIONAL { ?uri say:snippetImportedResource ?importedResource . }
164
+ OPTIONAL {
165
+ ?uri ext:hasTag ?tagUri .
166
+ ?tagUri skos:prefLabel ?tagValue .
167
+ }
168
+ ${
169
+ tags && tags.length
170
+ ? `
171
+ FILTER EXISTS {
172
+ ?uri ext:hasTag ?_tagUri .
173
+ VALUES ?_tagUri { ${tags.map((tag) => sparqlEscapeUri(tag.uri)).join('\n')} }
174
+ }
175
+ `
176
+ : ''
177
+ }
154
178
  ${
155
179
  name
156
180
  ? `FILTER (CONTAINS(LCASE(?label), ${sparqlEscapeString(name.toLowerCase())}))`
@@ -230,7 +254,7 @@ export const fetchSnippetLists = async ({
230
254
  }: {
231
255
  endpoint: string;
232
256
  abortSignal: AbortSignal;
233
- filter: SnippetFilter;
257
+ filter: SnippetListFilter;
234
258
  orderBy: OrderBy;
235
259
  }) => {
236
260
  // We don't currently use this count, so skip the query, but we'll need it if we make pagination
@@ -244,8 +268,7 @@ export const fetchSnippetLists = async ({
244
268
  // if (totalCount === 0) {
245
269
  // return { totalCount, results: [] };
246
270
  // }
247
-
248
- const queryResult = await executeQuery<BindingObject<SnippetListArgs>>({
271
+ const queryResult = await executeQuery({
249
272
  endpoint,
250
273
  query: buildSnippetListFetchQuery({ filter, orderBy }),
251
274
  abortSignal,
@@ -257,24 +280,32 @@ export const fetchSnippetLists = async ({
257
280
  uri: binding.uri?.value,
258
281
  label: binding.label?.value,
259
282
  createdOn: binding.createdOn?.value,
260
- importedResources: binding.importedResources?.value,
283
+ importedResource: binding.importedResource?.value,
284
+ tagUri: binding.tagUri?.value,
285
+ tagValue: binding.tagValue?.value,
261
286
  }))
262
- .reduce((mappedResults, bindings) => {
263
- const existing = mappedResults.get(bindings.uri) ?? {
264
- ...bindings,
287
+ .reduce((mappedResults, binding) => {
288
+ const existing = mappedResults.get(binding.uri) ?? {
289
+ ...binding,
265
290
  importedResources: [],
291
+ tags: [],
266
292
  };
267
- if (bindings.importedResources) {
293
+ if (binding.importedResource) {
268
294
  existing.importedResources = [
269
295
  ...existing.importedResources,
270
- bindings.importedResources,
296
+ binding.importedResource,
271
297
  ];
272
298
  }
273
- return mappedResults.set(bindings.uri, existing);
299
+ if (binding.tagUri) {
300
+ existing.tags = [
301
+ ...existing.tags,
302
+ { uri: binding.tagUri, value: binding.tagValue },
303
+ ].sort((tagA, tagB) => tagA.value.localeCompare(tagB.value));
304
+ }
305
+ return mappedResults.set(binding.uri, existing);
274
306
  }, new Map<string, SnippetListArgs>())
275
307
  .values(),
276
308
  ].map((slArgs) => new SnippetList(slArgs));
277
-
278
309
  return { results };
279
310
  };
280
311
 
@@ -0,0 +1 @@
1
+ export { default } from '@lblod/ember-rdfa-editor-lblod-plugins/components/common/tags/collapsible-tag-list';
@@ -0,0 +1 @@
1
+ export { default } from '@lblod/ember-rdfa-editor-lblod-plugins/components/common/tags/tag-selector';
@@ -0,0 +1,61 @@
1
+ .say-tag-selector .ember-power-select-multiple-option {
2
+ max-width: 95%;
3
+ }
4
+
5
+ .say-tag-selector__item {
6
+ overflow: hidden;
7
+ text-overflow: ellipsis;
8
+ display: inline-block;
9
+ }
10
+
11
+ .say-tag-selector
12
+ .ember-power-select-multiple-option
13
+ .ember-power-select-multiple-remove-btn {
14
+ flex-shrink: 0;
15
+ }
16
+
17
+ .say-collapsible-tag-list {
18
+ position: relative;
19
+ width: 100%;
20
+ }
21
+
22
+ .say-collapsible-tag-list__measure {
23
+ position: absolute;
24
+ // To ensure we don't cause any vertical scroll
25
+ overflow: hidden;
26
+
27
+ visibility: hidden;
28
+ pointer-events: none;
29
+ display: flex;
30
+ gap: 6px;
31
+ white-space: nowrap;
32
+ height: 0;
33
+ }
34
+
35
+ .say-collapsible-tag-list__visible {
36
+ display: flex;
37
+ flex-wrap: nowrap;
38
+ overflow: hidden;
39
+ gap: 6px;
40
+ }
41
+
42
+ .say-collapsible-tag-list--expanded .say-collapsible-tag-list__visible {
43
+ flex-wrap: wrap;
44
+ }
45
+
46
+ .say-collapsible-tag-list__pill {
47
+ display: inline-block;
48
+ white-space: nowrap;
49
+ text-overflow: ellipsis;
50
+ overflow: hidden;
51
+ }
52
+
53
+ .say-collapsible-tag-list__more {
54
+ cursor: pointer;
55
+ }
56
+
57
+ .say-collapsible-tag-list__less {
58
+ cursor: pointer;
59
+ border: none;
60
+ font-family: inherit;
61
+ }
@@ -75,7 +75,50 @@
75
75
  }
76
76
  }
77
77
 
78
- .say-snippet-lists-table {
78
+ .say-snippet-list-overview {
79
+ display: flex;
80
+ flex-direction: row;
81
+ flex-wrap: nowrap;
82
+ height: 100%;
83
+ }
84
+
85
+ .say-snippet-list-overview__sidebar {
86
+ flex-basis: 30rem;
87
+ padding: $au-unit;
88
+ height: 100%;
89
+ min-width: 0;
90
+ flex-grow: 0;
91
+ flex-shrink: 0;
92
+ background-color: var(--au-gray-100);
93
+ border-right: 1px solid $au-sidebar-border;
94
+ }
95
+
96
+ .say-snippet-list-overview__form {
97
+ display: flex;
98
+ flex-direction: column;
99
+ margin-top: $au-unit;
100
+ gap: $au-unit;
101
+ }
102
+
103
+ .say-snippet-list-overview__tag-selector {
104
+ width: 100%;
105
+ }
106
+
107
+ .say-snippet-list-overview__reset-filters-button {
108
+ align-self: flex-end;
109
+ padding: 0;
110
+ }
111
+
112
+ .say-snippet-list-overview__content {
113
+ flex-grow: 1;
114
+ height: 100%;
115
+ display: flex;
116
+ flex-direction: column;
117
+ }
118
+
119
+ .say-snippet-list-overview__table {
120
+ flex-grow: 1;
121
+ min-height: 0;
79
122
  .au-c-table-wrapper {
80
123
  margin-top: 20px;
81
124
  margin-right: 100px;
@@ -0,0 +1,26 @@
1
+ import Component from '@glimmer/component';
2
+ import { Tag } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/common/tags/types';
3
+ type Args = {
4
+ tags: Tag[];
5
+ };
6
+ export default class CollapsibleTagList extends Component<Args> {
7
+ visibleCount: number;
8
+ isExpanded: boolean;
9
+ containerElement: HTMLElement | null;
10
+ resizeObserver: ResizeObserver | null;
11
+ get tags(): Tag[];
12
+ get visibleTags(): Tag[];
13
+ get hiddenCount(): number;
14
+ get showMorePill(): boolean;
15
+ containerModifier: import("ember-modifier").FunctionBasedModifier<{
16
+ Args: {
17
+ Positional: unknown[];
18
+ Named: import("ember-modifier/-private/signature.js").EmptyObject;
19
+ };
20
+ Element: HTMLElement;
21
+ }>;
22
+ expand: () => void;
23
+ collapse: () => void;
24
+ recalculate: () => void;
25
+ }
26
+ export {};
@@ -0,0 +1,31 @@
1
+ import Component from '@glimmer/component';
2
+ import { Tag } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/common/tags/types';
3
+ import IntlService from 'ember-intl/services/intl';
4
+ type Signature<T extends Tag> = {
5
+ Args: {
6
+ tags: T[];
7
+ selectedTags?: T[];
8
+ onChange: (tags: T[]) => void;
9
+ } & ({
10
+ allowTagCreation?: false;
11
+ tagConstructor?: never;
12
+ } | {
13
+ allowTagCreation: true;
14
+ tagConstructor: (newTag: NewTag) => T;
15
+ });
16
+ Element: HTMLElement;
17
+ };
18
+ export type NewTag = {
19
+ value: string;
20
+ optionType: 'new';
21
+ searchTerm?: string;
22
+ };
23
+ type SelectorOption<T extends Tag> = T | NewTag;
24
+ export default class TagSelector<T extends Tag> extends Component<Signature<T>> {
25
+ intl: IntlService;
26
+ searchTerm: string | null;
27
+ changeSelection: (selectedTags: SelectorOption<T>[]) => void;
28
+ get options(): SelectorOption<T>[];
29
+ setSearchTerm: (term: string) => void;
30
+ }
31
+ export {};
@@ -1,6 +1,7 @@
1
1
  import Component from '@glimmer/component';
2
2
  import { OrderBy } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin/utils/fetch-data';
3
3
  import { SnippetPluginConfig, SnippetList } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
4
+ import { TagWithUri } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/common/tags/types';
4
5
  interface Signature {
5
6
  Args: {
6
7
  config: SnippetPluginConfig;
@@ -13,16 +14,21 @@ interface Signature {
13
14
  }
14
15
  export default class SnippetListModalComponent extends Component<Signature> {
15
16
  nameFilterText: string | null;
17
+ selectedTags: TagWithUri[];
16
18
  sort: OrderBy;
17
19
  error: unknown;
18
20
  snippetListUris: string[];
19
21
  allowMultipleSnippets: boolean;
20
22
  handleMultipleSnippetsCheckbox(checked: boolean): void;
23
+ setNameFilterText: (event: Event) => void;
24
+ setSelectedTags: (tags: TagWithUri[]) => void;
25
+ resetFilters: () => void;
21
26
  get config(): SnippetPluginConfig;
22
27
  closeModal(): void;
23
28
  saveAndClose(): void;
24
29
  snippetListSearch: import("ember-concurrency").TaskForAsyncTaskFunction<unknown, () => Promise<SnippetList[]>>;
25
30
  snippetListResource: import("reactiveweb/ember-concurrency").TaskInstance<SnippetList[]>;
31
+ tags: import("reactiveweb/function").State<Promise<TagWithUri[]>>;
26
32
  onChange(snippetListUris: string[]): void;
27
33
  }
28
34
  export {};
@@ -1,15 +1,19 @@
1
1
  import Component from '@glimmer/component';
2
2
  import { SnippetList } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
3
- interface Args {
4
- snippetLists: SnippetList[];
5
- snippetListUris: string[];
6
- listNameFilter: string | null;
7
- isLoading: boolean;
8
- onChange: (snippetListUris: string[]) => void;
3
+ import { OrderBy } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin/utils/fetch-data';
4
+ interface Signature {
5
+ Args: {
6
+ snippetLists?: SnippetList[] | null;
7
+ snippetListUris: string[];
8
+ listNameFilter: string | null;
9
+ isLoading: boolean;
10
+ onChange: (snippetListUris: string[]) => void;
11
+ sort: OrderBy;
12
+ };
9
13
  }
10
- export default class SnippetListViewComponent extends Component<Args> {
14
+ export default class SnippetListView extends Component<Signature> {
11
15
  onChange(snippetUri: string, isSelected: boolean): void;
12
16
  onClickRow(snippetList: SnippetList, event: Event): void;
13
- get snippetLists(): SnippetList[];
17
+ get snippetLists(): SnippetList[] | null | undefined;
14
18
  }
15
19
  export {};
@@ -1,4 +1 @@
1
- type PositionalParams = [array: unknown[], needle: unknown];
2
- export declare function inArray([theArray, needle]: PositionalParams): boolean;
3
- declare const _default: import("@ember/component/helper").FunctionBasedHelper<PositionalParams>;
4
- export default _default;
1
+ export default function inArray(arr: unknown[], needle: unknown): boolean;
@@ -0,0 +1,12 @@
1
+ import type { TaggableResourceType, TagWithUri } from './types';
2
+ import type { Option } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
3
+ type TagFilter = {
4
+ searchTerm?: Option<string>;
5
+ taggableTypes?: TaggableResourceType[];
6
+ };
7
+ export declare const fetchTags: ({ endpoint, abortSignal, filter, }: {
8
+ endpoint: string;
9
+ abortSignal?: AbortSignal;
10
+ filter: TagFilter;
11
+ }) => Promise<TagWithUri[]>;
12
+ export {};
@@ -0,0 +1,9 @@
1
+ export type Tag = {
2
+ value: string;
3
+ };
4
+ export type TagWithUri = Tag & {
5
+ uri: string;
6
+ };
7
+ declare const SNIPPET_LIST_TYPE: "https://say.data.gift/ns/SnippetList";
8
+ export type TaggableResourceType = typeof SNIPPET_LIST_TYPE;
9
+ export {};