Show “Use as” menu also for normal markers (fixes #75)

pull/108/head
Candid Dauth 2017-05-17 19:33:28 +02:00
rodzic 4c09d0168e
commit e2d9d27342
3 zmienionych plików z 28 dodań i 12 usunięć

Wyświetl plik

@ -62,8 +62,8 @@ fm.app.factory("fmMapMarkers", function($uibModal, fmUtils, $compile, $timeout,
showMarkerInfoBox: function(marker) {
var scope = $rootScope.$new();
scope.map = map;
scope.client = map.client;
scope.marker = marker;
scope.edit = function() {
@ -78,6 +78,10 @@ fm.app.factory("fmMapMarkers", function($uibModal, fmUtils, $compile, $timeout,
markersUi.deleteMarker(scope.marker);
};
scope.useForRoute = function(mode) {
map.searchUi.setRouteDestination(`${marker.lat},${marker.lon}`, mode);
};
openMarker = {
hide: map.infoBox.show(require("./view-marker.html"), scope, () => {
openMarker = null;

Wyświetl plik

@ -15,4 +15,12 @@
<button type="button" class="btn btn-default btn-sm" ng-click="edit()">Edit</button>
<button type="button" class="btn btn-default btn-sm" ng-click="move()">Move</button>
<button type="button" class="btn btn-default btn-sm" ng-click="confirm('Do you really want to remove the marker “' + marker.name + '”?') && delete()">Remove</button>
<div ng-if="map.searchUi" uib-dropdown keyboard-nav="true" class="dropup">
<button type="button" class="btn btn-default btn-sm" uib-dropdown-toggle>Use as <span class="caret"></span></button>
<ul class="dropdown-menu" uib-dropdown-menu role="menu">
<li role="menuitem"><a href="javascript:" ng-click="useForRoute(1)">Route start</a></li>
<li role="menuitem"><a href="javascript:" ng-click="useForRoute(2)">Route via</a></li>
<li role="menuitem"><a href="javascript:" ng-click="useForRoute(3)">Route destination</a></li>
</ul>
</div>
</div>

Wyświetl plik

@ -329,17 +329,7 @@ fm.app.factory("fmSearchQuery", function($rootScope, $compile, fmUtils, $timeout
};
popupScope.useForRoute = function(mode) {
searchUi.hide();
routeUi.show();
if(mode == 1)
routeUi.setFrom(query, results, result);
else if(mode == 2)
routeUi.addVia(query, results, result);
else if(mode == 3)
routeUi.setTo(query, results, result);
routeUi.submit(!!routeUi.getQueries());
searchUi.setRouteDestination(query, mode, results, result);
};
currentInfoBox = map.infoBox.show(require("./result-popup.html"), popupScope, () => {
@ -391,6 +381,20 @@ fm.app.factory("fmSearchQuery", function($rootScope, $compile, fmUtils, $timeout
routeUi.submit(noZoom);
},
setRouteDestination: function(query, mode, _results, _result) {
map.searchUi.hide();
routeUi.show();
if(mode == 1)
routeUi.setFrom(query, _results, _result);
else if(mode == 2)
routeUi.addVia(query, _results, _result);
else if(mode == 3)
routeUi.setTo(query, _results, _result);
routeUi.submit(!!routeUi.getQueries());
},
getCurrentSearchForHash: function() {
if(searchUi._el.is(":visible")) {
if(((scope.searchResults && scope.searchResults.features.length == 1) || !scope.showAll) && scope.activeResult && scope.activeResult.id)