@lblod/ember-rdfa-editor-lblod-plugins 39.2.0 → 39.3.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 +8 -0
- package/addon/components/besluit-target-group-plugin/besluit-target-group-field.gts +92 -0
- package/addon/components/besluit-topic-plugin/besluit-topic-select.hbs +1 -0
- package/addon/components/besluit-topic-plugin/besluit-topic-select.ts +2 -0
- package/addon/components/besluit-type-plugin/besluit-type-form.gts +4 -0
- package/addon/components/besluit-type-plugin/besluit-type-select.gts +2 -0
- package/addon/components/document-information-plugin/_private/besluit-topic-field.gts +45 -0
- package/addon/components/document-information-plugin/_private/besluit-type-field.gts +43 -0
- package/addon/components/document-information-plugin/document-information-modal.gts +386 -0
- package/addon/plugins/besluit-target-group-plugin/constants.ts +3 -0
- package/addon/plugins/besluit-target-group-plugin/extract-besluit-target-group-uris.ts +27 -0
- package/addon/plugins/besluit-target-group-plugin/queries.ts +68 -0
- package/addon/plugins/besluit-target-group-plugin/set-besluit-target-groups.ts +52 -0
- package/addon/plugins/besluit-target-group-plugin/types.ts +9 -0
- package/addon/plugins/besluit-topic-plugin/utils/extract-besluit-topic-uris.ts +45 -0
- package/addon/utils/_private/boolean.ts +3 -0
- package/addon/utils/constants.ts +2 -0
- package/app/components/document-information-plugin/document-information-modal.js +1 -0
- package/declarations/addon/components/besluit-target-group-plugin/besluit-target-group-field.d.ts +15 -0
- package/declarations/addon/components/besluit-topic-plugin/besluit-topic-select.d.ts +1 -0
- package/declarations/addon/components/besluit-type-plugin/besluit-type-form.d.ts +1 -0
- package/declarations/addon/components/besluit-type-plugin/besluit-type-select.d.ts +1 -0
- package/declarations/addon/components/document-information-plugin/_private/besluit-topic-field.d.ts +15 -0
- package/declarations/addon/components/document-information-plugin/_private/besluit-type-field.d.ts +17 -0
- package/declarations/addon/components/document-information-plugin/document-information-modal.d.ts +72 -0
- package/declarations/addon/plugins/besluit-target-group-plugin/constants.d.ts +1 -0
- package/declarations/addon/plugins/besluit-target-group-plugin/extract-besluit-target-group-uris.d.ts +2 -0
- package/declarations/addon/plugins/besluit-target-group-plugin/queries.d.ts +8 -0
- package/declarations/addon/plugins/besluit-target-group-plugin/set-besluit-target-groups.d.ts +4 -0
- package/declarations/addon/plugins/besluit-target-group-plugin/types.d.ts +8 -0
- package/declarations/addon/plugins/besluit-topic-plugin/utils/extract-besluit-topic-uris.d.ts +2 -0
- package/declarations/addon/utils/_private/boolean.d.ts +1 -0
- package/declarations/addon/utils/constants.d.ts +1 -0
- package/package.json +1 -1
- package/translations/en-US.yaml +10 -0
- package/translations/nl-BE.yaml +10 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @lblod/ember-rdfa-editor-lblod-plugins
|
|
2
2
|
|
|
3
|
+
## 39.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#689](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/689) [`1a3a255`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/1a3a255089cfdc4b689d73de87065e7a803fa9ac) Thanks [@elpoelma](https://github.com/elpoelma)! - Introduce customizable `document-information-modal` component which contains decision-type and decision-topic selector. This component can be customized to contain additional form fields.
|
|
8
|
+
|
|
9
|
+
- [#689](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/689) [`3eeddf4`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/3eeddf439cec260402c88364649673e0141e69ee) Thanks [@elpoelma](https://github.com/elpoelma)! - Add besluit-target-group plugin which can be used through the `document-information` plugin
|
|
10
|
+
|
|
3
11
|
## 39.2.0
|
|
4
12
|
|
|
5
13
|
### Minor Changes
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { TemplateOnlyComponent } from '@ember/component/template-only';
|
|
2
|
+
import t from 'ember-intl/helpers/t';
|
|
3
|
+
import AuAlert from '@appuniversum/ember-appuniversum/components/au-alert';
|
|
4
|
+
import AuLabel from '@appuniversum/ember-appuniversum/components/au-label';
|
|
5
|
+
import AuLoader from '@appuniversum/ember-appuniversum/components/au-loader';
|
|
6
|
+
import PowerSelectMultiple from 'ember-power-select/components/power-select-multiple';
|
|
7
|
+
import { BesluitTargetGroup } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-target-group-plugin/types';
|
|
8
|
+
import Component from '@glimmer/component';
|
|
9
|
+
import { action } from '@ember/object';
|
|
10
|
+
|
|
11
|
+
interface Signature {
|
|
12
|
+
Args: {
|
|
13
|
+
targetGroups?: BesluitTargetGroup[];
|
|
14
|
+
selected?: BesluitTargetGroup[];
|
|
15
|
+
onChange: (targetGroups: BesluitTargetGroup[]) => void;
|
|
16
|
+
isError?: boolean;
|
|
17
|
+
renderInPlace?: boolean;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
};
|
|
20
|
+
Element: HTMLDivElement;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const BesluitTargetGroupField: TemplateOnlyComponent<Signature> = <template>
|
|
24
|
+
<div ...attributes>
|
|
25
|
+
<AuLabel>
|
|
26
|
+
{{t 'besluit-target-group-plugin.label'}}
|
|
27
|
+
</AuLabel>
|
|
28
|
+
{{#if @isError}}
|
|
29
|
+
<AuAlert
|
|
30
|
+
@skin='error'
|
|
31
|
+
@title={{t 'besluit-target-group-plugin.error-title'}}
|
|
32
|
+
>
|
|
33
|
+
<p>{{t 'besluit-target-group-plugin.error-short'}}</p>
|
|
34
|
+
</AuAlert>
|
|
35
|
+
{{else if @targetGroups}}
|
|
36
|
+
<BesluitTargetGroupSelect
|
|
37
|
+
@besluitTargetGroups={{@targetGroups}}
|
|
38
|
+
@selected={{@selected}}
|
|
39
|
+
@onchange={{@onChange}}
|
|
40
|
+
@renderInPlace={{@renderInPlace}}
|
|
41
|
+
@disabled={{@disabled}}
|
|
42
|
+
/>
|
|
43
|
+
{{else}}
|
|
44
|
+
<AuLoader @hideMessage={{true}}>{{t 'common.loading'}}</AuLoader>
|
|
45
|
+
{{/if}}
|
|
46
|
+
</div>
|
|
47
|
+
</template>;
|
|
48
|
+
|
|
49
|
+
export default BesluitTargetGroupField;
|
|
50
|
+
|
|
51
|
+
type BesluitTargetGroupSelectSignature = {
|
|
52
|
+
Args: {
|
|
53
|
+
besluitTargetGroups: BesluitTargetGroup[];
|
|
54
|
+
selected?: BesluitTargetGroup[];
|
|
55
|
+
onchange: (targetGroups: BesluitTargetGroup[]) => void;
|
|
56
|
+
renderInPlace?: boolean;
|
|
57
|
+
disabled?: boolean;
|
|
58
|
+
};
|
|
59
|
+
Element: HTMLDivElement;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
class BesluitTargetGroupSelect extends Component<BesluitTargetGroupSelectSignature> {
|
|
63
|
+
@action
|
|
64
|
+
search(term: string) {
|
|
65
|
+
const lowerTerm = term.toLowerCase();
|
|
66
|
+
|
|
67
|
+
return this.args.besluitTargetGroups.filter((targetGroup) =>
|
|
68
|
+
targetGroup.label.toLowerCase().includes(lowerTerm),
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
<template>
|
|
73
|
+
<div ...attributes>
|
|
74
|
+
<PowerSelectMultiple
|
|
75
|
+
@searchEnabled={{true}}
|
|
76
|
+
@searchMessage={{t 'common.search.type-to-search'}}
|
|
77
|
+
@noMatchesMessage={{t 'common.search.no-results'}}
|
|
78
|
+
@search={{this.search}}
|
|
79
|
+
@options={{@besluitTargetGroups}}
|
|
80
|
+
@selected={{@selected}}
|
|
81
|
+
@onChange={{@onchange}}
|
|
82
|
+
@renderInPlace={{@renderInPlace}}
|
|
83
|
+
@disabled={{@disabled}}
|
|
84
|
+
as |targetGroup|
|
|
85
|
+
>
|
|
86
|
+
<span title={{targetGroup.definition}}>
|
|
87
|
+
{{targetGroup.label}}
|
|
88
|
+
</span>
|
|
89
|
+
</PowerSelectMultiple>
|
|
90
|
+
</div>
|
|
91
|
+
</template>
|
|
92
|
+
}
|
|
@@ -9,6 +9,7 @@ type Args = {
|
|
|
9
9
|
selected?: BesluitTopic[];
|
|
10
10
|
onchange: (topic: BesluitTopic[]) => void;
|
|
11
11
|
renderInPlace?: boolean;
|
|
12
|
+
disabled?: boolean;
|
|
12
13
|
};
|
|
13
14
|
|
|
14
15
|
export default class BesluitTopicSelectComponent extends Component<Args> {
|
|
@@ -32,6 +33,7 @@ export default class BesluitTopicSelectComponent extends Component<Args> {
|
|
|
32
33
|
besluitTopic.label.toLowerCase().includes(lowerTerm),
|
|
33
34
|
);
|
|
34
35
|
}
|
|
36
|
+
|
|
35
37
|
get renderInPlace() {
|
|
36
38
|
if (this.args.renderInPlace === false) return false;
|
|
37
39
|
return true;
|
|
@@ -10,6 +10,7 @@ interface Sig {
|
|
|
10
10
|
setType: (selected: BesluitTypeInstance) => void;
|
|
11
11
|
required?: boolean;
|
|
12
12
|
renderInPlace?: boolean;
|
|
13
|
+
disabled?: boolean;
|
|
13
14
|
};
|
|
14
15
|
Element: HTMLDivElement;
|
|
15
16
|
}
|
|
@@ -52,6 +53,7 @@ export default class BesluitTypePluginBesluitTypeSelectComponent extends Compone
|
|
|
52
53
|
@showWarningWhenEmpty={{false}}
|
|
53
54
|
@required={{@required}}
|
|
54
55
|
@renderInPlace={{this.renderInPlace}}
|
|
56
|
+
@disabled={{@disabled}}
|
|
55
57
|
/>
|
|
56
58
|
{{#if @selectedType.parent.subTypes.length}}
|
|
57
59
|
<BesluitTypeSelect
|
|
@@ -62,6 +64,7 @@ export default class BesluitTypePluginBesluitTypeSelectComponent extends Compone
|
|
|
62
64
|
@showWarningWhenEmpty={{true}}
|
|
63
65
|
@required={{@required}}
|
|
64
66
|
@renderInPlace={{this.renderInPlace}}
|
|
67
|
+
@disabled={{@disabled}}
|
|
65
68
|
/>
|
|
66
69
|
{{/if}}
|
|
67
70
|
{{#if @selectedType.subType.subTypes.length}}
|
|
@@ -73,6 +76,7 @@ export default class BesluitTypePluginBesluitTypeSelectComponent extends Compone
|
|
|
73
76
|
@showWarningWhenEmpty={{true}}
|
|
74
77
|
@required={{@required}}
|
|
75
78
|
@renderInPlace={{this.renderInPlace}}
|
|
79
|
+
@disabled={{@disabled}}
|
|
76
80
|
/>
|
|
77
81
|
{{/if}}
|
|
78
82
|
</div>
|
|
@@ -17,6 +17,7 @@ interface Sig {
|
|
|
17
17
|
onchange: (selected: BesluitType) => void;
|
|
18
18
|
required?: boolean;
|
|
19
19
|
renderInPlace?: boolean;
|
|
20
|
+
disabled?: boolean;
|
|
20
21
|
};
|
|
21
22
|
Element: HTMLDivElement;
|
|
22
23
|
}
|
|
@@ -58,6 +59,7 @@ export default class BesluitTypePluginBesluitTypeSelectComponent extends Compone
|
|
|
58
59
|
@options={{this.besluitTypes}}
|
|
59
60
|
@selected={{@selected}}
|
|
60
61
|
@onChange={{@onchange}}
|
|
62
|
+
@disabled={{@disabled}}
|
|
61
63
|
as |besluitType|
|
|
62
64
|
>
|
|
63
65
|
{{besluitType.label}}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { TemplateOnlyComponent } from '@ember/component/template-only';
|
|
2
|
+
import t from 'ember-intl/helpers/t';
|
|
3
|
+
import AuAlert from '@appuniversum/ember-appuniversum/components/au-alert';
|
|
4
|
+
import AuLabel from '@appuniversum/ember-appuniversum/components/au-label';
|
|
5
|
+
import AuLoader from '@appuniversum/ember-appuniversum/components/au-loader';
|
|
6
|
+
import BesluitTopicSelect from '@lblod/ember-rdfa-editor-lblod-plugins/components/besluit-topic-plugin/besluit-topic-select';
|
|
7
|
+
import type { BesluitTopic } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-topic-plugin/utils/fetchBesluitTopics';
|
|
8
|
+
|
|
9
|
+
interface BesluitTopicFieldSig {
|
|
10
|
+
Args: {
|
|
11
|
+
topics?: BesluitTopic[];
|
|
12
|
+
selected?: BesluitTopic[];
|
|
13
|
+
onChange: (topics: BesluitTopic[]) => void;
|
|
14
|
+
isError?: boolean;
|
|
15
|
+
renderInPlace?: boolean;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
};
|
|
18
|
+
Element: HTMLDivElement;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const BesluitTopicField: TemplateOnlyComponent<BesluitTopicFieldSig> =
|
|
22
|
+
<template>
|
|
23
|
+
<div ...attributes>
|
|
24
|
+
<AuLabel>
|
|
25
|
+
{{t 'besluit-topic-plugin.dt'}}
|
|
26
|
+
</AuLabel>
|
|
27
|
+
{{#if @isError}}
|
|
28
|
+
<AuAlert @skin='error' @title={{t 'besluit-topic-plugin.error-title'}}>
|
|
29
|
+
<p>{{t 'besluit-topic-plugin.error-short'}}</p>
|
|
30
|
+
</AuAlert>
|
|
31
|
+
{{else if @topics}}
|
|
32
|
+
<BesluitTopicSelect
|
|
33
|
+
@besluitTopics={{@topics}}
|
|
34
|
+
@selected={{@selected}}
|
|
35
|
+
@onchange={{@onChange}}
|
|
36
|
+
@renderInPlace={{@renderInPlace}}
|
|
37
|
+
@disabled={{@disabled}}
|
|
38
|
+
/>
|
|
39
|
+
{{else}}
|
|
40
|
+
<AuLoader @hideMessage={{true}}>{{t 'common.loading'}}</AuLoader>
|
|
41
|
+
{{/if}}
|
|
42
|
+
</div>
|
|
43
|
+
</template>;
|
|
44
|
+
|
|
45
|
+
export default BesluitTopicField;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { TemplateOnlyComponent } from '@ember/component/template-only';
|
|
2
|
+
import t from 'ember-intl/helpers/t';
|
|
3
|
+
import AuAlert from '@appuniversum/ember-appuniversum/components/au-alert';
|
|
4
|
+
import AuLoader from '@appuniversum/ember-appuniversum/components/au-loader';
|
|
5
|
+
import BesluitTypeForm from '@lblod/ember-rdfa-editor-lblod-plugins/components/besluit-type-plugin/besluit-type-form';
|
|
6
|
+
import type { BesluitType } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-type-plugin/utils/fetchBesluitTypes';
|
|
7
|
+
import type { BesluitTypeInstance } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-type-plugin/utils/besluit-type-instances';
|
|
8
|
+
|
|
9
|
+
interface BesluitTypeFieldSig {
|
|
10
|
+
Args: {
|
|
11
|
+
types?: BesluitType[] | null;
|
|
12
|
+
selected?: BesluitTypeInstance;
|
|
13
|
+
onChange: (selected: BesluitTypeInstance) => void;
|
|
14
|
+
isError?: boolean;
|
|
15
|
+
required?: boolean;
|
|
16
|
+
renderInPlace?: boolean;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
};
|
|
19
|
+
Element: HTMLDivElement;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const BesluitTypeField: TemplateOnlyComponent<BesluitTypeFieldSig> = <template>
|
|
23
|
+
<div ...attributes>
|
|
24
|
+
{{#if @isError}}
|
|
25
|
+
<AuAlert @skin='error' @title={{t 'besluit-type-plugin.error-title'}}>
|
|
26
|
+
<p>{{t 'besluit-type-plugin.error-short'}}</p>
|
|
27
|
+
</AuAlert>
|
|
28
|
+
{{else if @types}}
|
|
29
|
+
<BesluitTypeForm
|
|
30
|
+
@types={{@types}}
|
|
31
|
+
@selectedType={{@selected}}
|
|
32
|
+
@setType={{@onChange}}
|
|
33
|
+
@required={{@required}}
|
|
34
|
+
@renderInPlace={{@renderInPlace}}
|
|
35
|
+
@disabled={{@disabled}}
|
|
36
|
+
/>
|
|
37
|
+
{{else}}
|
|
38
|
+
<AuLoader @hideMessage={{true}}>{{t 'common.loading'}}</AuLoader>
|
|
39
|
+
{{/if}}
|
|
40
|
+
</div>
|
|
41
|
+
</template>;
|
|
42
|
+
|
|
43
|
+
export default BesluitTypeField;
|
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { cached, tracked } from '@glimmer/tracking';
|
|
3
|
+
import { on } from '@ember/modifier';
|
|
4
|
+
import { hash } from '@ember/helper';
|
|
5
|
+
import { task } from 'ember-concurrency';
|
|
6
|
+
import perform from 'ember-concurrency/helpers/perform';
|
|
7
|
+
import t from 'ember-intl/helpers/t';
|
|
8
|
+
import AuButton from '@appuniversum/ember-appuniversum/components/au-button';
|
|
9
|
+
import AuModal from '@appuniversum/ember-appuniversum/components/au-modal';
|
|
10
|
+
import type { SayController } from '@lblod/ember-rdfa-editor';
|
|
11
|
+
import type { BesluitTypePluginOptions } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-type-plugin';
|
|
12
|
+
import type { BesluitTopicPluginOptions } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-topic-plugin';
|
|
13
|
+
import fetchBesluitTypes from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-type-plugin/utils/fetchBesluitTypes';
|
|
14
|
+
import {
|
|
15
|
+
checkBesluitTypeInstance,
|
|
16
|
+
isValidTypeChoice,
|
|
17
|
+
type BesluitTypeInstance,
|
|
18
|
+
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-type-plugin/utils/besluit-type-instances';
|
|
19
|
+
import { setBesluitType } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-type-plugin/utils/set-besluit-type';
|
|
20
|
+
import {
|
|
21
|
+
fetchBesluitTopics,
|
|
22
|
+
type BesluitTopic,
|
|
23
|
+
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-topic-plugin/utils/fetchBesluitTopics';
|
|
24
|
+
import { updateBesluitTopicResource } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-topic-plugin/commands/update-besluit-topic-resource';
|
|
25
|
+
import { extractBesluitTopicUris } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-topic-plugin/utils/extract-besluit-topic-uris';
|
|
26
|
+
import {
|
|
27
|
+
getCurrentBesluitRange,
|
|
28
|
+
getCurrentBesluitURI,
|
|
29
|
+
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/decision-utils';
|
|
30
|
+
import BesluitTypeField from './_private/besluit-type-field';
|
|
31
|
+
import BesluitTopicField from './_private/besluit-topic-field';
|
|
32
|
+
import { WithBoundArgs } from '@glint/template';
|
|
33
|
+
import { not } from 'ember-truth-helpers';
|
|
34
|
+
import {
|
|
35
|
+
BesluitTargetGroup,
|
|
36
|
+
BesluitTargetGroupPluginOptions,
|
|
37
|
+
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-target-group-plugin/types';
|
|
38
|
+
import { fetchBesluitTargetGroups } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-target-group-plugin/queries';
|
|
39
|
+
import { extractBesluitTargetGroupUris } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-target-group-plugin/extract-besluit-target-group-uris';
|
|
40
|
+
import { setBesluitTargetGroups } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-target-group-plugin/set-besluit-target-groups';
|
|
41
|
+
import { getPromiseState } from 'reactiveweb/get-promise-state';
|
|
42
|
+
import { toBool } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/_private/boolean';
|
|
43
|
+
import BesluitTargetGroupField from '../besluit-target-group-plugin/besluit-target-group-field';
|
|
44
|
+
import { service } from '@ember/service';
|
|
45
|
+
import IntlService from 'ember-intl/services/intl';
|
|
46
|
+
|
|
47
|
+
interface Sig {
|
|
48
|
+
Args: {
|
|
49
|
+
controller: SayController;
|
|
50
|
+
title?: string;
|
|
51
|
+
besluitTypeOptions?: BesluitTypePluginOptions;
|
|
52
|
+
besluitTopicOptions?: BesluitTopicPluginOptions;
|
|
53
|
+
besluitTargetGroupOptions?: BesluitTargetGroupPluginOptions;
|
|
54
|
+
onSave?: () => void | Promise<void>;
|
|
55
|
+
onCancel?: () => void;
|
|
56
|
+
saveDisabled?: boolean;
|
|
57
|
+
requireBesluitType?: boolean;
|
|
58
|
+
};
|
|
59
|
+
Blocks: {
|
|
60
|
+
default: [
|
|
61
|
+
{
|
|
62
|
+
BesluitType: WithBoundArgs<
|
|
63
|
+
typeof BesluitTypeField,
|
|
64
|
+
| 'types'
|
|
65
|
+
| 'selected'
|
|
66
|
+
| 'onChange'
|
|
67
|
+
| 'isError'
|
|
68
|
+
| 'required'
|
|
69
|
+
| 'renderInPlace'
|
|
70
|
+
| 'disabled'
|
|
71
|
+
>;
|
|
72
|
+
BesluitTopic: WithBoundArgs<
|
|
73
|
+
typeof BesluitTopicField,
|
|
74
|
+
| 'topics'
|
|
75
|
+
| 'selected'
|
|
76
|
+
| 'onChange'
|
|
77
|
+
| 'isError'
|
|
78
|
+
| 'renderInPlace'
|
|
79
|
+
| 'disabled'
|
|
80
|
+
>;
|
|
81
|
+
BesluitTargetGroup: WithBoundArgs<
|
|
82
|
+
typeof BesluitTargetGroupField,
|
|
83
|
+
| 'targetGroups'
|
|
84
|
+
| 'selected'
|
|
85
|
+
| 'onChange'
|
|
86
|
+
| 'isError'
|
|
87
|
+
| 'renderInPlace'
|
|
88
|
+
| 'disabled'
|
|
89
|
+
>;
|
|
90
|
+
selectedTypeInstance: BesluitTypeInstance | undefined;
|
|
91
|
+
selectedTopics: BesluitTopic[] | undefined;
|
|
92
|
+
selectedTargetGroups: BesluitTargetGroup[] | undefined;
|
|
93
|
+
},
|
|
94
|
+
];
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export default class DocumentInformationModal extends Component<Sig> {
|
|
99
|
+
@service declare intl: IntlService;
|
|
100
|
+
|
|
101
|
+
@tracked stagedTypeInstance?: BesluitTypeInstance;
|
|
102
|
+
@tracked stagedTopics?: BesluitTopic[];
|
|
103
|
+
@tracked stagedTargetGroups?: BesluitTargetGroup[];
|
|
104
|
+
|
|
105
|
+
get modalTitle() {
|
|
106
|
+
return (
|
|
107
|
+
this.args.title ?? this.intl.t('document-information-plugin.modal-title')
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
get controller() {
|
|
112
|
+
return this.args.controller;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
get hasBesluit() {
|
|
116
|
+
return !!getCurrentBesluitRange(this.controller);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// default is true
|
|
120
|
+
get requireBesluitType() {
|
|
121
|
+
return this.args.requireBesluitType !== false && this.hasBesluit;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
get currentTypeInstance(): BesluitTypeInstance | undefined {
|
|
125
|
+
const types = this.types.resolved;
|
|
126
|
+
if (!types) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
return (
|
|
130
|
+
checkBesluitTypeInstance(this.controller.mainEditorState, types) ||
|
|
131
|
+
undefined
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
get selectedTypeInstance(): BesluitTypeInstance | undefined {
|
|
136
|
+
return this.stagedTypeInstance ?? this.currentTypeInstance;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
get hasStagedTypeInstance() {
|
|
140
|
+
return this.stagedTypeInstance !== undefined;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
get currentTopics(): BesluitTopic[] | undefined {
|
|
144
|
+
const topics = this.topics.resolved;
|
|
145
|
+
const uris = extractBesluitTopicUris(this.controller);
|
|
146
|
+
if (!topics || !uris.length) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
return topics.filter((topic) => uris.includes(topic.uri));
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
get selectedTopics(): BesluitTopic[] | undefined {
|
|
153
|
+
return this.stagedTopics ?? this.currentTopics;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
get hasStagedTopics() {
|
|
157
|
+
return this.stagedTopics !== undefined;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
get currentTargetGroups(): BesluitTargetGroup[] | undefined {
|
|
161
|
+
const targetGroups = this.targetGroups.resolved;
|
|
162
|
+
const uris = extractBesluitTargetGroupUris(this.controller);
|
|
163
|
+
if (!targetGroups || !uris.length) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
return targetGroups.filter((topic) => uris.includes(topic.uri));
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
get selectedTargetGroups(): BesluitTargetGroup[] | undefined {
|
|
170
|
+
return this.stagedTargetGroups ?? this.currentTargetGroups;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
get hasStagedTargetGroups() {
|
|
174
|
+
return this.stagedTargetGroups !== undefined;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
get saveDisabled() {
|
|
178
|
+
if (this.args.saveDisabled) {
|
|
179
|
+
return true;
|
|
180
|
+
}
|
|
181
|
+
if (!this.requireBesluitType) {
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
const selectedType = this.selectedTypeInstance;
|
|
185
|
+
if (!selectedType) {
|
|
186
|
+
return true;
|
|
187
|
+
}
|
|
188
|
+
// An existing type may predate the current type hierarchy, so only
|
|
189
|
+
// validate the choice when the user has actually changed it.
|
|
190
|
+
return this.hasStagedTypeInstance && !isValidTypeChoice(selectedType);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
@cached
|
|
194
|
+
get typesPromise() {
|
|
195
|
+
if (!this.args.besluitTypeOptions) {
|
|
196
|
+
throw new Error(
|
|
197
|
+
'`@besluitTypeOptions` argument of `DocumentInformationModal` component is not configured',
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
return fetchBesluitTypes(
|
|
201
|
+
this.args.besluitTypeOptions.classificatieUri,
|
|
202
|
+
this.args.besluitTypeOptions.endpoint,
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
get types() {
|
|
207
|
+
return getPromiseState(this.typesPromise);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
@cached
|
|
211
|
+
get topicsPromise() {
|
|
212
|
+
if (!this.args.besluitTopicOptions) {
|
|
213
|
+
throw new Error(
|
|
214
|
+
'`@besluitTopicOptions` argument of `DocumentInformationModal` component is not configured',
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
return fetchBesluitTopics({
|
|
218
|
+
config: { endpoint: this.args.besluitTopicOptions.endpoint },
|
|
219
|
+
}).then((res) => res.topics);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
get topics() {
|
|
223
|
+
return getPromiseState(this.topicsPromise);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
@cached
|
|
227
|
+
get targetGroupsPromise() {
|
|
228
|
+
if (!this.args.besluitTargetGroupOptions) {
|
|
229
|
+
throw new Error(
|
|
230
|
+
'`@besluitTargetGroupOptions` argument of `DocumentInformationModal` component is not configured',
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
return fetchBesluitTargetGroups({
|
|
234
|
+
config: this.args.besluitTargetGroupOptions,
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
get targetGroups() {
|
|
239
|
+
return getPromiseState(this.targetGroupsPromise);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
stageTypeInstance = (type: BesluitTypeInstance) => {
|
|
243
|
+
this.stagedTypeInstance = type;
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
stageBesluitTopics = (selected: BesluitTopic[]) => {
|
|
247
|
+
this.stagedTopics = selected;
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
stageTargetGroups = (selected: BesluitTargetGroup[]) => {
|
|
251
|
+
this.stagedTargetGroups = selected;
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
updateDocumentBesluitType() {
|
|
255
|
+
this.controller.doCommand((state, dispatch) => {
|
|
256
|
+
if (!this.selectedTypeInstance || !dispatch) {
|
|
257
|
+
return false;
|
|
258
|
+
}
|
|
259
|
+
const { result, transaction } = setBesluitType(
|
|
260
|
+
state,
|
|
261
|
+
this.selectedTypeInstance,
|
|
262
|
+
);
|
|
263
|
+
if (result.every((ok) => ok)) {
|
|
264
|
+
dispatch(transaction);
|
|
265
|
+
return true;
|
|
266
|
+
}
|
|
267
|
+
return false;
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
updateDocumentTopic() {
|
|
272
|
+
const resource = getCurrentBesluitURI(this.controller);
|
|
273
|
+
if (resource && this.selectedTopics) {
|
|
274
|
+
this.controller.doCommand(
|
|
275
|
+
updateBesluitTopicResource({
|
|
276
|
+
resource,
|
|
277
|
+
previousTopics: extractBesluitTopicUris(this.controller),
|
|
278
|
+
newTopics: this.selectedTopics,
|
|
279
|
+
}),
|
|
280
|
+
{
|
|
281
|
+
view: this.controller.mainEditorView,
|
|
282
|
+
},
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
updateDocumentTargetGroups() {
|
|
288
|
+
this.controller.doCommand((state, dispatch) => {
|
|
289
|
+
if (!this.selectedTargetGroups || !dispatch) {
|
|
290
|
+
return false;
|
|
291
|
+
}
|
|
292
|
+
const { result, transaction } = setBesluitTargetGroups(
|
|
293
|
+
state,
|
|
294
|
+
this.selectedTargetGroups,
|
|
295
|
+
);
|
|
296
|
+
if (result.every((ok) => ok)) {
|
|
297
|
+
dispatch(transaction);
|
|
298
|
+
return true;
|
|
299
|
+
}
|
|
300
|
+
return false;
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
saveChanges = task(async () => {
|
|
305
|
+
if (this.hasStagedTypeInstance) {
|
|
306
|
+
this.updateDocumentBesluitType();
|
|
307
|
+
}
|
|
308
|
+
if (this.hasStagedTopics) {
|
|
309
|
+
this.updateDocumentTopic();
|
|
310
|
+
}
|
|
311
|
+
if (this.hasStagedTargetGroups) {
|
|
312
|
+
this.updateDocumentTargetGroups();
|
|
313
|
+
}
|
|
314
|
+
await this.args.onSave?.();
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
cancel = () => {
|
|
318
|
+
this.args.onCancel?.();
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
<template>
|
|
322
|
+
<AuModal
|
|
323
|
+
@title={{this.modalTitle}}
|
|
324
|
+
@modalOpen={{true}}
|
|
325
|
+
@closeModal={{this.cancel}}
|
|
326
|
+
as |Modal|
|
|
327
|
+
>
|
|
328
|
+
<Modal.Body>
|
|
329
|
+
<form class='au-c-form'>
|
|
330
|
+
{{yield
|
|
331
|
+
(hash
|
|
332
|
+
BesluitType=(component
|
|
333
|
+
BesluitTypeField
|
|
334
|
+
types=this.types.resolved
|
|
335
|
+
selected=this.selectedTypeInstance
|
|
336
|
+
onChange=this.stageTypeInstance
|
|
337
|
+
isError=(toBool this.types.error)
|
|
338
|
+
required=this.requireBesluitType
|
|
339
|
+
renderInPlace=false
|
|
340
|
+
disabled=(not this.hasBesluit)
|
|
341
|
+
)
|
|
342
|
+
BesluitTopic=(component
|
|
343
|
+
BesluitTopicField
|
|
344
|
+
topics=this.topics.resolved
|
|
345
|
+
selected=this.selectedTopics
|
|
346
|
+
onChange=this.stageBesluitTopics
|
|
347
|
+
isError=(toBool this.topics.error)
|
|
348
|
+
renderInPlace=false
|
|
349
|
+
disabled=(not this.hasBesluit)
|
|
350
|
+
)
|
|
351
|
+
BesluitTargetGroup=(component
|
|
352
|
+
BesluitTargetGroupField
|
|
353
|
+
targetGroups=this.targetGroups.resolved
|
|
354
|
+
selected=this.selectedTargetGroups
|
|
355
|
+
onChange=this.stageTargetGroups
|
|
356
|
+
isError=(toBool this.targetGroups.error)
|
|
357
|
+
renderInPlace=false
|
|
358
|
+
disabled=(not this.hasBesluit)
|
|
359
|
+
)
|
|
360
|
+
selectedTypeInstance=this.selectedTypeInstance
|
|
361
|
+
selectedTopics=this.selectedTopics
|
|
362
|
+
selectedTargetGroups=this.selectedTargetGroups
|
|
363
|
+
)
|
|
364
|
+
}}
|
|
365
|
+
</form>
|
|
366
|
+
</Modal.Body>
|
|
367
|
+
<Modal.Footer>
|
|
368
|
+
<AuButton
|
|
369
|
+
@loading={{this.saveChanges.isRunning}}
|
|
370
|
+
@loadingMessage={{t 'common.loading'}}
|
|
371
|
+
@disabled={{this.saveDisabled}}
|
|
372
|
+
{{on 'click' (perform this.saveChanges)}}
|
|
373
|
+
>
|
|
374
|
+
{{t 'document-information-plugin.save'}}
|
|
375
|
+
</AuButton>
|
|
376
|
+
<AuButton
|
|
377
|
+
@skin='secondary'
|
|
378
|
+
@disabled={{this.saveChanges.isRunning}}
|
|
379
|
+
{{on 'click' this.cancel}}
|
|
380
|
+
>
|
|
381
|
+
{{t 'document-information-plugin.cancel'}}
|
|
382
|
+
</AuButton>
|
|
383
|
+
</Modal.Footer>
|
|
384
|
+
</AuModal>
|
|
385
|
+
</template>
|
|
386
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { EditorState, SayController } from '@lblod/ember-rdfa-editor';
|
|
2
|
+
import { getCurrentBesluitRange } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/decision-utils';
|
|
3
|
+
import { getOutgoingTripleList } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
|
|
4
|
+
import { BESLUIT_TARGET_GROUP_PREDICATE } from './constants';
|
|
5
|
+
|
|
6
|
+
export function extractBesluitTargetGroupUris(
|
|
7
|
+
controllerOrState: SayController | EditorState,
|
|
8
|
+
): string[] {
|
|
9
|
+
const besluitRange = getCurrentBesluitRange(controllerOrState);
|
|
10
|
+
if (!besluitRange) {
|
|
11
|
+
return [];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const targetGroupTriples = getOutgoingTripleList(
|
|
15
|
+
besluitRange.node.attrs,
|
|
16
|
+
BESLUIT_TARGET_GROUP_PREDICATE,
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
const topicUris = new Set<string>();
|
|
20
|
+
for (const triple of targetGroupTriples) {
|
|
21
|
+
if (triple.object.termType === 'NamedNode') {
|
|
22
|
+
topicUris.add(triple.object.value);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return [...topicUris];
|
|
27
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type BindingObject,
|
|
3
|
+
executeQuery,
|
|
4
|
+
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/sparql-helpers';
|
|
5
|
+
import type { BesluitTargetGroup } from './types';
|
|
6
|
+
|
|
7
|
+
const QUERY = `
|
|
8
|
+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
|
|
9
|
+
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
|
10
|
+
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
|
|
11
|
+
SELECT distinct * WHERE {
|
|
12
|
+
?uri
|
|
13
|
+
skos:inScheme <http://lblod.data.gift/id/conceptscheme/0f9c9346-bd6d-4677-9ffa-5b5089b60934>;
|
|
14
|
+
skos:prefLabel ?label;
|
|
15
|
+
skos:definition ?definition.
|
|
16
|
+
}
|
|
17
|
+
`;
|
|
18
|
+
|
|
19
|
+
const HARDCODED_TARGET_GROUPS: BesluitTargetGroup[] = [
|
|
20
|
+
{
|
|
21
|
+
uri: 'http://lblod.data.gift/id/concept/9aa8c940-4a25-4571-8063-9412494a10a7',
|
|
22
|
+
label: 'Burger',
|
|
23
|
+
definition:
|
|
24
|
+
'Een natuurlijke persoon die als individu gebruikmaakt van publieke dienstverlening, in een persoonlijke of niet-professionele hoedanigheid.',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
uri: 'http://lblod.data.gift/id/concept/d2b67dac-6a8c-4314-990e-8fa87a12edfc',
|
|
28
|
+
label: 'Lokaal Bestuur',
|
|
29
|
+
definition: 'Overheidsentiteiten binnen het lokaal bestuursniveau.',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
uri: 'http://lblod.data.gift/id/concept/2242298b-7f1b-4bc2-b685-5771522987b7',
|
|
33
|
+
label: 'Onderneming',
|
|
34
|
+
definition: 'Entiteiten die economische activiteiten uitoefenen.',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
uri: 'http://lblod.data.gift/id/concept/44a75e92-3733-4d1d-8737-ca81cc608678',
|
|
38
|
+
label: 'Vereniging',
|
|
39
|
+
definition:
|
|
40
|
+
'Juridische of organisatorische entiteiten die onder een van volgende categorieën vallen: verenigingen zonder winstoogmerk, internationale verenigingen zonder winstoogmerk, stichtingen, feitelijke verenigingen en afdelingen van koepelorganisaties.',
|
|
41
|
+
},
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
export type BesluitTargetGroupQueryConfig = {
|
|
45
|
+
endpoint: string;
|
|
46
|
+
abortSignal?: AbortSignal;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export async function fetchBesluitTargetGroups({
|
|
50
|
+
config,
|
|
51
|
+
}: {
|
|
52
|
+
config: BesluitTargetGroupQueryConfig;
|
|
53
|
+
}): Promise<BesluitTargetGroup[]> {
|
|
54
|
+
// TODO: remove the hardcoded codelist once the codelist is available on centrale vindplaats
|
|
55
|
+
return HARDCODED_TARGET_GROUPS;
|
|
56
|
+
const targetGroups = await executeQuery<BindingObject<BesluitTargetGroup>>({
|
|
57
|
+
query: QUERY,
|
|
58
|
+
...config,
|
|
59
|
+
}).then((queryResult) =>
|
|
60
|
+
queryResult.results.bindings.map<BesluitTargetGroup>((binding) => ({
|
|
61
|
+
uri: binding.uri.value,
|
|
62
|
+
label: binding.label.value,
|
|
63
|
+
definition: binding.definition.value,
|
|
64
|
+
})),
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
return targetGroups;
|
|
68
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { type EditorState } from '@lblod/ember-rdfa-editor';
|
|
2
|
+
import {
|
|
3
|
+
transactionCombinator,
|
|
4
|
+
type TransactionCombinatorResult,
|
|
5
|
+
} from '@lblod/ember-rdfa-editor/utils/transaction-utils';
|
|
6
|
+
import {
|
|
7
|
+
addPropertyToNode,
|
|
8
|
+
removePropertyFromNode,
|
|
9
|
+
} from '@lblod/ember-rdfa-editor/utils/rdfa-utils';
|
|
10
|
+
import { sayDataFactory } from '@lblod/ember-rdfa-editor/core/say-data-factory';
|
|
11
|
+
import { getCurrentBesluitURI } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/decision-utils';
|
|
12
|
+
import type { BesluitTargetGroup } from './types';
|
|
13
|
+
import { extractBesluitTargetGroupUris } from './extract-besluit-target-group-uris';
|
|
14
|
+
import { BESLUIT_TARGET_GROUP_PREDICATE } from './constants';
|
|
15
|
+
|
|
16
|
+
export function setBesluitTargetGroups(
|
|
17
|
+
initialState: EditorState,
|
|
18
|
+
targetGroups: BesluitTargetGroup[],
|
|
19
|
+
): TransactionCombinatorResult<boolean> {
|
|
20
|
+
const transaction = initialState.tr;
|
|
21
|
+
const besluitUri = getCurrentBesluitURI(initialState);
|
|
22
|
+
if (!besluitUri) {
|
|
23
|
+
return {
|
|
24
|
+
result: [false],
|
|
25
|
+
initialState,
|
|
26
|
+
transaction,
|
|
27
|
+
transactions: [transaction],
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const existingTargetGroupUris = extractBesluitTargetGroupUris(initialState);
|
|
31
|
+
const monads = existingTargetGroupUris.map((existingUri) => {
|
|
32
|
+
return removePropertyFromNode({
|
|
33
|
+
resource: besluitUri,
|
|
34
|
+
property: {
|
|
35
|
+
predicate: BESLUIT_TARGET_GROUP_PREDICATE.full,
|
|
36
|
+
object: sayDataFactory.namedNode(existingUri),
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
monads.push(
|
|
41
|
+
...targetGroups.map((targetGroup) => {
|
|
42
|
+
return addPropertyToNode({
|
|
43
|
+
resource: besluitUri,
|
|
44
|
+
property: {
|
|
45
|
+
predicate: BESLUIT_TARGET_GROUP_PREDICATE.full,
|
|
46
|
+
object: sayDataFactory.namedNode(targetGroup.uri),
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
}),
|
|
50
|
+
);
|
|
51
|
+
return transactionCombinator<boolean>(initialState)(monads);
|
|
52
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { EditorState, SayController } from '@lblod/ember-rdfa-editor';
|
|
2
|
+
import { getCurrentBesluitRange } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/decision-utils';
|
|
3
|
+
import { getOutgoingTripleList } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
|
|
4
|
+
import {
|
|
5
|
+
TOPIC_PREDICATE,
|
|
6
|
+
TOPIC_PREDICATE_DEPRECATED,
|
|
7
|
+
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-topic-plugin/commands/update-besluit-topic-resource';
|
|
8
|
+
|
|
9
|
+
const BESLUIT_THEMA_BASE_URI =
|
|
10
|
+
'https://data.vlaanderen.be/id/concept/BesluitThema/';
|
|
11
|
+
|
|
12
|
+
export function extractBesluitTopicUris(
|
|
13
|
+
controllerOrState: SayController | EditorState,
|
|
14
|
+
): string[] {
|
|
15
|
+
const besluitRange = getCurrentBesluitRange(controllerOrState);
|
|
16
|
+
if (!besluitRange) {
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const currentTopicTriples = getOutgoingTripleList(
|
|
21
|
+
besluitRange.node.attrs,
|
|
22
|
+
TOPIC_PREDICATE,
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
// TOPIC_PREDICATE_DEPRECATED is a fallback and only used if there are no triples with TOPIC_PREDICATE
|
|
26
|
+
const topicTriples =
|
|
27
|
+
currentTopicTriples.length > 0
|
|
28
|
+
? currentTopicTriples
|
|
29
|
+
: getOutgoingTripleList(
|
|
30
|
+
besluitRange.node.attrs,
|
|
31
|
+
TOPIC_PREDICATE_DEPRECATED,
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
const topicUris = new Set<string>();
|
|
35
|
+
for (const triple of topicTriples) {
|
|
36
|
+
if (
|
|
37
|
+
triple.object.termType === 'NamedNode' &&
|
|
38
|
+
triple.object.value.includes(BESLUIT_THEMA_BASE_URI)
|
|
39
|
+
) {
|
|
40
|
+
topicUris.add(triple.object.value);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return [...topicUris];
|
|
45
|
+
}
|
package/addon/utils/constants.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@lblod/ember-rdfa-editor-lblod-plugins/components/document-information-plugin/document-information-modal';
|
package/declarations/addon/components/besluit-target-group-plugin/besluit-target-group-field.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TemplateOnlyComponent } from '@ember/component/template-only';
|
|
2
|
+
import { BesluitTargetGroup } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-target-group-plugin/types';
|
|
3
|
+
interface Signature {
|
|
4
|
+
Args: {
|
|
5
|
+
targetGroups?: BesluitTargetGroup[];
|
|
6
|
+
selected?: BesluitTargetGroup[];
|
|
7
|
+
onChange: (targetGroups: BesluitTargetGroup[]) => void;
|
|
8
|
+
isError?: boolean;
|
|
9
|
+
renderInPlace?: boolean;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
};
|
|
12
|
+
Element: HTMLDivElement;
|
|
13
|
+
}
|
|
14
|
+
declare const BesluitTargetGroupField: TemplateOnlyComponent<Signature>;
|
|
15
|
+
export default BesluitTargetGroupField;
|
|
@@ -5,6 +5,7 @@ type Args = {
|
|
|
5
5
|
selected?: BesluitTopic[];
|
|
6
6
|
onchange: (topic: BesluitTopic[]) => void;
|
|
7
7
|
renderInPlace?: boolean;
|
|
8
|
+
disabled?: boolean;
|
|
8
9
|
};
|
|
9
10
|
export default class BesluitTopicSelectComponent extends Component<Args> {
|
|
10
11
|
AlertTriangleIcon: import("@ember/component/template-only").TOC<import("@appuniversum/ember-appuniversum/components/icons/alert-triangle").AlertTriangleIconSignature>;
|
package/declarations/addon/components/document-information-plugin/_private/besluit-topic-field.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TemplateOnlyComponent } from '@ember/component/template-only';
|
|
2
|
+
import type { BesluitTopic } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-topic-plugin/utils/fetchBesluitTopics';
|
|
3
|
+
interface BesluitTopicFieldSig {
|
|
4
|
+
Args: {
|
|
5
|
+
topics?: BesluitTopic[];
|
|
6
|
+
selected?: BesluitTopic[];
|
|
7
|
+
onChange: (topics: BesluitTopic[]) => void;
|
|
8
|
+
isError?: boolean;
|
|
9
|
+
renderInPlace?: boolean;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
};
|
|
12
|
+
Element: HTMLDivElement;
|
|
13
|
+
}
|
|
14
|
+
declare const BesluitTopicField: TemplateOnlyComponent<BesluitTopicFieldSig>;
|
|
15
|
+
export default BesluitTopicField;
|
package/declarations/addon/components/document-information-plugin/_private/besluit-type-field.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { TemplateOnlyComponent } from '@ember/component/template-only';
|
|
2
|
+
import type { BesluitType } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-type-plugin/utils/fetchBesluitTypes';
|
|
3
|
+
import type { BesluitTypeInstance } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-type-plugin/utils/besluit-type-instances';
|
|
4
|
+
interface BesluitTypeFieldSig {
|
|
5
|
+
Args: {
|
|
6
|
+
types?: BesluitType[] | null;
|
|
7
|
+
selected?: BesluitTypeInstance;
|
|
8
|
+
onChange: (selected: BesluitTypeInstance) => void;
|
|
9
|
+
isError?: boolean;
|
|
10
|
+
required?: boolean;
|
|
11
|
+
renderInPlace?: boolean;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
};
|
|
14
|
+
Element: HTMLDivElement;
|
|
15
|
+
}
|
|
16
|
+
declare const BesluitTypeField: TemplateOnlyComponent<BesluitTypeFieldSig>;
|
|
17
|
+
export default BesluitTypeField;
|
package/declarations/addon/components/document-information-plugin/document-information-modal.d.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import type { SayController } from '@lblod/ember-rdfa-editor';
|
|
3
|
+
import type { BesluitTypePluginOptions } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-type-plugin';
|
|
4
|
+
import type { BesluitTopicPluginOptions } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-topic-plugin';
|
|
5
|
+
import { type BesluitTypeInstance } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-type-plugin/utils/besluit-type-instances';
|
|
6
|
+
import { type BesluitTopic } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-topic-plugin/utils/fetchBesluitTopics';
|
|
7
|
+
import BesluitTypeField from './_private/besluit-type-field';
|
|
8
|
+
import BesluitTopicField from './_private/besluit-topic-field';
|
|
9
|
+
import { WithBoundArgs } from '@glint/template';
|
|
10
|
+
import { BesluitTargetGroup, BesluitTargetGroupPluginOptions } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-target-group-plugin/types';
|
|
11
|
+
import BesluitTargetGroupField from '../besluit-target-group-plugin/besluit-target-group-field';
|
|
12
|
+
import IntlService from 'ember-intl/services/intl';
|
|
13
|
+
interface Sig {
|
|
14
|
+
Args: {
|
|
15
|
+
controller: SayController;
|
|
16
|
+
title?: string;
|
|
17
|
+
besluitTypeOptions?: BesluitTypePluginOptions;
|
|
18
|
+
besluitTopicOptions?: BesluitTopicPluginOptions;
|
|
19
|
+
besluitTargetGroupOptions?: BesluitTargetGroupPluginOptions;
|
|
20
|
+
onSave?: () => void | Promise<void>;
|
|
21
|
+
onCancel?: () => void;
|
|
22
|
+
saveDisabled?: boolean;
|
|
23
|
+
requireBesluitType?: boolean;
|
|
24
|
+
};
|
|
25
|
+
Blocks: {
|
|
26
|
+
default: [
|
|
27
|
+
{
|
|
28
|
+
BesluitType: WithBoundArgs<typeof BesluitTypeField, 'types' | 'selected' | 'onChange' | 'isError' | 'required' | 'renderInPlace' | 'disabled'>;
|
|
29
|
+
BesluitTopic: WithBoundArgs<typeof BesluitTopicField, 'topics' | 'selected' | 'onChange' | 'isError' | 'renderInPlace' | 'disabled'>;
|
|
30
|
+
BesluitTargetGroup: WithBoundArgs<typeof BesluitTargetGroupField, 'targetGroups' | 'selected' | 'onChange' | 'isError' | 'renderInPlace' | 'disabled'>;
|
|
31
|
+
selectedTypeInstance: BesluitTypeInstance | undefined;
|
|
32
|
+
selectedTopics: BesluitTopic[] | undefined;
|
|
33
|
+
selectedTargetGroups: BesluitTargetGroup[] | undefined;
|
|
34
|
+
}
|
|
35
|
+
];
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export default class DocumentInformationModal extends Component<Sig> {
|
|
39
|
+
intl: IntlService;
|
|
40
|
+
stagedTypeInstance?: BesluitTypeInstance;
|
|
41
|
+
stagedTopics?: BesluitTopic[];
|
|
42
|
+
stagedTargetGroups?: BesluitTargetGroup[];
|
|
43
|
+
get modalTitle(): string;
|
|
44
|
+
get controller(): SayController;
|
|
45
|
+
get hasBesluit(): boolean;
|
|
46
|
+
get requireBesluitType(): boolean;
|
|
47
|
+
get currentTypeInstance(): BesluitTypeInstance | undefined;
|
|
48
|
+
get selectedTypeInstance(): BesluitTypeInstance | undefined;
|
|
49
|
+
get hasStagedTypeInstance(): boolean;
|
|
50
|
+
get currentTopics(): BesluitTopic[] | undefined;
|
|
51
|
+
get selectedTopics(): BesluitTopic[] | undefined;
|
|
52
|
+
get hasStagedTopics(): boolean;
|
|
53
|
+
get currentTargetGroups(): BesluitTargetGroup[] | undefined;
|
|
54
|
+
get selectedTargetGroups(): BesluitTargetGroup[] | undefined;
|
|
55
|
+
get hasStagedTargetGroups(): boolean;
|
|
56
|
+
get saveDisabled(): boolean;
|
|
57
|
+
get typesPromise(): Promise<import("@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-type-plugin/utils/fetchBesluitTypes").BesluitType[]>;
|
|
58
|
+
get types(): import("reactiveweb/get-promise-state").State<import("@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-type-plugin/utils/fetchBesluitTypes").BesluitType[]>;
|
|
59
|
+
get topicsPromise(): Promise<BesluitTopic[]>;
|
|
60
|
+
get topics(): import("reactiveweb/get-promise-state").State<BesluitTopic[]>;
|
|
61
|
+
get targetGroupsPromise(): Promise<BesluitTargetGroup[]>;
|
|
62
|
+
get targetGroups(): import("reactiveweb/get-promise-state").State<BesluitTargetGroup[]>;
|
|
63
|
+
stageTypeInstance: (type: BesluitTypeInstance) => void;
|
|
64
|
+
stageBesluitTopics: (selected: BesluitTopic[]) => void;
|
|
65
|
+
stageTargetGroups: (selected: BesluitTargetGroup[]) => void;
|
|
66
|
+
updateDocumentBesluitType(): void;
|
|
67
|
+
updateDocumentTopic(): void;
|
|
68
|
+
updateDocumentTargetGroups(): void;
|
|
69
|
+
saveChanges: import("ember-concurrency").TaskForAsyncTaskFunction<unknown, () => Promise<void>>;
|
|
70
|
+
cancel: () => void;
|
|
71
|
+
}
|
|
72
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const BESLUIT_TARGET_GROUP_PREDICATE: import("../../utils/namespace").Resource<"https://schema.org/audience", "schema:audience">;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { BesluitTargetGroup } from './types';
|
|
2
|
+
export type BesluitTargetGroupQueryConfig = {
|
|
3
|
+
endpoint: string;
|
|
4
|
+
abortSignal?: AbortSignal;
|
|
5
|
+
};
|
|
6
|
+
export declare function fetchBesluitTargetGroups({ config, }: {
|
|
7
|
+
config: BesluitTargetGroupQueryConfig;
|
|
8
|
+
}): Promise<BesluitTargetGroup[]>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type EditorState } from '@lblod/ember-rdfa-editor';
|
|
2
|
+
import { type TransactionCombinatorResult } from '@lblod/ember-rdfa-editor/utils/transaction-utils';
|
|
3
|
+
import type { BesluitTargetGroup } from './types';
|
|
4
|
+
export declare function setBesluitTargetGroups(initialState: EditorState, targetGroups: BesluitTargetGroup[]): TransactionCombinatorResult<boolean>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function toBool(arg: unknown): boolean;
|
|
@@ -29,3 +29,4 @@ export declare const BESTUURSPERIODES: {
|
|
|
29
29
|
export type BestuursperiodeLabel = keyof typeof BESTUURSPERIODES;
|
|
30
30
|
export type BestuursperiodeURI = (typeof BESTUURSPERIODES)[BestuursperiodeLabel];
|
|
31
31
|
export declare const ONDERDEEL: <Suffix extends string = string>(s: Suffix) => import("@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace").Resource<`https://wegenenverkeer.data.vlaanderen.be/ns/onderdeel#${Suffix}`, `onderdeel:${Suffix}`>;
|
|
32
|
+
export declare const SCHEMA: <Suffix extends string = string>(s: Suffix) => import("@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace").Resource<`https://schema.org/${Suffix}`, `schema:${Suffix}`>;
|
package/package.json
CHANGED
package/translations/en-US.yaml
CHANGED
|
@@ -124,6 +124,16 @@ besluit-topic-plugin:
|
|
|
124
124
|
error-rest-body: '. For more specific details about this problem, inspect the browser console.'
|
|
125
125
|
close-modal: OK
|
|
126
126
|
|
|
127
|
+
besluit-target-group-plugin:
|
|
128
|
+
label: Target group
|
|
129
|
+
error-title: 'Error'
|
|
130
|
+
error-short: 'Error fetching decision target groups'
|
|
131
|
+
|
|
132
|
+
document-information-plugin:
|
|
133
|
+
modal-title: 'Edit document information'
|
|
134
|
+
save: 'Save'
|
|
135
|
+
cancel: 'Cancel'
|
|
136
|
+
|
|
127
137
|
besluit-plugin:
|
|
128
138
|
missing-title-warning: This decision is missing a title.
|
|
129
139
|
missing-motivation-warning: This decision is missing a motivation block, a decision without this block will be harder to parse by our system.
|
package/translations/nl-BE.yaml
CHANGED
|
@@ -124,6 +124,16 @@ besluit-topic-plugin:
|
|
|
124
124
|
error-rest-body: '. Voor meer specifieke details, controleer de console in de browser.'
|
|
125
125
|
close-modal: OK
|
|
126
126
|
|
|
127
|
+
besluit-target-group-plugin:
|
|
128
|
+
label: Doelgroep
|
|
129
|
+
error-title: 'Error'
|
|
130
|
+
error-short: 'Fout bij ophalen doelgroepen'
|
|
131
|
+
|
|
132
|
+
document-information-plugin:
|
|
133
|
+
modal-title: 'Documentinformatie bewerken'
|
|
134
|
+
save: 'Opslaan'
|
|
135
|
+
cancel: 'Annuleren'
|
|
136
|
+
|
|
127
137
|
besluit-plugin:
|
|
128
138
|
missing-title-warning: Dit besluit heeft geen titel.
|
|
129
139
|
missing-motivation-warning: Dit besluit heeft geen motivatieblok, een besluit zonder dit blok zal moeilijker te ontleden zijn door ons systeem.
|