From 14c57f0f70799ada841a03a150f4f759578fa69b Mon Sep 17 00:00:00 2001
From: Eric <ericmabr@gmail.com>
Date: Thu, 15 Jun 2023 13:33:30 -0400
Subject: added pushpin selected icon chagne

---
 src/client/views/SidebarAnnos.tsx | 3 +++
 1 file changed, 3 insertions(+)

(limited to 'src/client/views/SidebarAnnos.tsx')

diff --git a/src/client/views/SidebarAnnos.tsx b/src/client/views/SidebarAnnos.tsx
index 741e87644..42993bfc4 100644
--- a/src/client/views/SidebarAnnos.tsx
+++ b/src/client/views/SidebarAnnos.tsx
@@ -219,7 +219,10 @@ export class SidebarAnnos extends React.Component<FieldViewProps & ExtraProps> {
                     {Array.from(this.allMetadata.keys())
                         .sort()
                         .map(key => renderMeta(key, this.allMetadata.get(key)))}
+                    Hello
                 </div>
+
+
                 <div style={{ width: '100%', height: `calc(100% - 38px)`, position: 'relative' }}>
                     <CollectionStackingView
                         {...this.props}
-- 
cgit v1.2.3-70-g09d2


From 6a85c8d4115a968f563369516d38549745e76303 Mon Sep 17 00:00:00 2001
From: Eric <ericmabr@gmail.com>
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/client/views/SidebarAnnos.tsx')

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<FieldViewProps & ExtraProps> {
                 <div className="sidebarAnnos-tagList" style={{ height: this.filtersHeight() }} onWheel={e => 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)))} */}
                 </div>
 
 
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<AntimodeMenuProps> {
                         <IconButton
                             tooltip="Center on pin" //
                             onPointerDown={this.Center}
-                            icon={<FontAwesomeIcon icon="taxi" />}
+                            icon={<FontAwesomeIcon icon="compress-arrows-alt" />}
                             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<ViewBoxAnnotatableProps
         this.layoutDoc._width = this.layoutDoc._layout_showSidebar ? NumCast(this.layoutDoc._width) * 1.2 : Math.max(20, NumCast(this.layoutDoc._width) - prevWidth);
     };
 
-    createNoteAnnotation = () => {
+    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<ViewBoxAnnotatableProps
      * Creates Pushpin doc and adds it to the list of annotations
      */
     @action
-    createPushpin = (latitude: number, longitude: number) => {
+    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<ViewBoxAnnotatableProps
         this.addDocument(mapMarker, this.annotationKey);
 
         // mapMarker.infoWindowOpen = true;
-    };
+    },"createpin");
 
     /*
      * Pushpin dblclick
@@ -519,6 +526,10 @@ export class MapBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps
     @action
     deselectPin = () => {
         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<ViewBoxAnnotatableProps
             this.map_docToPinMap.set(temp, newpin);
             this.selectedPin = undefined;
 
-            // setTimeout(() => this._sidebarRef.current?.makeDocUnfiltered(this._sidebarRef.current.));
+            
         }
+        
     };
 
+    getView = async (doc: Doc) => {
+        if (this._sidebarRef?.current?.makeDocUnfiltered(doc) && !this.SidebarShown) this.toggleSidebar();
+        return new Promise<Opt<DocumentView>>(res => DocumentManager.Instance.AddViewRenderedCb(doc, dv => res(dv)));
+    };
     /*
      * Pushpin onclick
      */
@@ -539,6 +555,9 @@ export class MapBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps
         this.deselectPin();
         this.selectedPin = pinDoc;
 
