@lblod/ember-rdfa-editor-lblod-plugins 22.5.2 → 23.0.0-dev.0459b40ac0bfac80168828d9ab8afa7c1418c4fa
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.changeset/mean-deers-call.md +5 -0
- package/CHANGELOG.md +11 -0
- package/addon/components/besluit-topic-plugin/besluit-topic-toolbar-dropdown.ts +1 -1
- package/addon/components/besluit-type-plugin/toolbar-dropdown.ts +1 -1
- package/addon/components/citation-plugin/citation-card.ts +1 -1
- package/addon/components/citation-plugin/citations/legal-document-detail.ts +1 -1
- package/addon/components/citation-plugin/citations/search-modal.ts +1 -1
- package/addon/components/lmb-plugin/search-modal.ts +1 -1
- package/addon/components/location-plugin/edit.gts +1 -1
- package/addon/components/lpdc-plugin/lpdc-modal.ts +1 -1
- package/addon/components/roadsign-regulation-plugin/measure-template.ts +1 -1
- package/addon/components/snippet-plugin/nodes/snippet.gts +28 -36
- package/addon/components/snippet-plugin/search-modal.ts +1 -1
- package/addon/components/snippet-plugin/snippet-insert.gts +9 -23
- package/addon/components/snippet-plugin/snippet-list/snippet-list-modal.ts +1 -1
- package/addon/components/variable-plugin/address/edit.ts +1 -1
- package/addon/components/variable-plugin/autofilled/edit.gts +225 -0
- package/addon/components/variable-plugin/autofilled/insert.gts +143 -0
- package/addon/components/variable-plugin/autofilled/nodeview.gts +100 -0
- package/addon/components/variable-plugin/codelist/edit.ts +1 -1
- package/addon/components/variable-plugin/codelist/insert.ts +1 -1
- package/addon/components/variable-plugin/location/edit.ts +1 -1
- package/addon/components/variable-plugin/utils/label-input.gts +28 -0
- package/addon/components/worship-plugin/search-modal.ts +1 -1
- package/addon/plugins/snippet-plugin/commands/insert-snippet.ts +91 -0
- package/addon/plugins/snippet-plugin/nodes/snippet.ts +8 -51
- package/addon/plugins/variable-plugin/plugins/autofiller.ts +98 -0
- package/addon/plugins/variable-plugin/variables/autofilled.ts +170 -0
- package/addon/plugins/variable-plugin/variables/index.ts +1 -0
- package/app/components/variable-plugin/autofilled/edit.js +1 -0
- package/app/components/variable-plugin/autofilled/insert.js +1 -0
- package/app/components/variable-plugin/autofilled/nodeview.js +1 -0
- package/declarations/addon/components/besluit-topic-plugin/besluit-topic-toolbar-dropdown.d.ts +1 -1
- package/declarations/addon/components/besluit-type-plugin/toolbar-dropdown.d.ts +1 -1
- package/declarations/addon/components/citation-plugin/citation-card.d.ts +1 -1
- package/declarations/addon/components/citation-plugin/citations/legal-document-detail.d.ts +1 -1
- package/declarations/addon/components/citation-plugin/citations/search-modal.d.ts +1 -1
- package/declarations/addon/components/lmb-plugin/search-modal.d.ts +1 -1
- package/declarations/addon/components/location-plugin/edit.d.ts +1 -1
- package/declarations/addon/components/lpdc-plugin/lpdc-modal.d.ts +1 -1
- package/declarations/addon/components/roadsign-regulation-plugin/measure-template.d.ts +1 -1
- package/declarations/addon/components/snippet-plugin/search-modal.d.ts +1 -1
- package/declarations/addon/components/snippet-plugin/snippet-list/snippet-list-modal.d.ts +1 -1
- package/declarations/addon/components/variable-plugin/address/edit.d.ts +1 -1
- package/declarations/addon/components/variable-plugin/autofilled/edit.d.ts +28 -0
- package/declarations/addon/components/variable-plugin/autofilled/insert.d.ts +20 -0
- package/declarations/addon/components/variable-plugin/autofilled/nodeview.d.ts +22 -0
- package/declarations/addon/components/variable-plugin/codelist/edit.d.ts +1 -1
- package/declarations/addon/components/variable-plugin/codelist/insert.d.ts +1 -1
- package/declarations/addon/components/variable-plugin/location/edit.d.ts +1 -1
- package/declarations/addon/components/variable-plugin/utils/label-input.d.ts +11 -1
- package/declarations/addon/components/worship-plugin/search-modal.d.ts +1 -1
- package/declarations/addon/plugins/snippet-plugin/commands/insert-snippet.d.ts +14 -0
- package/declarations/addon/plugins/snippet-plugin/nodes/snippet.d.ts +5 -13
- package/declarations/addon/plugins/variable-plugin/plugins/autofiller.d.ts +8 -0
- package/declarations/addon/plugins/variable-plugin/variables/autofilled.d.ts +2 -0
- package/declarations/addon/plugins/variable-plugin/variables/index.d.ts +1 -0
- package/package.json +6 -5
- package/pnpm-lock.yaml +99 -95
- package/translations/en-US.yaml +6 -0
- package/translations/nl-BE.yaml +6 -0
- package/addon/components/variable-plugin/utils/label-input.hbs +0 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @lblod/ember-rdfa-editor-lblod-plugins
|
|
2
2
|
|
|
3
|
+
## 23.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#478](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/478) [`b3cf324`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/b3cf324e6b959a50ba354e1563b04a0e12f41f67) Thanks [@abeforgit](https://github.com/abeforgit)! - Run recalculate numbers after inserting a snippet
|
|
8
|
+
|
|
9
|
+
### Minor Changes
|
|
10
|
+
|
|
11
|
+
- [#480](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/480) [`789180f`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/789180fde786000756c2880dca9591866bf7132f) Thanks [@piemonkey](https://github.com/piemonkey)! - Internal: update to latest ember-resources 7.0.2. Requires an upgrade only if consumer app uses
|
|
12
|
+
ember dependency-lint to maintain matching versions.
|
|
13
|
+
|
|
3
14
|
## 22.5.2
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
|
@@ -2,7 +2,7 @@ import { tracked } from '@glimmer/tracking';
|
|
|
2
2
|
import Component from '@glimmer/component';
|
|
3
3
|
import { action } from '@ember/object';
|
|
4
4
|
import { SayController } from '@lblod/ember-rdfa-editor';
|
|
5
|
-
import { trackedFunction } from '
|
|
5
|
+
import { trackedFunction } from 'reactiveweb/function';
|
|
6
6
|
import { ELI } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
|
|
7
7
|
import { AlertTriangleIcon } from '@appuniversum/ember-appuniversum/components/icons/alert-triangle';
|
|
8
8
|
import { CrossIcon } from '@appuniversum/ember-appuniversum/components/icons/cross';
|
|
@@ -7,7 +7,7 @@ import { sayDataFactory } from '@lblod/ember-rdfa-editor/core/say-data-factory';
|
|
|
7
7
|
import fetchBesluitTypes, {
|
|
8
8
|
BesluitType,
|
|
9
9
|
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-type-plugin/utils/fetchBesluitTypes';
|
|
10
|
-
import { trackedFunction } from '
|
|
10
|
+
import { trackedFunction } from 'reactiveweb/function';
|
|
11
11
|
import { unwrap } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
|
|
12
12
|
import { BesluitTypePluginOptions } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-type-plugin';
|
|
13
13
|
import { RDF } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
|
|
@@ -3,7 +3,7 @@ import { tracked } from '@glimmer/tracking';
|
|
|
3
3
|
import { restartableTask, timeout } from 'ember-concurrency';
|
|
4
4
|
import { action } from '@ember/object';
|
|
5
5
|
import { capitalize } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/strings';
|
|
6
|
-
import { task as trackedTask } from '
|
|
6
|
+
import { task as trackedTask } from 'reactiveweb/ember-concurrency';
|
|
7
7
|
import {
|
|
8
8
|
Option,
|
|
9
9
|
unwrap,
|
|
@@ -2,7 +2,7 @@ import Component from '@glimmer/component';
|
|
|
2
2
|
import { restartableTask, timeout } from 'ember-concurrency';
|
|
3
3
|
import { tracked } from '@glimmer/tracking';
|
|
4
4
|
import { action } from '@ember/object';
|
|
5
|
-
import { task as trackedTask } from '
|
|
5
|
+
import { task as trackedTask } from 'reactiveweb/ember-concurrency';
|
|
6
6
|
import { CalendarIcon } from '@appuniversum/ember-appuniversum/components/icons/calendar';
|
|
7
7
|
import { PlusTextIcon } from '@appuniversum/ember-appuniversum/components/icons/plus-text';
|
|
8
8
|
import { LinkExternalIcon } from '@appuniversum/ember-appuniversum/components/icons/link-external';
|
|
@@ -4,7 +4,7 @@ import { action } from '@ember/object';
|
|
|
4
4
|
import { restartableTask, timeout } from 'ember-concurrency';
|
|
5
5
|
import { service } from '@ember/service';
|
|
6
6
|
import { capitalize } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/strings';
|
|
7
|
-
import { task as trackedTask } from '
|
|
7
|
+
import { task as trackedTask } from 'reactiveweb/ember-concurrency';
|
|
8
8
|
import {
|
|
9
9
|
isGemeenteBesluitType,
|
|
10
10
|
LEGISLATION_TYPE_CONCEPTS,
|
|
@@ -3,7 +3,7 @@ import { tracked } from '@glimmer/tracking';
|
|
|
3
3
|
import { assert } from '@ember/debug';
|
|
4
4
|
import { action } from '@ember/object';
|
|
5
5
|
import { restartableTask } from 'ember-concurrency';
|
|
6
|
-
import { task as trackedTask } from '
|
|
6
|
+
import { task as trackedTask } from 'reactiveweb/ember-concurrency';
|
|
7
7
|
import { LmbPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/lmb-plugin';
|
|
8
8
|
|
|
9
9
|
import Mandatee from '@lblod/ember-rdfa-editor-lblod-plugins/models/mandatee';
|
|
@@ -3,7 +3,7 @@ import Component from '@glimmer/component';
|
|
|
3
3
|
import { restartableTask, timeout } from 'ember-concurrency';
|
|
4
4
|
import perform from 'ember-concurrency/helpers/perform';
|
|
5
5
|
import { trackedReset } from 'tracked-toolbox';
|
|
6
|
-
import { trackedTask } from '
|
|
6
|
+
import { trackedTask } from 'reactiveweb/ember-concurrency';
|
|
7
7
|
import { service } from '@ember/service';
|
|
8
8
|
import { on } from '@ember/modifier';
|
|
9
9
|
import type { SafeString } from '@ember/template/-private/handlebars';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
2
|
import { action } from '@ember/object';
|
|
3
3
|
import { restartableTask, timeout } from 'ember-concurrency';
|
|
4
|
-
import { task as trackedTask } from '
|
|
4
|
+
import { task as trackedTask } from 'reactiveweb/ember-concurrency';
|
|
5
5
|
|
|
6
6
|
import { tracked } from '@glimmer/tracking';
|
|
7
7
|
|
|
@@ -2,7 +2,7 @@ import Component from '@glimmer/component';
|
|
|
2
2
|
import { service } from '@ember/service';
|
|
3
3
|
import includeInstructions from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/roadsign-regulation-plugin/utils/includeInstructions';
|
|
4
4
|
import RoadsignRegistryService from '@lblod/ember-rdfa-editor-lblod-plugins/services/roadsign-registry';
|
|
5
|
-
import { trackedFunction } from '
|
|
5
|
+
import { trackedFunction } from 'reactiveweb/function';
|
|
6
6
|
|
|
7
7
|
type Args = {
|
|
8
8
|
template: string;
|
|
@@ -25,7 +25,10 @@ import {
|
|
|
25
25
|
RDF,
|
|
26
26
|
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
|
|
27
27
|
import { hasOutgoingNamedNodeTriple } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
|
|
28
|
-
import
|
|
28
|
+
import insertSnippet from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin/commands/insert-snippet';
|
|
29
|
+
import { isNone } from '@lblod/ember-rdfa-editor/utils/_private/option';
|
|
30
|
+
import { transactionCombinator } from '@lblod/ember-rdfa-editor/utils/transaction-utils';
|
|
31
|
+
import { recalculateNumbers } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/structure-plugin/recalculate-structure-numbers';
|
|
29
32
|
|
|
30
33
|
interface ButtonSig {
|
|
31
34
|
Args: {
|
|
@@ -93,7 +96,10 @@ export default class SnippetNode extends Component<Signature> {
|
|
|
93
96
|
const position = this.args.getPos();
|
|
94
97
|
if (position !== undefined) {
|
|
95
98
|
this.controller.withTransaction((tr) => {
|
|
96
|
-
return
|
|
99
|
+
return transactionCombinator(
|
|
100
|
+
this.controller.mainEditorState,
|
|
101
|
+
tr.deleteRange(position, position + this.node.nodeSize),
|
|
102
|
+
)([recalculateNumbers]).transaction;
|
|
97
103
|
});
|
|
98
104
|
}
|
|
99
105
|
}
|
|
@@ -121,46 +127,32 @@ export default class SnippetNode extends Component<Signature> {
|
|
|
121
127
|
}
|
|
122
128
|
@action
|
|
123
129
|
onInsert(content: string, title: string) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
130
|
+
this.closeModal();
|
|
131
|
+
const assignedSnippetListsIds = this.node.attrs.assignedSnippetListsIds;
|
|
132
|
+
let start = 0;
|
|
133
|
+
let end = 0;
|
|
134
|
+
const pos = this.args.getPos();
|
|
135
|
+
if (isNone(pos)) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
127
138
|
if (this.mode === 'add') {
|
|
128
139
|
// Add new snippet
|
|
129
|
-
|
|
130
|
-
|
|
140
|
+
start = pos + this.node.nodeSize;
|
|
141
|
+
end = pos + this.node.nodeSize;
|
|
131
142
|
} else {
|
|
132
143
|
//Replace current snippet
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
const domParser = new DOMParser();
|
|
138
|
-
const parsed = domParser.parseFromString(content, 'text/html').body;
|
|
139
|
-
const documentDiv = parsed.querySelector('div[data-say-document="true"]');
|
|
140
|
-
|
|
141
|
-
this.closeModal();
|
|
142
|
-
|
|
143
|
-
if (documentDiv) {
|
|
144
|
-
return createAndInsertSnippet(
|
|
145
|
-
{
|
|
146
|
-
controller: this.controller,
|
|
147
|
-
content,
|
|
148
|
-
title,
|
|
149
|
-
snippetListIds: this.node.attrs.assignedSnippetListsIds,
|
|
150
|
-
importedResources: this.node.attrs.importedResources,
|
|
151
|
-
},
|
|
152
|
-
(tr, snippet) => tr.replaceRangeWith(rangeStart, rangeEnd, snippet),
|
|
153
|
-
);
|
|
144
|
+
start = pos;
|
|
145
|
+
end = pos + this.node.nodeSize;
|
|
154
146
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
this.
|
|
161
|
-
|
|
147
|
+
this.controller.doCommand(
|
|
148
|
+
insertSnippet({
|
|
149
|
+
content,
|
|
150
|
+
title,
|
|
151
|
+
assignedSnippetListsIds,
|
|
152
|
+
importedResources: this.node.attrs.importedResources,
|
|
153
|
+
range: { start, end },
|
|
154
|
+
}),
|
|
162
155
|
);
|
|
163
|
-
this.closeModal();
|
|
164
156
|
}
|
|
165
157
|
|
|
166
158
|
<template>
|
|
@@ -2,7 +2,7 @@ import Component from '@glimmer/component';
|
|
|
2
2
|
import { assert } from '@ember/debug';
|
|
3
3
|
import { action } from '@ember/object';
|
|
4
4
|
import { restartableTask, timeout } from 'ember-concurrency';
|
|
5
|
-
import { task as trackedTask } from '
|
|
5
|
+
import { task as trackedTask } from 'reactiveweb/ember-concurrency';
|
|
6
6
|
|
|
7
7
|
import { tracked } from '@glimmer/tracking';
|
|
8
8
|
|
|
@@ -11,8 +11,8 @@ import {
|
|
|
11
11
|
Slice,
|
|
12
12
|
} from '@lblod/ember-rdfa-editor';
|
|
13
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
14
|
import { type ImportedResourceMap } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
|
|
15
|
+
import insertSnippet from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin/commands/insert-snippet';
|
|
16
16
|
import SearchModal from './search-modal';
|
|
17
17
|
|
|
18
18
|
interface Sig {
|
|
@@ -56,29 +56,15 @@ export default class SnippetInsertComponent extends Component<Sig> {
|
|
|
56
56
|
|
|
57
57
|
@action
|
|
58
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
59
|
this.closeModal();
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
}
|
|
60
|
+
this.controller.doCommand(
|
|
61
|
+
insertSnippet({
|
|
62
|
+
content,
|
|
63
|
+
title,
|
|
64
|
+
assignedSnippetListsIds: this.args.snippetListProperties?.listIds || [],
|
|
65
|
+
importedResources: this.args.snippetListProperties?.importedResources,
|
|
66
|
+
}),
|
|
67
|
+
);
|
|
82
68
|
}
|
|
83
69
|
|
|
84
70
|
get disabled() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
2
|
import { action } from '@ember/object';
|
|
3
3
|
import { restartableTask, timeout } from 'ember-concurrency';
|
|
4
|
-
import { task as trackedTask } from '
|
|
4
|
+
import { task as trackedTask } from 'reactiveweb/ember-concurrency';
|
|
5
5
|
|
|
6
6
|
import { tracked } from '@glimmer/tracking';
|
|
7
7
|
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/variable-plugin/utils/address-helpers';
|
|
12
12
|
import { restartableTask, timeout } from 'ember-concurrency';
|
|
13
13
|
import { trackedReset } from 'tracked-toolbox';
|
|
14
|
-
import { trackedTask } from '
|
|
14
|
+
import { trackedTask } from 'reactiveweb/ember-concurrency';
|
|
15
15
|
import { service } from '@ember/service';
|
|
16
16
|
import IntlService from 'ember-intl/services/intl';
|
|
17
17
|
import { AlertTriangleIcon } from '@appuniversum/ember-appuniversum/components/icons/alert-triangle';
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { tracked } from '@glimmer/tracking';
|
|
3
|
+
import { action } from '@ember/object';
|
|
4
|
+
import { service } from '@ember/service';
|
|
5
|
+
import { NodeSelection, type SayController } from '@lblod/ember-rdfa-editor';
|
|
6
|
+
import IntlService from 'ember-intl/services/intl';
|
|
7
|
+
import AuFormRow from '@appuniversum/ember-appuniversum/components/au-form-row';
|
|
8
|
+
import AuLabel from '@appuniversum/ember-appuniversum/components/au-label';
|
|
9
|
+
import AuButton from '@appuniversum/ember-appuniversum/components/au-button';
|
|
10
|
+
import AuCheckbox from '@appuniversum/ember-appuniversum/components/au-checkbox';
|
|
11
|
+
import AuNativeInput from '@lblod/ember-rdfa-editor-lblod-plugins/components/au-native-input';
|
|
12
|
+
import AuCard from '@appuniversum/ember-appuniversum/components/au-card';
|
|
13
|
+
import AuHeading from '@appuniversum/ember-appuniversum/components/au-heading';
|
|
14
|
+
import t from 'ember-intl/helpers/t';
|
|
15
|
+
import { on } from '@ember/modifier';
|
|
16
|
+
import { trackedReset } from 'tracked-toolbox';
|
|
17
|
+
import { EXT } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
|
|
18
|
+
import { sayDataFactory } from '@lblod/ember-rdfa-editor/core/say-data-factory/data-factory';
|
|
19
|
+
import { getOutgoingTriple } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
|
|
20
|
+
import LabelInput from '../utils/label-input';
|
|
21
|
+
import {
|
|
22
|
+
ContentLiteralTerm,
|
|
23
|
+
SayLiteral,
|
|
24
|
+
SayNamedNode,
|
|
25
|
+
} from '@lblod/ember-rdfa-editor/core/say-data-factory';
|
|
26
|
+
type Args = {
|
|
27
|
+
controller: SayController;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
type nodeProperty =
|
|
31
|
+
| {
|
|
32
|
+
predicate: string;
|
|
33
|
+
object: SayNamedNode<string>;
|
|
34
|
+
}
|
|
35
|
+
| {
|
|
36
|
+
predicate: string;
|
|
37
|
+
object: SayLiteral;
|
|
38
|
+
}
|
|
39
|
+
| {
|
|
40
|
+
predicate: string;
|
|
41
|
+
object: ContentLiteralTerm;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export default class AutoFilledVariableInsertComponent extends Component<Args> {
|
|
45
|
+
@service declare intl: IntlService;
|
|
46
|
+
|
|
47
|
+
// memo is the path to the trigger, which calls update
|
|
48
|
+
// see https://github.com/tracked-tools/tracked-toolbox?tab=readme-ov-file#trackedreset
|
|
49
|
+
// it's sort of badly explained in the docs, but it's a more generic version
|
|
50
|
+
// of localCopy, which we can't use here cause our derived state from the args
|
|
51
|
+
// is too complex to express as a string path
|
|
52
|
+
@trackedReset({
|
|
53
|
+
memo: 'args.controller.mainEditorState',
|
|
54
|
+
// using this as the first arg is special typescript syntax
|
|
55
|
+
// which allows you to explicitly type the this context, cause
|
|
56
|
+
// ts is not smart enough to know that
|
|
57
|
+
update(this: AutoFilledVariableInsertComponent) {
|
|
58
|
+
return this.convertToStringAttr;
|
|
59
|
+
},
|
|
60
|
+
})
|
|
61
|
+
convertToString: boolean = false;
|
|
62
|
+
|
|
63
|
+
@trackedReset({
|
|
64
|
+
memo: 'args.controller.mainEditorState',
|
|
65
|
+
update(this: AutoFilledVariableInsertComponent) {
|
|
66
|
+
return this.autofillKeyAttr;
|
|
67
|
+
},
|
|
68
|
+
})
|
|
69
|
+
autofillKey?: string;
|
|
70
|
+
|
|
71
|
+
@trackedReset({
|
|
72
|
+
memo: 'args.controller.mainEditorState',
|
|
73
|
+
update(this: AutoFilledVariableInsertComponent) {
|
|
74
|
+
return this.labelAttr;
|
|
75
|
+
},
|
|
76
|
+
})
|
|
77
|
+
label!: string;
|
|
78
|
+
|
|
79
|
+
get selectedVariable() {
|
|
80
|
+
const { selection } = this.controller.mainEditorState;
|
|
81
|
+
if (
|
|
82
|
+
selection instanceof NodeSelection &&
|
|
83
|
+
selection.node.type === this.controller.schema.nodes.autofilled_variable
|
|
84
|
+
) {
|
|
85
|
+
return {
|
|
86
|
+
node: selection.node,
|
|
87
|
+
pos: selection.from,
|
|
88
|
+
};
|
|
89
|
+
} else {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
get autofillKeyAttr() {
|
|
94
|
+
return this.selectedVariable?.node.attrs.autofillKey;
|
|
95
|
+
}
|
|
96
|
+
get convertToStringAttr() {
|
|
97
|
+
return this.selectedVariable?.node.attrs.convertToString;
|
|
98
|
+
}
|
|
99
|
+
get labelAttr() {
|
|
100
|
+
if (!this.selectedVariable) return '';
|
|
101
|
+
return getOutgoingTriple(this.selectedVariable.node.attrs, EXT('label'))
|
|
102
|
+
?.object.value;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
get showCard() {
|
|
106
|
+
return !!this.selectedVariable;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
get controller() {
|
|
110
|
+
return this.args.controller;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
get schema() {
|
|
114
|
+
return this.args.controller.schema;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
get documentLanguage() {
|
|
118
|
+
return this.controller.documentLanguage;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
@action
|
|
122
|
+
updateLabel(event: InputEvent) {
|
|
123
|
+
this.label = (event.target as HTMLInputElement).value;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
@action
|
|
127
|
+
updateAutofillKey(event: InputEvent) {
|
|
128
|
+
this.autofillKey = (event.target as HTMLInputElement).value;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
@action
|
|
132
|
+
updateConvertToString(value: boolean) {
|
|
133
|
+
this.convertToString = value;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
@action
|
|
137
|
+
edit() {
|
|
138
|
+
if (this.selectedVariable) {
|
|
139
|
+
this.controller.withTransaction(
|
|
140
|
+
(tr) => {
|
|
141
|
+
const position = this.selectedVariable?.pos as number;
|
|
142
|
+
tr.setNodeAttribute(position, 'autofillKey', this.autofillKey);
|
|
143
|
+
tr.setNodeAttribute(
|
|
144
|
+
position,
|
|
145
|
+
'convertToString',
|
|
146
|
+
this.convertToString,
|
|
147
|
+
);
|
|
148
|
+
const oldProperties = this.selectedVariable?.node.attrs.properties;
|
|
149
|
+
const newProperties = oldProperties.filter(
|
|
150
|
+
(property: nodeProperty) =>
|
|
151
|
+
property.predicate !== EXT('label').full,
|
|
152
|
+
);
|
|
153
|
+
newProperties.push({
|
|
154
|
+
predicate: EXT('label').full,
|
|
155
|
+
object: sayDataFactory.literal(this.label || ''),
|
|
156
|
+
});
|
|
157
|
+
tr.setNodeAttribute(position, 'properties', newProperties);
|
|
158
|
+
return tr;
|
|
159
|
+
},
|
|
160
|
+
// because the variable pill contains a nested editor, when it's
|
|
161
|
+
// selected, the currentEditorView is the nested one. When you run
|
|
162
|
+
// withTransaction without the optional second argument, it defaults to using
|
|
163
|
+
// the current view.
|
|
164
|
+
//
|
|
165
|
+
// Here, we don't want that, cause we want to edit the outside node, not
|
|
166
|
+
// any node in the nested editor.
|
|
167
|
+
{ view: this.controller.mainEditorView },
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
<template>
|
|
172
|
+
{{#if this.showCard}}
|
|
173
|
+
<AuCard
|
|
174
|
+
@flex={{true}}
|
|
175
|
+
@divided={{true}}
|
|
176
|
+
@isOpenInitially={{true}}
|
|
177
|
+
@expandable={{true}}
|
|
178
|
+
@shadow={{true}}
|
|
179
|
+
@size='small'
|
|
180
|
+
as |c|
|
|
181
|
+
>
|
|
182
|
+
<c.header>
|
|
183
|
+
<AuHeading @level='3' @skin='6'>
|
|
184
|
+
{{t 'variable-plugin.enter-variable-value'}}
|
|
185
|
+
</AuHeading>
|
|
186
|
+
</c.header>
|
|
187
|
+
<c.content>
|
|
188
|
+
<AuFormRow>
|
|
189
|
+
<LabelInput
|
|
190
|
+
@label={{this.label}}
|
|
191
|
+
@updateLabel={{this.updateLabel}}
|
|
192
|
+
/>
|
|
193
|
+
</AuFormRow>
|
|
194
|
+
<AuFormRow>
|
|
195
|
+
<AuLabel for='autofill_key'>
|
|
196
|
+
{{t 'variable-plugin.autofill.autofillKey'}}
|
|
197
|
+
</AuLabel>
|
|
198
|
+
<AuNativeInput
|
|
199
|
+
id='autofill_key'
|
|
200
|
+
placeholder={{t
|
|
201
|
+
'variable-plugin.autofill.autofillKeyPlaceholder'
|
|
202
|
+
}}
|
|
203
|
+
@type='text'
|
|
204
|
+
@width='block'
|
|
205
|
+
value={{this.autofillKey}}
|
|
206
|
+
{{on 'input' this.updateAutofillKey}}
|
|
207
|
+
/>
|
|
208
|
+
</AuFormRow>
|
|
209
|
+
<AuFormRow>
|
|
210
|
+
<AuCheckbox
|
|
211
|
+
id='convert_to_string'
|
|
212
|
+
@checked={{this.convertToString}}
|
|
213
|
+
@onChange={{this.updateConvertToString}}
|
|
214
|
+
>
|
|
215
|
+
{{t 'variable-plugin.autofill.convertToString'}}
|
|
216
|
+
</AuCheckbox>
|
|
217
|
+
</AuFormRow>
|
|
218
|
+
<AuButton {{on 'click' this.edit}}>
|
|
219
|
+
{{t 'variable-plugin.button'}}
|
|
220
|
+
</AuButton>
|
|
221
|
+
</c.content>
|
|
222
|
+
</AuCard>
|
|
223
|
+
{{/if}}
|
|
224
|
+
</template>
|
|
225
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { tracked } from '@glimmer/tracking';
|
|
3
|
+
import { action } from '@ember/object';
|
|
4
|
+
import { service } from '@ember/service';
|
|
5
|
+
import { type SayController } from '@lblod/ember-rdfa-editor';
|
|
6
|
+
import { sayDataFactory } from '@lblod/ember-rdfa-editor/core/say-data-factory';
|
|
7
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
8
|
+
import IntlService from 'ember-intl/services/intl';
|
|
9
|
+
import {
|
|
10
|
+
DCT,
|
|
11
|
+
EXT,
|
|
12
|
+
RDF,
|
|
13
|
+
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
|
|
14
|
+
import { replaceSelectionWithAndSelectNode } from '@lblod/ember-rdfa-editor-lblod-plugins/commands';
|
|
15
|
+
import AuFormRow from '@appuniversum/ember-appuniversum/components/au-form-row';
|
|
16
|
+
import AuLabel from '@appuniversum/ember-appuniversum/components/au-label';
|
|
17
|
+
import AuButton from '@appuniversum/ember-appuniversum/components/au-button';
|
|
18
|
+
import AuCheckbox from '@appuniversum/ember-appuniversum/components/au-checkbox';
|
|
19
|
+
import AuNativeInput from '@lblod/ember-rdfa-editor-lblod-plugins/components/au-native-input';
|
|
20
|
+
import t from 'ember-intl/helpers/t';
|
|
21
|
+
import { on } from '@ember/modifier';
|
|
22
|
+
import LabelInput from '@lblod/ember-rdfa-editor-lblod-plugins/components/variable-plugin/utils/label-input';
|
|
23
|
+
|
|
24
|
+
type Args = {
|
|
25
|
+
controller: SayController;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default class AutoFilledVariableInsertComponent extends Component<Args> {
|
|
29
|
+
@service declare intl: IntlService;
|
|
30
|
+
@tracked label: string = '';
|
|
31
|
+
@tracked autofillKey?: string;
|
|
32
|
+
@tracked convertToString?: boolean;
|
|
33
|
+
|
|
34
|
+
get controller() {
|
|
35
|
+
return this.args.controller;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
get schema() {
|
|
39
|
+
return this.args.controller.schema;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
get documentLanguage() {
|
|
43
|
+
return this.controller.documentLanguage;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@action
|
|
47
|
+
updateLabel(event: InputEvent) {
|
|
48
|
+
this.label = (event.target as HTMLInputElement).value;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@action
|
|
52
|
+
updateAutofillKey(event: InputEvent) {
|
|
53
|
+
this.autofillKey = (event.target as HTMLInputElement).value;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@action
|
|
57
|
+
updateConvertToString(value: boolean) {
|
|
58
|
+
this.convertToString = value;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@action
|
|
62
|
+
insert() {
|
|
63
|
+
const mappingSubject = `http://data.lblod.info/mappings/${uuidv4()}`;
|
|
64
|
+
const variableInstance = `http://data.lblod.info/variables/${uuidv4()}`;
|
|
65
|
+
const variableId = uuidv4();
|
|
66
|
+
|
|
67
|
+
const placeholder = this.intl.t('variable.autofilled.label', {
|
|
68
|
+
locale: this.documentLanguage,
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const label = this.label != '' ? this.label : placeholder;
|
|
72
|
+
const node = this.schema.nodes.autofilled_variable.create(
|
|
73
|
+
{
|
|
74
|
+
subject: mappingSubject,
|
|
75
|
+
rdfaNodeType: 'resource',
|
|
76
|
+
__rdfaId: variableId,
|
|
77
|
+
properties: [
|
|
78
|
+
{
|
|
79
|
+
predicate: RDF('type').full,
|
|
80
|
+
object: sayDataFactory.namedNode(EXT('Mapping').full),
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
predicate: EXT('instance').full,
|
|
84
|
+
object: sayDataFactory.namedNode(variableInstance),
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
predicate: EXT('label').full,
|
|
88
|
+
object: sayDataFactory.literal(label),
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
predicate: DCT('type').full,
|
|
92
|
+
object: sayDataFactory.literal('autofilled'),
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
predicate: EXT('content').full,
|
|
96
|
+
object: sayDataFactory.contentLiteral(),
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
autofillKey: this.autofillKey,
|
|
100
|
+
convertToString: this.convertToString,
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
this.schema.node('placeholder', {
|
|
104
|
+
placeholderText: `Autofill ${this.autofillKey}`,
|
|
105
|
+
}),
|
|
106
|
+
);
|
|
107
|
+
this.label = '';
|
|
108
|
+
|
|
109
|
+
this.controller.doCommand(replaceSelectionWithAndSelectNode(node), {
|
|
110
|
+
view: this.controller.mainEditorView,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
<template>
|
|
114
|
+
<AuFormRow>
|
|
115
|
+
<LabelInput @label={{this.label}} @updateLabel={{this.updateLabel}} />
|
|
116
|
+
</AuFormRow>
|
|
117
|
+
<AuFormRow>
|
|
118
|
+
<AuLabel for='autofill_key'>
|
|
119
|
+
{{t 'variable-plugin.autofill.autofillKey'}}
|
|
120
|
+
</AuLabel>
|
|
121
|
+
<AuNativeInput
|
|
122
|
+
id='autofill_key'
|
|
123
|
+
placeholder={{t 'variable-plugin.autofill.autofillKeyPlaceholder'}}
|
|
124
|
+
@type='text'
|
|
125
|
+
@width='block'
|
|
126
|
+
value={{this.autofillKey}}
|
|
127
|
+
{{on 'input' this.updateAutofillKey}}
|
|
128
|
+
/>
|
|
129
|
+
</AuFormRow>
|
|
130
|
+
<AuFormRow>
|
|
131
|
+
<AuCheckbox
|
|
132
|
+
id='convert_to_string'
|
|
133
|
+
@checked={{this.convertToString}}
|
|
134
|
+
@onChange={{this.updateConvertToString}}
|
|
135
|
+
>
|
|
136
|
+
{{t 'variable-plugin.autofill.convertToString'}}
|
|
137
|
+
</AuCheckbox>
|
|
138
|
+
</AuFormRow>
|
|
139
|
+
<AuButton {{on 'click' this.insert}}>
|
|
140
|
+
{{t 'variable-plugin.button'}}
|
|
141
|
+
</AuButton>
|
|
142
|
+
</template>
|
|
143
|
+
}
|