@lblod/ember-rdfa-editor-lblod-plugins 25.2.0 → 25.2.1-dev.3f3b7d0dfbeef50aaf66f35c51097fc42ad192cd

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 (56) hide show
  1. package/.changeset/metal-bags-pump.md +5 -0
  2. package/.changeset/twelve-mugs-think.md +9 -0
  3. package/.changeset/wild-walls-turn.md +17 -0
  4. package/CHANGELOG.md +8 -0
  5. package/addon/components/lmb-plugin/insert.ts +10 -3
  6. package/addon/components/lmb-plugin/list.hbs +16 -22
  7. package/addon/components/lmb-plugin/search-modal.ts +11 -11
  8. package/addon/components/location-plugin/nodeview.gts +16 -28
  9. package/addon/components/variable-plugin/address/nodeview.hbs +4 -18
  10. package/addon/components/variable-plugin/address/nodeview.ts +12 -23
  11. package/addon/components/variable-plugin/autofilled/insert.gts +3 -2
  12. package/addon/components/variable-plugin/codelist/insert.ts +1 -1
  13. package/addon/components/variable-plugin/date/nodeview.hbs +4 -12
  14. package/addon/components/variable-plugin/date/nodeview.ts +5 -23
  15. package/addon/components/variable-plugin/location/insert.ts +4 -2
  16. package/addon/components/variable-plugin/number/nodeview.hbs +4 -19
  17. package/addon/components/variable-plugin/number/nodeview.ts +12 -10
  18. package/addon/components/variable-plugin/person/edit.ts +12 -12
  19. package/addon/components/variable-plugin/person/nodeview.hbs +4 -18
  20. package/addon/components/variable-plugin/person/nodeview.ts +16 -23
  21. package/addon/components/variable-plugin/text/insert.ts +1 -1
  22. package/addon/components/variable-plugin/variable/nodeview.hbs +2 -8
  23. package/addon/components/variable-plugin/variable/nodeview.ts +16 -7
  24. package/addon/models/electee.ts +22 -0
  25. package/addon/plugins/lmb-plugin/index.ts +7 -9
  26. package/addon/plugins/lmb-plugin/utils/fetchElectees.ts +163 -0
  27. package/addon/plugins/variable-plugin/variables/autofilled.ts +2 -2
  28. package/addon/plugins/variable-plugin/variables/location.ts +2 -3
  29. package/addon/plugins/variable-plugin/variables/person.ts +27 -10
  30. package/addon/utils/namespace.ts +4 -1
  31. package/app/styles/variable-plugin.scss +21 -26
  32. package/declarations/addon/components/lmb-plugin/insert.d.ts +2 -2
  33. package/declarations/addon/components/lmb-plugin/search-modal.d.ts +6 -6
  34. package/declarations/addon/components/location-plugin/nodeview.d.ts +2 -3
  35. package/declarations/addon/components/variable-plugin/address/nodeview.d.ts +2 -8
  36. package/declarations/addon/components/variable-plugin/date/nodeview.d.ts +2 -6
  37. package/declarations/addon/components/variable-plugin/number/nodeview.d.ts +2 -4
  38. package/declarations/addon/components/variable-plugin/person/edit.d.ts +2 -2
  39. package/declarations/addon/components/variable-plugin/person/nodeview.d.ts +4 -9
  40. package/declarations/addon/components/variable-plugin/variable/nodeview.d.ts +2 -2
  41. package/declarations/addon/models/electee.d.ts +10 -0
  42. package/declarations/addon/plugins/lmb-plugin/index.d.ts +2 -2
  43. package/declarations/addon/plugins/lmb-plugin/utils/{fetchMandatees.d.ts → fetchElectees.d.ts} +4 -4
  44. package/declarations/addon/plugins/variable-plugin/variables/person.d.ts +5 -0
  45. package/package.json +3 -3
  46. package/pnpm-lock.yaml +24 -17
  47. package/translations/en-US.yaml +12 -11
  48. package/translations/nl-BE.yaml +9 -10
  49. package/addon/components/variable-plugin/autofilled/nodeview.gts +0 -100
  50. package/addon/components/variable-plugin/location/nodeview.hbs +0 -24
  51. package/addon/components/variable-plugin/location/nodeview.ts +0 -46
  52. package/addon/models/mandatee.ts +0 -35
  53. package/addon/plugins/lmb-plugin/utils/fetchMandatees.ts +0 -143
  54. package/declarations/addon/components/variable-plugin/autofilled/nodeview.d.ts +0 -22
  55. package/declarations/addon/components/variable-plugin/location/nodeview.d.ts +0 -11
  56. package/declarations/addon/models/mandatee.d.ts +0 -13
