@lblod/ember-rdfa-editor-lblod-plugins 22.4.0 → 22.4.1-dev.231e70cba3693ffca0bf8b8cfa53c06efaf0e451
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/.changeset/mighty-guests-peel.md +5 -0
- package/.changeset/yellow-tables-live.md +5 -0
- package/CHANGELOG.md +6 -0
- package/addon/components/lmb-plugin/list.hbs +1 -1
- package/addon/components/lmb-plugin/search-modal.hbs +10 -7
- package/addon/components/lmb-plugin/search-modal.ts +8 -1
- package/addon/components/snippet-plugin/nodes/snippet.gts +17 -30
- package/addon/components/snippet-plugin/search-modal.ts +1 -1
- package/addon/components/snippet-plugin/snippet-insert-placeholder.gts +15 -14
- package/addon/components/snippet-plugin/snippet-insert-rdfa.gts +82 -0
- package/addon/components/snippet-plugin/snippet-insert.gts +109 -0
- package/addon/components/snippet-plugin/snippet-list/snippet-list-modal.hbs +1 -1
- package/addon/components/snippet-plugin/snippet-list/snippet-list-modal.ts +8 -11
- package/addon/components/snippet-plugin/snippet-list/snippet-list-view.hbs +4 -1
- package/addon/components/snippet-plugin/snippet-list-select-rdfa.gts +25 -0
- package/addon/components/snippet-plugin/snippet-list-select.gts +104 -0
- package/addon/plugins/lmb-plugin/utils/fetchMandatees.ts +7 -18
- package/addon/plugins/snippet-plugin/commands/index.ts +1 -1
- package/addon/plugins/snippet-plugin/commands/{update-snippet-ids.ts → update-snippet-placeholder.ts} +23 -12
- package/addon/plugins/snippet-plugin/index.ts +19 -11
- package/addon/plugins/snippet-plugin/nodes/snippet-placeholder.ts +27 -9
- package/addon/plugins/snippet-plugin/nodes/snippet.ts +160 -2
- package/addon/plugins/snippet-plugin/utils/collate-imported-resources.ts +22 -0
- package/addon/plugins/snippet-plugin/utils/fetch-data.ts +52 -36
- package/addon/plugins/snippet-plugin/utils/rdfa-predicate.ts +3 -15
- package/addon/utils/sparql-helpers.ts +3 -4
- package/addon/utils/strings.ts +13 -0
- package/declarations/addon/components/snippet-plugin/nodes/snippet.d.ts +1 -1
- package/declarations/addon/components/snippet-plugin/search-modal.d.ts +1 -1
- package/declarations/addon/components/snippet-plugin/snippet-insert-placeholder.d.ts +2 -2
- package/declarations/addon/components/snippet-plugin/snippet-insert-rdfa.d.ts +13 -13
- package/declarations/addon/components/snippet-plugin/snippet-insert.d.ts +13 -9
- package/declarations/addon/components/snippet-plugin/snippet-list/snippet-list-modal.d.ts +2 -2
- package/declarations/addon/components/snippet-plugin/snippet-list-select-rdfa.d.ts +15 -19
- package/declarations/addon/components/snippet-plugin/snippet-list-select.d.ts +13 -5
- package/declarations/addon/plugins/snippet-plugin/commands/index.d.ts +1 -1
- package/declarations/addon/plugins/snippet-plugin/commands/update-snippet-placeholder.d.ts +11 -0
- package/declarations/addon/plugins/snippet-plugin/index.d.ts +12 -8
- package/declarations/addon/plugins/snippet-plugin/nodes/snippet-placeholder.d.ts +5 -1
- package/declarations/addon/plugins/snippet-plugin/nodes/snippet.d.ts +27 -2
- package/declarations/addon/plugins/snippet-plugin/utils/collate-imported-resources.d.ts +2 -0
- package/declarations/addon/plugins/snippet-plugin/utils/fetch-data.d.ts +0 -1
- package/declarations/addon/plugins/snippet-plugin/utils/rdfa-predicate.d.ts +1 -1
- package/declarations/addon/utils/sparql-helpers.d.ts +5 -3
- package/declarations/addon/utils/strings.d.ts +2 -0
- package/package.json +3 -3
- package/pnpm-lock.yaml +29 -29
- package/translations/en-US.yaml +1 -0
- package/translations/nl-BE.yaml +1 -0
- package/addon/components/snippet-plugin/snippet-insert-rdfa.hbs +0 -7
- package/addon/components/snippet-plugin/snippet-insert-rdfa.ts +0 -78
- package/addon/components/snippet-plugin/snippet-insert.hbs +0 -20
- package/addon/components/snippet-plugin/snippet-insert.ts +0 -95
- package/addon/components/snippet-plugin/snippet-list-select-rdfa.hbs +0 -8
- package/addon/components/snippet-plugin/snippet-list-select-rdfa.ts +0 -68
- package/addon/components/snippet-plugin/snippet-list-select.hbs +0 -17
- package/addon/components/snippet-plugin/snippet-list-select.ts +0 -29
- package/declarations/addon/plugins/snippet-plugin/commands/update-snippet-ids.d.ts +0 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @lblod/ember-rdfa-editor-lblod-plugins
|
|
2
2
|
|
|
3
|
+
## 22.4.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#474](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/474) [`714f260`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/714f260e2c9024fe8ea3f031b42b746fd2ac0c26) Thanks [@elpoelma](https://github.com/elpoelma)! - LMB-plugin: query mandatees using `application/x-www-form-urlencoded` approach
|
|
8
|
+
|
|
3
9
|
## 22.4.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
|
@@ -36,13 +36,16 @@
|
|
|
36
36
|
</mc.sidebar>
|
|
37
37
|
<mc.content @scroll={{true}}>
|
|
38
38
|
<div class='worship-modal--list-container'>
|
|
39
|
-
|
|
40
|
-
@error={{this.error}}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
{{#if this.error}}
|
|
40
|
+
<Common::Search::AlertLoadError @error={{this.error}} />
|
|
41
|
+
{{else}}
|
|
42
|
+
<LmbPlugin::List
|
|
43
|
+
@services={{this.servicesResource}}
|
|
44
|
+
@sort={{this.sort}}
|
|
45
|
+
@setSort={{this.setSort}}
|
|
46
|
+
@insert={{@onInsert}}
|
|
47
|
+
/>
|
|
48
|
+
{{/if}}
|
|
46
49
|
</div>
|
|
47
50
|
{{#if this.servicesResource.value.totalCount}}
|
|
48
51
|
{{#let
|
|
@@ -42,10 +42,17 @@ export default class LmbPluginSearchModalComponent extends Component<Args> {
|
|
|
42
42
|
return fetchMandatees({ endpoint: this.args.config.endpoint });
|
|
43
43
|
});
|
|
44
44
|
|
|
45
|
+
// TODO Either make this a trackedFunction or do filtering on the query and correctly pass an
|
|
46
|
+
// AbortController
|
|
45
47
|
search = restartableTask(async () => {
|
|
46
48
|
// Can't do what I want, so if the user modifies the filter before resolving the query will run again
|
|
47
49
|
if (!this.fetchData.lastComplete) {
|
|
48
|
-
|
|
50
|
+
try {
|
|
51
|
+
await this.fetchData.perform();
|
|
52
|
+
} catch (err) {
|
|
53
|
+
console.error('Got an error fetching LMB data', err);
|
|
54
|
+
this.error = err;
|
|
55
|
+
}
|
|
49
56
|
}
|
|
50
57
|
|
|
51
58
|
if (!this.fetchData.lastComplete?.value) return;
|
|
@@ -1,29 +1,27 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
2
|
import { on } from '@ember/modifier';
|
|
3
|
-
import AuIcon from '@appuniversum/ember-appuniversum/components/au-icon';
|
|
4
|
-
import { type EmberNodeArgs } from '@lblod/ember-rdfa-editor/utils/_private/ember-node';
|
|
5
3
|
import SearchModal from '../search-modal';
|
|
6
4
|
import { tracked } from '@glimmer/tracking';
|
|
7
5
|
import { action } from '@ember/object';
|
|
6
|
+
import t from 'ember-intl/helpers/t';
|
|
7
|
+
import AuIcon from '@appuniversum/ember-appuniversum/components/au-icon';
|
|
8
8
|
import { SynchronizeIcon } from '@appuniversum/ember-appuniversum/components/icons/synchronize';
|
|
9
9
|
import { BinIcon } from '@appuniversum/ember-appuniversum/components/icons/bin';
|
|
10
10
|
import { AddIcon } from '@appuniversum/ember-appuniversum/components/icons/add';
|
|
11
|
+
import { type EmberNodeArgs } from '@lblod/ember-rdfa-editor/utils/_private/ember-node';
|
|
11
12
|
import {
|
|
12
|
-
PNode,
|
|
13
|
+
type PNode,
|
|
13
14
|
ProseParser,
|
|
14
|
-
Selection,
|
|
15
|
+
type Selection,
|
|
15
16
|
Slice,
|
|
16
|
-
Transaction,
|
|
17
17
|
} from '@lblod/ember-rdfa-editor';
|
|
18
|
-
import {
|
|
18
|
+
import { findAncestors } from '@lblod/ember-rdfa-editor/utils/position-utils';
|
|
19
19
|
import {
|
|
20
20
|
EXT,
|
|
21
21
|
RDF,
|
|
22
22
|
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
|
|
23
|
-
import { findAncestors } from '@lblod/ember-rdfa-editor/utils/position-utils';
|
|
24
23
|
import { hasOutgoingNamedNodeTriple } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
|
|
25
|
-
import {
|
|
26
|
-
import t from 'ember-intl/helpers/t';
|
|
24
|
+
import { createAndInsertSnippet } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin/nodes/snippet';
|
|
27
25
|
|
|
28
26
|
interface Signature {
|
|
29
27
|
Args: EmberNodeArgs;
|
|
@@ -91,7 +89,6 @@ export default class SnippetNode extends Component<Signature> {
|
|
|
91
89
|
}
|
|
92
90
|
@action
|
|
93
91
|
onInsert(content: string, title: string) {
|
|
94
|
-
const assignedSnippetListsIds = this.node.attrs.assignedSnippetListsIds;
|
|
95
92
|
let rangeStart = 0;
|
|
96
93
|
let rangeEnd = 0;
|
|
97
94
|
if (this.args.getPos() === undefined) return;
|
|
@@ -110,28 +107,18 @@ export default class SnippetNode extends Component<Signature> {
|
|
|
110
107
|
const documentDiv = parsed.querySelector('div[data-say-document="true"]');
|
|
111
108
|
|
|
112
109
|
this.closeModal();
|
|
113
|
-
const parser = ProseParser.fromSchema(this.controller.schema);
|
|
114
110
|
|
|
115
111
|
if (documentDiv) {
|
|
116
|
-
return
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
},
|
|
127
|
-
htmlToDoc(content, {
|
|
128
|
-
schema: this.controller.schema,
|
|
129
|
-
parser,
|
|
130
|
-
editorView: this.controller.mainEditorView,
|
|
131
|
-
}).content,
|
|
132
|
-
),
|
|
133
|
-
);
|
|
134
|
-
});
|
|
112
|
+
return createAndInsertSnippet(
|
|
113
|
+
{
|
|
114
|
+
controller: this.controller,
|
|
115
|
+
content,
|
|
116
|
+
title,
|
|
117
|
+
snippetListIds: this.node.attrs.assignedSnippetListsIds,
|
|
118
|
+
importedResources: this.node.attrs.importedResources,
|
|
119
|
+
},
|
|
120
|
+
(tr, snippet) => tr.replaceRangeWith(rangeStart, rangeEnd, snippet),
|
|
121
|
+
);
|
|
135
122
|
}
|
|
136
123
|
|
|
137
124
|
this.controller.withTransaction((tr) =>
|
|
@@ -11,7 +11,7 @@ import { SnippetPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plug
|
|
|
11
11
|
|
|
12
12
|
interface Args {
|
|
13
13
|
config: SnippetPluginConfig;
|
|
14
|
-
assignedSnippetListsIds: string[];
|
|
14
|
+
assignedSnippetListsIds: string[] | undefined;
|
|
15
15
|
closeModal: () => void;
|
|
16
16
|
open: boolean;
|
|
17
17
|
onInsert: (content: string, title: string) => void;
|
|
@@ -7,7 +7,10 @@ import not from 'ember-truth-helpers/helpers/not';
|
|
|
7
7
|
import AuButton from '@appuniversum/ember-appuniversum/components/au-button';
|
|
8
8
|
import { AddIcon } from '@appuniversum/ember-appuniversum/components/icons/add';
|
|
9
9
|
import { type NodeType, type SayController } from '@lblod/ember-rdfa-editor';
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
type SnippetPluginConfig,
|
|
12
|
+
type SnippetList,
|
|
13
|
+
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
|
|
11
14
|
import { createSnippetPlaceholder } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin/nodes/snippet-placeholder';
|
|
12
15
|
import SnippetListModal from '@lblod/ember-rdfa-editor-lblod-plugins/components/snippet-plugin/snippet-list/snippet-list-modal';
|
|
13
16
|
|
|
@@ -35,19 +38,17 @@ export default class SnippetPluginSnippetInsertPlaceholder extends Component<Sig
|
|
|
35
38
|
}
|
|
36
39
|
|
|
37
40
|
@action
|
|
38
|
-
insertPlaceholder(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
listNames,
|
|
42
|
-
this.args.controller.schema,
|
|
43
|
-
);
|
|
41
|
+
insertPlaceholder(lists: SnippetList[] | undefined) {
|
|
42
|
+
if (lists) {
|
|
43
|
+
const node = createSnippetPlaceholder(lists, this.args.controller.schema);
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
this.args.controller.withTransaction(
|
|
46
|
+
(tr) => {
|
|
47
|
+
return tr.replaceSelectionWith(node);
|
|
48
|
+
},
|
|
49
|
+
{ view: this.args.controller.mainEditorView },
|
|
50
|
+
);
|
|
51
|
+
}
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
<template>
|
|
@@ -65,7 +66,7 @@ export default class SnippetPluginSnippetInsertPlaceholder extends Component<Sig
|
|
|
65
66
|
<SnippetListModal
|
|
66
67
|
@config={{@config}}
|
|
67
68
|
@assignedSnippetListsIds={{empty}}
|
|
68
|
-
@
|
|
69
|
+
@onSaveSnippetLists={{this.insertPlaceholder}}
|
|
69
70
|
@open={{this.isModalOpen}}
|
|
70
71
|
@closeModal={{this.closeModal}}
|
|
71
72
|
/>
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { isResourceNode } from '@lblod/ember-rdfa-editor/utils/node-utils';
|
|
2
|
+
import Component from '@glimmer/component';
|
|
3
|
+
|
|
4
|
+
import { SayController } from '@lblod/ember-rdfa-editor';
|
|
5
|
+
import {
|
|
6
|
+
type ImportedResourceMap,
|
|
7
|
+
type SnippetPluginConfig,
|
|
8
|
+
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
|
|
9
|
+
import { findParentNodeClosestToPos } from '@curvenote/prosemirror-utils';
|
|
10
|
+
import {
|
|
11
|
+
getAssignedSnippetListsIdsFromProperties,
|
|
12
|
+
getSnippetListIdsProperties,
|
|
13
|
+
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin/utils/rdfa-predicate';
|
|
14
|
+
import { ResolvedPNode } from '@lblod/ember-rdfa-editor/utils/_private/types';
|
|
15
|
+
import SnippetInsert from './snippet-insert';
|
|
16
|
+
|
|
17
|
+
interface Sig {
|
|
18
|
+
Args: {
|
|
19
|
+
controller: SayController;
|
|
20
|
+
config: SnippetPluginConfig;
|
|
21
|
+
node: ResolvedPNode;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default class SnippetInsertRdfaComponent extends Component<Sig> {
|
|
26
|
+
get disableInsert() {
|
|
27
|
+
return (this.snippetListProperties?.listIds.length ?? 0) === 0;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
get snippetListProperties():
|
|
31
|
+
| { listIds: string[]; importedResources: ImportedResourceMap }
|
|
32
|
+
| undefined {
|
|
33
|
+
const activeNode = this.args.node.value;
|
|
34
|
+
const activeNodeSnippetListIds = getSnippetListIdsProperties(activeNode);
|
|
35
|
+
|
|
36
|
+
if (activeNodeSnippetListIds.length > 0) {
|
|
37
|
+
return {
|
|
38
|
+
listIds: getAssignedSnippetListsIdsFromProperties(
|
|
39
|
+
activeNodeSnippetListIds,
|
|
40
|
+
),
|
|
41
|
+
importedResources: activeNode.attrs.importedResources,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (this.args.node.pos < 0) {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// If active node isn't a snippet list, go up until we find one
|
|
50
|
+
const doc = this.args.controller.mainEditorState.doc;
|
|
51
|
+
const pos = doc.resolve(this.args.node.pos);
|
|
52
|
+
let parentNode = findParentNodeClosestToPos(pos, (node) =>
|
|
53
|
+
isResourceNode(node),
|
|
54
|
+
);
|
|
55
|
+
while (parentNode) {
|
|
56
|
+
const properties = getSnippetListIdsProperties(parentNode.node);
|
|
57
|
+
|
|
58
|
+
if (properties.length > 0) {
|
|
59
|
+
return {
|
|
60
|
+
listIds: getAssignedSnippetListsIdsFromProperties(properties),
|
|
61
|
+
importedResources: parentNode.node.attrs.importedResources,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
parentNode = findParentNodeClosestToPos(
|
|
66
|
+
doc.resolve(parentNode.pos),
|
|
67
|
+
(node) => isResourceNode(node),
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
<template>
|
|
75
|
+
<SnippetInsert
|
|
76
|
+
@config={{@config}}
|
|
77
|
+
@controller={{@controller}}
|
|
78
|
+
@snippetListProperties={{this.snippetListProperties}}
|
|
79
|
+
@disabled={{this.disableInsert}}
|
|
80
|
+
/>
|
|
81
|
+
</template>
|
|
82
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { action } from '@ember/object';
|
|
2
|
+
import { on } from '@ember/modifier';
|
|
3
|
+
import Component from '@glimmer/component';
|
|
4
|
+
import { tracked } from '@glimmer/tracking';
|
|
5
|
+
import t from 'ember-intl/helpers/t';
|
|
6
|
+
import { AddIcon } from '@appuniversum/ember-appuniversum/components/icons/add';
|
|
7
|
+
import AuButton from '@appuniversum/ember-appuniversum/components/au-button';
|
|
8
|
+
import {
|
|
9
|
+
ProseParser,
|
|
10
|
+
type SayController,
|
|
11
|
+
Slice,
|
|
12
|
+
} from '@lblod/ember-rdfa-editor';
|
|
13
|
+
import { SnippetPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
|
|
14
|
+
import { createAndInsertSnippet } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin/nodes/snippet';
|
|
15
|
+
import { type ImportedResourceMap } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
|
|
16
|
+
import SearchModal from './search-modal';
|
|
17
|
+
|
|
18
|
+
interface Sig {
|
|
19
|
+
Args: {
|
|
20
|
+
controller: SayController;
|
|
21
|
+
config: SnippetPluginConfig;
|
|
22
|
+
snippetListProperties:
|
|
23
|
+
| { listIds: string[]; importedResources: ImportedResourceMap }
|
|
24
|
+
| undefined;
|
|
25
|
+
disabled?: boolean;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default class SnippetInsertComponent extends Component<Sig> {
|
|
30
|
+
@tracked showModal = false;
|
|
31
|
+
|
|
32
|
+
get controller() {
|
|
33
|
+
return this.args.controller;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@action
|
|
37
|
+
openModal() {
|
|
38
|
+
this.controller.focus();
|
|
39
|
+
this.showModal = true;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@action
|
|
43
|
+
closeModal() {
|
|
44
|
+
this.showModal = false;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
createSliceFromElement(element: Element) {
|
|
48
|
+
return new Slice(
|
|
49
|
+
ProseParser.fromSchema(this.controller.schema).parse(element, {
|
|
50
|
+
preserveWhitespace: true,
|
|
51
|
+
}).content,
|
|
52
|
+
0,
|
|
53
|
+
0,
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@action
|
|
58
|
+
onInsert(content: string, title: string) {
|
|
59
|
+
const domParser = new DOMParser();
|
|
60
|
+
const parsed = domParser.parseFromString(content, 'text/html').body;
|
|
61
|
+
const documentDiv = parsed.querySelector('div[data-say-document="true"]');
|
|
62
|
+
|
|
63
|
+
this.closeModal();
|
|
64
|
+
const assignedSnippetListProperties = this.args.snippetListProperties;
|
|
65
|
+
|
|
66
|
+
if (documentDiv && assignedSnippetListProperties) {
|
|
67
|
+
return createAndInsertSnippet(
|
|
68
|
+
{
|
|
69
|
+
controller: this.controller,
|
|
70
|
+
content,
|
|
71
|
+
title,
|
|
72
|
+
snippetListIds: assignedSnippetListProperties.listIds,
|
|
73
|
+
importedResources: assignedSnippetListProperties.importedResources,
|
|
74
|
+
},
|
|
75
|
+
(tr, snippet) => tr.replaceSelectionWith(snippet),
|
|
76
|
+
);
|
|
77
|
+
} else {
|
|
78
|
+
return this.controller.withTransaction((tr) =>
|
|
79
|
+
tr.replaceSelection(this.createSliceFromElement(parsed)),
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
get disabled() {
|
|
85
|
+
return this.args.disabled ?? false;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
<template>
|
|
89
|
+
<li class='au-c-list__item'>
|
|
90
|
+
<AuButton
|
|
91
|
+
@icon={{AddIcon}}
|
|
92
|
+
@iconAlignment='left'
|
|
93
|
+
@skin='link'
|
|
94
|
+
@disabled={{this.disabled}}
|
|
95
|
+
{{on 'click' this.openModal}}
|
|
96
|
+
>
|
|
97
|
+
{{t 'snippet-plugin.insert.title'}}
|
|
98
|
+
</AuButton>
|
|
99
|
+
</li>
|
|
100
|
+
|
|
101
|
+
<SearchModal
|
|
102
|
+
@open={{this.showModal}}
|
|
103
|
+
@closeModal={{this.closeModal}}
|
|
104
|
+
@config={{@config}}
|
|
105
|
+
@onInsert={{this.onInsert}}
|
|
106
|
+
@assignedSnippetListsIds={{@snippetListProperties.listIds}}
|
|
107
|
+
/>
|
|
108
|
+
</template>
|
|
109
|
+
}
|
|
@@ -19,8 +19,8 @@ import { trackedReset } from 'tracked-toolbox';
|
|
|
19
19
|
interface Signature {
|
|
20
20
|
Args: {
|
|
21
21
|
config: SnippetPluginConfig;
|
|
22
|
-
|
|
23
|
-
assignedSnippetListsIds: string[];
|
|
22
|
+
onSaveSnippetLists: (lists: SnippetList[]) => void;
|
|
23
|
+
assignedSnippetListsIds: string[] | undefined;
|
|
24
24
|
closeModal: () => void;
|
|
25
25
|
open: boolean;
|
|
26
26
|
};
|
|
@@ -37,7 +37,9 @@ export default class SnippetListModalComponent extends Component<Signature> {
|
|
|
37
37
|
@tracked error: unknown;
|
|
38
38
|
|
|
39
39
|
@trackedReset('args.assignedSnippetListsIds')
|
|
40
|
-
assignedSnippetListsIds: string[] = [
|
|
40
|
+
assignedSnippetListsIds: string[] = [
|
|
41
|
+
...(this.args.assignedSnippetListsIds ?? []),
|
|
42
|
+
];
|
|
41
43
|
|
|
42
44
|
get config() {
|
|
43
45
|
return this.args.config;
|
|
@@ -50,15 +52,10 @@ export default class SnippetListModalComponent extends Component<Signature> {
|
|
|
50
52
|
|
|
51
53
|
@action
|
|
52
54
|
saveAndClose() {
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
this.assignedSnippetListsIds.includes(snippetList.id as string),
|
|
56
|
-
)
|
|
57
|
-
.map((snippetList) => snippetList.label) as string[];
|
|
58
|
-
this.args.onSaveSnippetListIds(
|
|
59
|
-
this.assignedSnippetListsIds,
|
|
60
|
-
snippetListNames,
|
|
55
|
+
const snippetLists = this.snippetListResource.value?.filter((snippetList) =>
|
|
56
|
+
this.assignedSnippetListsIds.includes(snippetList.id),
|
|
61
57
|
);
|
|
58
|
+
this.args.onSaveSnippetLists(snippetLists || []);
|
|
62
59
|
this.args.closeModal();
|
|
63
60
|
// Clear selection for next time
|
|
64
61
|
this.assignedSnippetListsIds = [];
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
(t 'snippet-plugin.snippet-list.modal.table.select')
|
|
7
7
|
(t 'snippet-plugin.snippet-list.modal.subtitle')
|
|
8
8
|
(t 'snippet-plugin.snippet-list.modal.search.label')
|
|
9
|
-
|
|
9
|
+
(t 'snippet-plugin.snippet-list.modal.table.imported-resources')
|
|
10
|
+
as |list created select subtitle search imported|
|
|
10
11
|
}}
|
|
11
12
|
<AuDataTable
|
|
12
13
|
@content={{this.snippetLists}}
|
|
@@ -39,6 +40,7 @@
|
|
|
39
40
|
@currentSorting={{@sort}}
|
|
40
41
|
@class='data-table__header-title'
|
|
41
42
|
/>
|
|
43
|
+
<th>{{imported}}</th>
|
|
42
44
|
<AuDataTableThSortable
|
|
43
45
|
@field='createdOn'
|
|
44
46
|
@label={{created}}
|
|
@@ -55,6 +57,7 @@
|
|
|
55
57
|
/>
|
|
56
58
|
</td>
|
|
57
59
|
<td>{{row.label}}</td>
|
|
60
|
+
<td>{{row.importedResources}}</td>
|
|
58
61
|
<td class='snippet-list-table-created-column'>{{row.createdOn}}</td>
|
|
59
62
|
</c.body>
|
|
60
63
|
</t.content>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { TemplateOnlyComponent } from '@ember/component/template-only';
|
|
2
|
+
import { SayController } from '@lblod/ember-rdfa-editor';
|
|
3
|
+
import { type ResolvedPNode } from '@lblod/ember-rdfa-editor/utils/_private/types';
|
|
4
|
+
import { type SnippetPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
|
|
5
|
+
import SnippetListSelect from '@lblod/ember-rdfa-editor-lblod-plugins/components/snippet-plugin/snippet-list-select';
|
|
6
|
+
|
|
7
|
+
interface Sig {
|
|
8
|
+
Args: {
|
|
9
|
+
controller: SayController;
|
|
10
|
+
config: SnippetPluginConfig;
|
|
11
|
+
node: ResolvedPNode;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** @deprecated Use snippet-list-select directly */
|
|
16
|
+
const SnippetListSelectRdfaComponent: TemplateOnlyComponent<Sig> = <template>
|
|
17
|
+
<SnippetListSelect
|
|
18
|
+
@controller={{@controller}}
|
|
19
|
+
@config={{@config}}
|
|
20
|
+
@node={{@node}}
|
|
21
|
+
/>
|
|
22
|
+
</template>;
|
|
23
|
+
|
|
24
|
+
/** @deprecated Use snippet-list-select directly */
|
|
25
|
+
export default SnippetListSelectRdfaComponent;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { action } from '@ember/object';
|
|
2
|
+
import Component from '@glimmer/component';
|
|
3
|
+
import { tracked } from '@glimmer/tracking';
|
|
4
|
+
import { on } from '@ember/modifier';
|
|
5
|
+
import t from 'ember-intl/helpers/t';
|
|
6
|
+
import { UnorderedListIcon } from '@appuniversum/ember-appuniversum/components/icons/unordered-list';
|
|
7
|
+
import AuButton from '@appuniversum/ember-appuniversum/components/au-button';
|
|
8
|
+
import { type SayController } from '@lblod/ember-rdfa-editor';
|
|
9
|
+
import { type ResolvedPNode } from '@lblod/ember-rdfa-editor/utils/_private/types';
|
|
10
|
+
import { isResourceNode } from '@lblod/ember-rdfa-editor/utils/node-utils';
|
|
11
|
+
import { type OutgoingTriple } from '@lblod/ember-rdfa-editor/core/rdfa-processor';
|
|
12
|
+
import SnippetListModal from '@lblod/ember-rdfa-editor-lblod-plugins/components/snippet-plugin/snippet-list/snippet-list-modal';
|
|
13
|
+
import {
|
|
14
|
+
type ImportedResourceMap,
|
|
15
|
+
type SnippetPluginConfig,
|
|
16
|
+
type SnippetList,
|
|
17
|
+
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
|
|
18
|
+
import {
|
|
19
|
+
getAssignedSnippetListsIdsFromProperties,
|
|
20
|
+
getSnippetListIdsProperties,
|
|
21
|
+
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin/utils/rdfa-predicate';
|
|
22
|
+
import { updateSnippetPlaceholder } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin/commands';
|
|
23
|
+
|
|
24
|
+
interface Signature {
|
|
25
|
+
Args: {
|
|
26
|
+
controller: SayController;
|
|
27
|
+
config: SnippetPluginConfig;
|
|
28
|
+
node: ResolvedPNode;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default class SnippetListSelect extends Component<Signature> {
|
|
33
|
+
@tracked showModal = false;
|
|
34
|
+
|
|
35
|
+
@action
|
|
36
|
+
openModal() {
|
|
37
|
+
this.showModal = true;
|
|
38
|
+
}
|
|
39
|
+
@action
|
|
40
|
+
closeModal() {
|
|
41
|
+
this.showModal = false;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
get currentResource() {
|
|
45
|
+
return this.args.node.value.attrs.subject as string | undefined;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
get isResourceNode() {
|
|
49
|
+
return isResourceNode(this.args.node.value);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
get snippetListIdsProperties(): OutgoingTriple[] {
|
|
53
|
+
return getSnippetListIdsProperties(this.args.node.value);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
get assignedSnippetListsIds(): string[] {
|
|
57
|
+
return getAssignedSnippetListsIdsFromProperties(
|
|
58
|
+
this.snippetListIdsProperties,
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
get imported(): ImportedResourceMap {
|
|
63
|
+
return this.args.node.value.attrs['importedResources'];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@action
|
|
67
|
+
onSaveSnippetLists(lists: SnippetList[]) {
|
|
68
|
+
if (this.currentResource) {
|
|
69
|
+
this.args.controller?.doCommand(
|
|
70
|
+
updateSnippetPlaceholder({
|
|
71
|
+
resource: this.currentResource,
|
|
72
|
+
oldSnippetProperties: this.snippetListIdsProperties ?? [],
|
|
73
|
+
newSnippetLists: lists,
|
|
74
|
+
oldImportedResources: this.imported,
|
|
75
|
+
node: this.args.node,
|
|
76
|
+
}),
|
|
77
|
+
{
|
|
78
|
+
view: this.args.controller.mainEditorView,
|
|
79
|
+
},
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
<template>
|
|
85
|
+
{{#if this.isResourceNode}}
|
|
86
|
+
<AuButton
|
|
87
|
+
@icon={{UnorderedListIcon}}
|
|
88
|
+
@skin='secondary'
|
|
89
|
+
@iconAlignment='left'
|
|
90
|
+
{{on 'click' this.openModal}}
|
|
91
|
+
>
|
|
92
|
+
{{t 'snippet-plugin.snippet-list.open-modal'}}
|
|
93
|
+
</AuButton>
|
|
94
|
+
|
|
95
|
+
<SnippetListModal
|
|
96
|
+
@config={{@config}}
|
|
97
|
+
@assignedSnippetListsIds={{this.assignedSnippetListsIds}}
|
|
98
|
+
@onSaveSnippetLists={{this.onSaveSnippetLists}}
|
|
99
|
+
@open={{this.showModal}}
|
|
100
|
+
@closeModal={{this.closeModal}}
|
|
101
|
+
/>
|
|
102
|
+
{{/if}}
|
|
103
|
+
</template>
|
|
104
|
+
}
|
|
@@ -1,24 +1,12 @@
|
|
|
1
1
|
import Mandatee from '@lblod/ember-rdfa-editor-lblod-plugins/models/mandatee';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
type SparqlResponse = {
|
|
5
|
-
results: {
|
|
6
|
-
bindings: IBindings[];
|
|
7
|
-
};
|
|
8
|
-
};
|
|
2
|
+
import { executeQuery } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/sparql-helpers';
|
|
9
3
|
|
|
10
4
|
type FetchMandateesArgs = {
|
|
11
5
|
endpoint: string;
|
|
12
6
|
};
|
|
13
7
|
|
|
14
8
|
export async function fetchMandatees({ endpoint }: FetchMandateesArgs) {
|
|
15
|
-
const
|
|
16
|
-
method: 'POST',
|
|
17
|
-
headers: {
|
|
18
|
-
'Content-Type': 'application/json',
|
|
19
|
-
},
|
|
20
|
-
body: JSON.stringify({
|
|
21
|
-
query: `
|
|
9
|
+
const query = `
|
|
22
10
|
PREFIX besluit: <http://data.vlaanderen.be/ns/besluit#>
|
|
23
11
|
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
|
|
24
12
|
PREFIX mandaat: <http://data.vlaanderen.be/ns/mandaat#>
|
|
@@ -46,10 +34,11 @@ export async function fetchMandatees({ endpoint }: FetchMandateesArgs) {
|
|
|
46
34
|
}
|
|
47
35
|
filter (!bound(?endDate) || ?endDate > now()).
|
|
48
36
|
}
|
|
49
|
-
|
|
50
|
-
|
|
37
|
+
`;
|
|
38
|
+
const response = await executeQuery({
|
|
39
|
+
query,
|
|
40
|
+
endpoint,
|
|
51
41
|
});
|
|
52
|
-
const
|
|
53
|
-
const mandatees = queryJson.results.bindings.map(Mandatee.fromBinding);
|
|
42
|
+
const mandatees = response.results.bindings.map(Mandatee.fromBinding);
|
|
54
43
|
return mandatees;
|
|
55
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { updateSnippetPlaceholder } from './update-snippet-placeholder';
|