@dative-gpi/foundation-shared-components 0.0.193 → 0.0.195

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.
@@ -19,7 +19,7 @@
19
19
  :label="mapLayer.label"
20
20
  :key="mapLayer.name"
21
21
  :editable="true"
22
- @click="setMapBaseLayer(mapLayer.name)"
22
+ @click="setMapBaseLayer(mapLayer.name as 'osm' | 'imagery')"
23
23
  />
24
24
  </FSRow>
25
25
  <FSRow
@@ -83,7 +83,7 @@
83
83
  v-if="editingLocation"
84
84
  :label="$tr('ui.map.address', 'Address')"
85
85
  :modelValue="(innerModelValue.find((loc) => loc.id === $props.selectedLocationId))?.address"
86
- @update:locationCoord="($event: Address) => onNewCoordEntered($event.latitude, $event.longitude)"
86
+ @update:locationCoordinates="($event: Address) => onNewCoordEntered($event.latitude, $event.longitude)"
87
87
  @update:modelValue="($event: Address) => onNewAddressEntered($event)"
88
88
  @cancel="onCancel"
89
89
  @submit="onSubmit"
@@ -95,16 +95,17 @@
95
95
 
96
96
  <script lang="ts">
97
97
  import { computed, defineComponent, onMounted, type PropType, ref, watch } from "vue";
98
- import { v4 as uuidv4 } from "uuid";
99
98
 
100
- import { MarkerClusterGroup } from "leaflet.markercluster";
101
99
  import * as L from "leaflet";
100
+ import "leaflet.markercluster";
101
+ import { MarkerClusterGroup } from "leaflet";
102
+
103
+ import { useTranslations as useTranslationsProvider } from "@dative-gpi/bones-ui/composables";
102
104
 
103
105
  import { type Address, type SiteInfos } from '@dative-gpi/foundation-shared-domain/models';
104
106
 
105
107
  import { ColorEnum, type FSLocation, type MapLayer } from "../../models";
106
- import { useAddress } from "../../composables/useAddress";
107
- import { useColors } from "../../composables";
108
+ import { useColors, useAddress } from "../../composables";
108
109
 
109
110
  import FSMapEditPointAddressOverlay from "./FSMapEditPointAddressOverlay.vue";
110
111
  import FSButton from "../FSButton.vue";
