@lblod/ember-rdfa-editor-lblod-plugins 27.0.1 → 27.0.2-dev.751f44226897d2ee405ea11d48bec0779acfa8ed

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.
@@ -0,0 +1,14 @@
1
+ ---
2
+ '@lblod/ember-rdfa-editor-lblod-plugins': minor
3
+ ---
4
+
5
+ Location plugin: add support for configuring the location types to show.
6
+ The location types may be configured through the `@locationTypes` argument of the `location-plugin/insert` component.
7
+
8
+ The `@locationTypes` argument expects an array of `LocationType` values.
9
+ Supported `LocationType` values are:
10
+ - 'address'
11
+ - 'place'
12
+ - 'area'
13
+
14
+ By default the value of `@locationTypes` is `['address', 'place', 'area']`
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @lblod/ember-rdfa-editor-lblod-plugins
2
2
 
3
+ ## 27.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`3ca9431`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/3ca9431392d2927d1e5ee868745cda1cf7f78a4d) Thanks [@piemonkey](https://github.com/piemonkey)! - Correct default header format for decision articles in existing documents
8
+
3
9
  ## 27.0.1
4
10
 
5
11
  ### Patch Changes
@@ -35,7 +35,7 @@ import {
35
35
  } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/location-plugin/utils/address-helpers';
36
36
  import { type Point } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/location-plugin/utils/geo-helpers';
37
37
  import { type NodeContentsUtils } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/location-plugin/node-contents';
38
- import { type LocationType } from './map';
38
+ import { SUPPORTED_LOCATION_TYPES, type LocationType } from './map';
39
39
  import { type SafeString } from '@ember/template';
40
40
 
