From b2d824b412e6bbf9b4867ed13f49a433af7c26c7 Mon Sep 17 00:00:00 2001 From: zaultavangar Date: Sun, 17 Dec 2023 22:33:08 -0500 Subject: fixing some bugs with MapBox and MapAnchorMenu --- src/client/views/nodes/MapBox/MapAnchorMenu.tsx | 236 ++++++++++++++++-------- 1 file changed, 159 insertions(+), 77 deletions(-) (limited to 'src/client/views/nodes/MapBox/MapAnchorMenu.tsx') diff --git a/src/client/views/nodes/MapBox/MapAnchorMenu.tsx b/src/client/views/nodes/MapBox/MapAnchorMenu.tsx index b1fb3368c..1b1b74e7c 100644 --- a/src/client/views/nodes/MapBox/MapAnchorMenu.tsx +++ b/src/client/views/nodes/MapBox/MapAnchorMenu.tsx @@ -20,6 +20,7 @@ import { List } from '../../../../fields/List'; import { MarkerIcons } from './MarkerIcons'; import { CirclePicker, ColorResult } from 'react-color'; import { Position } from 'geojson'; +import { CalendarManager } from '../../../util/CalendarManager'; type MapAnchorMenuType = 'standard' | 'routeCreation' | 'calendar' | 'customize' | 'route'; @@ -45,13 +46,15 @@ export class MapAnchorMenu extends AntimodeMenu { public IsTargetToggler: () => boolean = returnFalse; public DisplayRoute: (routeInfoMap: Record | undefined, type: TransportationType) => void = unimplementedFunction; - public HideRoute: () => void = unimplementedFunction; public AddNewRouteToMap: (coordinates: Position[], origin: string, destination: any, createPinForDestination: boolean) => void = unimplementedFunction; public CreatePin: (feature: any) => void = unimplementedFunction; public UpdateMarkerColor: (color: string) => void = unimplementedFunction; public UpdateMarkerIcon: (iconKey: string) => void = unimplementedFunction; + + public Hide: () => void = unimplementedFunction; + public OpenAnimationPanel: (routeDoc: Doc | undefined) => void = unimplementedFunction; @observable @@ -70,14 +73,31 @@ export class MapAnchorMenu extends AntimodeMenu { private title: string | undefined = undefined; - public setPinDoc(pinDoc: Doc) { - this.pinDoc = pinDoc; - this.title = StrCast(pinDoc.title ? pinDoc.title : `${NumCast(pinDoc.longitude)}, ${NumCast(pinDoc.latitude)}`); + public setPinDoc(pinDoc: Doc | undefined) { + if (pinDoc){ + this.pinDoc = pinDoc; + this.title = StrCast(pinDoc.title ? pinDoc.title : `${NumCast(pinDoc.longitude)}, ${NumCast(pinDoc.latitude)}`); + } + } - public setRouteDoc(routeDoc: Doc) { - this.routeDoc = routeDoc; - this.title = StrCast(routeDoc.title ?? 'Map route'); + public setRouteDoc(routeDoc: Doc | undefined) { + if (routeDoc){ + this.routeDoc = routeDoc; + this.title = StrCast(routeDoc.title ?? 'Map route'); + } + } + + @action + public Reset(){ + this.destinationSelected = false; + this.currentRouteInfoMap = undefined; + this.destinationFeatures = []; + this.selectedDestinationFeature = undefined; + this.allMapPinDocs = []; + this.title = undefined; + this.routeDoc = undefined; + this.pinDoc = undefined; } public setAllMapboxPins(pinDocs: Doc[]) { @@ -263,7 +283,6 @@ export class MapAnchorMenu extends AntimodeMenu { console.log(coordinates); console.log(this.selectedDestinationFeature); this.AddNewRouteToMap(coordinates, this.title ?? '', this.selectedDestinationFeature, this.createPinForDestination); - this.HideRoute(); } }; @@ -277,86 +296,155 @@ export class MapAnchorMenu extends AntimodeMenu { return undefined; }; + getDirectionsButton: JSX.Element = ( + } + color={SettingsManager.userColor} /> + ) + + getAddToCalendarButton = (docType: string): JSX.Element => { + return ( + { + CalendarManager.Instance.open(undefined, docType === 'pin' ? this.pinDoc : this.routeDoc) + }} + icon={} + color={SettingsManager.userColor} + /> + ) + + } + addToCalendarButton: JSX.Element = ( + CalendarManager.Instance.open(undefined, this.pinDoc)} + icon={} + color={SettingsManager.userColor} /> + ) + + getLinkNoteToDocButton = (docType: string): JSX.Element => { + return ( +
+ } + color={SettingsManager.userColor} + /> +
+ ) + } + + linkNoteToPinOrRoutenButton: JSX.Element = ( +
+ } + color={SettingsManager.userColor} + /> +
+ ) + + customizePinButton: JSX.Element = ( + } + color={SettingsManager.userColor} + /> + ) + + centerOnPinButton: JSX.Element = ( + } + color={SettingsManager.userColor} + /> + ) + + backButton: JSX.Element = ( + } + color={SettingsManager.userColor} + /> + ) + + addRouteButton: JSX.Element = ( + } + color={SettingsManager.userColor} + /> + ) + + getDeleteButton = (type: string) => { + return ( + } + color={SettingsManager.userColor} + /> + ) + } + + animateRouteButton: JSX.Element = ( + this.OpenAnimationPanel(this.routeDoc)} + icon={} + color={SettingsManager.userColor} + /> + ) + + revertToOriginalMarkerButton = ( + this.revertToOriginalMarker()} + icon={} + color={SettingsManager.userColor} + /> + ) + render() { const buttons = (
{this.menuType === 'standard' && ( <> - } - color={SettingsManager.userColor} - /> - } color={SettingsManager.userColor} /> - } color={SettingsManager.userColor} /> -
- } - color={SettingsManager.userColor} - /> -
- } color={SettingsManager.userColor} /> - } - color={SettingsManager.userColor} - /> + {this.getDeleteButton('pin')} + {this.getDirectionsButton} + {this.getAddToCalendarButton('pin')} + {this.getLinkNoteToDocButton('pin')} + {this.customizePinButton} + {this.centerOnPinButton} )} {this.menuType === 'routeCreation' && ( <> - } - color={SettingsManager.userColor} - /> - } - color={SettingsManager.userColor} - /> + {this.backButton} + {this.addRouteButton} )} {this.menuType === 'route' && ( <> - } - color={SettingsManager.userColor} - /> - this.OpenAnimationPanel(this.routeDoc)} /**TODO: fix */ icon={} color={SettingsManager.userColor} /> -
- } - color={SettingsManager.userColor} - /> -
- } color={SettingsManager.userColor} /> + {this.getDeleteButton('route')} + {this.animateRouteButton} + {this.getAddToCalendarButton('route')} + {this.getLinkNoteToDocButton('route')} )} {this.menuType === 'customize' && ( <> - } - color={SettingsManager.userColor} - /> - this.revertToOriginalMarker()} - icon={} - color={SettingsManager.userColor} - /> + {this.backButton} + {this.revertToOriginalMarkerButton} )} @@ -373,12 +461,6 @@ export class MapAnchorMenu extends AntimodeMenu { )} */}
); - // return ( - //
- // HELLO THIS IS ANCHOR MENU - // {this.getElement(buttons)} - //
- // ) return this.getElement(
-- cgit v1.2.3-70-g09d2