@lblod/ember-rdfa-editor-lblod-plugins 35.1.2 → 35.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
@@ -1,5 +1,17 @@
1
1
  # @lblod/ember-rdfa-editor-lblod-plugins
2
2
 
3
+ ## 35.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#640](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/640) [`3180369`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/31803691c6e577dfed2d6e0f91962a5180906101) Thanks [@abeforgit](https://github.com/abeforgit)! - Add option to explicitly configure subject to link locations to
8
+
9
+ ### Patch Changes
10
+
11
+ - [#639](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/639) [`0946fdb`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/0946fdb3561050ed2b4f197305b0556007fe32d3) Thanks [@lagartoverde](https://github.com/lagartoverde)! - Fix typing in besluit topic select
12
+
13
+ - [#638](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/638) [`32f2217`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/32f22174393411561665f3266db62eb463bfc4ea) Thanks [@piemonkey](https://github.com/piemonkey)! - Invert oslo-location toggle to be 'GRB' in place of 'Open Streetmap'
14
+
3
15
  ## 35.1.2
4
16
 
5
17
  ### Patch Changes
@@ -6,6 +6,8 @@ import { BesluitTopic } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/bes
6
6
 
7
7
  type Args = {
8
8
  besluitTopics: BesluitTopic[];
9
+ selected?: BesluitTopic[];
10
+ onchange: (topic: BesluitTopic[]) => void;
9
11
  };
10
12
 
11
13
  export default class BesluitTopicSelectComponent extends Component<Args> {
@@ -52,12 +52,12 @@ export default class LocationPluginInsertComponent extends Component<Signature>
52
52
  const uri = `http://data.lblod.info/variables/${
53
53
  this.args.templateMode ? '--ref-uuid4-' : ''
54
54
  }${uuidv4()}`;
55
- replaceSelectionWithLocation(
56
- this.controller,
57
- uri,
58
- undefined,
59
- this.args.config.subjectTypesToLinkTo,
60
- );
55
+ replaceSelectionWithLocation({
56
+ controller: this.controller,
57
+ subject: uri,
58
+ subjectTypes: this.args.config.subjectTypesToLinkTo,
59
+ explicitSubjectToLinkTo: this.args.config.explicitSubjectToLinkTo,
60
+ });
61
61
  }
62
62
 
63
63
  <template>
@@ -35,6 +35,9 @@ import { transactionCombinator } from '@lblod/ember-rdfa-editor/utils/transactio
35
35
  import { updateSubject } from '@lblod/ember-rdfa-editor/plugins/rdfa-info/utils';
36
36
  import { replaceSelectionWithLocation } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/location-plugin/_private/utils/node-utils';
37
37
  import type { Option } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
38
+ import type { FullTriple } from '@lblod/ember-rdfa-editor/core/rdfa-processor';
39
+ import { PROV } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
40
+ import { SayDataFactory } from '@lblod/ember-rdfa-editor/core/say-data-factory';
38
41
 
39
42
  export type CurrentLocation = Address | GlobalCoordinates | undefined;
40
43
 
@@ -274,13 +277,29 @@ export default class LocationPluginInsertComponent extends Component<Signature>
274
277
  if (toInsert) {
275
278
  this.modalOpen = false;
276
279
  if (this.selectedLocationNode) {
277
- // Update, while keeping backlinks intact
278
- const { pos } = this.selectedLocationNode;
280
+ const df = new SayDataFactory();
281
+ const { pos, value: locNode } = this.selectedLocationNode;
282
+ // The location's subject has likely changed, so we should update the external links too
283
+ // if they exist
284
+ // NOTE: It's VERY important that this is done without mutating the triple objects
285
+ // otherwise the attributes will not update as expected when undo-ing
286
+ const newExternalTriples: FullTriple[] = (
287
+ locNode.attrs.externalTriples as FullTriple[]
288
+ ).map((tr) => {
289
+ if (PROV('atLocation').matches(tr.predicate)) {
290
+ return { ...tr, object: df.namedNode(toInsert.uri) };
291
+ } else {
292
+ return tr;
293
+ }
294
+ }); // update the location value and the external triples
279
295
  this.controller.withTransaction((tr) => {
280
296
  return transactionCombinator(
281
297
  this.controller.activeEditorState,
282
- tr.setNodeAttribute(pos, 'value', toInsert),
298
+ tr
299
+ .setNodeAttribute(pos, 'value', toInsert)
300
+ .setNodeAttribute(pos, 'externalTriples', newExternalTriples),
283
301
  )([
302
+ // Update the subject uri, while keeping backlinks intact
284
303
  updateSubject({
285
304
  pos,
286
305
  targetSubject: toInsert.uri,
@@ -292,12 +311,13 @@ export default class LocationPluginInsertComponent extends Component<Signature>
292
311
  });
293
312
  } else {
294
313
  // Insert
295
- replaceSelectionWithLocation(
296
- this.controller,
297
- toInsert.uri,
314
+ replaceSelectionWithLocation({
315
+ controller: this.controller,
316
+ subject: toInsert.uri,
298
317
  toInsert,
299
- this.args.config.subjectTypesToLinkTo,
300
- );
318
+ subjectTypes: this.args.config.subjectTypesToLinkTo,
319
+ explicitSubjectToLinkTo: this.args.config.explicitSubjectToLinkTo,
320
+ });
301
321
  }
302
322
  }
303
323
  }
@@ -230,7 +230,7 @@ class MapWrapper extends Component<MapWrapperSig> {
230
230
 
231
231
  export default class LocationPluginMapComponent extends Component<Signature> {
232
232
  @tracked vertices: GlobalCoordinates[] = [];
233
- @tracked useOpenStreetMaps = false;
233
+ @tracked useGRB = true;
234
234
 
235
235
  // Use untracked properties as otherwise the map jumps to any area or location we pick
236
236
  existingAreaBounds = generateBoundsFromShape(this.args.existingArea);
@@ -275,7 +275,7 @@ export default class LocationPluginMapComponent extends Component<Signature> {
275
275
  }
276
276
 
277
277
  get tileProvider() {
278
- if (this.useOpenStreetMaps) {
278
+ if (!this.useGRB) {
279
279
  return TILE_PROVIDER_CONSTANTS.OPEN_STREET_MAP;
280
280
  } else {
281
281
  return TILE_PROVIDER_CONSTANTS.GRB;
@@ -331,10 +331,11 @@ export default class LocationPluginMapComponent extends Component<Signature> {
331
331
  as |c|
332
332
  >
333
333
  <c.content>
334
- <AuToggleSwitch @onChange={{set this 'useOpenStreetMaps'}}>
335
- <p class='au-u-para-tiny'>{{t
336
- 'location-plugin.use-open-street-map'
337
- }}</p>
334
+ <AuToggleSwitch
335
+ @checked={{this.useGRB}}
336
+ @onChange={{set this 'useGRB'}}
337
+ >
338
+ <p class='au-u-para-tiny'>{{t 'location-plugin.use-grb'}}</p>
338
339
  </AuToggleSwitch>
339
340
  </c.content>
340
341
  </AuCard>
@@ -1,5 +1,13 @@
1
- import { SayController, NodeSelection, PNode } from '@lblod/ember-rdfa-editor';
2
- import { sayDataFactory } from '@lblod/ember-rdfa-editor/core/say-data-factory';
1
+ import {
2
+ SayController,
3
+ NodeSelection,
4
+ PNode,
5
+ RdfaAttrs,
6
+ } from '@lblod/ember-rdfa-editor';
7
+ import {
8
+ SayDataFactory,
9
+ sayDataFactory,
10
+ } from '@lblod/ember-rdfa-editor/core/say-data-factory';
3
11
  import {
4
12
  PROV,
5
13
  RDF,
@@ -12,6 +20,29 @@ import {
12
20
  } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
13
21
  import { Area, Place } from './geo-helpers';
14
22
  import { Address } from './address-helpers';
23
+ import { FullTriple } from '@lblod/ember-rdfa-editor/core/rdfa-processor';
24
+
25
+ const df = new SayDataFactory();
26
+ interface ReplaceSelectionWithLocationArgs {
27
+ /** SayController */
28
+ controller: SayController;
29
+ /** The uri of the Location resource */
30
+ subject: string;
31
+ /** The object representing the location to insert */
32
+ toInsert?: Place | Address | Area;
33
+ /**
34
+ * A list of Resources, each will be looked at in turn to compare the
35
+ * `rdf:type` of the resource, if no parent is found matching the first, then the second will be
36
+ * used, etc.
37
+ *
38
+ * If found, the location will be linked to that resource using prov:atLocation
39
+ */
40
+ subjectTypes?: Resource[];
41
+ /**
42
+ * If present, the location will be linked to this uri using prov:atLocation using external triples.
43
+ */
44
+ explicitSubjectToLinkTo?: string;
45
+ }
15
46
 
16
47
  /**
17
48
  * Creates an 'OSLO location' node in place of the selection, along with the RDFa to create a triple
@@ -19,18 +50,14 @@ import { Address } from './address-helpers';
19
50
  * prov:atLocation. This doesn't work well with the RDFa tools, but since refactoring is required to
20
51
  * clean up the RDFa structure inherited from variables and to make it work well with 'undo', this
21
52
  * work was put off until then.
22
- * @param controller - SayController
23
- * @param toInsert - The object representing the location to insert
24
- * @param subjectTypes - A list of Resources, each will be looked at in turn to compare the
25
- * `rdf:type` of the resource, if no parent is found matching the first, then the second will be
26
- * used, etc.
27
53
  */
28
- export function replaceSelectionWithLocation(
29
- controller: SayController,
30
- subject: string,
31
- toInsert?: Place | Address | Area,
32
- subjectTypes?: Resource[],
33
- ) {
54
+ export function replaceSelectionWithLocation({
55
+ controller,
56
+ subject,
57
+ toInsert,
58
+ subjectTypes,
59
+ explicitSubjectToLinkTo,
60
+ }: ReplaceSelectionWithLocationArgs) {
34
61
  let resourceToLink: { pos: number; node: PNode } | undefined;
35
62
  subjectTypes?.forEach((subjectType) => {
36
63
  if (!resourceToLink) {
@@ -59,7 +86,16 @@ export function replaceSelectionWithLocation(
59
86
  ),
60
87
  },
61
88
  ];
62
-
89
+ let externalTriples: FullTriple[];
90
+ if (explicitSubjectToLinkTo) {
91
+ externalTriples = [
92
+ {
93
+ subject: df.namedNode(explicitSubjectToLinkTo),
94
+ predicate: PROV('atLocation').full,
95
+ object: df.namedNode(subject),
96
+ },
97
+ ];
98
+ }
63
99
  controller.withTransaction((tr) => {
64
100
  tr.replaceSelectionWith(
65
101
  controller.schema.node('oslo_location', {
@@ -69,7 +105,8 @@ export function replaceSelectionWithLocation(
69
105
  value: toInsert,
70
106
  properties: [],
71
107
  backlinks,
72
- }),
108
+ externalTriples,
109
+ } satisfies RdfaAttrs & { value: Place | Address | Area | undefined }),
73
110
  );
74
111
  if (tr.selection.$anchor.nodeBefore) {
75
112
  const resolvedPos = tr.doc.resolve(
@@ -49,6 +49,7 @@ export interface LocationPluginConfig {
49
49
  defaultPlaceUriRoot: string;
50
50
  defaultPointUriRoot: string;
51
51
  subjectTypesToLinkTo?: Resource[];
52
+ explicitSubjectToLinkTo?: string;
52
53
  additionalRDFTypes?: NamedNode[];
53
54
  }
54
55
 
@@ -21,10 +21,10 @@ export function replaceSelectionWithLocation(
21
21
  toInsert: Place | Address | Area,
22
22
  subjectTypes?: Resource[],
23
23
  ) {
24
- return replaceSelectionWithLocationInternal(
24
+ return replaceSelectionWithLocationInternal({
25
25
  controller,
26
- toInsert.uri,
26
+ subject: toInsert.uri,
27
27
  toInsert,
28
28
  subjectTypes,
29
- );
29
+ });
30
30
  }
@@ -2,6 +2,8 @@ import Component from '@glimmer/component';
2
2
  import { BesluitTopic } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-topic-plugin/utils/fetchBesluitTopics';
3
3
  type Args = {
4
4
  besluitTopics: BesluitTopic[];
5
+ selected?: BesluitTopic[];
6
+ onchange: (topic: BesluitTopic[]) => void;
5
7
  };
6
8
  export default class BesluitTopicSelectComponent extends Component<Args> {
7
9
  AlertTriangleIcon: import("@ember/component/template-only").TOC<import("@appuniversum/ember-appuniversum/components/icons/alert-triangle").AlertTriangleIconSignature>;
@@ -20,7 +20,7 @@ interface Signature {
20
20
  }
21
21
  export default class LocationPluginMapComponent extends Component<Signature> {
22
22
  vertices: GlobalCoordinates[];
23
- useOpenStreetMaps: boolean;
23
+ useGRB: boolean;
24
24
  existingAreaBounds: LatLngBoundsExpression | undefined;
25
25
  existingLocationCoords: GlobalCoordinates | undefined;
26
26
  mapLocation: LeafletMapStart;
@@ -2,16 +2,32 @@ import { SayController } from '@lblod/ember-rdfa-editor';
2
2
  import { Resource } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
3
3
  import { Area, Place } from './geo-helpers';
4
4
  import { Address } from './address-helpers';
5
+ interface ReplaceSelectionWithLocationArgs {
6
+ /** SayController */
7
+ controller: SayController;
8
+ /** The uri of the Location resource */
9
+ subject: string;
10
+ /** The object representing the location to insert */
11
+ toInsert?: Place | Address | Area;
12
+ /**
13
+ * A list of Resources, each will be looked at in turn to compare the
14
+ * `rdf:type` of the resource, if no parent is found matching the first, then the second will be
15
+ * used, etc.
16
+ *
17
+ * If found, the location will be linked to that resource using prov:atLocation
18
+ */
19
+ subjectTypes?: Resource[];
20
+ /**
21
+ * If present, the location will be linked to this uri using prov:atLocation using external triples.
22
+ */
23
+ explicitSubjectToLinkTo?: string;
24
+ }
5
25
  /**
6
26
  * Creates an 'OSLO location' node in place of the selection, along with the RDFa to create a triple
7
27
  * with the nearest parent of one of the passed types as the subject and the predicate
8
28
  * prov:atLocation. This doesn't work well with the RDFa tools, but since refactoring is required to
9
29
  * clean up the RDFa structure inherited from variables and to make it work well with 'undo', this
10
30
  * work was put off until then.
11
- * @param controller - SayController
12
- * @param toInsert - The object representing the location to insert
13
- * @param subjectTypes - A list of Resources, each will be looked at in turn to compare the
14
- * `rdf:type` of the resource, if no parent is found matching the first, then the second will be
15
- * used, etc.
16
31
  */
17
- export declare function replaceSelectionWithLocation(controller: SayController, subject: string, toInsert?: Place | Address | Area, subjectTypes?: Resource[]): void;
32
+ export declare function replaceSelectionWithLocation({ controller, subject, toInsert, subjectTypes, explicitSubjectToLinkTo, }: ReplaceSelectionWithLocationArgs): void;
33
+ export {};
@@ -5,6 +5,7 @@ export interface LocationPluginConfig {
5
5
  defaultPlaceUriRoot: string;
6
6
  defaultPointUriRoot: string;
7
7
  subjectTypesToLinkTo?: Resource[];
8
+ explicitSubjectToLinkTo?: string;
8
9
  additionalRDFTypes?: NamedNode[];
9
10
  }
10
11
  export declare const osloLocation: (config: LocationPluginConfig) => import("@lblod/ember-rdfa-editor/core/say-node-spec").default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lblod/ember-rdfa-editor-lblod-plugins",
3
- "version": "35.1.2",
3
+ "version": "35.2.0",
4
4
  "description": "Ember addon providing lblod specific plugins for the ember-rdfa-editor",
5
5
  "keywords": [
6
6
  "ember-addon",
@@ -434,7 +434,7 @@ lmb-plugin:
434
434
 
435
435
  location-plugin:
436
436
  insert-placeholder: Insert location placeholder
437
- use-open-street-map: OpenStreetMap
437
+ use-grb: GRB
438
438
  modal:
439
439
  insert: Insert location
440
440
  edit: Edit location
@@ -431,7 +431,7 @@ lmb-plugin:
431
431
 
432
432
  location-plugin:
433
433
  insert-placeholder: Voeg locatie-placeholder in
434
- use-open-street-map: OpenStreetMap
434
+ use-grb: GRB
435
435
  modal:
436
436
  insert: Locatie invoegen
437
437
  edit: Bewerk locatie