@lblod/ember-rdfa-editor-lblod-plugins 22.3.0 → 22.4.0-dev.7c676d10b8e2f941178efb9e8894fd55eab7b455

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 (57) hide show
  1. package/.changeset/mighty-guests-peel.md +5 -0
  2. package/CHANGELOG.md +10 -0
  3. package/addon/components/decision-plugin/insert-article.gts +57 -7
  4. package/addon/components/snippet-plugin/nodes/snippet.gts +17 -30
  5. package/addon/components/snippet-plugin/search-modal.ts +1 -1
  6. package/addon/components/snippet-plugin/snippet-insert-placeholder.gts +15 -14
  7. package/addon/components/snippet-plugin/snippet-insert-rdfa.gts +82 -0
  8. package/addon/components/snippet-plugin/snippet-insert.gts +109 -0
  9. package/addon/components/snippet-plugin/snippet-list/snippet-list-modal.hbs +1 -1
  10. package/addon/components/snippet-plugin/snippet-list/snippet-list-modal.ts +8 -11
  11. package/addon/components/snippet-plugin/snippet-list/snippet-list-view.hbs +4 -1
  12. package/addon/components/snippet-plugin/snippet-list-select-rdfa.gts +25 -0
  13. package/addon/components/snippet-plugin/snippet-list-select.gts +104 -0
  14. package/addon/plugins/location-plugin/utils/geo-helpers.ts +5 -5
  15. package/addon/plugins/snippet-plugin/commands/index.ts +1 -1
  16. package/addon/plugins/snippet-plugin/commands/{update-snippet-ids.ts → update-snippet-placeholder.ts} +23 -12
  17. package/addon/plugins/snippet-plugin/index.ts +19 -11
  18. package/addon/plugins/snippet-plugin/nodes/snippet-placeholder.ts +27 -9
  19. package/addon/plugins/snippet-plugin/nodes/snippet.ts +160 -2
  20. package/addon/plugins/snippet-plugin/utils/collate-imported-resources.ts +22 -0
  21. package/addon/plugins/snippet-plugin/utils/fetch-data.ts +52 -36
  22. package/addon/plugins/snippet-plugin/utils/rdfa-predicate.ts +3 -15
  23. package/addon/plugins/variable-plugin/utils/address-helpers.ts +4 -4
  24. package/addon/utils/sparql-helpers.ts +3 -4
  25. package/addon/utils/strings.ts +13 -0
  26. package/declarations/addon/components/decision-plugin/insert-article.d.ts +12 -2
  27. package/declarations/addon/components/snippet-plugin/nodes/snippet.d.ts +1 -1
  28. package/declarations/addon/components/snippet-plugin/search-modal.d.ts +1 -1
  29. package/declarations/addon/components/snippet-plugin/snippet-insert-placeholder.d.ts +2 -2
  30. package/declarations/addon/components/snippet-plugin/snippet-insert-rdfa.d.ts +13 -13
  31. package/declarations/addon/components/snippet-plugin/snippet-insert.d.ts +13 -9
  32. package/declarations/addon/components/snippet-plugin/snippet-list/snippet-list-modal.d.ts +2 -2
  33. package/declarations/addon/components/snippet-plugin/snippet-list-select-rdfa.d.ts +15 -19
  34. package/declarations/addon/components/snippet-plugin/snippet-list-select.d.ts +13 -5
  35. package/declarations/addon/plugins/snippet-plugin/commands/index.d.ts +1 -1
  36. package/declarations/addon/plugins/snippet-plugin/commands/update-snippet-placeholder.d.ts +11 -0
  37. package/declarations/addon/plugins/snippet-plugin/index.d.ts +12 -8
  38. package/declarations/addon/plugins/snippet-plugin/nodes/snippet-placeholder.d.ts +5 -1
  39. package/declarations/addon/plugins/snippet-plugin/nodes/snippet.d.ts +27 -2
  40. package/declarations/addon/plugins/snippet-plugin/utils/collate-imported-resources.d.ts +2 -0
  41. package/declarations/addon/plugins/snippet-plugin/utils/fetch-data.d.ts +0 -1
  42. package/declarations/addon/plugins/snippet-plugin/utils/rdfa-predicate.d.ts +1 -1
  43. package/declarations/addon/utils/sparql-helpers.d.ts +5 -3
  44. package/declarations/addon/utils/strings.d.ts +2 -0
  45. package/package.json +3 -3
  46. package/pnpm-lock.yaml +30 -29
  47. package/translations/en-US.yaml +1 -0
  48. package/translations/nl-BE.yaml +1 -0
  49. package/addon/components/snippet-plugin/snippet-insert-rdfa.hbs +0 -7
  50. package/addon/components/snippet-plugin/snippet-insert-rdfa.ts +0 -78
  51. package/addon/components/snippet-plugin/snippet-insert.hbs +0 -20
  52. package/addon/components/snippet-plugin/snippet-insert.ts +0 -95
  53. package/addon/components/snippet-plugin/snippet-list-select-rdfa.hbs +0 -8
  54. package/addon/components/snippet-plugin/snippet-list-select-rdfa.ts +0 -68
  55. package/addon/components/snippet-plugin/snippet-list-select.hbs +0 -17
  56. package/addon/components/snippet-plugin/snippet-list-select.ts +0 -29
  57. package/declarations/addon/plugins/snippet-plugin/commands/update-snippet-ids.d.ts +0 -11