+        Doc.setDocFilter(this.rootDoc, "latitude", this.selectedPin.latitude, "match");
+        Doc.setDocFilter(this.rootDoc, "longitude", this.selectedPin.latitude, "match");
+
         this._bingMap.current.entities.remove(this.map_docToPinMap.get(this.selectedPin));
         const newpin = new this.MicrosoftMaps.Pushpin(new this.MicrosoftMaps.Location(this.selectedPin.latitude, this.selectedPin.longitude), {
             color: 'green',
@@ -552,17 +571,16 @@ export class MapBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps
         MapAnchorMenu.Instance.LinkNote = this.createNoteAnnotation;
 
         const point = this._bingMap.current.tryLocationToPixel(new this.MicrosoftMaps.Location(this.selectedPin.latitude, this.selectedPin.longitude));
-        const x = point.x + this.props.PanelWidth() / 2;
+        const x = point.x + (this.props.PanelWidth() - this.sidebarWidth()) / 2;
         const y = point.y + this.props.PanelHeight() / 2 + 32;
         const cpt = this.props.ScreenToLocalTransform().inverse().transformPoint(x, y);
-        MapAnchorMenu.Instance.jumpTo(cpt[0] - (this.sidebarWidth() / this.panelWidth()) * 200, cpt[1], true);
+        MapAnchorMenu.Instance.jumpTo(cpt[0], cpt[1], true);
+
         document.addEventListener('pointerdown', this.tryHideMapAnchorMenu, true);
         this.MicrosoftMaps.Events.addHandler(this._bingMap.current, 'click', this.mapOnClick);
 
         // Filter sidebar:
-        // if sidebar is open, filter.
-        if (this.layoutDoc._layout_showSidebar) {
-        }
+
     };
 
     /**
@@ -573,7 +591,7 @@ export class MapBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps
     }
 
     /**
-     * Map OnClick ~> creates a pushpin
+     * Map OnClick
      */
     @action
     mapOnClick = (e: { location: { latitude: any; longitude: any } }) => {
@@ -700,11 +718,16 @@ export class MapBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps
         this._bingMap.current.entities.remove(this.map_docToPinMap.get(pinDoc));
         this.map_docToPinMap.delete(pinDoc);
         this.selectedPin = undefined;
+
     };
 
     @action
     deleteSelectedPin = undoable(() => {
         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


From 2c46608d3207a8463907b0e1904d9b3026d6d1c8 Mon Sep 17 00:00:00 2001
From: Eric <ericmabr@gmail.com>
Date: Sat, 26 Aug 2023 12:33:47 -0400
Subject: Final1

---
 src/client/util/DocumentManager.ts        |  2 +-
 src/client/views/SidebarAnnos.tsx         |  1 +
 src/client/views/nodes/MapBox/MapBox.tsx  | 77 ++++++++++++++++++++++++++-----
 src/client/views/nodes/trails/PresBox.tsx |  4 +-
 4 files changed, 70 insertions(+), 14 deletions(-)

(limited to 'src/client/views/SidebarAnnos.tsx')

diff --git a/src/client/util/DocumentManager.ts b/src/client/util/DocumentManager.ts
index 7c3b5be05..5b627c2f3 100644
--- a/src/client/util/DocumentManager.ts
+++ b/src/client/util/DocumentManager.ts
@@ -310,7 +310,7 @@ export class DocumentManager {
         if (viewSpec && docView) {
             if (docView.ComponentView instanceof FormattedTextBox) docView.ComponentView?.focus(viewSpec, options);
             PresBox.restoreTargetDocView(docView, viewSpec, options.zoomTime ?? 500);
-            Doc.linkFollowHighlight(docView.rootDoc, undefined, options.effect);
+            Doc.linkFollowHighlight(viewSpec ? [docView.rootDoc, viewSpec]: docView.rootDoc, undefined, options.effect);
             if (options.playAudio) DocumentManager.playAudioAnno(docView.rootDoc);
             if (options.toggleTarget && (!options.didMove || docView.rootDoc.hidden)) docView.rootDoc.hidden = !docView.rootDoc.hidden;
             if (options.effect) docView.rootDoc[Animation] = options.effect;
diff --git a/src/client/views/SidebarAnnos.tsx b/src/client/views/SidebarAnnos.tsx
index 7635d719e..520485a71 100644
--- a/src/client/views/SidebarAnnos.tsx
+++ b/src/client/views/SidebarAnnos.tsx
@@ -87,6 +87,7 @@ export class SidebarAnnos extends React.Component<FieldViewProps & ExtraProps> {
 
         const taggedContent = this.childFilters()
             .filter(data => data.split(':')[0])
+            .filter(data => data.split(':')[0] !== 'latitude' && data.split(':')[0] !== 'longitude')
             .map(data => {
                 const key = data.split(':')[0];
                 const val = Field.Copy(this.allMetadata.get(key));
diff --git a/src/client/views/nodes/MapBox/MapBox.tsx b/src/client/views/nodes/MapBox/MapBox.tsx
index dbb38e763..93020354d 100644
--- a/src/client/views/nodes/MapBox/MapBox.tsx
+++ b/src/client/views/nodes/MapBox/MapBox.tsx
@@ -7,7 +7,7 @@ import { observer } from 'mobx-react';
 import * as React from 'react';
 import { TbHeartMinus } from 'react-icons/tb';
 import { Doc, DocListCast, Opt } from '../../../../fields/Doc';
-import { Width } from '../../../../fields/DocSymbols';
+import { Highlight, Width } from '../../../../fields/DocSymbols';
 import { Id } from '../../../../fields/FieldSymbols';
 import { InkTool } from '../../../../fields/InkField';
 import { ScriptField } from '../../../../fields/ScriptField';
@@ -133,6 +133,7 @@ export class MapBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps
     }
 
     componentWillUnmount(): void {
+        this.deselectPin();
         Object.keys(this._disposer).forEach(key => this._disposer[key]?.());
     }
     // iterate allMarkers to size, center, and zoom map to contain all markers
@@ -353,17 +354,18 @@ export class MapBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps
         this.layoutDoc._width = this.layoutDoc._layout_showSidebar ? NumCast(this.layoutDoc._width) * 1.2 : Math.max(20, NumCast(this.layoutDoc._width) - prevWidth);
     };
 
-    createNoteAnnotation = undoable(() => {
+    createNoteAnnotation = () => {
         !this.layoutDoc.layout_showSidebar && this.toggleSidebar();
-        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");
 
+        setTimeout(undoable(() => {
+            const note = this._sidebarRef.current?.anchorMenuClick(this.getAnchor(false));
+            if (note && this.selectedPin) {
+              note.latitude = this.selectedPin.latitude;
+              note.longitude = this.selectedPin.latitude;
+            }
+          },"create note annotation"))
+    
+    }
     sidebarDown = (e: React.PointerEvent) => {
         setupMoveUpEvents(this, e, this.sidebarMove, emptyFunction, () => setTimeout(this.toggleSidebar), true);
     };
@@ -818,7 +820,60 @@ export class MapBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps
         }
         this.MicrosoftMaps.Events.addHandler(this._bingMap.current, 'viewchangeend', undoable(this.updateLayout, 'Map Layout Change'));
         this.MicrosoftMaps.Events.addHandler(this._bingMap.current, 'maptypechanged', undoable(this.updateMapType, 'Map ViewType Change'));
-        // this.updateLayout();
+        this.updateLayout();
+        this._disposer.highlight = reaction( () => this.allMapPushpins.map(doc => doc[Highlight]),
+        () => this.allMapPushpins.forEach(doc => {
+
+            // if(doc[Highlight]){
+            //     this.deselectPin();
+            //     this.selectedPin = doc;
+
+            //     Doc.setDocFilter(this.rootDoc, "latitude", this.selectedPin.latitude, "match");
+            //     Doc.setDocFilter(this.rootDoc, "longitude", this.selectedPin.latitude, "match");
+
+            //     this._bingMap.current.entities.remove(this.map_docToPinMap.get(this.selectedPin));
+            //     const newpin = new this.MicrosoftMaps.Pushpin(new this.MicrosoftMaps.Location(this.selectedPin.latitude, this.selectedPin.longitude), {
+            //         color: 'green',
+            //     });
+            //     this.MicrosoftMaps.Events.addHandler(newpin, 'click', (e: any) => this.pushpinClicked(this.selectedPin as Doc));
+            //     this._bingMap.current.entities.push(newpin);
+            //     this.map_docToPinMap.set(this.selectedPin, newpin);
+
+            //     MapAnchorMenu.Instance.Delete = this.deleteSelectedPin;
+            //     MapAnchorMenu.Instance.Center = this.centerOnSelectedPin;
+            //     MapAnchorMenu.Instance.LinkNote = this.createNoteAnnotation;
+            // }
+            // if (doc[Highlight]) {
+            //     this._bingMap.current.entities.remove(this.map_docToPinMap.get(doc));
+            //     const newpin = new this.MicrosoftMaps.Pushpin(new this.MicrosoftMaps.Location(doc.latitude, doc.longitude), {
+            //         color: 'orange',
+            //     });
+            //     this.MicrosoftMaps.Events.addHandler(newpin, 'click', (e: any) => this.pushpinClicked(doc));
+            //     this._bingMap.current.entities.push(newpin);
+            //     this.map_docToPinMap.set(doc, newpin);
+
+            // } 
+            // if (this.map_docToPinMap.get(doc).getColor() == 'orange' && !doc[Highlight]) {
+            //     this._bingMap.current.entities.remove(this.map_docToPinMap.get(doc));
+            //     const newpin = new this.MicrosoftMaps.Pushpin(new this.MicrosoftMaps.Location(doc.latitude, doc.longitude), {});
+            //     this.MicrosoftMaps.Events.addHandler(newpin, 'click', (e: any) => this.pushpinClicked(doc));
+            //     this._bingMap.current.entities.push(newpin);
+            //     this.map_docToPinMap.set(doc, newpin);
+
+            // } 
+            // else if (this.map_docToPinMap.get(doc).getColor() != 'orange' && doc[Highlight]) {
+            //     this._bingMap.current.entities.remove(this.map_docToPinMap.get(doc));
+            //     const newpin = new this.MicrosoftMaps.Pushpin(new this.MicrosoftMaps.Location(doc.latitude, doc.longitude), {
+            //         color: 'orange',
+            //     });
+            //     this.MicrosoftMaps.Events.addHandler(newpin, 'click', (e: any) => this.pushpinClicked(doc));
+            //     this._bingMap.current.entities.push(newpin);
+            //     this.map_docToPinMap.set(doc, newpin);
+            // }
+
+            
+        })
+        , {fireImmediately: true})
         // this.updateMapType();
         this._disposer.location = reaction(
             () => ({ lat: this.rootDoc.latitude, lng: this.rootDoc.longitude, zoom: this.rootDoc.mapZoom, mapType: this.rootDoc.mapType }),
diff --git a/src/client/views/nodes/trails/PresBox.tsx b/src/client/views/nodes/trails/PresBox.tsx
index a94f1f04b..afd9bccab 100644
--- a/src/client/views/nodes/trails/PresBox.tsx
+++ b/src/client/views/nodes/trails/PresBox.tsx
@@ -661,8 +661,8 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
                 pinDoc.config_yRange = undefined; //targetDoc?.yrange;
             }
             if (pinProps.pinData.map) {
-                pinDoc.config_latitude = targetDoc?.latitude;
-                pinDoc.config_longitude = targetDoc?.longitude;
+                // pinDoc.config_latitude = targetDoc?.latitude;
+                // pinDoc.config_longitude = targetDoc?.longitude;
                 pinDoc.config_mapZoom = targetDoc?.mapZoom;
                 pinDoc.config_mapType = targetDoc?.mapType;
                 //...
-- 
cgit v1.2.3-70-g09d2

