@lblod/ember-rdfa-editor-lblod-plugins 39.1.1 → 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.
- package/CHANGELOG.md +14 -0
- package/addon/components/common/tags/collapsible-tag-list.gts +149 -0
- package/addon/components/common/tags/tag-selector.gts +117 -0
- package/addon/components/snippet-plugin/snippet-insert-placeholder.gts +10 -8
- package/addon/components/snippet-plugin/snippet-list/snippet-list-modal.gts +278 -0
- package/addon/components/snippet-plugin/snippet-list/snippet-list-view.gts +130 -0
- package/addon/components/snippet-plugin/snippet-list-select.gts +10 -9
- package/addon/helpers/in-array.ts +3 -9
- package/addon/plugins/common/tags/queries.ts +64 -0
- package/addon/plugins/common/tags/types.ts +12 -0
- package/addon/plugins/location-plugin/_private/utils/location-helpers.ts +5 -1
- package/addon/plugins/snippet-plugin/index.ts +11 -1
- package/addon/plugins/snippet-plugin/utils/fetch-data.ts +48 -17
- package/addon/utils/get-ranked-pnodes.ts +26 -7
- package/app/components/common/tags/collapsible-tag-list.js +1 -0
- package/app/components/common/tags/tag-selector.js +1 -0
- package/app/styles/common/tags.scss +61 -0
- package/app/styles/snippet-plugin.scss +44 -1
- package/declarations/addon/components/common/tags/collapsible-tag-list.d.ts +26 -0
- package/declarations/addon/components/common/tags/tag-selector.d.ts +31 -0
- package/declarations/addon/components/snippet-plugin/snippet-list/snippet-list-modal.d.ts +6 -0
- package/declarations/addon/components/snippet-plugin/snippet-list/snippet-list-view.d.ts +12 -8
- package/declarations/addon/helpers/in-array.d.ts +1 -4
- package/declarations/addon/plugins/common/tags/queries.d.ts +12 -0
- package/declarations/addon/plugins/common/tags/types.d.ts +9 -0
- package/declarations/addon/plugins/snippet-plugin/index.d.ts +4 -1
- package/declarations/addon/plugins/snippet-plugin/utils/fetch-data.d.ts +7 -1
- package/declarations/addon/utils/get-ranked-pnodes.d.ts +10 -2
- package/package.json +1 -1
- package/translations/en-US.yaml +16 -4
- package/translations/nl-BE.yaml +16 -4
- package/addon/components/snippet-plugin/snippet-list/snippet-list-modal.hbs +0 -63
- package/addon/components/snippet-plugin/snippet-list/snippet-list-modal.ts +0 -111
- package/addon/components/snippet-plugin/snippet-list/snippet-list-view.hbs +0 -66
- 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
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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
|
-
|
|
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
|
|
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;
|
|
@@ -3,5 +3,9 @@ import { Area, Place } from './geo-helpers';
|
|
|
3
3
|
|
|
4
4
|
// For 2 addresses that are the same, the belgianAddressUri will be the same, regardless of how they were created
|
|
5
5
|
export function getLocationUri(location: Address | Place | Area) {
|
|
6
|
-
|
|
6
|
+
if ('belgianAddressUri' in location && location.belgianAddressUri) {
|
|
7
|
+
return location.belgianAddressUri;
|
|
8
|
+
} else {
|
|
9
|
+
return location.uri;
|
|
10
|
+
}
|
|
7
11
|
}
|
|
@@ -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({
|
|
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 = {
|
|
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:
|
|
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
|
|
150
|
-
?
|
|
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 { ?
|
|
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:
|
|
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
|
-
|
|
283
|
+
importedResource: binding.importedResource?.value,
|
|
284
|
+
tagUri: binding.tagUri?.value,
|
|
285
|
+
tagValue: binding.tagValue?.value,
|
|
261
286
|
}))
|
|
262
|
-
.reduce((mappedResults,
|
|
263
|
-
const existing = mappedResults.get(
|
|
264
|
-
...
|
|
287
|
+
.reduce((mappedResults, binding) => {
|
|
288
|
+
const existing = mappedResults.get(binding.uri) ?? {
|
|
289
|
+
...binding,
|
|
265
290
|
importedResources: [],
|
|
291
|
+
tags: [],
|
|
266
292
|
};
|
|
267
|
-
if (
|
|
293
|
+
if (binding.importedResource) {
|
|
268
294
|
existing.importedResources = [
|
|
269
295
|
...existing.importedResources,
|
|
270
|
-
|
|
296
|
+
binding.importedResource,
|
|
271
297
|
];
|
|
272
298
|
}
|
|
273
|
-
|
|
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
|
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { EditorState, type PNode } from '@lblod/ember-rdfa-editor';
|
|
1
|
+
import { Attrs, EditorState, type PNode } from '@lblod/ember-rdfa-editor';
|
|
2
2
|
import { ResolvedPNode } from '@lblod/ember-rdfa-editor/utils/_private/types';
|
|
3
|
+
import { Address } from '../plugins/location-plugin/_private/utils/address-helpers';
|
|
4
|
+
import { Area, Place } from '../plugins/location-plugin/utils/geo-helpers';
|
|
5
|
+
import { getLocationUri } from '../plugins/location-plugin/_private/utils/location-helpers';
|
|
3
6
|
|
|
4
7
|
type NodeMetadataType = {
|
|
5
8
|
[uri: string]: {
|
|
@@ -42,25 +45,41 @@ function getSuggestionScore(
|
|
|
42
45
|
|
|
43
46
|
return score;
|
|
44
47
|
}
|
|
48
|
+
type NodeWithLocAttrs = PNode & {
|
|
49
|
+
attrs: Attrs & { value: Address | Place | Area };
|
|
50
|
+
};
|
|
51
|
+
type ResolvedLocAttrsNode = ResolvedPNode & { value: NodeWithLocAttrs };
|
|
52
|
+
function isNodeWithLocAttrs(node: PNode): node is NodeWithLocAttrs {
|
|
53
|
+
const value = node.attrs.value;
|
|
54
|
+
if (value) {
|
|
55
|
+
if (getLocationUri(value)) {
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
45
61
|
|
|
46
62
|
export function getRankedPNodes(
|
|
47
63
|
state: EditorState,
|
|
48
64
|
nodeType: string,
|
|
49
|
-
getUri: (node:
|
|
65
|
+
getUri: (node: NodeWithLocAttrs) => string,
|
|
50
66
|
): {
|
|
51
67
|
node: ResolvedPNode;
|
|
52
68
|
score: number;
|
|
53
69
|
}[] {
|
|
54
70
|
const doc = state.doc;
|
|
55
|
-
const nodesWithDistance: { node:
|
|
71
|
+
const nodesWithDistance: { node: ResolvedLocAttrsNode; distance: number }[] =
|
|
72
|
+
[];
|
|
56
73
|
const selection = state.selection;
|
|
57
74
|
doc.descendants((node, pos) => {
|
|
58
75
|
if (node.type.name === nodeType) {
|
|
59
76
|
const distance = Math.abs(pos - selection.from);
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
77
|
+
if (isNodeWithLocAttrs(node)) {
|
|
78
|
+
nodesWithDistance.push({
|
|
79
|
+
node: { value: node, pos },
|
|
80
|
+
distance: distance,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
64
83
|
return false;
|
|
65
84
|
}
|
|
66
85
|
return true;
|
|
@@ -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-
|
|
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 {};
|