From b8c7648c223128a236a2af875ac0f931e8369683 Mon Sep 17 00:00:00 2001 From: AKalinich-Luxoft Date: Fri, 2 Mar 2018 21:54:20 +0200 Subject: [PATCH] Removed unused places functionality from navi module. Fixed SendLocation hanlders to work with waypoints. Small updates in waypoints logic. --- app/controller/NavigationController.js | 189 ++++--------------------- app/controller/sdl/FuncSwitcher.js | 1 - app/model/NavigationModel.js | 10 -- app/view/navigationView.js | 70 +++------ ffw/NavigationRPC.js | 1 - 5 files changed, 52 insertions(+), 219 deletions(-) diff --git a/app/controller/NavigationController.js b/app/controller/NavigationController.js index 6768bbc61..a86b85f8e 100644 --- a/app/controller/NavigationController.js +++ b/app/controller/NavigationController.js @@ -37,21 +37,6 @@ SDL.NavigationController = Em.Object.create( * Model binding */ modelBinding: 'SDL.NavigationModel', - /** - * POI list switcher method - */ - showPoiList: function() { - if (!this.model.poi && this.model.LocationDetails.length == 0) { - SDL.PopUp.create().appendTo('body').popupActivate( - 'List is empty. Please navigate to some new places!' - ); - return; - } - if (this.model.poi == false && this.model.wp) { - this.model.toggleProperty('wp'); - } - this.model.toggleProperty('poi'); - }, /** * WP list switcher method */ @@ -62,9 +47,6 @@ SDL.NavigationController = Em.Object.create( ); return; } - if (this.model.wp == false && this.model.poi) { - this.model.toggleProperty('poi'); - } this.model.toggleProperty('wp'); }, /** @@ -76,6 +58,8 @@ SDL.NavigationController = Em.Object.create( SDL.NavigationController.startAnimation(); } + SDL.NavigationController.clearRoutes(); + SDL.NavigationController.addPOIMarker( request.params.latitudeDegrees, request.params.longitudeDegrees @@ -193,10 +177,13 @@ SDL.NavigationController = Em.Object.create( SDL.NavigationController.startAnimation(); } + SDL.NavigationController.clearRoutes(); + SDL.NavigationController.addPOIMarker( request.params.latitudeDegrees, request.params.longitudeDegrees ); + SDL.NavigationController.setRoutes(); FFW.Navigation.sendNavigationResult( @@ -217,8 +204,8 @@ SDL.NavigationController = Em.Object.create( var dt = SDL.NavigationController.convertDateTimeStructure(request.params.timeStamp); - var locations = SDL.deepCopy(SDL.NavigationModel.LocationDetails); - var insertInd = SDL.NavigationController.getInsertLocationIndex(locations, dt); + var waypoints = SDL.deepCopy(SDL.NavigationModel.WayPointDetails) + var insertInd = SDL.NavigationController.getInsertLocationIndex(waypoints, dt); var timeStampStuct = SDL.NavigationController.convertDateObject(dt); var location = { coordinate: { @@ -235,11 +222,25 @@ SDL.NavigationController = Em.Object.create( }; if (insertInd >= 0) { - locations.splice(insertInd, 0, location); + waypoints.splice(insertInd, 0, location); } else { - locations.push(location); + waypoints.push(location); + } + SDL.NavigationModel.set('WayPointDetails', waypoints); + + var latlng = new google.maps.LatLng( + request.params.latitudeDegrees, request.params.longitudeDegrees + ); + var marker = new google.maps.Marker({ + position: latlng, + map: SDL.NavigationController.map + }); + SDL.NavigationModel.WayPointMarkers.push(marker); + + if(SDL.NavigationController.isRouteSet){ + SDL.NavigationController.set('isRouteSet', false); + SDL.NavigationController.setRoutes(); } - SDL.NavigationModel.set('LocationDetails', locations); } FFW.Navigation.sendNavigationResult( @@ -277,46 +278,6 @@ SDL.NavigationController = Em.Object.create( } return -1; }, - /** - * Navigation view List Button action handler - * Opens selected WayPoint structure - * - * @param {Object} element - */ - openDestPoint: function(element) { - var itemID = element.itemID; - this.model.set( - 'currentWayPointData', - JSON.stringify(SDL.NavigationModel.LocationDetails[itemID], null, 2) - ); - SDL.NavigationView.codeEditor.activate( - function(data, isDeleted) { - if (isDeleted) { - var location = SDL.NavigationModel.LocationDetails[itemID]; - SDL.NavigationModel.LocationDetails.removeObject(location); - if (SDL.NavigationModel.LocationDetails.length == 0) { - SDL.NavigationModel.set('poi', false); - } - } else { - var locations = SDL.deepCopy(SDL.NavigationModel.LocationDetails); - var old_coords = locations[itemID].coordinate; - var new_location = JSON.parse(data); - locations.splice(itemID, 1); - var dt = - SDL.NavigationController.convertDateTimeStructure(new_location.timeStamp); - var insertInd = - SDL.NavigationController.getInsertLocationIndex(locations, dt); - - if (insertInd >= 0) { - locations.splice(insertInd, 0, new_location); - } else { - locations.push(new_location); - } - SDL.NavigationModel.set('LocationDetails', locations); - } - } - ); - }, /** * Navigation view List Button action handler * Selects current WayPoint @@ -644,8 +605,8 @@ SDL.NavigationController = Em.Object.create( } }, getLocationByCoord: function(lat, lng) { - for (var i = 0; i < this.model.LocationDetails.length; ++i) { - var point = this.model.LocationDetails[i]; + for (var i = 0; i < this.model.WayPointDetails.length; ++i) { + var point = this.model.WayPointDetails[i]; if (point.coordinate.latitudeDegrees == lat && point.coordinate.longitudeDegrees == lng) { return { @@ -702,94 +663,13 @@ SDL.NavigationController = Em.Object.create( ); data.push(wp); SDL.NavigationModel.set("WayPointDetails",data); - this.model.set("wp", true); + + SDL.NavigationModel.selectedLocationMarker.setMap(null); if(SDL.NavigationController.isRouteSet){ + SDL.NavigationController.set('isRouteSet', false); SDL.NavigationController.setRoutes(); } - else{ - SDL.NavigationModel.selectedLocationMarker.setMap(null); - FFW.Navigation.onWayPointChange(SDL.NavigationModel.WayPointDetails); - } - }, - addWaypointLocation: function(latlng) { - var res = SDL.NavigationController.getLocationByCoord( - latlng.lat(), latlng.lng() - ); - - if (res.index >= 0) { - return; - } - - var dt = new Date(); - var location = { - coordinate: { - latitudeDegrees: latlng.lat(), - longitudeDegrees: latlng.lng() - }, - locationName: 'Unknown Location', - addressLines: [], - locationDescription: '', - phoneNumber: '', - locationImage: { - value: '', - imageType: 'DYNAMIC' - }, - searchAddress: { - countryName: '', - countryCode: '', - postalCode: '', - administrativeArea: '', - subAdministrativeArea: '', - locality: '', - subLocality: '', - thoroughfare: '', - subThoroughfare: '' - }, - timeStamp: SDL.NavigationController.convertDateObject(dt) - }; - - var locations = SDL.deepCopy(SDL.NavigationModel.LocationDetails); - var insertInd = SDL.NavigationController.getInsertLocationIndex(locations, dt); - if (insertInd >= 0) { - locations.splice(insertInd, 0, location); - } else { - locations.push(location); - } - SDL.NavigationModel.set('LocationDetails', locations); - - geocoder = new google.maps.Geocoder(); - geocoder.geocode({'location': latlng}, function(results, status) { - if (status === 'OK') { - var res = SDL.NavigationController.getLocationByCoord( - latlng.lat(), latlng.lng() - ); - if (res.index < 0) { - return; - } - if (results[0]) { - res.location.addressLines = [results[0].formatted_address]; - } - if (results[1]) { - res.location.locationName = results[1].formatted_address; - } - - for (i = 0; i < results.length; ++i) { - var item = results[i]; - for (j = 0; j < item.address_components.length; ++j) { - SDL.NavigationController.setLocationInfoFromItem( - item.address_components[j], res.location - ); - } - } - - var locations = SDL.deepCopy(SDL.NavigationModel.LocationDetails); - locations[res.index] = res.location; - SDL.NavigationModel.set('LocationDetails', locations); - } else { - Em.Logger.error('Navigation: Geocoder failed due to: ' + status); - } - }); }, waypointSelected: function() { var data = SDL.NavigationView.codeEditor.content; @@ -959,12 +839,12 @@ SDL.NavigationController = Em.Object.create( if (SDL.NavigationController.isRouteSet == false && SDL.NavigationModel.selectedLocationMarker.getMap() == null) { var markerCounts = SDL.NavigationModel.WayPointMarkers.length; - if(markerCounts == 0){ + if(markerCounts == 0){ SDL.PopUp.create().appendTo('body').popupActivate( 'Error: Destination point is not set. Please select the destination point' ); return false; - }else{ + } else { var marker = SDL.NavigationModel.WayPointMarkers.pop(); SDL.NavigationModel.selectedLocationMarker.setMap(this.map); SDL.NavigationModel.selectedLocationMarker.setPosition(marker.getPosition()); @@ -983,10 +863,6 @@ SDL.NavigationController = Em.Object.create( return; } - SDL.NavigationController.addWaypointLocation( - SDL.NavigationModel.selectedLocationMarker.getPosition() - ); - if (SDL.NavigationController.polyline) { SDL.NavigationController.polyline.setMap(null); } @@ -1105,9 +981,6 @@ SDL.NavigationController = Em.Object.create( SDL.NavigationController.clearRoutes(); return; } - if (this.model.poi) { - this.model.toggleProperty('poi'); - } if (this.model.wp) { this.model.toggleProperty('wp'); } diff --git a/app/controller/sdl/FuncSwitcher.js b/app/controller/sdl/FuncSwitcher.js index dfa8c3bae..b77e0c361 100644 --- a/app/controller/sdl/FuncSwitcher.js +++ b/app/controller/sdl/FuncSwitcher.js @@ -59,7 +59,6 @@ SDL.FuncSwitcher = Em.Object.create( }.property('FLAGS.SimpleFunctionality'), rev: function() { var result = parseInt(FLAGS.SimpleFunctionality) === 1; - SDL.NavigationModel.set('poi', !result); return result; }.property('FLAGS.SimpleFunctionality'), pan: function() { diff --git a/app/model/NavigationModel.js b/app/model/NavigationModel.js index 7d222c980..1bed7f8cc 100644 --- a/app/model/NavigationModel.js +++ b/app/model/NavigationModel.js @@ -44,11 +44,6 @@ SDL.NavigationModel = Em.Object.create({ */ initialLoc: '230 Canal St, New York, NY 10013, USA', - /** - * POI list switcher flag - */ - poi: false, - /** * WP list switcher flag */ @@ -80,11 +75,6 @@ SDL.NavigationModel = Em.Object.create({ */ selectedLocationMarker: null, - /** - * Saved destination points array - */ - LocationDetails: [], - /** * Saved waypoints array */ diff --git a/app/view/navigationView.js b/app/view/navigationView.js index f35cc0302..7ecd5da59 100644 --- a/app/view/navigationView.js +++ b/app/view/navigationView.js @@ -39,7 +39,6 @@ SDL.NavigationView = Em.ContainerView.create( 'SDL.States.navigation.active:active_state:inactive_state' ], childViews: [ - 'POIList', 'WPList', 'codeEditor', 'clearButton', @@ -49,37 +48,6 @@ SDL.NavigationView = Em.ContainerView.create( 'navigate', 'animate' ], - POIList: SDL.List.extend( - { - elementId: 'poiList', //info_apps_list - itemsOnPage: 5, - classNameBindings: ['SDL.NavigationModel.poi::hidden'], - itemsBinding: 'this.itemGenerator', - itemGenerator: function() { - var items = []; - for (var i = 0; i < SDL.NavigationModel.LocationDetails.length; i++) { - var details = SDL.deepCopy(SDL.NavigationModel.LocationDetails[i]); - items.push( - { - type: SDL.Button, - params: { - itemID: i, - className: 'button', - text: details.locationName ? details.locationName : "Unknown location", - disabled: false, - icon: details.locationImage ? details.locationImage.value : null, - templateName: details.locationImage ? '' : 'text', - action: 'openDestPoint', - target: 'SDL.NavigationController' - } - } - ); - } - this.set('disableScrollbar', items.length <= this.itemsOnPage); - return items; - }.property('SDL.NavigationModel.LocationDetails.@each') - } - ), WPList: SDL.List.extend( { elementId: 'wpList', @@ -135,20 +103,20 @@ SDL.NavigationView = Em.ContainerView.create( ), clearButton: SDL.Button.extend( { - isButtonDisabled: function() { - return SDL.NavigationModel.WayPointDetails.length == 0 || - SDL.NavigationController.isAnimateStarted; - }.property('SDL.NavigationModel.WayPointDetails', - 'SDL.NavigationController.isAnimateStarted'), - classNameBindings: 'SDL.FuncSwitcher.rev::is-disabled', - elementId: 'clearButton', - disabledBinding: 'isButtonDisabled', - classNames: 'clearButton button', - text: 'Clear', - action: 'clearRoutes', - target: 'SDL.NavigationController' - } - ), + isButtonDisabled: function() { + return SDL.NavigationModel.WayPointDetails.length == 0 || + SDL.NavigationController.isAnimateStarted; + }.property('SDL.NavigationModel.WayPointDetails', + 'SDL.NavigationController.isAnimateStarted'), + classNameBindings: 'SDL.FuncSwitcher.rev::is-disabled', + elementId: 'clearButton', + disabledBinding: 'isButtonDisabled', + classNames: 'clearButton button', + text: 'Clear', + action: 'clearRoutes', + target: 'SDL.NavigationController' + } + ), WPButton: SDL.Button.extend( { isButtonDisabled: function() { @@ -186,9 +154,13 @@ SDL.NavigationView = Em.ContainerView.create( { classNameBindings: 'SDL.FuncSwitcher.rev::is-disabled', elementId: 'navigationButton', - disabledBinding: Em.Binding.oneWay( - 'SDL.NavigationController.isAnimateStarted' - ), + getDisabled: function() { + return SDL.NavigationController.isRouteSet || + SDL.NavigationController.isAnimateStarted; + } + .property('SDL.NavigationController.isRouteSet', + 'SDL.NavigationController.isAnimateStarted'), + disabledBinding: 'this.getDisabled', classNames: 'navigationButton button', text: 'Navigate', action: 'setRoutes', diff --git a/ffw/NavigationRPC.js b/ffw/NavigationRPC.js index e7de8dc5a..d975275a8 100644 --- a/ffw/NavigationRPC.js +++ b/ffw/NavigationRPC.js @@ -545,7 +545,6 @@ FFW.Navigation = FFW.RPCObserver.create( 'id': request.id, 'result': { 'code': resultCode, // type (enum) from SDL protocol - 'appID': appID, 'wayPoints': data, 'method': 'Navigation.GetWayPoints' }