@lblod/ember-rdfa-editor-lblod-plugins 21.0.0 → 22.0.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 (63) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/Dockerfile +1 -1
  3. package/README.md +0 -5
  4. package/addon/components/confidentiality-plugin/redact.gts +12 -4
  5. package/addon/components/decision-plugin/insert-article.gts +2 -1
  6. package/addon/components/hover-tooltip.gts +13 -16
  7. package/addon/components/lmb-plugin/insert.ts +43 -79
  8. package/addon/components/lmb-plugin/search-modal.ts +10 -8
  9. package/addon/components/snippet-plugin/nodes/placeholder.gts +0 -3
  10. package/addon/components/snippet-plugin/nodes/snippet.gts +6 -6
  11. package/addon/components/standard-template-plugin/template-provider.ts +1 -0
  12. package/addon/components/variable-plugin/date/edit.ts +12 -3
  13. package/addon/components/variable-plugin/number/insert.ts +7 -13
  14. package/addon/components/variable-plugin/person/edit.hbs +31 -0
  15. package/addon/components/variable-plugin/person/edit.ts +74 -0
  16. package/addon/components/variable-plugin/person/insert.hbs +10 -0
  17. package/addon/components/variable-plugin/person/insert.ts +82 -0
  18. package/addon/components/variable-plugin/person/nodeview.hbs +20 -0
  19. package/addon/components/variable-plugin/person/nodeview.ts +50 -0
  20. package/addon/models/mandatee.ts +3 -3
  21. package/addon/plugins/lmb-plugin/index.ts +19 -0
  22. package/addon/plugins/location-plugin/node.ts +2 -2
  23. package/addon/plugins/variable-plugin/variables/address.ts +2 -2
  24. package/addon/plugins/variable-plugin/variables/index.ts +1 -0
  25. package/addon/plugins/variable-plugin/variables/number.ts +2 -2
  26. package/addon/plugins/variable-plugin/variables/person.ts +93 -0
  27. package/addon/utils/translation.ts +9 -5
  28. package/app/components/{validation-plugin/validation-card.js → variable-plugin/person/edit.js} +1 -1
  29. package/app/components/{validation-plugin/validation-item.js → variable-plugin/person/insert.js} +1 -1
  30. package/app/components/variable-plugin/person/nodeview.js +1 -0
  31. package/declarations/addon/components/common/search/alert-load-error.d.ts +1 -1
  32. package/declarations/addon/components/common/search/alert-no-items.d.ts +1 -1
  33. package/declarations/addon/components/confidentiality-plugin/redact.d.ts +10 -3
  34. package/declarations/addon/components/lmb-plugin/insert.d.ts +2 -0
  35. package/declarations/addon/components/pagination/pagination-view.d.ts +1 -1
  36. package/declarations/addon/components/variable-plugin/address/edit.d.ts +2 -2
  37. package/declarations/addon/components/variable-plugin/number/insert.d.ts +2 -2
  38. package/declarations/addon/components/variable-plugin/person/edit.d.ts +23 -0
  39. package/declarations/addon/components/variable-plugin/person/insert.d.ts +16 -0
  40. package/declarations/addon/components/variable-plugin/person/nodeview.d.ts +22 -0
  41. package/declarations/addon/models/mandatee.d.ts +2 -2
  42. package/declarations/addon/plugins/lmb-plugin/index.d.ts +3 -0
  43. package/declarations/addon/plugins/variable-plugin/variables/index.d.ts +1 -0
  44. package/declarations/addon/plugins/variable-plugin/variables/person.d.ts +2 -0
  45. package/declarations/addon/utils/translation.d.ts +2 -2
  46. package/package.json +102 -93
  47. package/pnpm-lock.yaml +12635 -10132
  48. package/translations/en-US.yaml +6 -2
  49. package/translations/nl-BE.yaml +6 -4
  50. package/addon/components/validation-plugin/validation-card.hbs +0 -16
  51. package/addon/components/validation-plugin/validation-card.ts +0 -19
  52. package/addon/components/validation-plugin/validation-item.hbs +0 -8
  53. package/addon/components/validation-plugin/validation-item.ts +0 -58
  54. package/addon/plugins/decision-plugin/utils/validation-rules.ts +0 -11
  55. package/addon/plugins/validation/README.md +0 -84
  56. package/addon/plugins/validation/index.ts +0 -412
  57. package/addon/plugins/validation/utils/transaction-complies-with-shapes.ts +0 -28
  58. package/declarations/addon/components/validation-plugin/validation-card.d.ts +0 -13
  59. package/declarations/addon/components/validation-plugin/validation-item.d.ts +0 -18
  60. package/declarations/addon/plugins/decision-plugin/utils/validation-rules.d.ts +0 -10
  61. package/declarations/addon/plugins/validation/index.d.ts +0 -62
  62. package/declarations/addon/plugins/validation/utils/transaction-complies-with-shapes.d.ts +0 -10
  63. package/types/ember-intl.d.ts +0 -15
