@lblod/ember-rdfa-editor-lblod-plugins 39.1.2 → 39.2.0-dev.38cae02a7991968c27ded89188c6d34a0d293dc7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/.changeset/chatty-teachers-kick.md +5 -0
  2. package/.changeset/honest-cows-lie.md +5 -0
  3. package/CHANGELOG.md +8 -0
  4. package/addon/components/besluit-topic-plugin/besluit-topic-select.hbs +1 -0
  5. package/addon/components/besluit-topic-plugin/besluit-topic-select.ts +2 -0
  6. package/addon/components/besluit-type-plugin/besluit-type-form.gts +4 -0
  7. package/addon/components/besluit-type-plugin/besluit-type-select.gts +2 -0
  8. package/addon/components/common/tags/collapsible-tag-list.gts +149 -0
  9. package/addon/components/common/tags/tag-selector.gts +117 -0
  10. package/addon/components/document-information-plugin/_private/besluit-target-group-field.gts +92 -0
  11. package/addon/components/document-information-plugin/_private/besluit-topic-field.gts +45 -0
  12. package/addon/components/document-information-plugin/_private/besluit-type-field.gts +43 -0
  13. package/addon/components/document-information-plugin/document-information-modal.gts +373 -0
  14. package/addon/components/snippet-plugin/snippet-insert-placeholder.gts +10 -8
  15. package/addon/components/snippet-plugin/snippet-list/snippet-list-modal.gts +278 -0
  16. package/addon/components/snippet-plugin/snippet-list/snippet-list-view.gts +130 -0
  17. package/addon/components/snippet-plugin/snippet-list-select.gts +10 -9
  18. package/addon/helpers/in-array.ts +3 -9
  19. package/addon/plugins/besluit-target-group-plugin/_private/constants.ts +3 -0
  20. package/addon/plugins/besluit-target-group-plugin/_private/extract-besluit-target-group-uris.ts +27 -0
  21. package/addon/plugins/besluit-target-group-plugin/_private/queries.ts +67 -0
  22. package/addon/plugins/besluit-target-group-plugin/_private/set-besluit-target-groups.ts +52 -0
  23. package/addon/plugins/besluit-target-group-plugin/_private/types.ts +9 -0
  24. package/addon/plugins/besluit-topic-plugin/utils/extract-besluit-topic-uris.ts +45 -0
  25. package/addon/plugins/common/tags/queries.ts +64 -0
  26. package/addon/plugins/common/tags/types.ts +12 -0
  27. package/addon/plugins/snippet-plugin/index.ts +11 -1
  28. package/addon/plugins/snippet-plugin/utils/fetch-data.ts +48 -17
  29. package/addon/utils/_private/boolean.ts +3 -0
  30. package/addon/utils/constants.ts +2 -0
  31. package/app/components/common/tags/collapsible-tag-list.js +1 -0
  32. package/app/components/common/tags/tag-selector.js +1 -0
  33. package/app/components/document-information-plugin/document-information-modal.js +1 -0
  34. package/app/styles/common/tags.scss +61 -0
  35. package/app/styles/snippet-plugin.scss +44 -1
  36. package/declarations/addon/components/besluit-topic-plugin/besluit-topic-select.d.ts +1 -0
  37. package/declarations/addon/components/besluit-type-plugin/besluit-type-form.d.ts +1 -0
  38. package/declarations/addon/components/besluit-type-plugin/besluit-type-select.d.ts +1 -0
  39. package/declarations/addon/components/common/tags/collapsible-tag-list.d.ts +26 -0
  40. package/declarations/addon/components/common/tags/tag-selector.d.ts +31 -0
  41. package/declarations/addon/components/document-information-plugin/_private/besluit-target-group-field.d.ts +15 -0
  42. package/declarations/addon/components/document-information-plugin/_private/besluit-topic-field.d.ts +15 -0
  43. package/declarations/addon/components/document-information-plugin/_private/besluit-type-field.d.ts +17 -0
  44. package/declarations/addon/components/document-information-plugin/document-information-modal.d.ts +68 -0
  45. package/declarations/addon/components/snippet-plugin/snippet-list/snippet-list-modal.d.ts +6 -0
  46. package/declarations/addon/components/snippet-plugin/snippet-list/snippet-list-view.d.ts +12 -8
  47. package/declarations/addon/helpers/in-array.d.ts +1 -4
  48. package/declarations/addon/plugins/besluit-target-group-plugin/_private/constants.d.ts +1 -0
  49. package/declarations/addon/plugins/besluit-target-group-plugin/_private/extract-besluit-target-group-uris.d.ts +2 -0
  50. package/declarations/addon/plugins/besluit-target-group-plugin/_private/queries.d.ts +8 -0
  51. package/declarations/addon/plugins/besluit-target-group-plugin/_private/set-besluit-target-groups.d.ts +4 -0
  52. package/declarations/addon/plugins/besluit-target-group-plugin/_private/types.d.ts +8 -0
  53. package/declarations/addon/plugins/besluit-topic-plugin/utils/extract-besluit-topic-uris.d.ts +2 -0
  54. package/declarations/addon/plugins/common/tags/queries.d.ts +12 -0
  55. package/declarations/addon/plugins/common/tags/types.d.ts +9 -0
  56. package/declarations/addon/plugins/snippet-plugin/index.d.ts +4 -1
  57. package/declarations/addon/plugins/snippet-plugin/utils/fetch-data.d.ts +7 -1
  58. package/declarations/addon/utils/_private/boolean.d.ts +1 -0
  59. package/declarations/addon/utils/constants.d.ts +1 -0
  60. package/package.json +1 -1
  61. package/translations/en-US.yaml +26 -4
  62. package/translations/nl-BE.yaml +26 -4
  63. package/addon/components/snippet-plugin/snippet-list/snippet-list-modal.hbs +0 -63
  64. package/addon/components/snippet-plugin/snippet-list/snippet-list-modal.ts +0 -111
  65. package/addon/components/snippet-plugin/snippet-list/snippet-list-view.hbs +0 -66
  66. package/addon/components/snippet-plugin/snippet-list/snippet-list-view.ts +0 -57
