improved OSM Element selection

This commit is contained in:
PxlLoewe
2025-06-03 15:50:20 -07:00
parent 56856664a7
commit 0f50bf1db8
10 changed files with 118 additions and 154 deletions

View File

@@ -15,10 +15,7 @@ export interface MapStore {
id: number;
tab: "home" | "details" | "patient" | "log";
}[];
setOpenMissionMarker: (mission: {
open: MapStore["openMissionMarker"];
close: number[];
}) => void;
setOpenMissionMarker: (mission: { open: MapStore["openMissionMarker"]; close: number[] }) => void;
openAircraftMarker: {
id: number;
tab: "home" | "fms" | "aircraft" | "mission" | "chat";
@@ -29,6 +26,7 @@ export interface MapStore {
}) => void;
searchElements: OSMWay[];
setSearchElements: (elements: MapStore["searchElements"]) => void;
toggleSearchElementSelection: (elementId: number) => void;
setContextMenu: (popup: MapStore["contextMenu"]) => void;
searchPopup: {
lat: number;
@@ -39,10 +37,7 @@ export interface MapStore {
aircraftTabs: {
[aircraftId: string]: "home" | "fms" | "aircraft" | "mission" | "chat";
};
setAircraftTab: (
aircraftId: number,
tab: MapStore["aircraftTabs"][number],
) => void;
setAircraftTab: (aircraftId: number, tab: MapStore["aircraftTabs"][number]) => void;
}
export const useMapStore = create<MapStore>((set, get) => ({
@@ -88,6 +83,15 @@ export const useMapStore = create<MapStore>((set, get) => ({
set(() => ({
searchElements: elements,
})),
toggleSearchElementSelection: (elementId) => {
const searchElements = get().searchElements;
const element = searchElements.find((e) => e.wayID === elementId);
if (!element) return;
element.isSelected = !element.isSelected;
set(() => ({
searchElements: [...searchElements],
}));
},
aircraftTabs: {},
setAircraftTab: (aircraftId, tab) =>
set((state) => ({