@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
package/src/utils/geo.js CHANGED
@@ -93,16 +93,44 @@ export function parseGeoPoint(geo) {
93
93
  )
94
94
  }
95
95
 
96
+ const GEOMETRY_TYPES = ['Point', 'MultiPoint', 'LineString', 'MultiLineString', 'Polygon', 'MultiPolygon']
97
+
98
+ /**
99
+ * The GeoJSON geometry a property value holds: a geometry, or a Feature's
100
+ * geometry. Returns null for anything else, so a point-shaped value falls
101
+ * through to parseGeoPoint().
102
+ *
103
+ * @param {unknown} value The property value.
104
+ * @return {?object} The geometry, or null.
105
+ */
106
+ export function parseGeoGeometry(value) {
107
+ if (!value || typeof value !== 'object') {
108
+ return null
109
+ }
110
+ const geometry = value.type === 'Feature' ? value.geometry : value
111
+ if (!geometry || !GEOMETRY_TYPES.includes(geometry.type) || !Array.isArray(geometry.coordinates)) {
112
+ return null
113
+ }
114
+ if (geometry.type === 'Point') {
115
+ const point = parseGeoPoint(geometry)
116
+ return point ? { type: 'Point', coordinates: [point.lng, point.lat] } : null
117
+ }
118
+ return geometry.coordinates.length > 0 ? geometry : null
119
+ }
120
+
96
121
  /**
97
- * Turn an OpenRegister object into a GeoJSON Point Feature, or null when it has no
122
+ * Turn an OpenRegister object into a GeoJSON Feature, or null when it has no
98
123
  * usable location.
99
124
  *
100
- * Looks at `@self.geo` first (where the geo widget writes it). Falls back to plain
101
- * lat/lng fields on the object itself, so a schema that models coordinates as its own
102
- * properties still plots without having to migrate to `@self.geo`.
125
+ * With `geoProperty` set, that property is read first: a GeoJSON geometry of any
126
+ * type (point, line, polygon or a multi-geometry), a Feature, or a lat/lng value.
127
+ * Otherwise, or when it is empty, `@self.geo` is read (where the geo widget writes
128
+ * it), and then plain lat/lng fields on the object itself, so a schema that models
129
+ * coordinates as its own properties still plots.
103
130
  *
104
131
  * @param {object} obj The OpenRegister object.
105
132
  * @param {object} [options] Options.
133
+ * @param {string} [options.geoProperty] Property holding the object's geometry.
106
134
  * @param {string} [options.latField] Property holding latitude, for the fallback.
107
135
  * @param {string} [options.lngField] Property holding longitude, for the fallback.
108
136
  * @return {?object} A GeoJSON Feature whose `properties` is the object, or null.
@@ -112,14 +140,25 @@ export function objectToGeoFeature(obj, options = {}) {
112
140
  return null
113
141
  }
114
142
 
143
+ const { geoProperty, latField, lngField } = options
144
+ if (geoProperty) {
145
+ const value = obj[geoProperty]
146
+ const geometry = parseGeoGeometry(value)
147
+ const point = geometry ? null : parseGeoPoint(value)
148
+ if (geometry || point) {
149
+ return {
150
+ type: 'Feature',
151
+ geometry: geometry || { type: 'Point', coordinates: [point.lng, point.lat] },
152
+ properties: { ...obj },
153
+ }
154
+ }
155
+ }
156
+
115
157
  const self = obj['@self'] || {}
116
158
  let point = parseGeoPoint(self.geo)
117
159
 
118
- if (!point) {
119
- const { latField, lngField } = options
120
- if (latField && lngField) {
121
- point = finitePoint(obj[latField], obj[lngField])
122
- }
160
+ if (!point && latField && lngField) {
161
+ point = finitePoint(obj[latField], obj[lngField])
123
162
  }
124
163
  if (!point) {
125
164
  return null