@@ -1,12 +1,9 @@
1
1
  import Component from '@glimmer/component';
2
- import { service } from '@ember/service';
3
- import IntlService from 'ember-intl/services/intl';
4
- import { PencilIcon } from '@appuniversum/ember-appuniversum/components/icons/pencil';
5
2
 
6
3
  import { PNode, SayController } from '@lblod/ember-rdfa-editor';
7
4
  import { getOutgoingTriple } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
8
5
  import { EXT } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
9
- import Mandatee from '@lblod/ember-rdfa-editor-lblod-plugins/models/mandatee';
6
+ import { Person } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/variable-plugin/variables';
10
7
 
11
8
  type Args = {
12
9
  getPos: () => number | undefined;
@@ -15,36 +12,32 @@ type Args = {
15
12
  };
16
13
 
17
14
  export default class PersonNodeviewComponent extends Component<Args> {
18
- PencilIcon = PencilIcon;
19
-
20
- @service declare intl: IntlService;
21
-
22
15
  get controller() {
23
16
  return this.args.controller;
24
17
  }
25
18
 
26
- get documentLanguage() {
27
- return this.controller.documentLanguage;
28
- }
29
-
30
- get translations() {
31
- return {
32
- placeholder: this.intl.t('variable-plugin.person.nodeview-placeholder', {
33
- locale: this.documentLanguage,
34
- }),
35
- };
36
- }
37
-
38
19
  get node() {
39
20
  return this.args.node;
40
21
  }
41
22
 
42
- get mandatee() {
43
- return this.node.attrs.mandatee as Mandatee | null;
23
+ get person() {
24
+ return this.node.attrs.value as Person | null;
44
25
  }
45
26
 
46
27
  get label() {
47
- if (this.mandatee) return '';
28
+ if (this.person) return '';
48
29
  return getOutgoingTriple(this.node.attrs, EXT('label'))?.object.value;
49
30
  }
31
+
32
+ get filled() {
33
+ return !!this.person;
34
+ }
35
+
36
+ get content() {
37
+ if (this.person) {
38
+ return `${this.person.firstName} ${this.person.lastName}`;
39
+ } else {
40
+ return this.label;
41
+ }
42
+ }
50
43
  }
@@ -78,7 +78,7 @@ export default class TextVariableInsertComponent extends Component<Args> {
78
78
  ],
79
79
  },
80
80
  this.schema.node('placeholder', {
81
- placeholderText: 'text',
81
+ placeholderText: label,
82
82
  }),
83
83
  );
84
84
 
@@ -1,9 +1,8 @@
1
1
  {{! @glint-nocheck: not typesafe yet }}
2
2
  <AuPill
3
- @icon={{this.PencilIcon}}
4
- @iconAlignment='right'
5
- class='variable'
3
+ class='say-pill'
6
4
  {{on 'click' this.onClick}}
5
+ {{on 'focusout' this.resetVariable}}
7
6
  >
8
7
  <EmberNode::EmbeddedEditor
9
8
  @controller={{@controller}}
@@ -17,9 +16,4 @@
17
16
  @decorations={{@decorations}}
18
17
  @contentDecorations={{@contentDecorations}}
19
18
  />
