| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | import BaseContextMenu from './baseContextMenu/BaseContextMenu.js'; |
| 26 | import MenuItem from './baseContextMenu/MenuItem.js'; |
| 27 | import theNoteEditor from '../core/NoteEditor.js'; |
| 28 | import Zoomer from '../core/Zoomer.js'; |
| 29 | import theTranslator from '../core/uiLib/Translator.js'; |
| 30 | import theWayPointEditor from '../core/WayPointEditor.js'; |
| 31 | import theTravelNotesData from '../data/TravelNotesData.js'; |
| 32 | import PoiData from '../containers/PoiData.js'; |
| 33 | import theEventDispatcher from '../core/lib/EventDispatcher.js'; |
| 34 | import { LAT_LNG, INVALID_OBJ_ID } from '../main/Constants.js'; |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | class OsmSearchContextMenu extends BaseContextMenu { |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | #osmElement; |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | #latLng; |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | constructor ( contextMenuEvent, parentNode ) { |
| 65 | super ( contextMenuEvent, parentNode ); |
| 66 | this.#osmElement = |
| 67 | theTravelNotesData.searchData [ Number.parseInt ( contextMenuEvent.currentTarget.dataset.tanElementIndex ) ]; |
| 68 | this.#latLng = [ this.#osmElement.lat, this.#osmElement.lon ]; |
| 69 | theEventDispatcher.dispatch ( 'removeobject', { objId : this.targetObjId } ); |
| 70 | } |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | get menuItems ( ) { |
| 78 | return [ |
| 79 | new MenuItem ( |
| 80 | theTranslator.getText ( 'OsmSearchContextMenu - Select this point as start point' ), |
| 81 | ( INVALID_OBJ_ID !== theTravelNotesData.editedRouteObjId ) |
| 82 | && |
| 83 | ( LAT_LNG.defaultValue === theTravelNotesData.travel.editedRoute.wayPoints.first.lat ), |
| 84 | ( ) => theWayPointEditor.setStartPoint ( this.#latLng ) |
| 85 | ), |
| 86 | new MenuItem ( |
| 87 | theTranslator.getText ( 'OsmSearchContextMenu - Select this point as way point' ), |
| 88 | INVALID_OBJ_ID !== theTravelNotesData.editedRouteObjId, |
| 89 | ( ) => theWayPointEditor.addWayPoint ( this.#latLng ) |
| 90 | ), |
| 91 | new MenuItem ( |
| 92 | theTranslator.getText ( 'OsmSearchContextMenu - Select this point as end point' ), |
| 93 | ( INVALID_OBJ_ID !== theTravelNotesData.editedRouteObjId ) |
| 94 | && |
| 95 | ( LAT_LNG.defaultValue === theTravelNotesData.travel.editedRoute.wayPoints.last.lat ), |
| 96 | ( ) => theWayPointEditor.setEndPoint ( this.#latLng ) |
| 97 | ), |
| 98 | new MenuItem ( |
| 99 | theTranslator.getText ( 'OsmSearchContextMenu - Create a route note with this result' ), |
| 100 | true, |
| 101 | ( ) => theNoteEditor.newSearchRouteNote ( this.#osmElement ) |
| 102 | ), |
| 103 | new MenuItem ( |
| 104 | theTranslator.getText ( 'OsmSearchContextMenu - Create a travel note with this result' ), |
| 105 | true, |
| 106 | ( ) => theNoteEditor.newSearchTravelNote ( this.#osmElement ) |
| 107 | ), |
| 108 | new MenuItem ( |
| 109 | theTranslator.getText ( |
| 110 | theNoteEditor.osmSearchNoteDialog |
| 111 | ? |
| 112 | 'OsmSearchContextMenu - Hide note dialog' |
| 113 | : |
| 114 | 'OsmSearchContextMenu - Show note dialog' |
| 115 | ), |
| 116 | true, |
| 117 | ( ) => theNoteEditor.changeOsmSearchNoteDialog ( ) |
| 118 | ), |
| 119 | new MenuItem ( |
| 120 | theTranslator.getText ( 'OsmSearchContextMenu - Zoom to this result' ), |
| 121 | true, |
| 122 | ( ) => new Zoomer ( ).zoomToPoi ( new PoiData ( this.#latLng, this.#osmElement.geometry ) ) |
| 123 | ) |
| 124 | ]; |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | export default OsmSearchContextMenu; |
| 129 | |
| 130 | |
| 131 | |