@lblod/ember-rdfa-editor-lblod-plugins 11.1.0 → 11.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 CHANGED
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [11.2.0] - 2023-09-04
11
+ ### Added
12
+ - ember-modifier is now explicitely a peerDependency
13
+ - GN4470: ability to specifly single/multi-select per codelist instance
10
14
  ## [11.1.0] - 2023-08-29
11
15
 
12
16
  ### Fixed
@@ -691,7 +695,7 @@ add onclick handler to pencil icon in variable plugin
691
695
 
692
696
  # Changelog
693
697
 
694
- [unreleased]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v11.1.0...HEAD
698
+ [unreleased]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v11.2.0...HEAD
695
699
  [8.0.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v8.0.0...v8.0.1
696
700
  [8.0.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v7.1.0...v8.0.0
697
701
  [7.1.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v7.0.0...v7.1.0
@@ -707,6 +711,7 @@ add onclick handler to pencil icon in variable plugin
707
711
  [3.0.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v2.1.2...v3.0.0
708
712
  [2.1.2]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v2.1.1...v2.1.2
709
713
  [2.1.1]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v2.1.0...v2.1.1
714
+ [11.2.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v11.1.0...v11.2.0
710
715
  [11.1.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v11.0.0...v11.1.0
711
716
  [11.0.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v10.0.0...v11.0.0
712
717
  [10.0.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v9.1.1...v10.0.0
@@ -72,7 +72,12 @@ export default class CodelistEditComponent extends Component<Args> {
72
72
  });
73
73
 
74
74
  get multiSelect() {
75
- return this.codelistOptions.value?.type === MULTI_SELECT_CODELIST_TYPE;
75
+ const localStyle = this.selectedCodelist.value?.node.attrs
76
+ .selectionStyle as string;
77
+ if (localStyle) {
78
+ return localStyle === 'multi';
79
+ } else
80
+ return this.codelistOptions.value?.type === MULTI_SELECT_CODELIST_TYPE;
76
81
  }
77
82
 
78
83
  @action
@@ -1,12 +1,22 @@
1
1
  <PowerSelect
2
2
  @allowClear={{false}}
3
3
  @searchEnabled={{false}}
4
- @options={{this.subtypes.value}}
5
- @selected={{this.selectedSubtype}}
6
- @onChange={{this.updateSubtype}}
7
- as |subtype|
4
+ @options={{this.codelistData.value}}
5
+ @selected={{this.selectedCodelist}}
6
+ @onChange={{this.selectCodelist}}
7
+ as |codelist|
8
8
  >
9
- {{subtype.label}}
9
+ {{codelist.label}}
10
+ </PowerSelect>
11
+ <PowerSelect
12
+ @allowClear={{false}}
13
+ @searchEnabled={{false}}
14
+ @options={{this.selectionStyles}}
15
+ @selected={{this.selectedStyle}}
16
+ @onChange={{this.selectStyle}}
17
+ as |style|
18
+ >
19
+ {{style.label}}
10
20
  </PowerSelect>
11
21
  <AuFormRow>
12
22
  <VariablePlugin::Utils::LabelInput
@@ -16,7 +26,7 @@
16
26
  </AuFormRow>
17
27
  <AuButton
18
28
  {{on 'click' this.insert}}
19
- @disabled={{not this.selectedSubtype}}
29
+ @disabled={{not this.selectedCodelist}}
20
30
  >
21
31
  {{t 'variable-plugin.button'}}
22
32
  </AuButton>
@@ -15,16 +15,22 @@ export type CodelistInsertOptions = {
15
15
  publisher?: string;
16
16
  endpoint: string;
17
17
  };
18
+
18
19
  type Args = {
19
20
  controller: SayController;
20
21
  options: CodelistInsertOptions;
21
22
  };
22
23
 
23
- export default class CodelistInsertComponent extends Component<Args> {
24
- @tracked selectedSubtype?: CodeList;
25
- @tracked label?: string;
24
+ interface SelectStyle {
25
+ label: string;
26
+ value: string;
27
+ }
26
28
 
29
+ export default class CodelistInsertComponent extends Component<Args> {
27
30
  @service declare intl: IntlService;
31
+ @tracked selectedCodelist?: CodeList;
32
+ @tracked label?: string;
33
+ @tracked selectedStyleValue = 'single';
28
34
 
29
35
  get controller() {
30
36
  return this.args.controller;
@@ -42,9 +48,28 @@ export default class CodelistInsertComponent extends Component<Args> {
42
48
  return this.args.options.endpoint;
43
49
  }
44
50
 
45
- subtypes = trackedFunction(this, async () => {
51
+ get selectionStyles() {
52
+ const singleSelect = {
53
+ label: this.intl.t('variable.codelist.single-select'),
54
+ value: 'single',
55
+ };
56
+ const multiSelect = {
57
+ label: this.intl.t('variable.codelist.multi-select'),
58
+ value: 'multi',
59
+ };
60
+ return [singleSelect, multiSelect];
61
+ }
62
+
63
+ get selectedStyle() {
64
+ return this.selectionStyles.find(
65
+ (style) => style.value === this.selectedStyleValue,
66
+ );
67
+ }
68
+
69
+ codelistData = trackedFunction(this, async () => {
46
70
  return fetchCodeListsByPublisher(this.endpoint, this.publisher);
47
71
  });
72
+
48
73
  @action
49
74
  updateLabel(event: InputEvent) {
50
75
  this.label = (event.target as HTMLInputElement).value;
@@ -58,12 +83,13 @@ export default class CodelistInsertComponent extends Component<Args> {
58
83
  {
59
84
  mappingResource,
60
85
  variableInstance,
61
- codelistResource: this.selectedSubtype?.uri,
62
- label: this.label ?? this.selectedSubtype?.label,
86
+ codelistResource: this.selectedCodelist?.uri,
87
+ label: this.label ?? this.selectedCodelist?.label,
63
88
  source: this.endpoint,
89
+ selectionStyle: this.selectedStyleValue,
64
90
  },
65
91
  this.schema.node('placeholder', {
66
- placeholderText: this.selectedSubtype?.label,
92
+ placeholderText: this.selectedCodelist?.label,
67
93
  }),
68
94
  );
69
95
 
@@ -78,7 +104,12 @@ export default class CodelistInsertComponent extends Component<Args> {
78
104
  }
79
105
 
80
106
  @action
81
- updateSubtype(subtype: CodeList) {
82
- this.selectedSubtype = subtype;
107
+ selectCodelist(codelist: CodeList) {
108
+ this.selectedCodelist = codelist;
109
+ }
110
+
111
+ @action
112
+ selectStyle(style: SelectStyle) {
113
+ this.selectedStyleValue = style.value;
83
114
  }
84
115
  }
@@ -29,3 +29,7 @@ export function parseVariableSource(variableNode: HTMLElement) {
29
29
  .find((el) => hasRDFaAttribute(el, 'property', DCT('source')))
30
30
  ?.getAttribute('resource');
31
31
  }
32
+
33
+ export function parseSelectionStyle(element: HTMLElement): string | null {
34
+ return element.dataset.selectionStyle ?? null;
35
+ }
@@ -10,6 +10,7 @@ import { DOMOutputSpec, PNode } from '@lblod/ember-rdfa-editor';
10
10
  import {
11
11
  isVariable,
12
12
  parseLabel,
13
+ parseSelectionStyle,
13
14
  parseVariableInstance,
14
15
  parseVariableSource,
15
16
  parseVariableType,
@@ -43,6 +44,7 @@ const parseDOM = [
43
44
 
44
45
  const source = parseVariableSource(node);
45
46
  const label = parseLabel(node);
47
+ const selectionStyle = parseSelectionStyle(node);
46
48
  const codelistSpan = [...node.children].find((el) =>
47
49
  hasRDFaAttribute(el, 'property', EXT('codelist')),
48
50
  );
@@ -53,6 +55,7 @@ const parseDOM = [
53
55
  variableInstance:
54
56
  variableInstance ?? `http://data.lblod.info/variables/${uuidv4()}`,
55
57
  mappingResource,
58
+ selectionStyle,
56
59
  codelistResource,
57
60
  source,
58
61
  label,
@@ -66,8 +69,14 @@ const parseDOM = [
66
69
  ];
67
70
 
68
71
  const toDOM = (node: PNode): DOMOutputSpec => {
69
- const { mappingResource, codelistResource, variableInstance, source, label } =
70
- node.attrs;
72
+ const {
73
+ mappingResource,
74
+ codelistResource,
75
+ variableInstance,
76
+ source,
77
+ label,
78
+ selectionStyle,
79
+ } = node.attrs;
71
80
 
72
81
  const codelistResourceSpan = codelistResource
73
82
  ? span({
@@ -79,6 +88,7 @@ const toDOM = (node: PNode): DOMOutputSpec => {
79
88
  mappingResource,
80
89
  {
81
90
  'data-label': label as string,
91
+ 'data-selection-style': selectionStyle as string,
82
92
  },
83
93
  instanceSpan(variableInstance),
84
94
  typeSpan('codelist'),
@@ -111,6 +121,9 @@ const emberNodeConfig: EmberNodeConfig = {
111
121
  label: {
112
122
  default: 'codelijst',
113
123
  },
124
+ selectionStyle: {
125
+ default: null,
126
+ },
114
127
  },
115
128
  toDOM,
116
129
  parseDOM,
@@ -10,17 +10,31 @@ type Args = {
10
10
  controller: SayController;
11
11
  options: CodelistInsertOptions;
12
12
  };
13
+ interface SelectStyle {
14
+ label: string;
15
+ value: string;
16
+ }
13
17
  export default class CodelistInsertComponent extends Component<Args> {
14
- selectedSubtype?: CodeList;
15
- label?: string;
16
18
  intl: IntlService;
19
+ selectedCodelist?: CodeList;
20
+ label?: string;
21
+ selectedStyleValue: string;
17
22
  get controller(): SayController;
18
23
  get schema(): import("prosemirror-model").Schema<any, any>;
19
24
  get publisher(): string | undefined;
20
25
  get endpoint(): string;
21
- subtypes: import("ember-resources/util/function").State<Promise<CodeList[]>>;
26
+ get selectionStyles(): {
27
+ label: string;
28
+ value: string;
29
+ }[];
30
+ get selectedStyle(): {
31
+ label: string;
32
+ value: string;
33
+ } | undefined;
34
+ codelistData: import("ember-resources/util/function").State<Promise<CodeList[]>>;
22
35
  updateLabel(event: InputEvent): void;
23
36
  insert(): void;
24
- updateSubtype(subtype: CodeList): void;
37
+ selectCodelist(codelist: CodeList): void;
38
+ selectStyle(style: SelectStyle): void;
25
39
  }
26
40
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lblod/ember-rdfa-editor-lblod-plugins",
3
- "version": "11.1.0",
3
+ "version": "11.2.0",
4
4
  "description": "Ember addon providing lblod specific plugins for the ember-rdfa-editor",
5
5
  "keywords": [
6
6
  "ember-addon",
@@ -149,7 +149,8 @@
149
149
  "peerDependencies": {
150
150
  "@appuniversum/ember-appuniversum": "^2.4.2",
151
151
  "@lblod/ember-rdfa-editor": "^5.2.0",
152
- "ember-concurrency": "^2.3.7"
152
+ "ember-concurrency": "^2.3.7",
153
+ "ember-modifier": "^3.2.7"
153
154
  },
154
155
  "overrides": {
155
156
  "ember-intl": {
@@ -3,3 +3,4 @@ export declare function parseVariableType(variableNode: HTMLElement): string | n
3
3
  export declare function parseVariableInstance(variableNode: HTMLElement): string | null | undefined;
4
4
  export declare function parseLabel(variableNode: HTMLElement): string | null;
5
5
  export declare function parseVariableSource(variableNode: HTMLElement): string | null | undefined;
6
+ export declare function parseSelectionStyle(element: HTMLElement): string | null;
@@ -195,6 +195,9 @@ variable:
195
195
  error-number-below: The number should be smaller than or equal to {maxValue}
196
196
  error-min-bigger-than-max: The minimum should be smaller than the maximum
197
197
  written-number-label: Show as words
198
+ codelist:
199
+ single-select: Single selection
200
+ multi-select: Multiple selection
198
201
  variable-plugin:
199
202
  insert-variable: Insert variable
200
203
  button: Insert
@@ -356,4 +359,4 @@ editor-plugins:
356
359
  contact: In case of persisting issues, contact <a href="mailto:{email}">{email}</a>.
357
360
  nodeview:
358
361
  placeholder: Insert address
359
-
362
+
@@ -206,6 +206,9 @@ variable:
206
206
  error-number-below: Het getal moet kleiner dan of gelijk zijn aan {maxValue}
207
207
  written-number-label: Getal voluit schrijven
208
208
  error-min-bigger-than-max: Het minimum moet kleiner zijn dan het maximum
209
+ codelist:
210
+ single-select: Enkelvoudige selectie
211
+ multi-select: Meervoudige selectie
209
212
  variable-plugin:
210
213
  insert-variable: Voeg variabele in
211
214
  button: Voeg in
@@ -359,4 +362,3 @@ editor-plugins:
359
362
  contact: Bij blijvende problemen, contacteer <a href="mailto:{email}">{email}</a>.
360
363
  nodeview:
361
364
  placeholder: Voeg adres in
362
-