@@ -0,0 +1,5 @@
1
+ ---
2
+ '@lblod/ember-rdfa-editor-lblod-plugins': minor
3
+ ---
4
+
5
+ Introduce customizable `document-information-modal` component which contains decision-type and decision-topic selector. This component can be customized to contain additional form fields.
@@ -0,0 +1,5 @@
1
+ ---
2
+ '@lblod/ember-rdfa-editor-lblod-plugins': minor
3
+ ---
4
+
5
+ Add besluit-target-group plugin which can be used through the `document-information` plugin
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @lblod/ember-rdfa-editor-lblod-plugins
2
2
 
3
+ ## 39.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#686](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/686) [`25cb100`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/25cb10062fc4dc92e211bd4921171c73222152ee) Thanks [@elpoelma](https://github.com/elpoelma)! - snippet-list plugin: introduce tag filtering
8
+
9
+ - [#686](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/686) [`25cb100`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/25cb10062fc4dc92e211bd4921171c73222152ee) Thanks [@elpoelma](https://github.com/elpoelma)! - snippet-list plugin: move filtering options to separate sidebar
10
+
3
11
  ## 39.1.2
4
12
 
5
13
  ### Patch Changes
@@ -9,6 +9,7 @@
9
9
  @selected={{@selected}}
10
10
  @onChange={{@onchange}}
11
11
  @renderInPlace={{this.renderInPlace}}
12
+ @disabled={{@disabled}}
12
13
  as |besluitTopic|
13
14
  >
14
15
  {{besluitTopic.label}}
@@ -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,149 @@
1
+ import Component from '@glimmer/component';
2
+ import AuPill from '@appuniversum/ember-appuniversum/components/au-pill';
3
+ import { modifier } from 'ember-modifier';
4
+ import { tracked } from '@glimmer/tracking';
5
+ import { on } from '@ember/modifier';
6
+ import t from 'ember-intl/helpers/t';
7
+ import { Tag } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/common/tags/types';
8
+
9
+ type Args = {
10
+ tags: Tag[];
11
+ };
12
+
13
+ export default class CollapsibleTagList extends Component<Args> {
14
+ @tracked visibleCount = this.tags.length;
15
+ @tracked isExpanded = false;
16
+
17
+ containerElement: HTMLElement | null = null;
18
+ resizeObserver: ResizeObserver | null = null;
19
+
20
+ get tags() {
21
+ return this.args.tags;
22
+ }
23
+
24
+ get visibleTags() {
25
+ return this.isExpanded ? this.tags : this.tags.slice(0, this.visibleCount);
26
+ }
27
+
28
+ get hiddenCount() {
29
+ return this.tags.length - this.visibleCount;
30
+ }
31
+
32
+ get showMorePill() {
33
+ return !this.isExpanded && this.hiddenCount > 0;
34
+ }
35
+
36
+ containerModifier = modifier((element: HTMLElement) => {
37
+ this.containerElement = element;
38
+ this.resizeObserver = new ResizeObserver(() => {
39
+ if (!this.isExpanded) this.recalculate();
40
+ });
41
+ this.resizeObserver.observe(element);
42
+ this.recalculate();
43
+ return () => {
44
+ this.resizeObserver?.disconnect();
45
+ };
46
+ });
47
+
48
+ expand = () => {
49
+ this.isExpanded = true;
50
+ };
51
+
52
+ collapse = () => {
53
+ this.isExpanded = false;
54
+ this.recalculate();
55
+ };
56
+
57
+ recalculate = () => {
58
+ const container = this.containerElement;
59
+ if (!container) return;
60
+
61
+ const measureRow = container.querySelector('[data-measure-row]');
62
+ if (!measureRow) return;
63
+
64
+ const availableWidth = container.clientWidth;
65
+ const tagEls = Array.from(
66
+ measureRow.querySelectorAll('[data-measure-tag]'),
67
+ );
68
+ const moreEl = measureRow.querySelector('[data-measure-more]');
69
+ if (!moreEl) return;
70
+
71
+ const gap = Number.parseFloat(getComputedStyle(measureRow).columnGap) || 0;
72
+
73
+ let total = 0;
74
+ let fitCount = tagEls.length;
75
+
76
+ for (let i = 0; i < tagEls.length; i++) {
77
+ const tagWidth = (tagEls[i] as HTMLElement).getBoundingClientRect().width;
78
+ const nextTotal = total + (i > 0 ? gap : 0) + tagWidth;
79
+
80
+ const remainingAfterThis = tagEls.length - (i + 1);
81
+ const moreWidth =
82
+ remainingAfterThis > 0 ? gap + moreEl.getBoundingClientRect().width : 0;
83
+
84
+ if (nextTotal + moreWidth > availableWidth) {
85
+ fitCount = i;
86
+ break;
87
+ }
88
+
89
+ total = nextTotal;
90
+ }
91
+
92
+ this.visibleCount = fitCount;
93
+ };
94
+
95
+ <template>
96
+ <div
97
+ class='say-collapsible-tag-list
98
+ {{if this.isExpanded "say-collapsible-tag-list--expanded"}}'
99
+ {{this.containerModifier}}
100
+ >
101
+ {{! hidden row used only to measure natural widths }}
102
+ <div
103
+ class='say-collapsible-tag-list__measure'
104
+ data-measure-row
105
+ aria-hidden='true'
106
+ >
107
+ {{#each this.tags as |tag|}}
108
+ <span data-measure-tag>
109
+ <AuPill class='say-collapsible-tag-list__pill'>
110
+ {{tag.value}}
111
+ </AuPill>
112
+ </span>
113
+ {{/each}}
114
+ <span data-measure-more>
115
+ <AuPill class='say-collapsible-tag-list__pill'>
116
+ +{{this.tags.length}}
117
+ </AuPill>
118
+ </span>
119
+ </div>
120
+ <div class='say-collapsible-tag-list__visible'>
121
+ {{#each this.visibleTags as |tag|}}
122
+ <AuPill class='say-collapsible-tag-list__pill' title={{tag.value}}>
123
+ {{tag.value}}
124
+ </AuPill>
125
+ {{/each}}
126
+
127
+ {{#if this.showMorePill}}
128
+ <AuPill
129
+ type='button'
130
+ class='say-collapsible-tag-list__pill say-collapsible-tag-list__more'
131
+ {{on 'click' this.expand}}
132
+ >
133
+ +{{this.hiddenCount}}
134
+ </AuPill>
135
+ {{/if}}
136
+
137
+ {{#if this.isExpanded}}
138
+ <button
139
+ type='button'
140
+ class='au-u-muted au-u-italic say-collapsible-tag-list__less'
141
+ {{on 'click' this.collapse}}
142
+ >
143
+ {{t 'common.tags.collapsible-tag-list.show-less'}}
144
+ </button>
145
+ {{/if}}
146
+ </div>
147
+ </div>
148
+ </template>
149
+ }
@@ -0,0 +1,117 @@
1
+ import Component from '@glimmer/component';
2
+ import PowerSelectMultiple from 'ember-power-select/components/power-select-multiple';
3
+ import t from 'ember-intl/helpers/t';
4
+ import { Tag } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/common/tags/types';
5
+ import { service } from '@ember/service';
6
+ import IntlService from 'ember-intl/services/intl';
7
+ import { tracked } from '@glimmer/tracking';
8
+
9
+ type Signature<T extends Tag> = {
10
+ Args: {
11
+ tags: T[];
12
+ selectedTags?: T[];
13
+ onChange: (tags: T[]) => void;
14
+ } & (
15
+ | {
16
+ allowTagCreation?: false;
17
+ tagConstructor?: never;
18
+ }
19
+ | {
20
+ allowTagCreation: true;
21
+ tagConstructor: (newTag: NewTag) => T;
22
+ }
23
+ );
24
+ Element: HTMLElement;
25
+ };
26
+ export type NewTag = {
27
+ value: string;
28
+ // this works better than a boolean "isNew" for runtime type-checking
29
+ optionType: 'new';
30
+ searchTerm?: string;
31
+ };
32
+
33
+ type SelectorOption<T extends Tag> = T | NewTag;
34
+
35
+ export default class TagSelector<T extends Tag> extends Component<
36
+ Signature<T>
37
+ > {
38
+ @service declare intl: IntlService;
39
+
40
+ @tracked searchTerm: string | null = null;
41
+
42
+ changeSelection = (selectedTags: SelectorOption<T>[]) => {
43
+ // split up the selected options into existing and new tags
44
+ // this is a bit verbose but it's the most type-safe way to do this
45
+ const existingTags: T[] = [];
46
+ const newTags: NewTag[] = [];
47
+ for (const tagOrNew of selectedTags) {
48
+ if ('optionType' in tagOrNew) {
49
+ newTags.push(tagOrNew);
50
+ } else {
51
+ existingTags.push(tagOrNew);
52
+ }
53
+ }
54
+
55
+ this.searchTerm = null;
56
+ // power-select doesn't allow you to make more than 1 new option at at time
57
+ // but just in case
58
+ if (newTags.length > 1) {
59
+ throw new Error(
60
+ 'unexpected state, only one new tag should be created at a time',
61
+ );
62
+ }
63
+ const addOption = newTags[0];
64
+ let newSelectedTags;
65
+ if (addOption && this.args.allowTagCreation) {
66
+ const newOption = this.args.tagConstructor(addOption);
67
+ newSelectedTags = [...existingTags, newOption];
68
+ } else {
69
+ newSelectedTags = existingTags;
70
+ }
71
+
72
+ this.args.onChange(newSelectedTags);
73
+ };
74
+
75
+ get options() {
76
+ const options: SelectorOption<T>[] = this.args.tags.slice();
77
+
78
+ if (
79
+ this.args.allowTagCreation &&
80
+ this.searchTerm &&
81
+ !options.find((tag) => tag.value === this.searchTerm)
82
+ ) {
83
+ options.push({
84
+ optionType: 'new',
85
+ value: this.intl.t('common.tags.tag-selector.create-new-tag', {
86
+ tagName: this.searchTerm,
87
+ }),
88
+ searchTerm: this.searchTerm,
89
+ });
90
+ }
91
+ return options;
92
+ }
93
+
94
+ setSearchTerm = (term: string) => {
95
+ this.searchTerm = term;
96
+ };
97
+
98
+ <template>
99
+ <PowerSelectMultiple
100
+ @onChange={{this.changeSelection}}
101
+ @onInput={{this.setSearchTerm}}
102
+ @options={{this.options}}
103
+ @searchEnabled={{true}}
104
+ @selected={{@selectedTags}}
105
+ @searchField='value'
106
+ @placeholder={{t 'common.tags.tag-selector.placeholder'}}
107
+ @noMatchesMessage={{t 'common.tags.tag-selector.no-results-message'}}
108
+ class='say-tag-selector'
109
+ ...attributes
110
+ as |tag|
111
+ >
112
+ <span class='say-tag-selector__item' title={{tag.value}}>
113
+ {{tag.value}}
114
+ </span>
115
+ </PowerSelectMultiple>
116
+ </template>
117
+ }
@@ -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/_private/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
+ }
@@ -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;