@@ -0,0 +1,5 @@
1
+ ---
2
+ '@lblod/ember-rdfa-editor-lblod-plugins': minor
3
+ ---
4
+
5
+ Allow resources imported into snippet placeholders to be linked to resources in the document
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @lblod/ember-rdfa-editor-lblod-plugins
2
2
 
3
+ ## 22.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#471](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/471) [`8132a55`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/8132a550124cf90b47c3d1c759ce43bd9f72cfab) Thanks [@elpoelma](https://github.com/elpoelma)! - Introduce opt-in option to `insert-article` component to allow for inserting decision articles everywhere in a document (not just to the article-container of a decision). Useful when e.g. creating snippets.
8
+
9
+ ### Patch Changes
10
+
11
+ - [#470](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/470) [`fdfd8b8`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/fdfd8b80c58adc07e968d131dce7618b57b27e49) Thanks [@piemonkey](https://github.com/piemonkey)! - Correct CRS URI used in location plugin to correctly use http: instead of https:
12
+
3
13
  ## 22.3.0
4
14
 
5
15
  ### Minor Changes
@@ -3,36 +3,69 @@ import { on } from '@ember/modifier';
3
3
  import { action } from '@ember/object';
4
4
  import Component from '@glimmer/component';
5
5
  import { AddIcon } from '@appuniversum/ember-appuniversum/components/icons/add';
6
- import { SayController } from '@lblod/ember-rdfa-editor';
6
+ import { PNode, SayController } from '@lblod/ember-rdfa-editor';
7
7
  import { getCurrentBesluitRange } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-topic-plugin/utils/helpers';
8
8
  import insertArticle from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/decision-plugin/commands/insert-article-command';
9
9
  import { buildArticleStructure } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/decision-plugin/utils/build-article-structure';
10
- import t from 'ember-intl/helpers/t';
11
10
  import { not } from 'ember-truth-helpers';
11
+ import { service } from '@ember/service';
12
+ import IntlService from 'ember-intl/services/intl';
13
+ import { recalculateNumbers } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/structure-plugin/recalculate-structure-numbers';
14
+ import { transactionCombinator } from '@lblod/ember-rdfa-editor/utils/transaction-utils';
12
15
 
13
16
  export interface InsertArticleOptions {
14
17
  uriGenerator?: () => string;
18
+ insertFreely?: boolean;
15
19
  }
16
20
  interface Sig {
17
- Args: { controller: SayController; options?: InsertArticleOptions };
21
+ Args: {
22
+ controller: SayController;
23
+ label: string;
24
+ options?: InsertArticleOptions;
25
+ };
18
26
  }
19
27
  export default class InsertArticleComponent extends Component<Sig> {
28
+ @service declare intl: IntlService;
29
+
20
30
  get controller() {
21
31
  return this.args.controller;
22
32
  }
23
33
 
34
+ get options() {
35
+ return this.args.options;
36
+ }
37
+
38
+ get label() {
39
+ return this.args.label ?? this.intl.t('besluit-plugin.insert.article');
40
+ }
41
+
24
42
  get schema() {
25
43
  return this.controller.schema;
26
44
  }
45
+
27
46
  get decisionRange() {
28
47
  return getCurrentBesluitRange(this.controller);
29
48
  }
49
+
30
50
  get decisionLocation() {
31
51
  return this.decisionRange
32
52
  ? { pos: this.decisionRange.from, node: this.decisionRange.node }
33
53
  : null;
34
54
  }
55
+
35
56
  get canInsert() {
57
+ if (this.options?.insertFreely) {
58
+ return this.canInsertFreely;
59
+ } else {
60
+ return this.canInsertInDecision;
61
+ }
62
+ }
63
+
64
+ get canInsertFreely() {
65
+ return true;
66
+ }
67
+
68
+ get canInsertInDecision() {
36
69
  if (!this.decisionLocation) {
37
70
  return false;
38
71
  }
@@ -51,15 +84,32 @@ export default class InsertArticleComponent extends Component<Sig> {
51
84
  this.schema,
52
85
  this.args.options?.uriGenerator,
53
86
  );
54
- if (!structureNode) {
55
- return;
87
+ if (this.args.options?.insertFreely) {
88
+ this.insertFreely(structureNode);
89
+ } else {
90
+ this.insertInDecision(structureNode);
56
91
  }
92
+ }
93
+
94
+ @action
95
+ insertFreely(node: PNode) {
96
+ this.controller.withTransaction((tr) => {
97
+ return transactionCombinator(
98
+ this.controller.activeEditorState,
99
+ tr.replaceSelectionWith(node),
100
+ )([recalculateNumbers]).transaction;
101
+ });
102
+ this.controller.focus();
103
+ }
104
+
105
+ @action
106
+ insertInDecision(node: PNode) {
57
107
  if (!this.decisionLocation) {
58
108
  return;
59
109
  }
60
110
  this.controller.doCommand(
61
111
  insertArticle({
62
- node: structureNode,
112
+ node,
63
113
  decisionLocation: this.decisionLocation,
64
114
  }),
65
115
  );
@@ -75,7 +125,7 @@ export default class InsertArticleComponent extends Component<Sig> {
75
125
  @disabled={{not this.canInsert}}
76
126
  {{on 'click' this.doInsert}}
77
127
  >
78
- {{t 'besluit-plugin.insert.article'}}
128
+ {{this.label}}
79
129
  </AuButton>
80
130
  </li>
81
131
  </template>
@@ -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 { htmlToDoc } from '@lblod/ember-rdfa-editor/utils/_private/html-utils';
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 { v4 as uuidv4 } from 'uuid';
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 this.controller.withTransaction((tr: Transaction) => {
117
- return tr.replaceRangeWith(
118
- rangeStart,
119
- rangeEnd,
120
- this.controller.schema.node(
121
- 'snippet',
122
- {
123
- assignedSnippetListsIds,
124
- title,
125
- subject: `http://data.lblod.info/snippets/${uuidv4()}`,
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 { type SnippetPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
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(listIds: string[], listNames: string[]) {
39
- const node = createSnippetPlaceholder(
40
- listIds,
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
- this.args.controller.withTransaction(
46
- (tr) => {
47
- return tr.replaceSelectionWith(node);
48
- },
49
- { view: this.args.controller.mainEditorView },
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
- @onSaveSnippetListIds={{this.insertPlaceholder}}
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
+ }
@@ -40,7 +40,7 @@
40
40
  <AuButton
41
41
  @skin='primary'
42
42
  {{on 'click' this.saveAndClose}}
43
- @disabled={{@onSaveSnippetListIds.isRunning}}
43
+ @disabled={{@onSaveSnippetLists.isRunning}}
44
44
  >
45
45
  {{t 'snippet-plugin.snippet-list.modal.button.update'}}
46
46
  </AuButton>
@@ -19,8 +19,8 @@ import { trackedReset } from 'tracked-toolbox';
19
19
  interface Signature {
20
20
  Args: {
21
21
  config: SnippetPluginConfig;
22
- onSaveSnippetListIds: (listIds: string[], listNames: string[]) => void;
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[] = [...this.args.assignedSnippetListsIds];
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 snippetListNames: string[] = this.snippetListResource.value
54
- ?.filter((snippetList) =>
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
- as |list created select subtitle search|
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;