@lblod/ember-rdfa-editor-lblod-plugins 7.0.0 → 8.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 (43) hide show
  1. package/CHANGELOG.md +35 -2
  2. package/README.md +34 -10
  3. package/addon/components/decision-plugin/decision-plugin-card.hbs +22 -6
  4. package/addon/components/decision-plugin/decision-plugin-card.ts +37 -18
  5. package/addon/components/generic-rdfa-variable/insert-menu.hbs +30 -0
  6. package/addon/components/generic-rdfa-variable/insert-menu.ts +97 -0
  7. package/addon/components/rdfa-date-plugin/date.hbs +9 -0
  8. package/addon/components/rdfa-date-plugin/date.ts +55 -0
  9. package/addon/components/variable-plugin/insert-variable-card.hbs +19 -0
  10. package/addon/components/variable-plugin/insert-variable-card.ts +26 -5
  11. package/addon/components/variable-plugin/number-settings.hbs +31 -0
  12. package/addon/components/variable-plugin/template-variable-card.hbs +3 -0
  13. package/addon/components/variable-plugin/template-variable-card.ts +3 -0
  14. package/addon/components/variable-plugin/variable.hbs +7 -1
  15. package/addon/components/variable-plugin/variable.ts +39 -0
  16. package/addon/plugins/decision-plugin/commands/insert-motivation.ts +59 -6
  17. package/addon/plugins/decision-plugin/utils/validation-rules.ts +11 -0
  18. package/addon/plugins/rdfa-date-plugin/nodes/date.ts +150 -114
  19. package/addon/plugins/validation/README.md +1 -1
  20. package/addon/plugins/validation/index.ts +2 -17
  21. package/addon/plugins/variable-plugin/nodes.ts +68 -3
  22. package/addon/plugins/variable-plugin/utils/constants.ts +29 -15
  23. package/addon/plugins/variable-plugin/utils/fetch-data.ts +9 -5
  24. package/app/components/generic-rdfa-variable/insert-menu.js +1 -0
  25. package/app/components/rdfa-date-plugin/date.js +1 -0
  26. package/app/components/variable-plugin/number-settings.js +1 -0
  27. package/app/styles/besluit-plugin.scss +1 -1
  28. package/app/styles/generic-rdfa-variable.scss +20 -0
  29. package/app/styles/variable-plugin.scss +31 -0
  30. package/components/decision-plugin/decision-plugin-card.d.ts +4 -2
  31. package/components/generic-rdfa-variable/insert-menu.d.ts +17 -0
  32. package/components/rdfa-date-plugin/date.d.ts +16 -0
  33. package/components/variable-plugin/insert-variable-card.d.ts +4 -0
  34. package/components/variable-plugin/template-variable-card.d.ts +1 -0
  35. package/components/variable-plugin/variable.d.ts +11 -0
  36. package/package.json +8 -4
  37. package/plugins/decision-plugin/commands/insert-motivation.d.ts +3 -2
  38. package/plugins/decision-plugin/utils/validation-rules.d.ts +10 -0
  39. package/plugins/rdfa-date-plugin/nodes/date.d.ts +2 -3
  40. package/plugins/variable-plugin/nodes.d.ts +22 -1
  41. package/plugins/variable-plugin/utils/constants.d.ts +11 -2
  42. package/translations/en-US.yaml +29 -1
  43. package/translations/nl-BE.yaml +29 -1
