+ import RegionSearch from '../../../components/RegionSearch.svelte';
+ import { getInfoByName } from '../../../data/regions';
+ import { sortedNameInfos } from '../utils';
+
+ /**
+ * @type {import("../../../stores/params").RegionParam}
+ */
+ export let region;
+
+ /**
+ * @type {string[]}
+ */
+ export let value = [];
+
+ let syncedValues = value ? (Array.isArray(value) ? value : [value]) : [''];
+
+ $: defaultRegion = {
+ id: '',
+ displayName: `Use Configured: ${region.displayName}`,
+ };
+ $: allItems = [defaultRegion, ...sortedNameInfos];
+
+ function toKey(e) {
+ return !e.detail || e.detail.id === '' ? '' : `${e.detail.id}@${e.detail.level}`;
+ }
+
+ $: selectedItems = syncedValues.map((d) => (!d ? defaultRegion : getInfoByName(d)));
+
+
+
+
+ {#each syncedValues as s}
+
+ {/each}
+ {
+ syncedValues = e.detail ? [toKey(e)] : [''];
+ }}
+ on:add={(e) => {
+ if (syncedValues.length === 1 && syncedValues[0] === '') {
+ // replace default
+ syncedValues = [toKey(e)];
+ } else {
+ syncedValues = [...syncedValues, toKey(e)];
+ }
+ }}
+ on:remove={(e) => {
+ if (syncedValues.length === 1) {
+ syncedValues = [''];
+ } else {
+ const key = toKey(e);
+ syncedValues = syncedValues.filter((d) => d !== key);
+ }
+ }}
+ />
+
+
+
diff --git a/src/modes/dashboard/config/SensorsPicker.svelte b/src/modes/dashboard/config/SensorsPicker.svelte
index 63c28f80..12e1cd03 100644
--- a/src/modes/dashboard/config/SensorsPicker.svelte
+++ b/src/modes/dashboard/config/SensorsPicker.svelte
@@ -44,11 +44,18 @@
syncedValues = [...syncedValues, e.detail.key];
}
}}
+ on:remove={(e) => {
+ if (syncedValues.length === 1) {
+ syncedValues = [''];
+ } else {
+ syncedValues = syncedValues.filter((d) => d !== e.detail.key);
+ }
+ }}
/>