@conduction/nextcloud-vue 2.182.0 → 2.183.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.
@@ -2,7 +2,7 @@ import script from './CnMapWidget2.vue.js';
2
2
  import { render } from './CnMapWidget3.vue.js';
3
3
 
4
4
  script.render = render;
5
- script.__scopeId = "data-v-356bff56";
5
+ script.__scopeId = "data-v-1fc9cf51";
6
6
  const __sfc_main = script;
7
7
 
8
8
  export { __sfc_main as default };
@@ -9,6 +9,7 @@ import { resolveFilterTokens } from '../../utils/resolveFilterTokens.js';
9
9
  import { safeHref } from '../../utils/safeHref.js';
10
10
  import { SAFE_MARKDOWN_DOMPURIFY_CONFIG } from '../../utils/safeMarkdownDompurifyConfig.js';
11
11
  import { hasImagePosition, toImagePoint, imageBounds, paddedImageBounds, fromImagePoint } from './imageCoordinates.js';
12
+ import { featureDetailUrl, spatialFilterRequest } from './spatialFilter.js';
12
13
 
13
14
  const ALLOWED_LAYER_TYPES = ['tile', 'wms', 'wfs', 'geojson', 'image'];
14
15
 
@@ -198,14 +199,16 @@ var script = {
198
199
 
199
200
  /**
200
201
  * Marker config. `{ features?, dataSource?, geoProperty?, latField?, lngField?, xField?, yField?,
201
- * popupField?, clustering?, iconColor?, iconUrl?, centerMarker? }`. On an image map
202
+ * popupField?, clustering?, iconColor?, iconUrl?, centerMarker?, detailLink? }`. On an image map
202
203
  * (a layer of type `image`) markers read `xField` / `yField` (default `x` / `y`,
203
204
  * pixels from the picture's top left) instead of `latField` / `lngField`. `features[]` is inline;
204
205
  * `dataSource.url` is HTTP-fetched on mount; `dataSource.{register, schema}`
205
206
  * plots the objects of an OpenRegister register/schema via `geoProperty` (a property
206
207
  * holding a GeoJSON geometry of any type, or a point) when set, else `@self.geo`.
207
208
  * `centerMarker: true` adds an extra pin at the map's `center`, alongside any
208
- * source markers.
209
+ * source markers. `dataSource.spatialFilter` (`{ bbox }`, `{ near, radius }` or
210
+ * `{ within }`) narrows a register source to an area; `detailLink` is the address
211
+ * a clicked object opens in a new tab (see spatialFilter.js).
209
212
  *
210
213
  * @type {object|null}
211
214
  */
@@ -613,14 +616,18 @@ var script = {
613
616
  },
614
617
 
615
618
  /**
616
- * The data-source filter with its tokens resolved, serialised so a new
617
- * record re-reads the markers.
619
+ * The data-source filter with its tokens resolved, and the spatial
620
+ * filter, serialised so a new record or a new area re-reads the markers.
618
621
  *
619
622
  * @return {string}
623
+ * @spec openspec/changes/map-spatial-filter-and-detail-link/specs/map-spatial-filter-and-detail-link/spec.md#requirement-a-map-can-narrow-its-objects-to-an-area
620
624
  */
621
625
  filterKey() {
622
626
  const ds = this.cfg.markers && this.cfg.markers.dataSource;
623
- return ds && ds.filter ? JSON.stringify(this.sourceFilter(ds)) : ''
627
+ if (!ds || (!ds.filter && !ds.spatialFilter)) {
628
+ return ''
629
+ }
630
+ return JSON.stringify([ds.filter ? this.sourceFilter(ds) : null, ds.spatialFilter || null])
624
631
  },
625
632
 
626
633
  unplottedLabel() {
@@ -1163,6 +1170,7 @@ var script = {
1163
1170
  * @type {{feature: object, latlng: object}}
1164
1171
  */
1165
1172
  this.$emit('marker-click', { feature, latlng: e.latlng });
1173
+ this.openFeatureDetail(feature);
1166
1174
  });
1167
1175
  },
1168
1176
  });
@@ -1660,8 +1668,11 @@ var script = {
1660
1668
  * skipped rather than dropped at (0, 0) — an invisible wrong marker is worse
1661
1669
  * than an absent one.
1662
1670
  *
1663
- * @param {{register: string, schema: string, limit?: number}} ds The data source.
1671
+ * A `spatialFilter` narrows the objects to an area (see spatialFilter.js).
1672
+ *
1673
+ * @param {{register: string, schema: string, limit?: number, spatialFilter?: object}} ds The data source.
1664
1674
  * @return {Promise<Array<object>>} GeoJSON Feature array.
1675
+ * @spec openspec/changes/map-spatial-filter-and-detail-link/specs/map-spatial-filter-and-detail-link/spec.md#requirement-a-map-can-narrow-its-objects-to-an-area
1665
1676
  */
1666
1677
  async fetchRegisterFeatures(ds) {
1667
1678
  try {
@@ -1673,7 +1684,11 @@ var script = {
1673
1684
  '/apps/openregister/api/objects/{register}/{schema}',
1674
1685
  { register: ds.register, schema: ds.schema },
1675
1686
  );
1676
- const res = await axios.get(url, { params: { ...this.sourceFilter(ds), _limit: ds.limit || 500 } });
1687
+ const params = { ...this.sourceFilter(ds), _limit: ds.limit || 500 };
1688
+ const spatial = spatialFilterRequest(ds.spatialFilter, this.cfg.markers && this.cfg.markers.geoProperty);
1689
+ const res = spatial && spatial.body
1690
+ ? await axios.post(url + '/geo-search', spatial.body, { params })
1691
+ : await axios.get(url, { params: { ...params, ...(spatial ? spatial.params : {}) } });
1677
1692
  const rows = (res && res.data && res.data.results) || [];
1678
1693
 
1679
1694
  const latField = this.cfg.markers && this.cfg.markers.latField;
@@ -1693,6 +1708,20 @@ var script = {
1693
1708
  }
1694
1709
  },
1695
1710
 
1711
+ /**
1712
+ * Open a clicked object's detail address in a new tab, when it has one.
1713
+ *
1714
+ * @param {object} feature The clicked GeoJSON feature.
1715
+ * @return {void}
1716
+ * @spec openspec/changes/map-spatial-filter-and-detail-link/specs/map-spatial-filter-and-detail-link/spec.md#requirement-a-clicked-object-opens-its-detail-page
1717
+ */
1718
+ openFeatureDetail(feature) {
1719
+ const href = featureDetailUrl(feature, this.cfg.markers && this.cfg.markers.detailLink);
1720
+ if (href !== null) {
1721
+ window.open(href, '_blank', 'noopener,noreferrer');
1722
+ }
1723
+ },
1724
+
1696
1725
  /**
1697
1726
  * Normalise a fetched payload into a GeoJSON Feature array.
1698
1727
  * Accepts FeatureCollection, raw Feature[], or flat rows that