package/CHANGELOG.md CHANGED
@@ -7,6 +7,36 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+
11
+ ## [8.0.0] - 2023-06-13
12
+ ### Fixed
13
+ - Bump `@lblod/ember-rdfa-editor` package to fix annotation not present for some structures
14
+ - Change variable label to be stored in the data-attributes and solve bug with date not getting a default label
15
+
16
+ ### Added
17
+ - navigation links in TOC of readme
18
+ - support for option labels in Variable-plugin
19
+ - Generic rdfa variables input plugin - HTML only input
20
+ - Number variable - support min/max
21
+
22
+ ### Breaking
23
+ - Add label to variables
24
+
25
+ ### Dependencies
26
+ - Bumps `webpack` from 5.75.0 to 5.76.0
27
+ - Move `tracked-toolbox` to dependencies
28
+ - Bumps `prettier` from 2.8.0 to 2.8.8
29
+ - Bumps `minimist` from 0.2.2 to 0.2.4
30
+ - Bumps `socket.io-parser` from 4.2.1 to 4.2.4
31
+ - Bumps `decode-uri-component` from 0.2.0 to 0.2.2
32
+ - Bumps loader-utils from 1.0.4 to 2.0.4
33
+ - Bumps handlebars-loader from 1.7.2 to 1.7.3
34
+
35
+ ## [7.1.0] - 2023-05-18
36
+
37
+ ### Added
38
+ - validate motivering and article section
39
+
10
40
  ## [7.0.0] - 2023-05-17
11
41
  ### Added
12
42
  - add docker build for easy demo environments
@@ -14,9 +44,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
14
44
  - BREAKING: Endpoint config for `CitationPlugin`
15
45
  ### Fixed
16
46
  - Remove structure doesn't always work - disable the "Remove <structure>" button correctly
47
+ - Fix initialization of default date properties
17
48
 
18
49
  ### Fixed
19
- - Fix initialization of default date properties
50
+
20
51
  ## [6.1.0] - 2023-05-11
21
52
 
22
53
  ### Added
@@ -438,7 +469,9 @@ add onclick handler to pencil icon in variable plugin
438
469
 
439
470
  # Changelog
440
471
 
