Handle empty route destinations properly

pull/54/merge
Candid Dauth 2016-11-20 20:48:07 +03:00
rodzic b3f9755389
commit ca1e8745b8
1 zmienionych plików z 10 dodań i 2 usunięć

Wyświetl plik

@ -44,7 +44,10 @@
if(destination.suggestionQuery == destination.query)
return $q.resolve();
if(destination.query.trim() != "") {
if(destination.query.trim() == "") {
destination.suggestions = [ ];
destination.suggestionQuery = destination.query;
} else {
var query = destination.query;
return map.socket.emit("find", { query: query }).then(function(results) {
@ -64,11 +67,16 @@
if(!dragging)
scope.reset();
if(scope.destinations[0].query.trim() == "" || scope.destinations[scope.destinations.length-1].query.trim() == "")
return;
var points;
var mode = scope.routeMode;
return $q.all(scope.destinations.map(scope.loadSuggestions)).then(function() {
points = scope.destinations.map(function(destination) {
points = scope.destinations.filter(function(destination) {
return destination.query.trim() != "";
}).map(function(destination) {
if(destination.suggestions.length == 0)
throw "No place has been found for search term “" + destination.query + "”.";