Skip to content

Commit 54c7e76

Browse files
committed
auto search bar, improve sidebar toggling
1 parent ea02da9 commit 54c7e76

6 files changed

Lines changed: 25 additions & 13 deletions

File tree

client/src/MapStore.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,6 @@ export default class MapStore {
144144
return foundMapLayerSearchable;
145145
});
146146

147-
public static mapLayerSearchableEnabled = ref(false);
148-
149147
// ToolTips
150148
public static toolTipMenuOpen = ref(false);
151149

@@ -222,9 +220,6 @@ export default class MapStore {
222220
};
223221
};
224222

225-
// Charts
226-
public static chartsOpen = ref(false);
227-
228223
// SideBar Cards
229224
public static activeSideBarCard: Ref<undefined | SideBarCard> = ref(undefined);
230225

client/src/components/Charts/Charts.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ export default defineComponent({
3838
);
3939
const enabledMapPanels: Ref<number[]> = ref([]);
4040
const enabledChartPanels: Ref<Record<number, number[]>> = ref({});
41-
const chartVisible = computed(() => MapStore.chartsOpen.value);
4241
const addingEditingChart = ref(false);
4342
const editingChart: Ref<CustomChart | null> = ref(null);
4443
const editingChartIndex = ref(-1);
@@ -119,7 +118,6 @@ export default defineComponent({
119118
}
120119
};
121120
return {
122-
chartVisible,
123121
proMode: MapStore.proMode,
124122
configuredChartsByMap,
125123
addingEditingChart,

client/src/components/VectorFeatureSearch/Editor/VectorFeatureSearchEditor.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export default defineComponent({
2828
sortable: false,
2929
hoverHighlight: false,
3030
geospatialFilterEnabled: false,
31+
autoOpenSideBar: true,
3132
zoomButton: false,
3233
selectionButton: false,
3334
zoomType: 'level',
@@ -261,6 +262,7 @@ export default defineComponent({
261262
<strong>Display</strong>
262263
</v-expansion-panel-title>
263264
<v-expansion-panel-text>
265+
<v-switch v-model="localData.display.autoOpenSideBar" label="Auto Open Sidebar" />
264266
<v-expansion-panels>
265267
<v-expansion-panel>
266268
<v-expansion-panel-title>

client/src/map/mapVectorLayers.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { calculateColors } from './mapColors';
99
import { updateProps } from './mapProperties';
1010
import { getLayerDefaultFilter, updateFilters } from './mapFilters';
1111
import { subLayerMapping, updateHeatmap } from './mapHeatmap';
12+
import { getVectorLayerDisplayConfig } from '../utils';
1213

1314
const addedLayers: Ref<VectorMapLayer[]> = ref([]);
1415
const defaultAnnotationColor = 'black';
@@ -293,6 +294,13 @@ const toggleVectorMapLayers = (map: maplibregl.Map) => {
293294
if (MapStore.visibleMapLayers.value.has(`${layer.type}_${layer.id}`)) {
294295
// eslint-disable-next-line @typescript-eslint/no-use-before-define
295296
updateVectorLayer(layer);
297+
if (layer?.default_style.searchableVectorFeatureData) {
298+
if (layer.default_style.searchableVectorFeatureData.display.autoOpenSideBar) {
299+
if (MapStore.activeSideBarCard.value !== 'searchableVectors') {
300+
MapStore.toggleContext('searchableVectors');
301+
}
302+
}
303+
}
296304
}
297305
});
298306
};

client/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -862,6 +862,7 @@ export interface SearchableVectorData {
862862
mainTextSearchFields?: { title: string, value: string }[];
863863
configurableFilters: string[]; // Keys for searchable vector features
864864
display: {
865+
autoOpenSideBar: boolean;
865866
geospatialFilterEnabled: boolean; // Filter results based on map display as well
866867
sortable: boolean; // Ability to sort items by something other than the name of the titleKey field.
867868
titleKey: string; // key of property to display

client/src/views/HomePage.vue

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,13 @@ export default defineComponent({
7676
7777
const toggleVectorFeatureSearch = () => {
7878
if (MapStore.mapLayerVectorSearchable.value.length) {
79-
MapStore.mapLayerSearchableEnabled.value = !MapStore.mapLayerSearchableEnabled.value;
8079
MapStore.toggleContext('searchableVectors');
8180
}
8281
};
8382
8483
const chartView = computed(() => MapStore.activeSideBarCard.value === 'charts');
8584
const toggleChartView = () => {
8685
MapStore.toggleContext('charts');
87-
MapStore.chartsOpen.value = MapStore.sideBarCardSettings.value.charts.enabled;
8886
};
8987
9088
const osmBaseMapType = computed(() => {
@@ -102,6 +100,16 @@ export default defineComponent({
102100
return '20px';
103101
});
104102
103+
const SideBarHasData = computed(() => {
104+
if (MapStore.activeSideBarCard.value === 'searchableVectors') {
105+
return !!MapStore.mapLayerVectorSearchable.value.length;
106+
}
107+
if (MapStore.activeSideBarCard.value === 'charts') {
108+
return true;
109+
}
110+
return false;
111+
});
112+
105113
return {
106114
oauthClient,
107115
loginText,
@@ -129,11 +137,11 @@ export default defineComponent({
129137
mapLayerVectorSearch: MapStore.mapLayerVectorSearchable,
130138
hasVectorFeatureSearch,
131139
toggleVectorFeatureSearch,
132-
mapLayerVectorSearchEnabled: MapStore.mapLayerSearchableEnabled,
133140
sideBarWidth: MapStore.currentSideBarWidth,
134141
sideBarOpen: MapStore.sideBarOpen,
135142
activeSideBar: MapStore.activeSideBarCard,
136143
rightSideBarPadding,
144+
SideBarHasData,
137145
};
138146
},
139147
});
@@ -232,7 +240,7 @@ export default defineComponent({
232240
v-bind="props"
233241
class="mx-2"
234242
size="30"
235-
:color="mapLayerVectorSearchEnabled ? 'primary' : ''"
243+
:color="activeSideBar === 'searchableVectors' ? 'primary' : ''"
236244
@click="toggleVectorFeatureSearch()"
237245
>
238246
mdi-map-search-outline
@@ -302,10 +310,10 @@ export default defineComponent({
302310
</v-col>
303311
</v-row>
304312
<selected-feature-list />
305-
<v-navigation-drawer :model-value="sideBarOpen" location="right" :width="sideBarWidth" permanent>
313+
<v-navigation-drawer v-if="SideBarHasData" :model-value="sideBarOpen" location="right" :width="sideBarWidth" permanent>
306314
<indicator-filterable-list v-if="activeSideBar === 'indicators'" :indicators="indicators" />
307315
<charts v-if="activeSideBar === 'charts'" />
308-
<VectorFeatureSearch v-if="activeSideBar === 'searchableVectors'" />
316+
<VectorFeatureSearch v-if="mapLayerVectorSearch.length && activeSideBar === 'searchableVectors'" />
309317
</v-navigation-drawer>
310318
<MapLegend class="static-map-legend" :style="`right: ${rightSideBarPadding};transition: all 0.2s ease`" />
311319
</v-container>

0 commit comments

Comments
 (0)