Skip to content

Commit

Permalink
#3 Search from URL and link profile locations to search
Browse files Browse the repository at this point in the history
  • Loading branch information
simison committed Nov 20, 2014
1 parent 1bc4f7b commit 54ef44c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion public/modules/search/config/search.client.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ angular.module('search').config(['$stateProvider',
// Search state routing
$stateProvider.
state('search', {
url: '/search',
url: '/search?location',
templateUrl: 'modules/search/views/search.client.view.html'
});
}
Expand Down
13 changes: 10 additions & 3 deletions public/modules/search/controllers/search.client.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
/* This declares to JSHint that 'settings' is a global variable: */
/*global settings:false */

angular.module('search').controller('SearchController', ['$scope', '$http', '$geolocation', '$location', '$state', '$timeout', '$log', 'Offers', 'leafletBoundsHelpers', 'Authentication', 'Languages',
function($scope, $http, $geolocation, $location, $state, $timeout, $log, Offers, leafletBoundsHelpers, Authentication, Languages) {
angular.module('search').controller('SearchController', ['$scope', '$http', '$geolocation', '$location', '$state', '$stateParams', '$timeout', '$log', 'Offers', 'leafletBoundsHelpers', 'Authentication', 'Languages',
function($scope, $http, $geolocation, $location, $state, $stateParams, $timeout, $log, Offers, leafletBoundsHelpers, Authentication, Languages) {

$scope.user = Authentication.user; // Currently logged in user

Expand All @@ -17,7 +17,6 @@ angular.module('search').controller('SearchController', ['$scope', '$http', '$ge
$scope.offer = false; // Offer to show
$scope.notFound = false;


/**
* Center map to user's location
*/
Expand Down Expand Up @@ -360,5 +359,13 @@ angular.module('search').controller('SearchController', ['$scope', '$http', '$ge
return title;
};


// Init search with URL
if($stateParams.location && $stateParams.location !== '') {
$scope.userReacted = true;
$scope.searchQuery = $stateParams.location;
$scope.searchAddress();
};

}
]);
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ <h4>Last seen</h4>
-->

<div class="profile-sidebar-section" ng-show="profile.locationLiving">
<i class="fa fa-fw fa-building text-muted"></i> Lives in <a href="#">{{profile.locationLiving}}</a>
<i class="fa fa-fw fa-building text-muted"></i> Lives in <a ui-sref="search({location:profile.locationLiving})">{{profile.locationLiving}}</a>
</div>

<div class="profile-sidebar-section" ng-show="profile.locationFrom">
<i class="fa fa-fw fa-home text-muted"></i> From <a href="#">{{profile.locationFrom}}</a>
<i class="fa fa-fw fa-home text-muted"></i> From <a ui-sref="search({location:profile.locationFrom})">{{profile.locationFrom}}</a>
</div>

<div class="profile-sidebar-section" ng-show="profile.languages.length">
Expand Down

0 comments on commit 54ef44c

Please sign in to comment.