package/CHANGELOG.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # @lblod/ember-rdfa-editor-lblod-plugins
2
2
 
3
+ ## 22.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [#448](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/448) [`e6fe1df`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/e6fe1dfd89c0e7fba6d58c0f373438fdd7730403) Thanks [@piemonkey](https://github.com/piemonkey)! - Update ember-intl to v7, drops support for v5 and v6 due to API changes
8
+
9
+ - [#448](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/448) [`e6fe1df`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/e6fe1dfd89c0e7fba6d58c0f373438fdd7730403) Thanks [@piemonkey](https://github.com/piemonkey)! - Update ember-modifier to v4 and drop support for older versions
10
+
11
+ - [#448](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/448) [`e6fe1df`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/e6fe1dfd89c0e7fba6d58c0f373438fdd7730403) Thanks [@piemonkey](https://github.com/piemonkey)! - Update to ember-power-select v7.1, drops support for older versions
12
+
13
+ - [#448](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/448) [`e6fe1df`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/e6fe1dfd89c0e7fba6d58c0f373438fdd7730403) Thanks [@piemonkey](https://github.com/piemonkey)! - Update all dependencies to latest supported versions
14
+
15
+ - [#448](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/448) [`e6fe1df`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/e6fe1dfd89c0e7fba6d58c0f373438fdd7730403) Thanks [@piemonkey](https://github.com/piemonkey)! - Run pnpm up to update dependencies to latest supported versions
16
+
17
+ - [#451](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/451) [`8f560c6`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/8f560c688458eb6c143c20a6758749811871d78e) Thanks [@elpoelma](https://github.com/elpoelma)! - Remove `nodeType`-based validation plugin. This validation plugin validated documents based on the presence of nodes with a specific node-type. This turned out not to be as useful/intuitive.
18
+
19
+ ### Minor Changes
20
+
21
+ - [#455](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/455) [`0ae858b`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/0ae858b4dd6bf8034024e312abc468e2bc1bc21f) Thanks [@lagartoverde](https://github.com/lagartoverde)! - Added person variable
22
+
23
+ - [#448](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/448) [`e6fe1df`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/e6fe1dfd89c0e7fba6d58c0f373438fdd7730403) Thanks [@piemonkey](https://github.com/piemonkey)! - Update to ember-template-imports 4.1.1
24
+
25
+ ### Patch Changes
26
+
27
+ - [#453](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/453) [`9ffbcae`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/9ffbcae60370a43d80e03887fc3f41473cd8b849) Thanks [@abeforgit](https://github.com/abeforgit)! - fix: allow basic templates to be inserted again
28
+
29
+ - [#450](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/450) [`19d811d`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/19d811dfae52ff0dca37ddedcb0a141fbb3cb5b0) Thanks [@elpoelma](https://github.com/elpoelma)! - lbm-plugin: add support for inserting independent mandatees (who are not part of a fraction)
30
+
31
+ - [#454](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/454) [`fdeb6cd`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/fdeb6cd7b9bfcf7f13ad3c4005f2179776d3ef41) Thanks [@piemonkey](https://github.com/piemonkey)! - Use icon classes in order to support embeddable editor
32
+
3
33
  ## 21.0.0
4
34
 
5
35
  ### Major Changes
package/Dockerfile CHANGED
@@ -3,7 +3,7 @@ FROM node:20-slim AS builder
3
3
  LABEL maintainer="info@redpencil.io"
4
4
 
5
5
  RUN corepack enable
6
- RUN corepack prepare pnpm@latest-8 --activate
6
+ RUN corepack prepare pnpm@9.4 --activate
7
7
  WORKDIR /app
8
8
  COPY package.json pnpm-lock.yaml ./
9
9
  RUN pnpm i --frozen-lockfile
package/README.md CHANGED
@@ -30,7 +30,6 @@ This addon contains the following editor plugins:
30
30
  - [standard-template-plugin](#standard-template-plugin)
31
31
  - [table-of-contents-plugin](#table-of-contents-plugin)
32
32
  - [variable-plugin](#variable-plugin)
33
- - [validation-plugin](#validation-plugin)
34
33
  - [template-comments-plugin](#template-comments-plugin)
35
34
 
36
35
  You can configure your editor like this:
@@ -785,10 +784,6 @@ You can also add an insert component meant for use outside of `insert-variable-c
785
784
  <VariablePlugin::Address::Insert @controller={{this.controller}} />
786
785
  ```
787
786
 
788
- ## validation-plugin
789
-
790
- see [the plugin docs](addon/plugins/validation/README.md)
791
-
792
787
  ## template-comments-plugin
793
788
 
794
789
  A plugin to insert a template comment anywhere in the document.
@@ -1,13 +1,21 @@
1
- import Mark from '@lblod/ember-rdfa-editor/components/toolbar/mark';
1
+ import { TemplateOnlyComponent } from '@ember/component/template-only';
2
2
  import t from 'ember-intl/helpers/t';
3
3
  import { NotVisibleIcon } from '@appuniversum/ember-appuniversum/components/icons/not-visible';
4
+ import { SayController } from '@lblod/ember-rdfa-editor';
5
+ import Mark from '@lblod/ember-rdfa-editor/components/toolbar/mark';
6
+
7
+ interface Sig {
8
+ Args: {
9
+ controller: SayController;
10
+ };
11
+ }
4
12
 
5
- <template>
13
+ const Redact: TemplateOnlyComponent<Sig> = <template>
6
14
  <Mark
7
15
  @icon={{NotVisibleIcon}}
8
16
  @title={{t 'confidentiality-plugin.redact'}}
9
17
  @mark='redacted'
10
- {{! @glint-expect-error: not typesafe yet }}
11
18
  @controller={{@controller}}
12
19
  />
13
- </template>
20
+ </template>;
21
+ export default Redact;
@@ -2,6 +2,7 @@ import AuButton from '@appuniversum/ember-appuniversum/components/au-button';
2
2
  import { on } from '@ember/modifier';
3
3
  import { action } from '@ember/object';
4
4
  import Component from '@glimmer/component';
5
+ import { AddIcon } from '@appuniversum/ember-appuniversum/components/icons/add';
5
6
  import { SayController } from '@lblod/ember-rdfa-editor';
6
7
  import { getCurrentBesluitRange } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-topic-plugin/utils/helpers';
7
8
  import insertArticle from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/decision-plugin/commands/insert-article-command';
@@ -68,7 +69,7 @@ export default class InsertArticleComponent extends Component<Sig> {
68
69
  <template>
69
70
  <li class='au-csidebar-list__item'>
70
71
  <AuButton
71
- @icon='add'
72
+ @icon={{AddIcon}}
72
73
  @iconAlignment='left'
73
74
  @skin='link'
74
75
  @disabled={{not this.canInsert}}
@@ -24,21 +24,18 @@ interface Sig {
24
24
  }
25
25
 
26
26
  export default class HoverTooltip extends Component<Sig> {
27
- hover = modifier<HoverModifierSig>(
28
- (element) => {
29
- element.addEventListener('mouseenter', this.showTooltip);
30
- element.addEventListener('mouseleave', this.hideTooltip);
31
- element.addEventListener('focus', this.showTooltip);
32
- element.addEventListener('blur', this.hideTooltip);
33
- return () => {
34
- element.removeEventListener('mouseenter', this.showTooltip);
35
- element.removeEventListener('mouseleave', this.hideTooltip);
36
- element.removeEventListener('focus', this.showTooltip);
37
- element.removeEventListener('blur', this.hideTooltip);
38
- };
39
- },
40
- { eager: false },
41
- );
27
+ hover = modifier<HoverModifierSig>((element) => {
28
+ element.addEventListener('mouseenter', this.showTooltip);
29
+ element.addEventListener('mouseleave', this.hideTooltip);
30
+ element.addEventListener('focus', this.showTooltip);
31
+ element.addEventListener('blur', this.hideTooltip);
32
+ return () => {
33
+ element.removeEventListener('mouseenter', this.showTooltip);
34
+ element.removeEventListener('mouseleave', this.hideTooltip);
35
+ element.removeEventListener('focus', this.showTooltip);
36
+ element.removeEventListener('blur', this.hideTooltip);
37
+ };
38
+ });
42
39
  @tracked tooltipOpen = false;
43
40
 
44
41
  get placement(): Placement | undefined {
@@ -56,7 +53,7 @@ export default class HoverTooltip extends Component<Sig> {
56
53
  <Velcro @placement={{this.placement}} as |velcro|>
57
54
  {{#let velcro.loop as |loop|}}
58
55
  {{yield
59
- (hash velcroHook=velcro.hook handleHover=(modifier this.hover))
56
+ (hash velcroHook=velcro.hook handleHover=this.hover)
60
57
  to='hover'
61
58
  }}
62
59
  {{#if this.tooltipOpen}}
@@ -6,12 +6,16 @@ import { AddIcon } from '@appuniversum/ember-appuniversum/components/icons/add';
6
6
  import { SayController } from '@lblod/ember-rdfa-editor';
7
7
  import { LmbPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/lmb-plugin';
8
8
  import Mandatee from '@lblod/ember-rdfa-editor-lblod-plugins/models/mandatee';
9
- import { v4 as uuid } from 'uuid';
10
- import { sayDataFactory } from '@lblod/ember-rdfa-editor/core/say-data-factory';
9
+ import { v4 as uuidv4 } from 'uuid';
11
10
  import {
12
- MANDAAT,
13
- FOAF,
11
+ DCT,
12
+ EXT,
13
+ RDF,
14
14
  } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
15
+ import { replaceSelectionWithAndSelectNode } from '@lblod/ember-rdfa-editor-lblod-plugins/commands';
16
+ import { service } from '@ember/service';
17
+ import IntlService from 'ember-intl/services/intl';
18
+ import { sayDataFactory } from '@lblod/ember-rdfa-editor/core/say-data-factory';
15
19
 
16
20
  interface Args {
17
21
  controller: SayController;
@@ -19,6 +23,7 @@ interface Args {
19
23
  }
20
24
 
21
25
  export default class LmbPluginInsertComponent extends Component<Args> {
26
+ @service declare intl: IntlService;
22
27
  AddIcon = AddIcon;
23
28
 
24
29
  @tracked showModal = false;
@@ -40,82 +45,41 @@ export default class LmbPluginInsertComponent extends Component<Args> {
40
45
 
41
46
  @action
42
47
  onInsert(mandatee: Mandatee) {
43
- const schema = this.controller.schema;
44
- const firstNameUuid = uuid();
45
- const firstNameNode = schema.node(
46
- 'inline_rdfa',
47
- {
48
- rdfaNodeType: 'literal',
49
- __rdfaId: firstNameUuid,
50
- backlinks: [
51
- {
52
- subject: sayDataFactory.literalNode(mandatee.personUri),
53
- predicate: FOAF('gebruikteVoornaam').prefixed,
54
- },
55
- ],
56
- },
57
- [schema.text(mandatee.firstName)],
58
- );
59
- const lastNameUuid = uuid();
60
- const lastNameNode = schema.node(
61
- 'inline_rdfa',
62
- {
63
- rdfaNodeType: 'literal',
64
- __rdfaId: lastNameUuid,
65
- backlinks: [
66
- {
67
- subject: sayDataFactory.literalNode(mandatee.personUri),
68
- predicate: FOAF('familyName').prefixed,
69
- },
70
- ],
71
- },
72
- [schema.text(mandatee.lastName)],
73
- );
48
+ const mappingSubject = `http://data.lblod.info/mappings/${uuidv4()}`;
49
+ const variableInstance = `http://data.lblod.info/variables/${uuidv4()}`;
50
+ const variableId = uuidv4();
51
+
52
+ const label = this.intl.t('variable.person.label', {
53
+ locale: this.controller.documentLanguage,
54
+ });
55
+ const node = this.controller.schema.nodes.person_variable.create({
56
+ subject: mappingSubject,
57
+ rdfaNodeType: 'resource',
58
+ __rdfaId: variableId,
59
+ mandatee,
60
+ properties: [
61
+ {
62
+ predicate: RDF('type').full,
63
+ object: sayDataFactory.namedNode(EXT('Mapping').full),
64
+ },
65
+ {
66
+ predicate: EXT('instance').full,
67
+ object: sayDataFactory.namedNode(variableInstance),
68
+ },
69
+ {
70
+ predicate: EXT('label').full,
71
+ object: sayDataFactory.literal(label),
72
+ },
73
+ {
74
+ predicate: DCT('type').full,
75
+ object: sayDataFactory.literal('person'),
76
+ },
77
+ ],
78
+ });
74
79
 
75
- const personNode = schema.node(
76
- 'inline_rdfa',
77
- {
78
- rdfaNodeType: 'resource',
79
- subject: mandatee.personUri,
80
- properties: [
81
- {
82
- predicate: FOAF('gebruikteVoornaam').prefixed,
83
- object: sayDataFactory.literalNode(firstNameUuid),
84
- },
85
- {
86
- predicate: FOAF('familyName').prefixed,
87
- object: sayDataFactory.literalNode(lastNameUuid),
88
- },
89
- ],
90
- backlinks: [
91
- {
92
- subject: sayDataFactory.literalNode(mandatee.mandateeUri),
93
- predicate: MANDAAT('isBestuurlijkeAliasVan').prefixed,
94
- },
95
- ],
96
- },
97
- [firstNameNode, lastNameNode],
98
- );
99
- const mandateeNode = schema.node(
100
- 'inline_rdfa',
101
- {
102
- rdfaNodeType: 'resource',
103
- subject: mandatee.mandateeUri,
104
- properties: [
105
- {
106
- predicate: MANDAAT('isBestuurlijkeAliasVan').prefixed,
107
- object: sayDataFactory.resourceNode(mandatee.personUri),
108
- },
109
- ],
110
- },
111
- [personNode],
112
- );
113
- this.controller.withTransaction(
114
- (tr) => {
115
- return tr.replaceSelectionWith(mandateeNode);
116
- },
117
- { view: this.controller.mainEditorView },
118
- );
80
+ this.controller.doCommand(replaceSelectionWithAndSelectNode(node), {
81
+ view: this.controller.mainEditorView,
82
+ });
119
83
  this.closeModal();
120
84
  }
121
85
  }
@@ -53,31 +53,33 @@ export default class LmbPluginSearchModalComponent extends Component<Args> {
53
53
  },
54
54
  body: JSON.stringify({
55
55
  query: `
56
- PREFIX besluit: <http://data.vlaanderen.be/ns/besluit#>
57
- PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
56
+ PREFIX besluit: <http://data.vlaanderen.be/ns/besluit#>
57
+ PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
58
58
  PREFIX mandaat: <http://data.vlaanderen.be/ns/mandaat#>
59
59
  PREFIX foaf: <http://xmlns.com/foaf/0.1/>
60
60
  PREFIX persoon: <http://data.vlaanderen.be/ns/persoon#>
61
61
  PREFIX org: <http://www.w3.org/ns/org#>
62
62
  PREFIX regorg: <https://www.w3.org/ns/regorg#>
63
- SELECT DISTINCT ?mandatee ?person ?firstName ?lastName ?statusLabel ?fractieLabel ?roleLabel WHERE {
63
+ SELECT DISTINCT ?mandatee ?person ?firstName ?lastName ?statusLabel ?fractieLabel ?roleLabel WHERE {
64
64
  ?mandatee a mandaat:Mandataris;
65
65
  org:holds ?mandaat;
66
66
  mandaat:status ?status;
67
- mandaat:isBestuurlijkeAliasVan ?person;
68
- org:hasMembership ?membership.
67
+ mandaat:isBestuurlijkeAliasVan ?person.
69
68
  ?person foaf:familyName ?lastName;
70
69
  persoon:gebruikteVoornaam ?firstName.
71
70
  ?status skos:prefLabel ?statusLabel.
72
- ?membership org:organisation ?fractie.
73
- ?fractie regorg:legalName ?fractieLabel.
74
71
  ?mandaat org:role ?role.
75
72
  ?role skos:prefLabel ?roleLabel.
76
73
  OPTIONAL {
77
74
  ?mandatee mandaat:einde ?endDate
78
75
  }
76
+ OPTIONAL {
77
+ ?mandatee org:hasMembership ?membership.
78
+ ?membership org:organisation ?fractie.
79
+ ?fractie regorg:legalName ?fractieLabel.
80
+ }
79
81
  filter (!bound(?endDate) || ?endDate > now()).
80
- }
82
+ }
81
83
  `,
82
84
  }),
83
85
  });
@@ -11,9 +11,6 @@ interface Signature {
11
11
  Args: EmberNodeArgs;
12
12
  }
13
13
 
14
- // We don't have a way to type template only components without ember-source 5, so create an empty
15
- // class to allow for type checking
16
- // eslint-disable-next-line ember/no-empty-glimmer-component-classes
17
14
  export default class SnippetPluginPlaceholder extends Component<Signature> {
18
15
  @service declare intl: IntlService;
19
16
  get listNames() {
@@ -5,6 +5,9 @@ import { type EmberNodeArgs } from '@lblod/ember-rdfa-editor/utils/_private/embe
5
5
  import SearchModal from '../search-modal';
6
6
  import { tracked } from '@glimmer/tracking';
7
7
  import { action } from '@ember/object';
8
+ import { SynchronizeIcon } from '@appuniversum/ember-appuniversum/components/icons/synchronize';
9
+ import { BinIcon } from '@appuniversum/ember-appuniversum/components/icons/bin';
10
+ import { AddIcon } from '@appuniversum/ember-appuniversum/components/icons/add';
8
11
  import {
9
12
  PNode,
10
13
  ProseParser,
@@ -29,9 +32,6 @@ interface Signature {
29
32
  };
30
33
  }
31
34
 
32
- // We don't have a way to type template only components without ember-source 5, so create an empty
33
- // class to allow for type checking
34
- // eslint-disable-next-line ember/no-empty-glimmer-component-classes
35
35
  export default class SnippetNode extends Component<Signature> {
36
36
  @tracked showModal: boolean = false;
37
37
  @tracked mode: string = '';
@@ -154,7 +154,7 @@ export default class SnippetNode extends Component<Signature> {
154
154
  type='button'
155
155
  {{on 'click' this.editFragment}}
156
156
  >
157
- <AuIcon @icon='synchronize' @size='large' />
157
+ <AuIcon @icon={{SynchronizeIcon}} @size='large' />
158
158
  <div class='say-snippet-button-text'>
159
159
  {{t 'snippet-plugin.snippet-node.change-fragment'}}
160
160
  </div>
@@ -164,7 +164,7 @@ export default class SnippetNode extends Component<Signature> {
164
164
  type='button'
165
165
  {{on 'click' this.deleteFragment}}
166
166
  >
167
- <AuIcon @icon='bin' />
167
+ <AuIcon @icon={{BinIcon}} />
168
168
  <div class='say-snippet-button-text'>
169
169
  {{t 'snippet-plugin.snippet-node.remove-fragment'}}
170
170
  </div>
@@ -174,7 +174,7 @@ export default class SnippetNode extends Component<Signature> {
174
174
  type='button'
175
175
  {{on 'click' this.addFragment}}
176
176
  >
177
- <AuIcon @icon='add' />
177
+ <AuIcon @icon={{AddIcon}} />
178
178
  <div class='say-snippet-button-text'>
179
179
  {{t 'snippet-plugin.snippet-node.add-fragment'}}
180
180
  </div>
@@ -63,6 +63,7 @@ export default class TemplateProviderComponent extends Component<Args> {
63
63
  templateIsApplicable(template: StandardTemplate) {
64
64
  const { $from } = this.controller.mainEditorState.selection;
65
65
  const containsTypes =
66
+ template.contexts.length === 0 ||
66
67
  this.controller.externalContextStore
67
68
  .match(null, 'a')
68
69
  .dataset.some((quad) => {
@@ -175,14 +175,23 @@ export default class DateEditComponent extends Component<Args> {
175
175
  get humanError(): string | null {
176
176
  if (this.customDateFormatError) {
177
177
  const { error, payload } = this.customDateFormatError;
178
+ const locale = this.intl.primaryLocale ?? this.intl.locales[0];
178
179
  if (error === 'character') {
179
- const msg = this.intl.lookup(`date-plugin.validation.${error}`) ?? '';
180
+ const msg =
181
+ this.intl.getTranslation(`date-plugin.validation.${error}`, locale) ??
182
+ '';
180
183
  const suggestion =
181
- this.intl.lookup('date-plugin.validation.character-suggestion') ?? '';
184
+ this.intl.getTranslation(
185
+ 'date-plugin.validation.character-suggestion',
186
+ locale,
187
+ ) ?? '';
182
188
  const chars = payload?.invalidCharacters ?? '';
183
189
  return `${msg}: ${chars}. ${suggestion}: '${chars}'`;
184
190
  }
185
- return this.intl.lookup(`date-plugin.validation.${error}`) ?? null;
191
+ return (
192
+ this.intl.getTranslation(`date-plugin.validation.${error}`, locale) ??
193
+ null
194
+ );
186
195
  }
187
196
  return null;
188
197
  }
@@ -27,19 +27,13 @@ export default class NumberInsertComponent extends Component<Args> {
27
27
  @tracked validMinimum = true;
28
28
  @tracked validMaximum = true;
29
29
 
30
- minimumInput = modifier(
31
- (element: HTMLInputElement) => {
32
- this.validMinimum = element.checkValidity();
33
- },
34
- { eager: false },
35
- );
36
-
37
- maximumInput = modifier(
38
- (element: HTMLInputElement) => {
39
- this.validMaximum = element.checkValidity();
40
- },
41
- { eager: false },
42
- );
30
+ minimumInput = modifier((element: HTMLInputElement) => {
31
+ this.validMinimum = element.checkValidity();
32
+ });
33
+
34
+ maximumInput = modifier((element: HTMLInputElement) => {
35
+ this.validMaximum = element.checkValidity();
36
+ });
43
37
 
44
38
  get controller() {
45
39
  return this.args.controller;
@@ -0,0 +1,31 @@
1
+ {{! @glint-nocheck: not typesafe yet }}
2
+ {{#if this.showCard}}
3
+ <AuCard
4
+ @flex={{true}}
5
+ @divided={{true}}
6
+ @shadow={{true}}
7
+ @size='small'
8
+ as |c|
9
+ >
10
+ <c.header>
11
+ <AuHeading @level='3' @skin='6'>
12
+ {{t 'variable-plugin.person.card-title'}}
13
+ </AuHeading>
14
+ </c.header>
15
+ <c.content>
16
+ <AuButton {{on 'click' this.openModal}}>
17
+ {{#if this.isEditing}}
18
+ {{t 'editor-plugins.utils.edit'}}
19
+ {{else}}
20
+ {{t 'editor-plugins.utils.insert'}}
21
+ {{/if}}
22
+ </AuButton>
23
+ </c.content>
24
+ </AuCard>
25
+ <LmbPlugin::SearchModal
26
+ @open={{this.showModal}}
27
+ @closeModal={{this.closeModal}}
28
+ @config={{@config}}
29
+ @onInsert={{this.onInsert}}
30
+ />
31
+ {{/if}}
@@ -0,0 +1,74 @@
1
+ import Component from '@glimmer/component';
2
+ import { action } from '@ember/object';
3
+ import { SayController, PNode } from '@lblod/ember-rdfa-editor';
4
+ import { NodeSelection } from '@lblod/ember-rdfa-editor';
5
+ import { trackedFunction } from 'ember-resources/util/function';
6
+ import { tracked } from '@glimmer/tracking';
7
+ import { LmbPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/lmb-plugin';
8
+ import Mandatee from '@lblod/ember-rdfa-editor-lblod-plugins/models/mandatee';
9
+
10
+ type Args = {
11
+ controller: SayController;
12
+ config: LmbPluginConfig;
13
+ };
14
+
15
+ type PersonNode = {
16
+ node: PNode;
17
+ pos: number;
18
+ };
19
+
20
+ export default class PersonEditComponent extends Component<Args> {
21
+ @tracked showModal = false;
22
+
23
+ get controller() {
24
+ return this.args.controller;
25
+ }
26
+
27
+ selectedPersonNode = trackedFunction(this, () => {
28
+ const { selection } = this.controller.mainEditorState;
29
+ if (
30
+ selection instanceof NodeSelection &&
31
+ selection.node.type === this.controller.schema.nodes.person_variable
32
+ ) {
33
+ const personNode: PersonNode = {
34
+ node: selection.node,
35
+ pos: selection.from,
36
+ };
37
+ return personNode;
38
+ }
39
+ return;
40
+ });
41
+
42
+ get showCard() {
43
+ return !!this.selectedPersonNode.value;
44
+ }
45
+
46
+ get isEditing() {
47
+ const personNode = this.selectedPersonNode.value;
48
+ return !!personNode?.node.attrs.mandatee;
49
+ }
50
+
51
+ @action
52
+ openModal() {
53
+ this.controller.focus();
54
+ this.showModal = true;
55
+ }
56
+
57
+ @action
58
+ closeModal() {
59
+ this.showModal = false;
60
+ }
61
+ @action
62
+ onInsert(mandatee: Mandatee) {
63
+ const personNode = this.selectedPersonNode.value as PersonNode;
64
+ this.controller.withTransaction((tr) => {
65
+ tr.setNodeAttribute(personNode.pos, 'mandatee', mandatee);
66
+ return tr.setNodeAttribute(
67
+ personNode.pos,
68
+ 'content',
69
+ mandatee.mandateeUri,
70
+ );
71
+ });
72
+ this.closeModal();
73
+ }
74
+ }
@@ -0,0 +1,10 @@
1
+ {{! @glint-nocheck: not typesafe yet }}
2
+ <AuFormRow>
3
+ <VariablePlugin::Utils::LabelInput
4
+ @label={{this.label}}
5
+ @updateLabel={{this.updateLabel}}
6
+ />
7
+ </AuFormRow>
8
+ <AuButton {{on 'click' this.insert}}>
9
+ {{t 'variable-plugin.button'}}
10
+ </AuButton>