20
- {{#if this.label}}
21
- <span class='label'>
22
- ({{this.label}})
23
- </span>
24
- {{/if}}
25
19
  </AuPill>
@@ -3,15 +3,12 @@ import { NodeSelection, ProsePlugin, SayView } from '@lblod/ember-rdfa-editor';
3
3
  import { editableNodePlugin } from '@lblod/ember-rdfa-editor/plugins/editable-node';
4
4
  import { tracked } from '@glimmer/tracking';
5
5
  import { action } from '@ember/object';
6
- import { PencilIcon } from '@appuniversum/ember-appuniversum/components/icons/pencil';
7
6
 
8
7
  import { EmberNodeArgs } from '@lblod/ember-rdfa-editor/utils/ember-node';
9
8
  import { getOutgoingTriple } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
10
9
  import { EXT } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
11
10
 
12
11
  export default class VariableNodeViewComponent extends Component<EmberNodeArgs> {
13
- PencilIcon = PencilIcon;
14
-
15
12
  @tracked innerView?: SayView;
16
13
 
17
14
  get plugins(): ProsePlugin[] {
@@ -39,11 +36,23 @@ export default class VariableNodeViewComponent extends Component<EmberNodeArgs>
39
36
  initEditor(view: SayView) {
40
37
  this.innerView = view;
41
38
  }
42
-
39
+ @action
40
+ resetVariable() {
41
+ if (this.innerView && this.innerView.state.doc.childCount === 0) {
42
+ const tr = this.innerView.state.tr;
43
+ const placeholderNode = this.innerView.state.schema.node('placeholder', {
44
+ placeholderText: this.label,
45
+ });
46
+ tr.insert(0, placeholderNode);
47
+ this.innerView?.dispatch(tr);
48
+ }
49
+ }
43
50
  get label() {
44
- if (this.innerView?.state.doc.firstChild?.type.name !== 'placeholder') {
45
- return '';
51
+ const labelTriple = getOutgoingTriple(this.args.node.attrs, EXT('label'));
52
+ if (labelTriple) {
53
+ return labelTriple.object.value;
54
+ } else {
55
+ return this.args.node.attrs.label;
46
56
  }
47
- return getOutgoingTriple(this.args.node.attrs, EXT('label'))?.object.value;
48
57
  }
49
58
  }
@@ -0,0 +1,22 @@
1
+ import { IBindings } from 'fetch-sparql-endpoint';
2
+ import { unwrap } from '../utils/option';
3
+
4
+ export default class Electee {
5
+ constructor(
6
+ readonly uri: string,
7
+ readonly firstName: string,
8
+ readonly lastName: string,
9
+ readonly kandidatenlijst?: string,
10
+ ) {}
11
+ static fromBinding(binding: IBindings) {
12
+ const uri = unwrap(binding['person'].value);
13
+ const firstName = unwrap(binding['firstName'].value);
14
+ const lastName = unwrap(binding['lastName'].value);
15
+ const kandidatenlijst = binding['kandidatenlijstLabel']?.value;
16
+ return new Electee(uri, firstName, lastName, kandidatenlijst);
17
+ }
18
+
19
+ get fullName() {
20
+ return `${this.firstName} ${this.lastName}`;
21
+ }
22
+ }
@@ -1,6 +1,6 @@
1
1
  import { SayController } from '@lblod/ember-rdfa-editor';
2
- import Mandatee from '@lblod/ember-rdfa-editor-lblod-plugins/models/mandatee';
3
2
  import { BestuursperiodeLabel } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
3
+ import { Person } from '../variable-plugin/variables';
4
4
 
5
5
  export type LmbPluginConfig = {
6
6
  endpoint: string;
@@ -8,18 +8,16 @@ export type LmbPluginConfig = {
8
8
  defaultAdminUnit?: string;
9
9
  };
10
10
 
11
- export function createMandateeNode(
12
- controller: SayController,
13
- mandatee: Mandatee,
14
- ) {
11
+ export function createPersonNode(controller: SayController, person: Person) {
15
12
  const schema = controller.schema;
16
- const mandateeNode = schema.node(
13
+ const fullName = `${person.firstName} ${person.lastName}`;
14
+ const electeeNode = schema.node(
17
15
  'inline_rdfa',
18
16
  {
19
17
  rdfaNodeType: 'resource',
20
- subject: mandatee.mandateeUri,
18
+ subject: person.uri,
21
19
  },
22
- [schema.text(`${mandatee.fullName}`)],
20
+ [schema.text(`${fullName}`)],
23
21
  );
24
- return mandateeNode;
22
+ return electeeNode;
25
23
  }
@@ -0,0 +1,163 @@
1
+ import { SearchSort } from '@lblod/ember-rdfa-editor-lblod-plugins/components/lmb-plugin/search-modal';
2
+ import Electee from '@lblod/ember-rdfa-editor-lblod-plugins/models/electee';
3
+ import { BESTUURSPERIODES } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
4
+ import {
5
+ executeQuery,
6
+ sparqlEscapeString,
7
+ } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/sparql-helpers';
8
+
9
+ export type FetchMandateesArgs = {
10
+ endpoint: string;
11
+ searchString: string;
12
+ adminUnitSearch: string;
13
+ page: number;
14
+ pageSize: number;
15
+ sort: SearchSort;
16
+ period: (typeof BESTUURSPERIODES)[keyof typeof BESTUURSPERIODES];
17
+ };
18
+
19
+ export async function countElectees({
20
+ endpoint,
21
+ searchString,
22
+ adminUnitSearch,
23
+ period,
24
+ }: Pick<
25
+ FetchMandateesArgs,
26
+ 'searchString' | 'endpoint' | 'period' | 'adminUnitSearch'
27
+ >) {
28
+ const query = /* sparql */ `
29
+ PREFIX besluit: <http://data.vlaanderen.be/ns/besluit#>
30
+ PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
31
+ PREFIX mandaat: <http://data.vlaanderen.be/ns/mandaat#>
32
+ PREFIX foaf: <http://xmlns.com/foaf/0.1/>
33
+ PREFIX persoon: <http://data.vlaanderen.be/ns/persoon#>
34
+ PREFIX person: <http://www.w3.org/ns/person#>
35
+ PREFIX lmb: <http://lblod.data.gift/vocabularies/lmb/>
36
+ PREFIX org: <http://www.w3.org/ns/org#>
37
+
38
+ SELECT (COUNT(DISTINCT ?person) as ?count) WHERE {
39
+ ?person a person:Person;
40
+ foaf:familyName ?lastName;
41
+ persoon:gebruikteVoornaam ?firstName.
42
+
43
+ ?bestuursorgaanIT lmb:heeftBestuursperiode <${period}>;
44
+ mandaat:isTijdspecialisatieVan/besluit:bestuurt/skos:prefLabel ?adminUnitName.
45
+ {
46
+ ?verkiezing mandaat:steltSamen ?bestuursorgaanIT.
47
+ ?kandidatenlijst mandaat:behoortTot ?verkiezing.
48
+
49
+ ?verkiezingsresultaat mandaat:isResultaatVoor ?kandidatenlijst.
50
+ ?verkiezingsresultaat mandaat:isResultaatVan ?person.
51
+ }
52
+ UNION
53
+ {
54
+ ?mandatee a mandaat:Mandataris;
55
+ org:holds ?mandaat;
56
+ mandaat:isBestuurlijkeAliasVan ?person.
57
+ ?bestuursorgaanIT org:hasPost ?mandaat.
58
+ }
59
+
60
+ ${adminUnitSearch.length ? `FILTER(contains(lcase(?adminUnitName), lcase(${sparqlEscapeString(adminUnitSearch)}) )).` : ''}
61
+ ${searchString.length ? `FILTER(contains(lcase(concat(?firstName, " ", ?lastName)), lcase(${sparqlEscapeString(searchString)}) )).` : ''}
62
+ }
63
+ `;
64
+ const response = await executeQuery({
65
+ query,
66
+ endpoint,
67
+ });
68
+ return Number(response.results.bindings[0].count.value);
69
+ }
70
+
71
+ export async function fetchElectees({
72
+ endpoint,
73
+ page,
74
+ pageSize,
75
+ searchString,
76
+ adminUnitSearch,
77
+ sort,
78
+ period,
79
+ }: FetchMandateesArgs) {
80
+ const count = await countElectees({
81
+ endpoint,
82
+ searchString,
83
+ period,
84
+ adminUnitSearch,
85
+ });
86
+ let sortString = '?lastName ?firstName';
87
+ if (sort) {
88
+ const [key, direction] = sort;
89
+ switch (key) {
90
+ case 'fullName':
91
+ sortString = `${direction}(?lastName) ?firstName`;
92
+ break;
93
+ case 'kandidatenlijst':
94
+ sortString = `${direction}(?kandidatenlijstLabel) ?lastName ?firstName`;
95
+ break;
96
+ default:
97
+ break;
98
+ }
99
+ }
100
+
101
+ /**
102
+ * This query fetches two types of people:
103
+ * - People who have participated in the elections (and may or may not have a mandatee)
104
+ * - People who have a mandatee
105
+ * (here we filter out the ones who participated in the elections as we don't want to get duplicates)
106
+ */
107
+ const query = /* sparql */ `
108
+ PREFIX besluit: <http://data.vlaanderen.be/ns/besluit#>
109
+ PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
110
+ PREFIX mandaat: <http://data.vlaanderen.be/ns/mandaat#>
111
+ PREFIX foaf: <http://xmlns.com/foaf/0.1/>
112
+ PREFIX persoon: <http://data.vlaanderen.be/ns/persoon#>
113
+ PREFIX person: <http://www.w3.org/ns/person#>
114
+ PREFIX lmb: <http://lblod.data.gift/vocabularies/lmb/>
115
+ PREFIX org: <http://www.w3.org/ns/org#>
116
+
117
+ SELECT DISTINCT ?person ?firstName ?lastName ?kandidatenlijstLabel WHERE {
118
+ ?person a person:Person;
119
+ foaf:familyName ?lastName;
120
+ persoon:gebruikteVoornaam ?firstName.
121
+
122
+
123
+ ?bestuursorgaanIT lmb:heeftBestuursperiode <${period}>;
124
+ mandaat:isTijdspecialisatieVan/besluit:bestuurt/skos:prefLabel ?adminUnitName.
125
+ {
126
+ ?verkiezing mandaat:steltSamen ?bestuursorgaanIT.
127
+ ?kandidatenlijst mandaat:behoortTot ?verkiezing.
128
+ ?kandidatenlijst skos:prefLabel ?kandidatenlijstLabel.
129
+
130
+ ?verkiezingsresultaat mandaat:isResultaatVoor ?kandidatenlijst.
131
+ ?verkiezingsresultaat mandaat:isResultaatVan ?person.
132
+ }
133
+ UNION
134
+ {
135
+ ?mandatee a mandaat:Mandataris;
136
+ org:holds ?mandaat;
137
+ mandaat:isBestuurlijkeAliasVan ?person.
138
+ ?bestuursorgaanIT org:hasPost ?mandaat.
139
+
140
+ FILTER NOT EXISTS {
141
+ ?_bestuursorgaanIT lmb:heeftBestuursperiode <${period}>.
142
+ ?verkiezing mandaat:steltSamen ?_bestuursorgaanIT.
143
+ ?kandidatenlijst mandaat:behoortTot ?verkiezing.
144
+ ?kandidatenlijst skos:prefLabel ?kandidatenlijstLabel.
145
+
146
+ ?verkiezingsresultaat mandaat:isResultaatVoor ?kandidatenlijst.
147
+ ?verkiezingsresultaat mandaat:isResultaatVan ?person.
148
+ }
149
+ }
150
+
151
+ ${adminUnitSearch.length ? `FILTER(contains(lcase(?adminUnitName), lcase(${sparqlEscapeString(adminUnitSearch)}) )).` : ''}
152
+ ${searchString.length ? `FILTER(contains(lcase(concat(?firstName, " ", ?lastName)), lcase(${sparqlEscapeString(searchString)}) )).` : ''}
153
+ }
154
+ ORDER BY ${sortString}
155
+ LIMIT ${pageSize} OFFSET ${page * pageSize}
156
+ `;
157
+ const response = await executeQuery({
158
+ query,
159
+ endpoint,
160
+ });
161
+ const electees = response.results.bindings.map(Electee.fromBinding);
162
+ return { electees, count };
163
+ }
@@ -22,7 +22,7 @@ import {
22
22
  parseVariableInstance,
23
23
  parseVariableType,
24
24
  } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/variable-attribute-parsers';
25
- import AutofilledNodeViewComponent from '@lblod/ember-rdfa-editor-lblod-plugins/components/variable-plugin/autofilled/nodeview';
25
+ import NodeViewComponent from '@lblod/ember-rdfa-editor-lblod-plugins/components/variable-plugin/variable/nodeview';
26
26
  import type { ComponentLike } from '@glint/template';
27
27
  import { hasOutgoingNamedNodeTriple } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
28
28
  import { renderRdfaAware } from '@lblod/ember-rdfa-editor/core/schema';
@@ -139,7 +139,7 @@ const toDOM = (node: PNode): DOMOutputSpec => {
139
139
 
140
140
  const emberNodeConfig: EmberNodeConfig = {
141
141
  name: 'autofilled-variable',
142
- component: AutofilledNodeViewComponent as unknown as ComponentLike,
142
+ component: NodeViewComponent as unknown as ComponentLike,
143
143
  inline: true,
144
144
  group: 'inline variable',
145
145
  content: 'inline*',
@@ -20,7 +20,7 @@ import {
20
20
  typeSpan,
21
21
  } from '../utils/dom-constructors';
22
22
  import { contentSpan } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/dom-output-spec-helpers';
23
- import LocationNodeViewComponent from '@lblod/ember-rdfa-editor-lblod-plugins/components/variable-plugin/location/nodeview';
23
+ import NodeViewComponent from '@lblod/ember-rdfa-editor-lblod-plugins/components/variable-plugin/variable/nodeview';
24
24
  import type { ComponentLike } from '@glint/template';
25
25
 
26
26
  const CONTENT_SELECTOR = `span[property~='${EXT('content').prefixed}'],
@@ -35,7 +35,6 @@ const parseDOM = [
35
35
  node.querySelector(CONTENT_SELECTOR) &&
36
36
  parseVariableType(node) === 'location'
37
37
  ) {
38
- console.log('Parse location: ', node);
39
38
  const mappingResource = node.getAttribute('resource');
40
39
  if (!mappingResource) {
41
40
  return false;
@@ -74,7 +73,7 @@ const toDOM = (node: PNode): DOMOutputSpec => {
74
73
 
75
74
  const emberNodeConfig: EmberNodeConfig = {
76
75
  name: 'location',
77
- component: LocationNodeViewComponent as unknown as ComponentLike,
76
+ component: NodeViewComponent as unknown as ComponentLike,
78
77
  inline: true,
79
78
  group: 'inline variable',
80
79
  content: 'inline*',
@@ -19,13 +19,18 @@ import PersonNodeViewComponent from '@lblod/ember-rdfa-editor-lblod-plugins/comp
19
19
  import type { ComponentLike } from '@glint/template';
20
20
  import { hasOutgoingNamedNodeTriple } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
21
21
  import { renderRdfaAware } from '@lblod/ember-rdfa-editor/core/schema';
22
- import Mandatee from '@lblod/ember-rdfa-editor-lblod-plugins/models/mandatee';
23
22
  import { getTranslationFunction } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/translation';
24
23
 
25
24
  const TRANSLATION_FALLBACKS = {
26
25
  nodeview_placeholder: 'persoon',
27
26
  };
28
27
 
28
+ export type Person = {
29
+ uri: string;
30
+ firstName: string;
31
+ lastName: string;
32
+ };
33
+
29
34
  const rdfaAware = true;
30
35
  const parseDOM = [
31
36
  {
@@ -44,9 +49,24 @@ const parseDOM = [
44
49
  if (attrs.rdfaNodeType !== 'resource') {
45
50
  return false;
46
51
  }
52
+ let value: Person | undefined;
53
+ if (node.dataset.value) {
54
+ value = JSON.parse(node.dataset.value) as Person;
55
+ } else if (node.dataset.mandatee) {
56
+ const mandatee = JSON.parse(node.dataset.mandatee) as {
57
+ personUri: string;
58
+ firstName: string;
59
+ lastName: string;
60
+ };
61
+ value = {
62
+ uri: mandatee.personUri,
63
+ firstName: mandatee.firstName,
64
+ lastName: mandatee.lastName,
65
+ };
66
+ }
47
67
  return {
48
68
  ...attrs,
49
- mandatee: JSON.parse(node.getAttribute('data-mandatee') ?? '{}'),
69
+ value,
50
70
  };
51
71
  }
52
72
 
@@ -58,16 +78,16 @@ const parseDOM = [
58
78
 
59
79
  const serialize = (node: PNode, state: EditorState): DOMOutputSpec => {
60
80
  const t = getTranslationFunction(state);
61
- const mandatee = node.attrs.mandatee as Mandatee;
81
+ const person = node.attrs.value as Person | undefined;
62
82
  return renderRdfaAware({
63
83
  renderable: node,
64
84
  tag: 'span',
65
85
  attrs: {
66
86
  ...node.attrs,
67
- 'data-mandatee': JSON.stringify(mandatee),
87
+ 'data-value': JSON.stringify(person),
68
88
  },
69
- content: mandatee
70
- ? `${mandatee.fullName}`
89
+ content: person
90
+ ? `${person.firstName} ${person.lastName}`
71
91
  : t(
72
92
  'variable-plugin.person.nodeview-placeholder',
73
93
  TRANSLATION_FALLBACKS.nodeview_placeholder,
@@ -90,10 +110,7 @@ const emberNodeConfig: EmberNodeConfig = {
90
110
  selectable: true,
91
111
  attrs: {
92
112
  ...rdfaAttrSpec({ rdfaAware }),
93
- content: {
94
- default: null,
95
- },
96
- mandatee: {
113
+ value: {
97
114
  default: null,
98
115
  },
99
116
  },
@@ -68,7 +68,10 @@ export function hasOutgoingNamedNodeTriple(
68
68
  });
69
69
  }
70
70
 
71
- export function getOutgoingTriple(rdfaAttrs: Attrs, predicate: Resource) {
71
+ export function getOutgoingTriple(
72
+ rdfaAttrs: Attrs,
73
+ predicate: Resource,
74
+ ): Option<OutgoingTriple> {
72
75
  return (isRdfaAttrs(rdfaAttrs) &&
73
76
  rdfaAttrs.rdfaNodeType === 'resource' &&
74
77
  rdfaAttrs.properties.find((prop) =>
@@ -49,39 +49,34 @@
49
49
  }
50
50
  }
51
51
 
52
+ .ember-node.say-active:has(> .say-pill) {
53
+ outline: none;
54
+ }
55
+
52
56
  .ember-node {
53
57
  white-space: normal !important;
54
- .variable {
55
- min-height: 30px;
56
- [contenteditable] {
57
- white-space: break-spaces;
58
- word-break: break-all;
59
- word-wrap: break-word;
60
- outline: 0px;
61
- padding: 2px;
62
- }
63
- .label {
64
- font-size: var(--au-tiny);
65
- color: var(--au-blue-700);
66
- user-select: none;
67
- margin: 0.3rem;
68
- }
69
- .au-c-icon {
70
- margin: 0;
58
+ .say-pill [contenteditable].mark-highlight-manual {
59
+ color: var(--au-orange-700);
60
+ &.ProseMirror-selectednode {
61
+ background-color: var(--au-blue-300);
62
+ outline: none;
71
63
  }
72
64
  }
65
+ .unfilled-variable {
66
+ color: var(--au-orange-700);
67
+ background-color: var(--au-orange-300);
68
+ font-style: italic;
69
+ line-height: 1.2rem;
70
+ padding: 0.3rem;
71
+ }
73
72
  }
74
73
 
75
74
  .ember-node.ProseMirror-selectednode {
76
- > .variable {
77
- &.atomic {
78
- background-color: var(--au-blue-200);
79
- }
80
- outline: 2px solid var(--au-blue-500);
81
-
82
- ::selection {
83
- background-color: var(--au-blue-300);
84
- }
75
+ > .say-pill.atomic {
76
+ background-color: var(--au-blue-200);
77
+ }
78
+ .unfilled-variable {
79
+ background-color: var(--au-blue-200);
85
80
  }
86
81
  }
87
82
 
@@ -1,7 +1,7 @@
1
1
  import Component from '@glimmer/component';
2
2
  import { SayController } from '@lblod/ember-rdfa-editor';
3
3
  import { LmbPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/lmb-plugin';
4
- import Mandatee from '@lblod/ember-rdfa-editor-lblod-plugins/models/mandatee';
4
+ import Electee from '@lblod/ember-rdfa-editor-lblod-plugins/models/electee';
5
5
  import IntlService from 'ember-intl/services/intl';
6
6
  interface Args {
7
7
  controller: SayController;
@@ -14,6 +14,6 @@ export default class LmbPluginInsertComponent extends Component<Args> {
14
14
  get controller(): SayController;
15
15
  openModal(): void;
16
16
  closeModal(): void;
17
- onInsert(mandatee: Mandatee): void;
17
+ onInsert(electee: Electee): void;
18
18
  }
19
19
  export {};
@@ -1,14 +1,14 @@
1
1
  import Component from '@glimmer/component';
2
2
  import { LmbPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/lmb-plugin';
3
- import Mandatee from '@lblod/ember-rdfa-editor-lblod-plugins/models/mandatee';
4
- import { FetchMandateesArgs } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/lmb-plugin/utils/fetchMandatees';
3
+ import Electee from '@lblod/ember-rdfa-editor-lblod-plugins/models/electee';
4
+ import { FetchMandateesArgs } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/lmb-plugin/utils/fetchElectees';
5
5
  import { BestuursperiodeLabel, BestuursperiodeURI } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
6
- export type SearchSort = [keyof Mandatee, 'ASC' | 'DESC'] | false;
6
+ export type SearchSort = [keyof Electee, 'ASC' | 'DESC'] | false;
7
7
  interface Args {
8
8
  config: LmbPluginConfig;
9
9
  open: boolean;
10
10
  closeModal: () => void;
11
- onInsert: (mandatee: Mandatee) => void;
11
+ onInsert: (electee: Electee) => void;
12
12
  }
13
13
  interface AdminPeriodOption {
14
14
  label: BestuursperiodeLabel;
@@ -31,7 +31,7 @@ export default class LmbPluginSearchModalComponent extends Component<Args> {
31
31
  setAdminUnitSearch: (event: InputEvent) => void;
32
32
  closeModal(): Promise<void>;
33
33
  search: import("ember-concurrency").TaskForAsyncTaskFunction<unknown, ({ endpoint, searchString, page, pageSize, sort, period, adminUnitSearch, }: FetchMandateesArgs) => Promise<{
34
- results: Mandatee[];
34
+ results: Electee[];
35
35
  totalCount: number;
36
36
  }>>;
37
37
  servicesResource: import("reactiveweb/ember-concurrency").TaskInstance<unknown>;
@@ -39,6 +39,6 @@ export default class LmbPluginSearchModalComponent extends Component<Args> {
39
39
  setInputSearchText(event: InputEvent): void;
40
40
  previousPage(): void;
41
41
  nextPage(): void;
42
- onInsert(mandatee: Mandatee): Promise<void>;
42
+ onInsert(electee: Electee): Promise<void>;
43
43
  }
44
44
  export {};
@@ -14,10 +14,9 @@ type Signature = {
14
14
  };
15
15
  export default class AddressNodeviewComponent extends Component<Signature> {
16
16
  intl: IntlService;
17
- get translations(): {
18
- placeholder: string;
19
- };
20
17
  get address(): Address | null;
21
18
  get label(): string | undefined;
19
+ get filled(): boolean;
20
+ get content(): string | undefined;
22
21
  }
23
22
  export {};
@@ -1,5 +1,4 @@
1
1
  import Component from '@glimmer/component';
2
- import IntlService from 'ember-intl/services/intl';
3
2
  import { PNode, SayController } from '@lblod/ember-rdfa-editor';
4
3
  import { Address } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/variable-plugin/utils/address-helpers';
5
4
  type Args = {
@@ -8,15 +7,10 @@ type Args = {
8
7
  controller: SayController;
9
8
  };
10
9
  export default class AddressNodeviewComponent extends Component<Args> {
11
- PencilIcon: TOC<import("@appuniversum/ember-appuniversum/components/icons/pencil").PencilIconSignature>;
12
- intl: IntlService;
13
- get controller(): SayController;
14
- get documentLanguage(): string;
15
- get translations(): {
16
- placeholder: string;
17
- };
18
10
  get node(): PNode;
19
11
  get address(): Address | null;
20
12
  get label(): string | undefined;
13
+ get filled(): boolean;
14
+ get content(): string | undefined;
21
15
  }
22
16
  export {};
@@ -1,6 +1,5 @@
1
1
  import Component from '@glimmer/component';
2
2
  import { DecorationSource, PNode, SayController, SayView } from '@lblod/ember-rdfa-editor';
3
- import IntlService from 'ember-intl/services/intl';
4
3
  type Args = {
5
4
  getPos: () => number | undefined;
6
5
  node: PNode;
@@ -11,11 +10,8 @@ type Args = {
11
10
  contentDecorations?: DecorationSource;
12
11
  };
13
12
  export default class DateNodeviewComponent extends Component<Args> {
14
- PencilIcon: TOC<import("@appuniversum/ember-appuniversum/components/icons/pencil").PencilIconSignature>;
15
- intl: IntlService;
16
- get controller(): SayController;
17
- get documentLanguage(): string;
18
- get humanReadableDate(): string;
13
+ get filled(): boolean;
14
+ get humanReadableDate(): string | undefined;
19
15
  get label(): string | undefined;
20
16
  }
21
17
  export {};