@conduction/nextcloud-vue 2.181.1 → 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.
Files changed (29) hide show
  1. package/dist/esm/components/CnMapWidget/CnMapWidget.vue.js +1 -1
  2. package/dist/esm/components/CnMapWidget/CnMapWidget2.vue.js +43 -11
  3. package/dist/esm/components/CnMapWidget/CnMapWidget2.vue.js.map +1 -1
  4. package/dist/esm/components/CnMapWidget/CnMapWidget3.vue.js.map +1 -1
  5. package/dist/esm/components/CnMapWidget/basemapPresets.js +81 -0
  6. package/dist/esm/components/CnMapWidget/basemapPresets.js.map +1 -0
  7. package/dist/esm/components/CnMapWidget/spatialFilter.js +136 -0
  8. package/dist/esm/components/CnMapWidget/spatialFilter.js.map +1 -0
  9. package/dist/esm/components/CnMapWidgetForm/CnMapWidgetForm.vue.js +1 -1
  10. package/dist/esm/components/CnMapWidgetForm/CnMapWidgetForm2.vue.js +37 -12
  11. package/dist/esm/components/CnMapWidgetForm/CnMapWidgetForm2.vue.js.map +1 -1
  12. package/dist/esm/components/CnMapWidgetForm/CnMapWidgetForm3.vue.js +27 -9
  13. package/dist/esm/components/CnMapWidgetForm/CnMapWidgetForm3.vue.js.map +1 -1
  14. package/dist/esm/l10n/nl.json.js +5 -1
  15. package/dist/esm/l10n/nl.json.js.map +1 -1
  16. package/dist/esm/library-style.js +1 -1
  17. package/dist/esm/nextcloud-vue.css +23 -23
  18. package/dist/esm/utils/geo.js +49 -10
  19. package/dist/esm/utils/geo.js.map +1 -1
  20. package/dist/nextcloud-vue.cjs.js +369 -43
  21. package/dist/nextcloud-vue.cjs.js.map +2 -2
  22. package/dist/nextcloud-vue.css +23 -23
  23. package/l10n/nl.json +5 -1
  24. package/package.json +1 -1
  25. package/src/components/CnMapWidget/CnMapWidget.vue +48 -11
  26. package/src/components/CnMapWidget/basemapPresets.js +78 -0
  27. package/src/components/CnMapWidget/spatialFilter.js +132 -0
  28. package/src/components/CnMapWidgetForm/CnMapWidgetForm.vue +53 -13
  29. package/src/utils/geo.js +48 -9
@@ -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-683678f9";
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
 
@@ -197,14 +198,17 @@ var script = {
197
198
  },
198
199
 
199
200
  /**
200
- * Marker config. `{ features?, dataSource?, latField?, lngField?, xField?, yField?,
201
- * popupField?, clustering?, iconColor?, iconUrl?, centerMarker? }`. On an image map
201
+ * Marker config. `{ features?, dataSource?, geoProperty?, latField?, lngField?, xField?, yField?,
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
- * plots the objects of an OpenRegister register/schema via their `@self.geo`.
206
+ * plots the objects of an OpenRegister register/schema via `geoProperty` (a property
207
+ * holding a GeoJSON geometry of any type, or a point) when set, else `@self.geo`.
206
208
  * `centerMarker: true` adds an extra pin at the map's `center`, alongside any
207
- * 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).
208
212
  *
209
213
  * @type {object|null}
210
214
  */
@@ -612,14 +616,18 @@ var script = {
612
616
  },
613
617
 
614
618
  /**
615
- * The data-source filter with its tokens resolved, serialised so a new
616
- * 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.
617
621
  *
618
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
619
624
  */
620
625
  filterKey() {
621
626
  const ds = this.cfg.markers && this.cfg.markers.dataSource;
622
- 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])
623
631
  },
624
632
 
625
633
  unplottedLabel() {
@@ -1162,6 +1170,7 @@ var script = {
1162
1170
  * @type {{feature: object, latlng: object}}
1163
1171
  */
1164
1172
  this.$emit('marker-click', { feature, latlng: e.latlng });
1173
+ this.openFeatureDetail(feature);
1165
1174
  });
1166
1175
  },
1167
1176
  });
@@ -1659,8 +1668,11 @@ var script = {
1659
1668
  * skipped rather than dropped at (0, 0) — an invisible wrong marker is worse
1660
1669
  * than an absent one.
1661
1670
  *
1662
- * @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.
1663
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
1664
1676
  */
1665
1677
  async fetchRegisterFeatures(ds) {
1666
1678
  try {
@@ -1672,16 +1684,22 @@ var script = {
1672
1684
  '/apps/openregister/api/objects/{register}/{schema}',
1673
1685
  { register: ds.register, schema: ds.schema },
1674
1686
  );
1675
- 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 : {}) } });
1676
1692
  const rows = (res && res.data && res.data.results) || [];
1677
1693
 
1678
1694
  const latField = this.cfg.markers && this.cfg.markers.latField;
1679
1695
  const lngField = this.cfg.markers && this.cfg.markers.lngField;
1696
+ const geoProperty = this.cfg.markers && this.cfg.markers.geoProperty;
1680
1697
 
1681
1698
  // (0, 0) is where an unset pair of numbers lands, not a place.
1682
1699
  return rows
1683
- .map((row) => objectToGeoFeature(row, { latField, lngField }))
1684
- .filter((feature) => feature && !(feature.geometry.coordinates[0] === 0 && feature.geometry.coordinates[1] === 0))
1700
+ .map((row) => objectToGeoFeature(row, { geoProperty, latField, lngField }))
1701
+ .filter((feature) => feature && !(feature.geometry.type === 'Point'
1702
+ && feature.geometry.coordinates[0] === 0 && feature.geometry.coordinates[1] === 0))
1685
1703
  } catch (err) {
1686
1704
  this.markersFailed = true;
1687
1705
  // eslint-disable-next-line no-console
@@ -1690,6 +1708,20 @@ var script = {
1690
1708
  }
1691
1709
  },
1692
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
+
1693
1725
  /**
1694
1726
  * Normalise a fetched payload into a GeoJSON Feature array.
1695
1727
  * Accepts FeatureCollection, raw Feature[], or flat rows that