@lblod/ember-rdfa-editor-lblod-plugins 24.1.2 → 24.2.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.
- package/CHANGELOG.md +10 -0
- package/addon/components/besluit-topic-plugin/besluit-topic-toolbar-dropdown.ts +5 -17
- package/addon/components/besluit-type-plugin/toolbar-dropdown.ts +10 -18
- package/addon/components/decision-plugin/decision-plugin-card.gts +10 -16
- package/addon/components/decision-plugin/insert-article.gts +16 -15
- package/addon/components/lpdc-plugin/lpdc-insert.ts +10 -12
- package/addon/components/roadsign-regulation-plugin/roadsign-regulation-card.ts +22 -13
- package/addon/components/roadsign-regulation-plugin/roadsigns-modal.ts +12 -13
- package/addon/plugins/besluit-topic-plugin/utils/helpers.ts +5 -6
- package/addon/plugins/decision-plugin/commands/insert-article-command.ts +32 -5
- package/addon/plugins/decision-plugin/utils/build-article-structure.ts +16 -0
- package/addon/plugins/lpdc-plugin/api.ts +6 -0
- package/addon/plugins/lpdc-plugin/types.ts +2 -0
- package/addon/plugins/roadsign-regulation-plugin/index.ts +5 -0
- package/addon/utils/translation.ts +0 -1
- package/declarations/addon/components/decision-plugin/insert-article.d.ts +3 -1
- package/declarations/addon/components/lpdc-plugin/lpdc-insert.d.ts +1 -0
- package/declarations/addon/components/roadsign-regulation-plugin/roadsign-regulation-card.d.ts +2 -0
- package/declarations/addon/components/roadsign-regulation-plugin/roadsigns-modal.d.ts +1 -2
- package/declarations/addon/plugins/besluit-topic-plugin/utils/helpers.d.ts +1 -1
- package/declarations/addon/plugins/decision-plugin/commands/insert-article-command.d.ts +8 -3
- package/declarations/addon/plugins/decision-plugin/utils/build-article-structure.d.ts +8 -1
- package/declarations/addon/plugins/lpdc-plugin/types.d.ts +2 -0
- package/declarations/addon/plugins/roadsign-regulation-plugin/index.d.ts +5 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @lblod/ember-rdfa-editor-lblod-plugins
|
|
2
2
|
|
|
3
|
+
## 24.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#489](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/489) [`9a89b99`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/9a89b992a2e6520e06720c099bff1dd7f115d9ab) Thanks [@piemonkey](https://github.com/piemonkey)! - Add config to specify an external decision URI when creating decision article structures
|
|
8
|
+
|
|
9
|
+
- [#489](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/489) [`9a89b99`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/9a89b992a2e6520e06720c099bff1dd7f115d9ab) Thanks [@piemonkey](https://github.com/piemonkey)! - Add config to specify an external decision URI in lpdc plugin
|
|
10
|
+
|
|
11
|
+
- [#489](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/489) [`9a89b99`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/9a89b992a2e6520e06720c099bff1dd7f115d9ab) Thanks [@piemonkey](https://github.com/piemonkey)! - Add config to specify an external decision URI and type in roadsign-regulation-plugin
|
|
12
|
+
|
|
3
13
|
## 24.1.2
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
|
@@ -74,22 +74,16 @@ export default class BesluitTopicToolbarDropdownComponent extends Component<Args
|
|
|
74
74
|
|
|
75
75
|
@action
|
|
76
76
|
updateBesluitTopic() {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if (!currentBesluitURI || !this.topics.value) {
|
|
77
|
+
if (!this.topics.isFinished || !this.decisionRange) {
|
|
80
78
|
return;
|
|
81
79
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (!besluit) {
|
|
85
|
-
console.warn(
|
|
86
|
-
`We have a besluit URI (${currentBesluitURI}), but can't find a besluit ancestor`,
|
|
87
|
-
);
|
|
80
|
+
if (!this.topics.value) {
|
|
81
|
+
console.warn('Request for besluit topics failed');
|
|
88
82
|
return;
|
|
89
83
|
}
|
|
90
84
|
|
|
91
85
|
const outgoingBesluitTopics = getOutgoingTripleList(
|
|
92
|
-
|
|
86
|
+
this.decisionRange.node.attrs,
|
|
93
87
|
ELI(ELI_SUBJECT),
|
|
94
88
|
);
|
|
95
89
|
|
|
@@ -120,13 +114,7 @@ export default class BesluitTopicToolbarDropdownComponent extends Component<Args
|
|
|
120
114
|
upsertBesluitTopic(selected: BesluitTopic[]) {
|
|
121
115
|
this.besluitTopicsSelected = selected;
|
|
122
116
|
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
const resource =
|
|
126
|
-
(currentBesluitRange &&
|
|
127
|
-
'node' in currentBesluitRange &&
|
|
128
|
-
(currentBesluitRange.node.attrs.subject as string)) ||
|
|
129
|
-
undefined;
|
|
117
|
+
const resource = getCurrentBesluitURI(this.controller);
|
|
130
118
|
|
|
131
119
|
if (this.besluitTopicsSelected && resource) {
|
|
132
120
|
this.controller.doCommand(
|
|
@@ -8,7 +8,6 @@ import fetchBesluitTypes, {
|
|
|
8
8
|
BesluitType,
|
|
9
9
|
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-type-plugin/utils/fetchBesluitTypes';
|
|
10
10
|
import { trackedFunction } from 'reactiveweb/function';
|
|
11
|
-
import { unwrap } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
|
|
12
11
|
import { BesluitTypePluginOptions } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-type-plugin';
|
|
13
12
|
import { RDF } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
|
|
14
13
|
import { getOutgoingTripleList } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
|
|
@@ -16,7 +15,10 @@ import { AlertTriangleIcon } from '@appuniversum/ember-appuniversum/components/i
|
|
|
16
15
|
import { CrossIcon } from '@appuniversum/ember-appuniversum/components/icons/cross';
|
|
17
16
|
import { MailIcon } from '@appuniversum/ember-appuniversum/components/icons/mail';
|
|
18
17
|
import { CircleXIcon } from '@appuniversum/ember-appuniversum/components/icons/circle-x';
|
|
19
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
getCurrentBesluitRange,
|
|
20
|
+
getCurrentBesluitURI,
|
|
21
|
+
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-topic-plugin/utils/helpers';
|
|
20
22
|
|
|
21
23
|
type Args = {
|
|
22
24
|
controller: SayController;
|
|
@@ -69,11 +71,7 @@ export default class EditorPluginsToolbarDropdownComponent extends Component<Arg
|
|
|
69
71
|
}
|
|
70
72
|
|
|
71
73
|
get currentBesluitURI() {
|
|
72
|
-
|
|
73
|
-
const node = unwrap(this.doc.nodeAt(this.currentBesluitRange.from));
|
|
74
|
-
return node.attrs['subject'] as string | undefined;
|
|
75
|
-
}
|
|
76
|
-
return;
|
|
74
|
+
return getCurrentBesluitURI(this.controller);
|
|
77
75
|
}
|
|
78
76
|
|
|
79
77
|
get showCard() {
|
|
@@ -82,16 +80,14 @@ export default class EditorPluginsToolbarDropdownComponent extends Component<Arg
|
|
|
82
80
|
|
|
83
81
|
@action
|
|
84
82
|
updateBesluitTypes() {
|
|
85
|
-
if (!this.
|
|
83
|
+
if (!this.types.isFinished || !this.currentBesluitRange) {
|
|
86
84
|
return;
|
|
87
85
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
console.warn(
|
|
91
|
-
`We have a besluit URI (${this.currentBesluitURI}), but can't find a besluit ancestor`,
|
|
92
|
-
);
|
|
86
|
+
if (!this.types.value) {
|
|
87
|
+
console.warn('Request for besluit types failed');
|
|
93
88
|
return;
|
|
94
89
|
}
|
|
90
|
+
const besluit = this.currentBesluitRange;
|
|
95
91
|
const besluitTypes = getOutgoingTripleList(besluit.node.attrs, RDF('type'));
|
|
96
92
|
const besluitTypeRelevant = besluitTypes.find(
|
|
97
93
|
(type) =>
|
|
@@ -192,11 +188,7 @@ export default class EditorPluginsToolbarDropdownComponent extends Component<Arg
|
|
|
192
188
|
}
|
|
193
189
|
|
|
194
190
|
insert() {
|
|
195
|
-
const resource =
|
|
196
|
-
(this.currentBesluitRange &&
|
|
197
|
-
'node' in this.currentBesluitRange &&
|
|
198
|
-
(this.currentBesluitRange.node.attrs.subject as string)) ||
|
|
199
|
-
undefined;
|
|
191
|
+
const resource = this.currentBesluitURI;
|
|
200
192
|
if (this.besluitType && resource) {
|
|
201
193
|
this.cardExpanded = false;
|
|
202
194
|
if (this.previousBesluitType) {
|
|
@@ -6,20 +6,15 @@ import {
|
|
|
6
6
|
insertDescription,
|
|
7
7
|
insertTitle,
|
|
8
8
|
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/decision-plugin/commands';
|
|
9
|
-
import type {
|
|
9
|
+
import type { SayController, Selection } from '@lblod/ember-rdfa-editor';
|
|
10
10
|
import { service } from '@ember/service';
|
|
11
11
|
import IntlService from 'ember-intl/services/intl';
|
|
12
12
|
import { AlertTriangleIcon } from '@appuniversum/ember-appuniversum/components/icons/alert-triangle';
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
getOutgoingTriple,
|
|
16
|
-
hasOutgoingNamedNodeTriple,
|
|
17
|
-
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
|
|
13
|
+
import { getOutgoingTriple } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
|
|
18
14
|
import {
|
|
19
15
|
BESLUIT,
|
|
20
16
|
ELI,
|
|
21
17
|
PROV,
|
|
22
|
-
RDF,
|
|
23
18
|
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
|
|
24
19
|
import { NodeWithPos } from '@curvenote/prosemirror-utils';
|
|
25
20
|
import AuAlert from '@appuniversum/ember-appuniversum/components/au-alert';
|
|
@@ -28,6 +23,7 @@ import { on } from '@ember/modifier';
|
|
|
28
23
|
import { not } from 'ember-truth-helpers';
|
|
29
24
|
import t from 'ember-intl/helpers/t';
|
|
30
25
|
import { TemplateOnlyComponent } from '@ember/component/template-only';
|
|
26
|
+
import { getCurrentBesluitRange } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-topic-plugin/utils/helpers';
|
|
31
27
|
|
|
32
28
|
interface DecisionCardOptions {
|
|
33
29
|
articleUriGenerator?: () => string;
|
|
@@ -50,15 +46,13 @@ export default class DecisionPluginCard extends Component<Sig> {
|
|
|
50
46
|
}
|
|
51
47
|
|
|
52
48
|
get decisionNodeLocation(): NodeWithPos | null {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
})[0] ?? null
|
|
61
|
-
);
|
|
49
|
+
const besluitRange = getCurrentBesluitRange(this.controller);
|
|
50
|
+
return besluitRange
|
|
51
|
+
? {
|
|
52
|
+
pos: besluitRange.from,
|
|
53
|
+
node: besluitRange.node,
|
|
54
|
+
}
|
|
55
|
+
: null;
|
|
62
56
|
}
|
|
63
57
|
|
|
64
58
|
@action
|
|
@@ -10,12 +10,12 @@ import { buildArticleStructure } from '@lblod/ember-rdfa-editor-lblod-plugins/pl
|
|
|
10
10
|
import { not } from 'ember-truth-helpers';
|
|
11
11
|
import { service } from '@ember/service';
|
|
12
12
|
import IntlService from 'ember-intl/services/intl';
|
|
13
|
-
import { recalculateNumbers } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/structure-plugin/recalculate-structure-numbers';
|
|
14
|
-
import { transactionCombinator } from '@lblod/ember-rdfa-editor/utils/transaction-utils';
|
|
15
13
|
|
|
16
14
|
export interface InsertArticleOptions {
|
|
17
15
|
uriGenerator?: () => string;
|
|
18
16
|
insertFreely?: boolean;
|
|
17
|
+
/** Pass a decision URI instead of finding one in the document. Implies `insertFreely`. */
|
|
18
|
+
decisionUri?: string;
|
|
19
19
|
}
|
|
20
20
|
interface Sig {
|
|
21
21
|
Args: {
|
|
@@ -53,18 +53,18 @@ export default class InsertArticleComponent extends Component<Sig> {
|
|
|
53
53
|
: null;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
get canInsertFreely() {
|
|
57
|
+
return this.options?.insertFreely || this.options?.decisionUri;
|
|
58
|
+
}
|
|
59
|
+
|
|
56
60
|
get canInsert() {
|
|
57
|
-
if (this.
|
|
58
|
-
return
|
|
61
|
+
if (this.canInsertFreely) {
|
|
62
|
+
return true;
|
|
59
63
|
} else {
|
|
60
64
|
return this.canInsertInDecision;
|
|
61
65
|
}
|
|
62
66
|
}
|
|
63
67
|
|
|
64
|
-
get canInsertFreely() {
|
|
65
|
-
return true;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
68
|
get canInsertInDecision() {
|
|
69
69
|
if (!this.decisionLocation) {
|
|
70
70
|
return false;
|
|
@@ -83,8 +83,9 @@ export default class InsertArticleComponent extends Component<Sig> {
|
|
|
83
83
|
const structureNode = buildArticleStructure(
|
|
84
84
|
this.schema,
|
|
85
85
|
this.args.options?.uriGenerator,
|
|
86
|
+
this.args.options?.decisionUri,
|
|
86
87
|
);
|
|
87
|
-
if (this.
|
|
88
|
+
if (this.canInsertFreely) {
|
|
88
89
|
this.insertFreely(structureNode);
|
|
89
90
|
} else {
|
|
90
91
|
this.insertInDecision(structureNode);
|
|
@@ -93,12 +94,12 @@ export default class InsertArticleComponent extends Component<Sig> {
|
|
|
93
94
|
|
|
94
95
|
@action
|
|
95
96
|
insertFreely(node: PNode) {
|
|
96
|
-
this.controller.
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
)
|
|
101
|
-
|
|
97
|
+
this.controller.doCommand(
|
|
98
|
+
insertArticle({
|
|
99
|
+
node,
|
|
100
|
+
insertFreely: true,
|
|
101
|
+
}),
|
|
102
|
+
);
|
|
102
103
|
this.controller.focus();
|
|
103
104
|
}
|
|
104
105
|
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
type LpdcPluginConfig,
|
|
12
12
|
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/lpdc-plugin';
|
|
13
13
|
import { v4 as uuidv4 } from 'uuid';
|
|
14
|
-
import {
|
|
14
|
+
import { getCurrentBesluitURI } from '../../plugins/besluit-topic-plugin/utils/helpers';
|
|
15
15
|
import { SRO } from '../../utils/constants';
|
|
16
16
|
|
|
17
17
|
interface Args {
|
|
@@ -39,21 +39,19 @@ export default class LpdcPluginsInsertComponent extends Component<Args> {
|
|
|
39
39
|
this.showModal = false;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
get decisionUri() {
|
|
43
|
+
return (
|
|
44
|
+
this.args.config?.decisionUri ?? getCurrentBesluitURI(this.controller)
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
42
48
|
get isButtonDisabled() {
|
|
43
|
-
return !
|
|
49
|
+
return !this.decisionUri;
|
|
44
50
|
}
|
|
45
51
|
|
|
46
52
|
@action
|
|
47
53
|
onLpdcInsert(lpdc: LPDC) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const resource =
|
|
51
|
-
(currentBesluitRange &&
|
|
52
|
-
'node' in currentBesluitRange &&
|
|
53
|
-
(currentBesluitRange.node.attrs.subject as string)) ||
|
|
54
|
-
undefined;
|
|
55
|
-
|
|
56
|
-
if (!resource) {
|
|
54
|
+
if (!this.decisionUri) {
|
|
57
55
|
throw new Error('No besluit found in selection');
|
|
58
56
|
}
|
|
59
57
|
|
|
@@ -80,7 +78,7 @@ export default class LpdcPluginsInsertComponent extends Component<Args> {
|
|
|
80
78
|
|
|
81
79
|
this.controller.doCommand(
|
|
82
80
|
addProperty({
|
|
83
|
-
resource,
|
|
81
|
+
resource: this.decisionUri,
|
|
84
82
|
property: {
|
|
85
83
|
predicate: SRO('bekrachtigt').full,
|
|
86
84
|
object: sayDataFactory.resourceNode(uri),
|
|
@@ -6,6 +6,7 @@ import { AddIcon } from '@appuniversum/ember-appuniversum/components/icons/add';
|
|
|
6
6
|
import { OutgoingTriple } from '@lblod/ember-rdfa-editor/core/rdfa-processor';
|
|
7
7
|
import { RDF } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
|
|
8
8
|
import { getCurrentBesluitRange } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-topic-plugin/utils/helpers';
|
|
9
|
+
import { RoadsignRegulationPluginOptions } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/roadsign-regulation-plugin';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Card displaying a hint of the Date plugin
|
|
@@ -26,6 +27,7 @@ const acceptedTypes = [
|
|
|
26
27
|
|
|
27
28
|
type Args = {
|
|
28
29
|
controller: SayController;
|
|
30
|
+
options: RoadsignRegulationPluginOptions;
|
|
29
31
|
};
|
|
30
32
|
|
|
31
33
|
export default class RoadsignRegulationCard extends Component<Args> {
|
|
@@ -53,21 +55,28 @@ export default class RoadsignRegulationCard extends Component<Args> {
|
|
|
53
55
|
}
|
|
54
56
|
|
|
55
57
|
get showCard() {
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
const decisionContext = this.args.options.decisionContext;
|
|
59
|
+
let decisionTypes = [];
|
|
60
|
+
if (decisionContext && decisionContext.decisionType) {
|
|
61
|
+
decisionTypes = [decisionContext.decisionType];
|
|
62
|
+
} else {
|
|
63
|
+
const decisionRange = getCurrentBesluitRange(this.controller);
|
|
64
|
+
if (!decisionRange) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
const decisionNode = decisionRange.node;
|
|
68
|
+
const properties: OutgoingTriple[] = decisionNode.attrs.properties;
|
|
69
|
+
decisionTypes = properties
|
|
70
|
+
.filter(
|
|
71
|
+
({ predicate, object }) =>
|
|
72
|
+
RDF('type').matches(predicate) && object.termType === 'NamedNode',
|
|
73
|
+
)
|
|
74
|
+
.map((property) => property.object.value);
|
|
59
75
|
}
|
|
60
|
-
const decisionNode = decisionRange.node;
|
|
61
|
-
const properties: OutgoingTriple[] = decisionNode.attrs.properties;
|
|
62
76
|
|
|
63
|
-
const decisionHasAcceptedType =
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
RDF('type').matches(predicate) &&
|
|
67
|
-
object.termType === 'NamedNode' &&
|
|
68
|
-
acceptedTypes.includes(object.value)
|
|
69
|
-
);
|
|
70
|
-
});
|
|
77
|
+
const decisionHasAcceptedType = decisionTypes.some((type) =>
|
|
78
|
+
acceptedTypes.includes(type),
|
|
79
|
+
);
|
|
71
80
|
return decisionHasAcceptedType;
|
|
72
81
|
}
|
|
73
82
|
}
|
|
@@ -47,7 +47,7 @@ type Args = {
|
|
|
47
47
|
options: RoadsignRegulationPluginOptions;
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
-
export default class
|
|
50
|
+
export default class RoadsignsModal extends Component<Args> {
|
|
51
51
|
endpoint: string;
|
|
52
52
|
imageBaseUrl: string;
|
|
53
53
|
|
|
@@ -99,12 +99,10 @@ export default class RoadsignRegulationCard extends Component<Args> {
|
|
|
99
99
|
get controller() {
|
|
100
100
|
return this.args.controller;
|
|
101
101
|
}
|
|
102
|
-
get decisionRange() {
|
|
103
|
-
return getCurrentBesluitRange(this.controller);
|
|
104
|
-
}
|
|
105
102
|
get decisionLocation() {
|
|
106
|
-
|
|
107
|
-
|
|
103
|
+
const decisionRange = getCurrentBesluitRange(this.controller);
|
|
104
|
+
return decisionRange
|
|
105
|
+
? { node: decisionRange.node, pos: decisionRange.from }
|
|
108
106
|
: null;
|
|
109
107
|
}
|
|
110
108
|
|
|
@@ -320,9 +318,11 @@ export default class RoadsignRegulationCard extends Component<Args> {
|
|
|
320
318
|
`;
|
|
321
319
|
const domParser = new DOMParser();
|
|
322
320
|
const htmlNode = domParser.parseFromString(regulationHTML, 'text/html');
|
|
321
|
+
const passedDecisionUri = this.args.options.decisionContext?.decisionUri;
|
|
323
322
|
const article = buildArticleStructure(
|
|
324
323
|
this.controller.activeEditorState.schema,
|
|
325
324
|
this.args.options.articleUriGenrator,
|
|
325
|
+
this.args.options.decisionContext?.decisionUri,
|
|
326
326
|
);
|
|
327
327
|
const contentFragment = ProseParser.fromSchema(
|
|
328
328
|
this.args.controller.schema,
|
|
@@ -331,13 +331,12 @@ export default class RoadsignRegulationCard extends Component<Args> {
|
|
|
331
331
|
}).content;
|
|
332
332
|
const nodeToInsert = article.copy(contentFragment);
|
|
333
333
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
);
|
|
334
|
+
const insertArgs: Parameters<typeof insertArticle>[0] = passedDecisionUri
|
|
335
|
+
? { node: nodeToInsert, insertFreely: true }
|
|
336
|
+
: { node: nodeToInsert, decisionLocation: unwrap(this.decisionLocation) };
|
|
337
|
+
this.args.controller.doCommand(insertArticle(insertArgs), {
|
|
338
|
+
view: this.args.controller.mainEditorView,
|
|
339
|
+
});
|
|
341
340
|
this.args.closeModal();
|
|
342
341
|
}
|
|
343
342
|
|
|
@@ -4,7 +4,6 @@ import {
|
|
|
4
4
|
RDF,
|
|
5
5
|
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
|
|
6
6
|
import { hasOutgoingNamedNodeTriple } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
|
|
7
|
-
import { unwrap } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
|
|
8
7
|
import { ElementPNode } from '@lblod/ember-rdfa-editor/plugins/datastore';
|
|
9
8
|
import { findAncestors } from '@lblod/ember-rdfa-editor/utils/position-utils';
|
|
10
9
|
|
|
@@ -36,13 +35,13 @@ export const getCurrentBesluitRange = (
|
|
|
36
35
|
};
|
|
37
36
|
};
|
|
38
37
|
|
|
39
|
-
export const getCurrentBesluitURI = (
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
export const getCurrentBesluitURI = (
|
|
39
|
+
controllerOrState: SayController | EditorState,
|
|
40
|
+
) => {
|
|
41
|
+
const currentBesluitRange = getCurrentBesluitRange(controllerOrState);
|
|
42
42
|
|
|
43
43
|
if (currentBesluitRange) {
|
|
44
|
-
|
|
45
|
-
return node.attrs['subject'] as string | undefined;
|
|
44
|
+
return currentBesluitRange.node.attrs['subject'] as string | undefined;
|
|
46
45
|
}
|
|
47
46
|
|
|
48
47
|
return;
|
|
@@ -19,19 +19,46 @@ import { SayDataFactory } from '@lblod/ember-rdfa-editor/core/say-data-factory';
|
|
|
19
19
|
import { recalculateNumbers } from '../../structure-plugin/recalculate-structure-numbers';
|
|
20
20
|
import { transactionCombinator } from '@lblod/ember-rdfa-editor/utils/transaction-utils';
|
|
21
21
|
|
|
22
|
-
interface
|
|
22
|
+
interface InsertArticleToDecisionArgs {
|
|
23
23
|
node: PNode;
|
|
24
|
-
decisionLocation: NodeWithPos;
|
|
24
|
+
decisionLocation: NodeWithPos | null;
|
|
25
|
+
insertFreely?: false;
|
|
25
26
|
}
|
|
27
|
+
interface InsertArticleFreelyArgs {
|
|
28
|
+
node: PNode;
|
|
29
|
+
insertFreely: true;
|
|
30
|
+
}
|
|
31
|
+
|
|
26
32
|
export default function insertArticle({
|
|
27
33
|
node,
|
|
28
|
-
|
|
29
|
-
}:
|
|
34
|
+
...args
|
|
35
|
+
}: InsertArticleToDecisionArgs | InsertArticleFreelyArgs): Command {
|
|
30
36
|
return function (
|
|
31
37
|
state: EditorState,
|
|
32
38
|
dispatch?: (tr: Transaction) => void,
|
|
33
39
|
): boolean {
|
|
34
|
-
|
|
40
|
+
if ('insertFreely' in args) {
|
|
41
|
+
const tr = state.tr;
|
|
42
|
+
const { result, transaction } = transactionCombinator(
|
|
43
|
+
state,
|
|
44
|
+
tr.replaceSelectionWith(node),
|
|
45
|
+
)([recalculateNumbers]);
|
|
46
|
+
|
|
47
|
+
transaction.scrollIntoView();
|
|
48
|
+
if (result.every((ok) => ok)) {
|
|
49
|
+
if (dispatch) {
|
|
50
|
+
dispatch(transaction);
|
|
51
|
+
}
|
|
52
|
+
return true;
|
|
53
|
+
} else {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const decision = args.decisionLocation;
|
|
59
|
+
if (!decision) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
35
62
|
const decisionResource = decision.node.attrs.subject;
|
|
36
63
|
const container = getOutgoingTriple(decision.node.attrs, PROV('value'));
|
|
37
64
|
if (container) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Schema } from '@lblod/ember-rdfa-editor';
|
|
2
2
|
import {
|
|
3
3
|
BESLUIT,
|
|
4
|
+
ELI,
|
|
4
5
|
PROV,
|
|
5
6
|
RDF,
|
|
6
7
|
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
|
|
@@ -11,6 +12,13 @@ import { v4 as uuid } from 'uuid';
|
|
|
11
12
|
export function buildArticleStructure(
|
|
12
13
|
schema: Schema,
|
|
13
14
|
uriGenerator?: () => string,
|
|
15
|
+
/**
|
|
16
|
+
* Adds a backlink to this resource instead of relying on being linked to the decision after
|
|
17
|
+
* creation.
|
|
18
|
+
* Adding backlinks like this does not play nice with the RDFa tools, but if combined with a
|
|
19
|
+
* document with this URI imported it works as expected. It creates valid RDFa in either case.
|
|
20
|
+
*/
|
|
21
|
+
decisionUri?: string,
|
|
14
22
|
) {
|
|
15
23
|
let articleResource: string;
|
|
16
24
|
if (uriGenerator) {
|
|
@@ -34,6 +42,14 @@ export function buildArticleStructure(
|
|
|
34
42
|
object: factory.contentLiteral(),
|
|
35
43
|
},
|
|
36
44
|
] satisfies OutgoingTriple[],
|
|
45
|
+
backlinks: !decisionUri
|
|
46
|
+
? undefined
|
|
47
|
+
: [
|
|
48
|
+
{
|
|
49
|
+
subject: factory.resourceNode(decisionUri),
|
|
50
|
+
predicate: ELI('has_part'),
|
|
51
|
+
},
|
|
52
|
+
],
|
|
37
53
|
hasTitle: false,
|
|
38
54
|
structureType: 'article',
|
|
39
55
|
displayStructureName: true,
|
|
@@ -81,6 +81,12 @@ export const fetchLpdcs = async ({
|
|
|
81
81
|
},
|
|
82
82
|
});
|
|
83
83
|
|
|
84
|
+
if (!results.ok) {
|
|
85
|
+
throw new Error(
|
|
86
|
+
`Received '${results.status}: ${results.statusText}' when fetching from LPDC`,
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
84
90
|
const resultJson = (await results.json()) as FetchResults;
|
|
85
91
|
|
|
86
92
|
return {
|
|
@@ -2,4 +2,9 @@ export type RoadsignRegulationPluginOptions = {
|
|
|
2
2
|
endpoint: string;
|
|
3
3
|
imageBaseUrl: string;
|
|
4
4
|
articleUriGenrator?: () => string;
|
|
5
|
+
/** Instead of finding a decision node in the document, pass the relevant URI and type */
|
|
6
|
+
decisionContext?: {
|
|
7
|
+
decisionUri: string;
|
|
8
|
+
decisionType?: string;
|
|
9
|
+
};
|
|
5
10
|
};
|
|
@@ -4,6 +4,8 @@ import IntlService from 'ember-intl/services/intl';
|
|
|
4
4
|
export interface InsertArticleOptions {
|
|
5
5
|
uriGenerator?: () => string;
|
|
6
6
|
insertFreely?: boolean;
|
|
7
|
+
/** Pass a decision URI instead of finding one in the document. Implies `insertFreely`. */
|
|
8
|
+
decisionUri?: string;
|
|
7
9
|
}
|
|
8
10
|
interface Sig {
|
|
9
11
|
Args: {
|
|
@@ -23,8 +25,8 @@ export default class InsertArticleComponent extends Component<Sig> {
|
|
|
23
25
|
pos: number;
|
|
24
26
|
node: PNode;
|
|
25
27
|
} | null;
|
|
28
|
+
get canInsertFreely(): string | true | undefined;
|
|
26
29
|
get canInsert(): boolean;
|
|
27
|
-
get canInsertFreely(): boolean;
|
|
28
30
|
get canInsertInDecision(): boolean;
|
|
29
31
|
doInsert(): void;
|
|
30
32
|
insertFreely(node: PNode): void;
|
|
@@ -11,6 +11,7 @@ export default class LpdcPluginsInsertComponent extends Component<Args> {
|
|
|
11
11
|
get controller(): SayController;
|
|
12
12
|
openModal(): void;
|
|
13
13
|
closeModal(): void;
|
|
14
|
+
get decisionUri(): string | undefined;
|
|
14
15
|
get isButtonDisabled(): boolean;
|
|
15
16
|
onLpdcInsert(lpdc: LPDC): void;
|
|
16
17
|
}
|
package/declarations/addon/components/roadsign-regulation-plugin/roadsign-regulation-card.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
2
|
import { SayController } from '@lblod/ember-rdfa-editor';
|
|
3
|
+
import { RoadsignRegulationPluginOptions } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/roadsign-regulation-plugin';
|
|
3
4
|
type Args = {
|
|
4
5
|
controller: SayController;
|
|
6
|
+
options: RoadsignRegulationPluginOptions;
|
|
5
7
|
};
|
|
6
8
|
export default class RoadsignRegulationCard extends Component<Args> {
|
|
7
9
|
AddIcon: TOC<import("@appuniversum/ember-appuniversum/components/icons/add").AddIconSignature>;
|
|
@@ -17,7 +17,7 @@ type Args = {
|
|
|
17
17
|
controller: SayController;
|
|
18
18
|
options: RoadsignRegulationPluginOptions;
|
|
19
19
|
};
|
|
20
|
-
export default class
|
|
20
|
+
export default class RoadsignsModal extends Component<Args> {
|
|
21
21
|
endpoint: string;
|
|
22
22
|
imageBaseUrl: string;
|
|
23
23
|
pageSize: number;
|
|
@@ -38,7 +38,6 @@ export default class RoadsignRegulationCard extends Component<Args> {
|
|
|
38
38
|
constructor(parent: unknown, args: Args);
|
|
39
39
|
get schema(): import("prosemirror-model").Schema<any, any>;
|
|
40
40
|
get controller(): SayController;
|
|
41
|
-
get decisionRange(): import("@lblod/ember-rdfa-editor/plugins/datastore").ElementPNode | undefined;
|
|
42
41
|
get decisionLocation(): {
|
|
43
42
|
node: import("prosemirror-model").Node;
|
|
44
43
|
pos: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { EditorState, SayController } from '@lblod/ember-rdfa-editor';
|
|
2
2
|
import { ElementPNode } from '@lblod/ember-rdfa-editor/plugins/datastore';
|
|
3
3
|
export declare const getCurrentBesluitRange: (controllerOrState: SayController | EditorState) => ElementPNode | undefined;
|
|
4
|
-
export declare const getCurrentBesluitURI: (
|
|
4
|
+
export declare const getCurrentBesluitURI: (controllerOrState: SayController | EditorState) => string | undefined;
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { NodeWithPos } from '@curvenote/prosemirror-utils';
|
|
2
2
|
import { Command, PNode } from '@lblod/ember-rdfa-editor';
|
|
3
|
-
interface
|
|
3
|
+
interface InsertArticleToDecisionArgs {
|
|
4
4
|
node: PNode;
|
|
5
|
-
decisionLocation: NodeWithPos;
|
|
5
|
+
decisionLocation: NodeWithPos | null;
|
|
6
|
+
insertFreely?: false;
|
|
6
7
|
}
|
|
7
|
-
|
|
8
|
+
interface InsertArticleFreelyArgs {
|
|
9
|
+
node: PNode;
|
|
10
|
+
insertFreely: true;
|
|
11
|
+
}
|
|
12
|
+
export default function insertArticle({ node, ...args }: InsertArticleToDecisionArgs | InsertArticleFreelyArgs): Command;
|
|
8
13
|
export {};
|
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
import { Schema } from '@lblod/ember-rdfa-editor';
|
|
2
|
-
export declare function buildArticleStructure(schema: Schema, uriGenerator?: () => string
|
|
2
|
+
export declare function buildArticleStructure(schema: Schema, uriGenerator?: () => string,
|
|
3
|
+
/**
|
|
4
|
+
* Adds a backlink to this resource instead of relying on being linked to the decision after
|
|
5
|
+
* creation.
|
|
6
|
+
* Adding backlinks like this does not play nice with the RDFa tools, but if combined with a
|
|
7
|
+
* document with this URI imported it works as expected. It creates valid RDFa in either case.
|
|
8
|
+
*/
|
|
9
|
+
decisionUri?: string): import("prosemirror-model").Node;
|
|
@@ -2,4 +2,9 @@ export type RoadsignRegulationPluginOptions = {
|
|
|
2
2
|
endpoint: string;
|
|
3
3
|
imageBaseUrl: string;
|
|
4
4
|
articleUriGenrator?: () => string;
|
|
5
|
+
/** Instead of finding a decision node in the document, pass the relevant URI and type */
|
|
6
|
+
decisionContext?: {
|
|
7
|
+
decisionUri: string;
|
|
8
|
+
decisionType?: string;
|
|
9
|
+
};
|
|
5
10
|
};
|