41
41
  interface Message {
@@ -47,6 +47,7 @@ interface Message {
47
47
 
48
48
  type Signature = {
49
49
  Args: {
50
+ locationTypes?: readonly LocationType[];
50
51
  locationType: LocationType;
51
52
  setLocationType: (type: LocationType) => void;
52
53
  defaultMunicipality?: string;
@@ -107,6 +108,31 @@ export default class LocationPluginEditComponent extends Component<Signature> {
107
108
  })
108
109
  newTruncatedValue?: boolean;
109
110
 
111
+ get locationTypes() {
112
+ const unsupportedLocationType = this.args.locationTypes?.find(
113
+ (locationType) => !SUPPORTED_LOCATION_TYPES.includes(locationType),
114
+ );
115
+ if (unsupportedLocationType) {
116
+ throw new Error(
117
+ `${unsupportedLocationType} is not supported. Supported location types are ${SUPPORTED_LOCATION_TYPES.join(
118
+ ', ',
119
+ )}`,
120
+ );
121
+ }
122
+ return this.args.locationTypes ?? SUPPORTED_LOCATION_TYPES;
123
+ }
124
+
125
+ locationTypeLabel = (locationType: LocationType) => {
126
+ switch (locationType) {
127
+ case 'address':
128
+ return this.intl.t('location-plugin.types.address');
129
+ case 'place':
130
+ return this.intl.t('location-plugin.types.place');
131
+ case 'area':
132
+ return this.intl.t('location-plugin.types.area');
133
+ }
134
+ };
135
+
110
136
  get message(): Message | undefined {
111
137
  const value = this.newAddress.value as Address | undefined;
112
138
 
@@ -372,15 +398,11 @@ export default class LocationPluginEditComponent extends Component<Signature> {
372
398
  @onChange={{@setLocationType}}
373
399
  as |Group|
374
400
  >
375
- <Group.Radio @value='address'>
376
- {{t 'location-plugin.types.address'}}
377
- </Group.Radio>
378
- <Group.Radio @value='place'>
379
- {{t 'location-plugin.types.place'}}
380
- </Group.Radio>
381
- <Group.Radio @value='area'>
382
- {{t 'location-plugin.types.area'}}
383
- </Group.Radio>
401
+ {{#each this.locationTypes as |locationType|}}
402
+ <Group.Radio @value={{locationType}}>
403
+ {{this.locationTypeLabel locationType}}
404
+ </Group.Radio>
405
+ {{/each}}
384
406
  </AuRadioGroup>
385
407
  </fs.content>
386
408
  </AuFieldset>
@@ -28,7 +28,10 @@ import { replaceSelectionWithLocation } from '@lblod/ember-rdfa-editor-lblod-plu
28
28
  import { type LocationPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/location-plugin/node';
29
29
  import { NodeContentsUtils } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/location-plugin/node-contents';
30
30
  import Edit from './edit';
31
- import LocationMap, { type LocationType } from './map';
31
+ import LocationMap, {
32
+ SUPPORTED_LOCATION_TYPES,
33
+ type LocationType,
34
+ } from './map';
32
35
 
33
36
  export type CurrentLocation = Address | GlobalCoordinates | undefined;
34
37
 
@@ -55,6 +58,7 @@ interface Signature {
55
58
  config: LocationPluginConfig;
56
59
  defaultMunicipality?: string;
57
60
  templateMode?: boolean;
61
+ locationTypes?: LocationType[];
58
62
  };
59
63
  Element: HTMLLIElement;
60
64
  }
@@ -65,6 +69,10 @@ export default class LocationPluginInsertComponent extends Component<Signature>
65
69
  @tracked chosenPoint: GeoPos | undefined;
66
70
  @tracked isLoading = false;
67
71
 
72
+ get locationTypes() {
73
+ return this.args.locationTypes ?? SUPPORTED_LOCATION_TYPES;
74
+ }
75
+
68
76
  @trackedReset({
69
77
  memo: 'modalOpen',
70
78
  update: updateFromNode(Address, (address) => address),
@@ -99,11 +107,13 @@ export default class LocationPluginInsertComponent extends Component<Signature>
99
107
  update(component: LocationPluginInsertComponent) {
100
108
  return (
101
109
  updateFromNode(Place, () => 'place')(component) ??
102
- updateFromNode(Area, () => 'area', 'address')(component)
110
+ updateFromNode(Area, () => 'area')(component) ??
111
+ updateFromNode(Address, () => 'address')(component) ??
112
+ component.locationTypes[0]
103
113
  );
104
114
  },
105
115
  })
106
- locationType: LocationType = 'address';
116
+ declare locationType: LocationType;
107
117
 
108
118
  @trackedReset({
109
119
  memo: 'controller.activeEditorState',
@@ -284,6 +294,7 @@ export default class LocationPluginInsertComponent extends Component<Signature>
284
294
  <Edit
285
295
  @locationType={{this.locationType}}
286
296
  @setLocationType={{this.setLocationType}}
297
+ @locationTypes={{this.locationTypes}}
287
298
  @selectedLocationNode={{this.selectedLocationNode}}
288
299
  @setAddressToInsert={{this.setAddressToInsert}}
289
300
  @setIsLoading={{this.setIsLoading}}
@@ -20,7 +20,8 @@ import {
20
20
  type GlobalCoordinates,
21
21
  } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/location-plugin/utils/geo-helpers';
22
22
 
23
- export type LocationType = 'address' | 'place' | 'area';
23
+ export const SUPPORTED_LOCATION_TYPES = ['address', 'place', 'area'] as const;
24
+ export type LocationType = (typeof SUPPORTED_LOCATION_TYPES)[number];
24
25
 
25
26
  const MAP_TILE_ATTRIBUTION =
26
27
  '&copy; <a target="_blank" href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors';
@@ -245,7 +245,9 @@ export const emberNodeConfig: (
245
245
  attrs.rdfaNodeType === 'resource' &&
246
246
  node.dataset.sayRenderAs === 'structure'
247
247
  ) {
248
- const headerFormat = node.dataset.sayHeaderFormat;
248
+ // Since there are existing decision articles with no sayHeaderFormat, the default if
249
+ // unset is the default for these structures, 'name'
250
+ const headerFormat = node.dataset.sayHeaderFormat ?? 'name';
249
251
  // strict selector here to avoid false positives when structures are nested
250
252
  // :scope refers to the element on which we call querySelector
251
253
  // say-structure-header-content data attribute is now deprecated in favour of using an
@@ -14,6 +14,7 @@ interface Message {
14
14
  }
15
15
  type Signature = {
16
16
  Args: {
17
+ locationTypes?: readonly LocationType[];
17
18
  locationType: LocationType;
18
19
  setLocationType: (type: LocationType) => void;
19
20
  defaultMunicipality?: string;
@@ -34,6 +35,8 @@ export default class LocationPluginEditComponent extends Component<Signature> {
34
35
  newHousenumber?: string;
35
36
  newBusnumber?: string;
36
37
  newTruncatedValue?: boolean;
38
+ get locationTypes(): readonly ("address" | "area" | "place")[];
39
+ locationTypeLabel: (locationType: LocationType) => string;
37
40
  get message(): Message | undefined;
38
41
  get currentAddress(): Address | null;
39
42
  get currentMunicipality(): string | undefined;
@@ -14,6 +14,7 @@ interface Signature {
14
14
  config: LocationPluginConfig;
15
15
  defaultMunicipality?: string;
16
16
  templateMode?: boolean;
17
+ locationTypes?: LocationType[];
17
18
  };
18
19
  Element: HTMLLIElement;
19
20
  }
@@ -22,6 +23,7 @@ export default class LocationPluginInsertComponent extends Component<Signature>
22
23
  modalOpen: boolean;
23
24
  chosenPoint: GeoPos | undefined;
24
25
  isLoading: boolean;
26
+ get locationTypes(): readonly ["address", "place", "area"] | ("address" | "area" | "place")[];
25
27
  addressToInsert?: Address;
26
28
  savedLocation: GeoPos | undefined;
27
29
  placeName: string;
@@ -4,7 +4,8 @@ import { type LatLngBoundsExpression } from 'leaflet';
4
4
  import { type LeafletMouseEvent } from 'leaflet';
5
5
  import { Address } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/location-plugin/utils/address-helpers';
6
6
  import { GeoPos, type GlobalCoordinates } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/location-plugin/utils/geo-helpers';
7
- export type LocationType = 'address' | 'place' | 'area';
7
+ export declare const SUPPORTED_LOCATION_TYPES: readonly ["address", "place", "area"];
8
+ export type LocationType = (typeof SUPPORTED_LOCATION_TYPES)[number];
8
9
  interface Signature {
9
10
  Args: {
10
11
  address: Address | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lblod/ember-rdfa-editor-lblod-plugins",
3
- "version": "27.0.1",
3
+ "version": "27.0.2-dev.751f44226897d2ee405ea11d48bec0779acfa8ed",
4
4
  "description": "Ember addon providing lblod specific plugins for the ember-rdfa-editor",
5
5
  "keywords": [
6
6
  "ember-addon",