441
- [unreleased]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v7.0.0...HEAD
472
+ [unreleased]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v8.0.0...HEAD
473
+ [8.0.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v7.1.0...v8.0.0
474
+ [7.1.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v7.0.0...v7.1.0
442
475
  [7.0.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v6.1.0...v7.0.0
443
476
  [6.1.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v6.0.0...v6.1.0
444
477
  [6.0.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v5.0.1...v6.0.0
package/README.md CHANGED
@@ -19,16 +19,18 @@ ember install ember-rdfa-editor-lblod-plugins
19
19
 
20
20
  This addon contains the following editor plugins:
21
21
 
22
- * besluit-type-plugin
23
- * citaten-plugin
24
- * import-snippet-plugin
25
- * insert-variable-plugin
26
- * rdfa-date-plugin
27
- * roadsign-regulation-plugin
28
- * standard-template-plugin
29
- * table-of-contents-plugin
30
- * template-variable-plugin
31
- * validation-plugin
22
+ * [besluit-type-plugin](#besluit-type-plugin)
23
+ * [citaten-plugin](#citaten-plugin)
24
+ * [decision-plugin](#decision-plugin)
25
+ * [import-snippet-plugin](#import-snippet-plugin)
26
+ * [insert-variable-plugin](#insert-variable-plugin)
27
+ * [rdfa-date-plugin](#rdfa-date-plugin)
28
+ * [roadsign-regulation-plugin](#roadsign-regulation-plugin)
29
+ * [standard-template-plugin](#standard-template-plugin)
30
+ * [table-of-contents-plugin](#table-of-contents-plugin)
31
+ * [template-variable-plugin](#template-variable-plugin)
32
+ * [validation-plugin](#validation-plugin)
33
+ * [address-plugin](#address-plugin)
32
34
 
33
35
  You can configure your editor like this:
34
36
  ```hbs
@@ -76,6 +78,28 @@ You can need to specify the endpoint from which the plugin will fetch the types
76
78
  }
77
79
  ```
78
80
 
81
+ ## decision-plugin
82
+
83
+ This plugin provides some warnings to the user if the validation for a besluit fails, it need to be used with the validation plugin as it exports some validation rules for it.
84
+ In order to use it you will need to add its card to the sidebar like
85
+ ```hbs
86
+ <DecisionPlugin::DecisionPluginCard
87
+ @controller={{this.controller}}
88
+ />
89
+ ```
90
+
91
+ and then import the rule and add it to the config of your validation plugin like
92
+ ```js
93
+ import { atLeastOneArticleContainer } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/decision-plugin/utils/validation-rules';
94
+ ...
95
+ @tracked validationPlugin = validation((schema: Schema) => ({
96
+ shapes: [
97
+ atLeastOneArticleContainer(schema),
98
+ ]
99
+ })
100
+ ```
101
+ With these changes you will see a warning if the decision is missing a title, a motivation block or an article block.
102
+
79
103
  ## citaten-plugin
80
104
 
81
105
  Plugin which allows a user to insert references to a legal resource or legal expression into the document.
@@ -1,8 +1,24 @@
1
1
  {{#if this.canInsertTitle}}
2
- <AuAlert class="title-alert" @skin="warning" @closable={{false}} @icon="alert-triangle" @title={{t "besluit-plugin.missing-title-warning"}}>
3
- <AuButton @iconAlignment="left" @skin="link-secondary" @disabled={{not this.canInsertTitle}} {{on 'click'
4
- this.insertTitle}}>
5
- {{t "besluit-plugin.insert.decision-title"}}
6
- </AuButton>
7
- </AuAlert>
2
+ <AuAlert class="validation-alert" @skin="warning" @closable={{false}} @icon="alert-triangle" @title={{t "besluit-plugin.missing-title-warning"}}>
3
+ <AuButton @iconAlignment="left" @skin="link-secondary" @disabled={{not this.canInsertTitle}} {{on 'click'
4
+ this.insertTitle}}>
5
+ {{t "besluit-plugin.insert.decision-title"}}
6
+ </AuButton>
7
+ </AuAlert>
8
+ {{/if}}
9
+ {{#if this.canInsertMotivation}}
10
+ <AuAlert class="validation-alert" @skin="warning" @closable={{false}} @icon="alert-triangle" @title={{t "besluit-plugin.missing-motivation-warning"}}>
11
+ <AuButton @iconAlignment="left" @skin="link-secondary" @disabled={{not this.canInsertMotivation}} {{on 'click'
12
+ this.insertMotivation}}>
13
+ {{t "besluit-plugin.insert.motivation"}}
14
+ </AuButton>
15
+ </AuAlert>
16
+ {{/if}}
17
+ {{#if this.missingArticleBlock}}
18
+ <AuAlert class="validation-alert" @skin="warning" @closable={{false}} @icon="alert-triangle" @title={{t "besluit-plugin.missing-article-block-warning"}}>
19
+ <AuButton @iconAlignment="left" @skin="link-secondary" @disabled={{not this.missingArticleBlock}} {{on 'click'
20
+ this.insertArticleBlock}}>
21
+ {{t "besluit-plugin.insert.article-block"}}
22
+ </AuButton>
23
+ </AuAlert>
8
24
  {{/if}}
@@ -1,9 +1,13 @@
1
1
  import Component from '@glimmer/component';
2
2
  import { action } from '@ember/object';
3
- import { insertTitle } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/decision-plugin/commands';
3
+ import {
4
+ insertMotivation,
5
+ insertArticleContainer,
6
+ } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/decision-plugin/commands';
4
7
  import { SayController } from '@lblod/ember-rdfa-editor';
5
8
  import { inject as service } from '@ember/service';
6
9
  import IntlService from 'ember-intl/services/intl';
10
+ import { VALIDATION_KEY } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/validation';
7
11
 
8
12
  type Args = {
9
13
  controller: SayController;
@@ -24,26 +28,41 @@ export default class DecisionPluginCard extends Component<Args> {
24
28
  }
25
29
 
26
30
  @action
27
- insertTitle() {
28
- this.controller.doCommand(
29
- insertTitle({
30
- placeholderText: this.intl.t('besluit-plugin.insert.decision-title'),
31
- }),
32
- {
33
- view: this.controller.mainEditorView,
34
- }
35
- );
31
+ insertMotivation() {
32
+ this.controller.doCommand(insertMotivation({ intl: this.intl }), {
33
+ view: this.controller.mainEditorView,
34
+ });
35
+ this.focus();
36
+ }
37
+
38
+ get canInsertMotivation() {
39
+ return this.controller.checkCommand(insertMotivation({ intl: this.intl }), {
40
+ view: this.controller.mainEditorView,
41
+ });
42
+ }
43
+
44
+ @action
45
+ insertArticleBlock() {
46
+ this.controller.doCommand(insertArticleContainer({ intl: this.intl }), {
47
+ view: this.controller.mainEditorView,
48
+ });
36
49
  this.focus();
37
50
  }
38
51
 
39
- get canInsertTitle() {
40
- return this.controller.checkCommand(
41
- insertTitle({
42
- placeholderText: this.intl.t('besluit-plugin.insert.decision-title'),
43
- }),
44
- {
45
- view: this.controller.mainEditorView,
52
+ get missingArticleBlock() {
53
+ const state = VALIDATION_KEY.getState(this.controller.activeEditorState);
54
+ if (state) {
55
+ let missingArticleBlock = false;
56
+ const results = state.report.results;
57
+ if (!results) return false;
58
+ for (const result of results) {
59
+ if (result.sourceShape.name === 'at-least-one-article-container') {
60
+ missingArticleBlock = true;
61
+ }
46
62
  }
47
- );
63
+ return missingArticleBlock;
64
+ } else {
65
+ return false;
66
+ }
48
67
  }
49
68
  }
@@ -0,0 +1,30 @@
1
+ <Toolbar::Button
2
+ @title={{t 'generic-rdfa-variable.menu.insert'}}
3
+ @icon='html-plus'
4
+ {{on 'click' this.showModal}}
5
+ />
6
+ <AuModal
7
+ @modalOpen={{this.modalOpen}}
8
+ @closeModal={{this.onCancel}}
9
+ @initialFocus={{false}}
10
+ class='generic-rdfa-plugin-modal'
11
+ >
12
+ <:title>{{t 'generic-rdfa-variable.menu.insert'}}</:title>
13
+ <:body>
14
+ <div
15
+ class='generic-rdfa-variable-textarea-wrapper'
16
+ {{did-insert this.setupHtmlEditor}}
17
+ >
18
+ </div>
19
+ </:body>
20
+ <:footer>
21
+ <AuButtonGroup>
22
+ <AuButton @skin='primary' {{on 'click' this.onInsert}}>
23
+ {{t 'generic-rdfa-variable.modal.insert'}}
24
+ </AuButton>
25
+ <AuButton @skin='secondary' {{on 'click' this.onCancel}}>
26
+ {{t 'generic-rdfa-variable.modal.cancel'}}
27
+ </AuButton>
28
+ </AuButtonGroup>
29
+ </:footer>
30
+ </AuModal>
@@ -0,0 +1,97 @@
1
+ import Component from '@glimmer/component';
2
+ import { action } from '@ember/object';
3
+ import { SayController } from '@lblod/ember-rdfa-editor';
4
+ import { tracked } from 'tracked-built-ins';
5
+
6
+ import { DOMParser as ProseParser } from 'prosemirror-model';
7
+
8
+ import { basicSetup, EditorView } from 'codemirror';
9
+ import { EditorState } from '@codemirror/state';
10
+ import { html } from '@codemirror/lang-html';
11
+ import { tooltips } from '@codemirror/view';
12
+
13
+ type Args = {
14
+ controller: SayController;
15
+ };
16
+
17
+ export default class GenericRdfaVariableInsertMenu extends Component<Args> {
18
+ @tracked modalOpen = false;
19
+ private htmlEditor?: EditorView;
20
+
21
+ get controller() {
22
+ return this.args.controller;
23
+ }
24
+
25
+ get schema() {
26
+ return this.args.controller.schema;
27
+ }
28
+
29
+ @action
30
+ showModal() {
31
+ this.modalOpen = true;
32
+ }
33
+
34
+ @action
35
+ closeModal() {
36
+ this.modalOpen = false;
37
+
38
+ // The recommended way to focus the editor is to call `this.controller.focus()` before opening the modal
39
+ // e.g. in the `showModal` fn, then `focus-trap` inside modal will record it as the element that should
40
+ // be focused when `focus-trap` is deactivated (modal is closed).
41
+ //
42
+ // However, for some reason, this doesn't work in this case. Maybe because `initialFocus` is false, maybe
43
+ // because of something else, I wasn't able to get to the bottom of it.
44
+ //
45
+ // So, we're doing it the other way here: we wait for the modal to close, wait for the `focus-trap` to
46
+ // deactivate, and then focus the editor.
47
+ setTimeout(() => {
48
+ this.controller.focus();
49
+ }, 0);
50
+ }
51
+
52
+ @action
53
+ onCancel() {
54
+ this.closeModal();
55
+ }
56
+
57
+ @action
58
+ setupHtmlEditor(element: HTMLElement) {
59
+ this.htmlEditor = new EditorView({
60
+ state: EditorState.create({
61
+ extensions: [
62
+ basicSetup,
63
+ html(),
64
+ tooltips({ position: 'absolute', parent: element }),
65
+ ],
66
+ }),
67
+ parent: element,
68
+ });
69
+
70
+ this.htmlEditor.focus();
71
+ }
72
+
73
+ @action
74
+ onInsert() {
75
+ if (!this.htmlEditor) {
76
+ return;
77
+ }
78
+
79
+ const editorContent = this.htmlEditor.state.sliceDoc();
80
+
81
+ if (!editorContent) {
82
+ return;
83
+ }
84
+
85
+ const domParser = new DOMParser();
86
+
87
+ this.controller.withTransaction((tr) => {
88
+ return tr.replaceSelectionWith(
89
+ ProseParser.fromSchema(this.schema).parse(
90
+ domParser.parseFromString(editorContent, 'text/html')
91
+ )
92
+ );
93
+ });
94
+
95
+ this.closeModal();
96
+ }
97
+ }
@@ -0,0 +1,9 @@
1
+ <AuPill @icon="pencil" @iconAlignment="right" class="variable" {{on 'click' this.onClick}}>
2
+
3
+ {{this.humanReadableDate}}
4
+ {{#if @node.attrs.label}}
5
+ <span class="label">
6
+ ({{@node.attrs.label}})
7
+ </span>
8
+ {{/if}}
9
+ </AuPill>
@@ -0,0 +1,55 @@
1
+ import Component from '@glimmer/component';
2
+ import {
3
+ DecorationSource,
4
+ NodeSelection,
5
+ PNode,
6
+ SayController,
7
+ SayView,
8
+ } from '@lblod/ember-rdfa-editor';
9
+ import { action } from '@ember/object';
10
+ import {
11
+ formatDate,
12
+ validateDateFormat,
13
+ } from '../../plugins/rdfa-date-plugin/utils';
14
+ import { DateOptions } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/rdfa-date-plugin';
15
+
16
+ type Args = {
17
+ getPos: () => number | undefined;
18
+ node: PNode;
19
+ updateAttribute: (attr: string, value: unknown) => void;
20
+ controller: SayController;
21
+ view: SayView;
22
+ selected: boolean;
23
+ contentDecorations?: DecorationSource;
24
+ };
25
+
26
+ export default class VariableComponent extends Component<Args> {
27
+ @action
28
+ onClick() {
29
+ const tr = this.args.controller.activeEditorState.tr;
30
+ tr.setSelection(
31
+ NodeSelection.create(
32
+ this.args.controller.activeEditorState.doc,
33
+ this.args.getPos() as number
34
+ )
35
+ );
36
+ this.args.controller.activeEditorView.dispatch(tr);
37
+ }
38
+
39
+ get humanReadableDate() {
40
+ const value = this.args.node.attrs.value as string;
41
+ const format = this.args.node.attrs.format as string;
42
+ if (value) {
43
+ if (validateDateFormat(format).type === 'ok') {
44
+ return formatDate(new Date(value), format);
45
+ } else {
46
+ return 'Ongeldig formaat';
47
+ }
48
+ } else {
49
+ const options = this.args.node.type.spec.options as DateOptions;
50
+ return (this.args.node.attrs.onlyDate as boolean)
51
+ ? options.placeholder.insertDate
52
+ : options.placeholder.insertDateTime;
53
+ }
54
+ }
55
+ }
@@ -36,6 +36,25 @@
36
36
  {{subtype.label}}
37
37
  </PowerSelect>
38
38
  {{/if}}
39
+ <AuFormRow>
40
+ <AuLabel for='label'>
41
+ {{t 'variable-plugin.label'}}
42
+ </AuLabel>
43
+ <AuInput
44
+ id="label"
45
+ placeholder={{t 'variable-plugin.labelPlaceholder'}}
46
+ @type="text"
47
+ @width="block"
48
+ @value={{this.variableLabel}}
49
+ {{on "input" this.updateVariableLabel}}
50
+ />
51
+ </AuFormRow>
52
+ {{#if (eq this.type 'number')}}
53
+ <VariablePlugin::NumberSettings
54
+ @minimumValue={{this.extraAttributes.minimumValue}}
55
+ @maximumValue={{this.extraAttributes.maximumValue}}
56
+ />
57
+ {{/if}}
39
58
  <AuButton
40
59
  {{on 'click' this.insert}}
41
60
  @disabled={{or
@@ -25,6 +25,8 @@ export default class EditorPluginsInsertCodelistCardComponent extends Component<
25
25
  @tracked hasSubtype = false;
26
26
  @tracked selectedSubtype?: CodeList;
27
27
  @tracked subtypes?: CodeList[];
28
+ @tracked variableLabel?: string;
29
+ @tracked extraAttributes: Record<string, unknown> = {};
28
30
  publisher: string;
29
31
  endpoint: string;
30
32
 
@@ -64,16 +66,30 @@ export default class EditorPluginsInsertCodelistCardComponent extends Component<
64
66
  return this.args.controller;
65
67
  }
66
68
 
69
+ @action
70
+ updateVariableLabel(event: InputEvent) {
71
+ this.variableLabel = (event.target as HTMLInputElement).value;
72
+ }
73
+
67
74
  @action
68
75
  insert() {
69
76
  if (!this.selectedVariable) {
70
77
  return;
71
78
  }
72
- const node = this.selectedVariable.constructor(
73
- this.controller.schema,
74
- this.endpoint,
75
- this.selectedSubtype
76
- );
79
+
80
+ const node = this.selectedVariable.constructor({
81
+ schema: this.controller.schema,
82
+ codelist: this.selectedSubtype,
83
+ label: this.variableLabel !== '' ? this.variableLabel : undefined,
84
+ attributes: {
85
+ source: this.endpoint,
86
+ ...this.extraAttributes,
87
+ },
88
+ });
89
+
90
+ this.variableLabel = '';
91
+ this.extraAttributes = {};
92
+
77
93
  this.controller.withTransaction(
78
94
  (tr) => {
79
95
  return tr.replaceSelectionWith(node);
@@ -108,6 +124,11 @@ export default class EditorPluginsInsertCodelistCardComponent extends Component<
108
124
  @action
109
125
  updateSubtype(subtype: CodeList) {
110
126
  this.selectedSubtype = subtype;
127
+ this.extraAttributes = {};
128
+ }
129
+
130
+ get type() {
131
+ return this.selectedVariable?.label;
111
132
  }
112
133
 
113
134
  get showCard() {
@@ -0,0 +1,31 @@
1
+ <div class='number-settings'>
2
+ <AuFormRow>
3
+ {{#let (unique-id) as |id|}}
4
+ <AuLabel for={{id}}>
5
+ {{t 'variable-plugin.number.minimum'}}
6
+ </AuLabel>
7
+ <AuInput
8
+ id={{id}}
9
+ @value={{@minimumValue}}
10
+ placeholder={{t 'variable-plugin.number.minimum-placeholder'}}
11
+ @width='block'
12
+ @type='number'
13
+ />
14
+ {{/let}}
15
+ </AuFormRow>
16
+ <div class='to'><span>{{t 'variable-plugin.number.to'}}</span></div>
17
+ <AuFormRow>
18
+ {{#let (unique-id) as |id|}}
19
+ <AuLabel for={{id}}>
20
+ {{t 'variable-plugin.number.maximum'}}
21
+ </AuLabel>
22
+ <AuInput
23
+ id={{id}}
24
+ @value={{@maximumValue}}
25
+ placeholder={{t 'variable-plugin.number.maximum-placeholder'}}
26
+ @width='block'
27
+ @type='number'
28
+ />
29
+ {{/let}}
30
+ </AuFormRow>
31
+ </div>
@@ -7,6 +7,9 @@
7
7
  </AuHeading>
8
8
  </c.header>
9
9
  <c.content>
10
+ <AuLabel for='label'>
11
+ {{this.label}}
12
+ </AuLabel>
10
13
  {{#if this.multiSelect}}
11
14
  <PowerSelectMultiple
12
15
  @allowClear={{false}}
@@ -24,6 +24,7 @@ export default class EditorPluginsTemplateVariableCardComponent extends Componen
24
24
  @tracked selectedVariable: { pos: number; node: PNode } | undefined;
25
25
  @tracked showCard = false;
26
26
  @tracked multiSelect = false;
27
+ @tracked label?: string;
27
28
  mappingUri?: string;
28
29
 
29
30
  get controller() {
@@ -93,6 +94,7 @@ export default class EditorPluginsTemplateVariableCardComponent extends Componen
93
94
  const codelistURI = variable.node.attrs.codelistResource as string;
94
95
  void this.fetchCodeListOptions.perform(source, codelistURI);
95
96
  this.showCard = true;
97
+ this.label = variable.node.attrs.label as string;
96
98
  } else if (type === 'location') {
97
99
  const source =
98
100
  (variable.node.attrs.source as string | undefined) ??
@@ -103,6 +105,7 @@ export default class EditorPluginsTemplateVariableCardComponent extends Componen
103
105
  const zonalityUri = roadSignRegulation?.node.attrs.zonality as
104
106
  | string
105
107
  | undefined;
108
+ this.label = variable.node.attrs.label as string;
106
109
  if (zonalityUri === ZONAL_URI) {
107
110
  void this.fetchCodeListOptions.perform(
108
111
  source,
@@ -1,9 +1,15 @@
1
- <AuPill @icon="pencil" @iconAlignment="right" class="variable">
1
+ <AuPill @icon="pencil" @iconAlignment="right" class="variable" {{on 'click' this.onClick}}>
2
2
  <EmberNode::EmbeddedEditor
3
3
  @controller={{@controller}}
4
4
  @node={{@node}}
5
5
  @view={{@view}}
6
6
  @getPos={{@getPos}}
7
7
  @selected={{@selected}}
8
+ @initEditor={{this.initEditor}}
8
9
  />
10
+ {{#if @node.attrs.label}}
11
+ <span class="label">
12
+ ({{@node.attrs.label}})
13
+ </span>
14
+ {{/if}}
9
15
  </AuPill>
@@ -0,0 +1,39 @@
1
+ import Component from '@glimmer/component';
2
+ import {
3
+ NodeSelection,
4
+ SayController,
5
+ SayView,
6
+ } from '@lblod/ember-rdfa-editor';
7
+ import { tracked } from '@glimmer/tracking';
8
+ import { action } from '@ember/object';
9
+
10
+ type Args = {
11
+ controller: SayController;
12
+ };
13
+
14
+ export default class VariableComponent extends Component<Args> {
15
+ @tracked innerView?: SayView;
16
+
17
+ @action
18
+ onClick() {
19
+ if (this.innerView) {
20
+ if (this.innerView.state.doc.firstChild?.type.name === 'placeholder') {
21
+ this.innerView.focus();
22
+ // Use request animation frame to only change the selection when the focus has been established
23
+ window.requestAnimationFrame(() => {
24
+ if (this.innerView) {
25
+ const tr = this.innerView.state.tr;
26
+ tr.setSelection(NodeSelection.create(this.innerView?.state.doc, 0));
27
+ this.innerView?.dispatch(tr);
28
+ }
29
+ });
30
+ } else {
31
+ this.innerView.focus();
32
+ }
33
+ }
34
+ }
35
+ @action
36
+ initEditor(view: SayView) {
37
+ this.innerView = view;
38
+ }
39
+ }