From 6a85c8d4115a968f563369516d38549745e76303 Mon Sep 17 00:00:00 2001 From: Eric Date: Thu, 24 Aug 2023 12:47:57 -0400 Subject: All working except createnote undo, and center on selected pin getAnchor --- src/client/views/SidebarAnnos.tsx | 5 ++- src/client/views/nodes/MapBox/MapAnchorMenu.tsx | 2 +- src/client/views/nodes/MapBox/MapBox.tsx | 47 ++++++++++++++++++------- src/fields/Doc.ts | 4 +-- 4 files changed, 40 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/client/views/SidebarAnnos.tsx b/src/client/views/SidebarAnnos.tsx index cd50865fb..7635d719e 100644 --- a/src/client/views/SidebarAnnos.tsx +++ b/src/client/views/SidebarAnnos.tsx @@ -225,10 +225,9 @@ export class SidebarAnnos extends React.Component {
e.stopPropagation()}> {this.allUsers.map(renderUsers)} {this.allHashtags.map(renderTag)} - {Array.from(this.allMetadata.keys()) + {/* {Array.from(this.allMetadata.keys()) .sort() - .map(key => renderMeta(key, this.allMetadata.get(key)))} - Hello + .map(key => renderMeta(key, this.allMetadata.get(key)))} */}
diff --git a/src/client/views/nodes/MapBox/MapAnchorMenu.tsx b/src/client/views/nodes/MapBox/MapAnchorMenu.tsx index 439c1f14f..897bb90a6 100644 --- a/src/client/views/nodes/MapBox/MapAnchorMenu.tsx +++ b/src/client/views/nodes/MapBox/MapAnchorMenu.tsx @@ -120,7 +120,7 @@ export class MapAnchorMenu extends AntimodeMenu { } + icon={} color={StrCast(Doc.UserDoc().userColor)} /> )} diff --git a/src/client/views/nodes/MapBox/MapBox.tsx b/src/client/views/nodes/MapBox/MapBox.tsx index 654d446a2..dbb38e763 100644 --- a/src/client/views/nodes/MapBox/MapBox.tsx +++ b/src/client/views/nodes/MapBox/MapBox.tsx @@ -14,6 +14,7 @@ import { ScriptField } from '../../../../fields/ScriptField'; import { NumCast, StrCast } from '../../../../fields/Types'; import { emptyFunction, returnEmptyDoclist, returnEmptyFilter, returnEmptyString, returnFalse, returnOne, setupMoveUpEvents, Utils } from '../../../../Utils'; import { Docs } from '../../../documents/Documents'; +import { DocumentManager } from '../../../util/DocumentManager'; import { DragManager } from '../../../util/DragManager'; import { SnappingManager } from '../../../util/SnappingManager'; import { Transform } from '../../../util/Transform'; @@ -352,10 +353,16 @@ export class MapBox extends ViewBoxAnnotatableComponent { + createNoteAnnotation = undoable(() => { !this.layoutDoc.layout_showSidebar && this.toggleSidebar(); - setTimeout(() => this._sidebarRef.current?.anchorMenuClick(this.getAnchor(false))); // give time for sidebarRef to be created - }; + setTimeout(() =>{ + const note = this._sidebarRef.current?.anchorMenuClick(this.getAnchor(false)); + if (note && this.selectedPin) { + note.latitude = this.selectedPin.latitude; + note.longitude = this.selectedPin.latitude; + } + }); // give time for sidebarRef to be created + }, "create linked note"); sidebarDown = (e: React.PointerEvent) => { setupMoveUpEvents(this, e, this.sidebarMove, emptyFunction, () => setTimeout(this.toggleSidebar), true); @@ -488,7 +495,7 @@ export class MapBox extends ViewBoxAnnotatableComponent { + createPushpin = undoable((latitude: number, longitude: number) => { // Stores the pushpin as a MapMarkerDocument const mapMarker = Docs.Create.PushpinDocument( NumCast(latitude), @@ -501,7 +508,7 @@ export class MapBox extends ViewBoxAnnotatableComponent { if (this.selectedPin) { + // Removes filter + Doc.setDocFilter(this.rootDoc, "latitude", this.selectedPin.latitude, "remove"); + Doc.setDocFilter(this.rootDoc, "longitude", this.selectedPin.longitude, "remove"); + const temp = this.selectedPin; this._bingMap.current.entities.remove(this.map_docToPinMap.get(temp)); const newpin = new this.MicrosoftMaps.Pushpin(new this.MicrosoftMaps.Location(temp.latitude, temp.longitude)); @@ -527,10 +538,15 @@ export class MapBox extends ViewBoxAnnotatableComponent this._sidebarRef.current?.makeDocUnfiltered(this._sidebarRef.current.)); + } + }; + getView = async (doc: Doc) => { + if (this._sidebarRef?.current?.makeDocUnfiltered(doc) && !this.SidebarShown) this.toggleSidebar(); + return new Promise>(res => DocumentManager.Instance.AddViewRenderedCb(doc, dv => res(dv))); + }; /* * Pushpin onclick */ @@ -539,6 +555,9 @@ export class MapBox extends ViewBoxAnnotatableComponent creates a pushpin + * Map OnClick */ @action mapOnClick = (e: { location: { latitude: any; longitude: any } }) => { @@ -700,11 +718,16 @@ export class MapBox extends ViewBoxAnnotatableComponent { if (this.selectedPin) { + // Removes filter + Doc.setDocFilter(this.rootDoc, "latitude", this.selectedPin.latitude, "remove"); + Doc.setDocFilter(this.rootDoc, "longitude", this.selectedPin.longitude, "remove"); + this.removePushpin(this.selectedPin); } MapAnchorMenu.Instance.fadeOut(true); diff --git a/src/fields/Doc.ts b/src/fields/Doc.ts index 6d4f4180d..7ba4f0e6f 100644 --- a/src/fields/Doc.ts +++ b/src/fields/Doc.ts @@ -1490,8 +1490,8 @@ export namespace Doc { runInAction(() => { for (let i = 0; i < childFilters.length; i++) { const fields = childFilters[i].split(FilterSep); // split key:value:modifier - if (fields[0] === key && (fields[1] === value || modifiers === 'match' || (fields[2] === 'match' && modifiers === 'remove'))) { - if (fields[2] === modifiers && modifiers && fields[1] === value) { + if (fields[0] === key && (fields[1] === value.toString() || modifiers === 'match' || (fields[2] === 'match' && modifiers === 'remove'))) { + if (fields[2] === modifiers && modifiers && fields[1] === value.toString()) { if (toggle) modifiers = 'remove'; else return; } -- cgit v1.2.3-70-g09d2