@@ -145,7 +146,7 @@ export default defineComponent({
145
146
  default: () => [45.71, 5.07]
146
147
  },
147
148
  selectedLayer: {
148
- type: String,
149
+ type: String as PropType<"osm" | "imagery">,
149
150
  required: false,
150
151
  default: "osm"
151
152
  },
@@ -183,18 +184,24 @@ export default defineComponent({
183
184
  type: Boolean,
184
185
  required: false,
185
186
  default: true
187
+ },
188
+ grayscale: {
189
+ type: Boolean,
190
+ required: false,
191
+ default: false
186
192
  }
187
193
  },
188
194
  emits: ["update:modelValue", "update:selectedLocationId", "update:selectedSiteId"],
189
195
  setup(props, { emit }) {
190
196
  const { reverseSearch } = useAddress();
191
197
  const { getColors } = useColors();
192
-
198
+ const { $tr } = useTranslationsProvider();
199
+
193
200
  const innerSelectedLayer = ref(props.selectedLayer);
194
201
  const innerModelValue = ref(props.modelValue);
195
202
  const editingLocation = ref(false);
196
-
197
- const mapId = `map-${uuidv4()}`;
203
+
204
+ const mapId = `map-${Math.random().toString(36).substring(7)}`;
198
205
  const defaultZoom = 15;
199
206
  const markers: { [key: string]: L.Marker } = {};
200
207
  const sites: { [key: string]: L.Polygon } = {};
@@ -213,7 +220,7 @@ export default defineComponent({
213
220
  spiderfyOnMaxZoom: false,
214
221
  showCoverageOnHover: false,
215
222
  disableClusteringAtZoom: 17,
216
- iconCreateFunction: function(cluster: any) {
223
+ iconCreateFunction: function (cluster: any) {
217
224
  return L.divIcon({
218
225
  html: `<div>
219
226
  <span>${cluster.getChildCount()}</span>
@@ -228,27 +235,19 @@ export default defineComponent({
228
235
  const mapLayers: MapLayer[] = [
229
236
  {
230
237
  name: "osm",
231
- label: "OpenStreetMap",
238
+ label: $tr("ui.map.layer.osm", "Map"),
232
239
  layer: L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
233
- maxZoom: 19,
240
+ maxZoom: 20,
234
241
  attribution: '© OpenStreetMap'
235
242
  })
236
243
  },
237
244
  {
238
245
  name: "imagery",
239
- label: "Imagery",
240
- layer: L.tileLayer('https://tiles.stadiamaps.com/tiles/alidade_satellite/{z}/{x}/{y}{r}.jpg', {
241
- maxZoom: 20,
246
+ label: $tr("ui.map.layer.imagery", "Imagery"),
247
+ layer: L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
242
248
  attribution: 'Tiles &copy; Esri &mdash; Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community',
249
+ maxZoom: 19
243
250
  }),
244
- },
245
- {
246
- name: "light",
247
- label: "Light",
248
- layer: L.tileLayer('https://tiles.stadiamaps.com/tiles/alidade_smooth/{z}/{x}/{y}{r}.png', {
249
- maxZoom: 20,
250
- attribution: '&copy; <a href="https://www.stadiamaps.com/" target="_blank">Stadia Maps</a> &copy; <a href="https://openmaptiles.org/" target="_blank">OpenMapTiles</a> &copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
251
- })
252
251
  }
253
252
  ];
254
253
 
@@ -257,6 +256,7 @@ export default defineComponent({
257
256
  "--fs-map-location-pin-color": getColors(ColorEnum.Primary).base,
258
257
  "--fs-map-mylocation-pin-color-alpha": getColors(ColorEnum.Primary).base + "50",
259
258
  "--fs-map-leaflet-container-height": props.height as string,
259
+ "--fs-map-container-grayscale": props.grayscale ? '0.9' : '0'
260
260
  };
261
261
  });
262
262
 
@@ -273,7 +273,7 @@ export default defineComponent({
273
273
  const marker = L.marker([location.address.latitude, location.address.longitude], { icon }).addTo(markerLayerGroup);
274
274
  markers[location.id] = marker;
275
275
  marker.on('click', () => emit('update:selectedLocationId', location.id));
276
-
276
+
277
277
  });
278
278
  };
279
279
 
@@ -337,7 +337,7 @@ export default defineComponent({
337
337
  });
338
338
  };
339
339
 
340
- const setMapBaseLayer = (layerName: string) => {
340
+ const setMapBaseLayer = (layerName: 'osm' | 'imagery') => {
341
341
  innerSelectedLayer.value = layerName;
342
342
  const layer = mapLayers.find((mapLayer) => mapLayer.name === layerName) ?? mapLayers[0];
343
343
  baseLayerGroup.clearLayers();
@@ -16,20 +16,20 @@
16
16
  </FSText>
17
17
  <v-spacer />
18
18
  <FSButton
19
- v-if="menuLocationCoord"
19
+ v-if="menuLocationCoordinates"
20
20
  icon="mdi-arrow-collapse"
21
21
  variant="icon"
22
- @click="menuLocationCoord = !menuLocationCoord"
22
+ @click="menuLocationCoordinates = !menuLocationCoordinates"
23
23
  />
24
24
  <FSButton
25
25
  v-else
26
26
  icon="mdi-arrow-expand"
27
27
  variant="icon"
28
- @click="menuLocationCoord = !menuLocationCoord"
28
+ @click="menuLocationCoordinates = !menuLocationCoordinates"
29
29
  />
30
30
  </FSRow>
31
31
  <FSCol
32
- v-if="menuLocationCoord"
32
+ v-if="menuLocationCoordinates"
33
33
  >
34
34
  <FSAutoCompleteAddress
35
35
  :modelValue="$props.modelValue"
@@ -37,7 +37,7 @@
37
37
  />
38
38
  <FSForm
39
39
  variant="standard"
40
- @submit="onCoordinateChange()"
40
+ @submit="onCoordinatesChange()"
41
41
  >
42
42
  <FSRow>
43
43
  <FSNumberField
@@ -109,14 +109,14 @@ export default defineComponent({
109
109
  required: false,
110
110
  }
111
111
  },
112
- emits: ["update:modelValue", "update:locationCoord", "submit", "cancel"],
112
+ emits: ["update:modelValue", "update:locationCoordinates", "submit", "cancel"],
113
113
  setup(props, { emit }) {
114
- const menuLocationCoord = ref(false);
114
+ const menuLocationCoordinates = ref(false);
115
115
 
116
116
  const latitude = ref(props.modelValue.latitude);
117
117
  const longitude = ref(props.modelValue.longitude);
118
118
 
119
- const onCoordinateChange = () => {
119
+ const onCoordinatesChange = () => {
120
120
  const newModelValue = new Address({
121
121
  country: "",
122
122
  formattedAddress: "",
@@ -126,7 +126,7 @@ export default defineComponent({
126
126
  latitude: latitude.value,
127
127
  longitude: longitude.value,
128
128
  });
129
- emit("update:locationCoord", newModelValue);
129
+ emit("update:locationCoordinates", newModelValue);
130
130
  };
131
131
 
132
132
  const onAddressFieldSubmit = (address: Address|null) => {
@@ -150,11 +150,11 @@ export default defineComponent({
150
150
  });
151
151
 
152
152
  return {
153
- menuLocationCoord,
153
+ menuLocationCoordinates,
154
154
  longitude,
155
155
  latitude,
156
156
  onAddressFieldSubmit,
157
- onCoordinateChange,
157
+ onCoordinatesChange,
158
158
  onSubmit,
159
159
  onCancel
160
160
  };
@@ -1,3 +1,4 @@
1
+ export * from "./useAddress";
1
2
  export * from "./useAutocomplete";
2
3
  export * from "./useBreakpoints";
3
4
  export * from "./useColors";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dative-gpi/foundation-shared-components",
3
3
  "sideEffects": false,
4
- "version": "0.0.193",
4
+ "version": "0.0.195",
5
5
  "description": "",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -10,8 +10,8 @@
10
10
  "author": "",
11
11
  "license": "ISC",
12
12
  "dependencies": {
13
- "@dative-gpi/foundation-shared-domain": "0.0.193",
14
- "@dative-gpi/foundation-shared-services": "0.0.193",
13
+ "@dative-gpi/foundation-shared-domain": "0.0.195",
14
+ "@dative-gpi/foundation-shared-services": "0.0.195",
15
15
  "leaflet": "1.9.4",
16
16
  "leaflet.markercluster": "1.5.3"
17
17
  },
@@ -35,5 +35,5 @@
35
35
  "sass": "1.71.1",
36
36
  "sass-loader": "13.3.2"
37
37
  },
38
- "gitHead": "8614b06db4bd739e668e1cb60cfbcabb786595a7"
38
+ "gitHead": "acda9a6c41eb4f36cd702ef36bfe6be21bb6dd70"
39
39
  }
@@ -6,6 +6,7 @@
6
6
  .fs-leaflet-container {
7
7
  width: 100%;
8
8
  height: var(--fs-map-leaflet-container-height);
9
+ filter: grayscale(var(--fs-map-container-grayscale));
9
10
  }
10
11
 
11
12
  .fs-map-overlay-layer-choice {