Commit ad60c48f authored by Benoit Lavenier's avatar Benoit Lavenier

[enh] Auto apply search when location changed

[fix] Fix HTML tag on search template
parent 7795549d
......@@ -212,11 +212,12 @@ function MkLookupAbstractController($scope, $state, $filter, $q, $location, $tra
var stateParams = {};
var location = $scope.search.location && $scope.search.location.trim().toLowerCase();
if ($scope.search.geoPoint && $scope.search.geoPoint.lat && $scope.search.geoPoint.lon) {
// match location OR geo distance
if ($scope.search.location && $scope.search.location.length) {
var locationCity = $scope.search.location.split(',')[0];
if (location && location.length) {
var locationCity = location.split(',')[0];
filters.push({
or : [
// No position defined
......@@ -239,7 +240,7 @@ function MkLookupAbstractController($scope, $state, $filter, $q, $location, $tra
}}
]
});
stateParams.location = $scope.search.location;
stateParams.location = $scope.search.location.trim();
}
else {
......@@ -667,6 +668,16 @@ function MkLookupController($scope, $rootScope, $controller, $focus, $timeout, m
/* -- manage events -- */
$scope.onGeoPointChanged = function() {
if ($scope.search.loading) return;
if ($scope.search.geoPoint && $scope.search.geoPoint.lat && $scope.search.geoPoint.lon && !$scope.search.geoPoint.exact) {
$scope.doSearch();
}
};
$scope.$watch('search.geoPoint', $scope.onGeoPointChanged, true);
$scope.onToggleAdvanced = function() {
if ($scope.search.loading || !$scope.entered) return;
......
......@@ -19,6 +19,7 @@
<div class="item-input">
<div class="animate-show-hide ng-hide" ng-show="entered">
<!-- selected location -->
<div ng-show="!search.loading && search.geoPoint"
class="button button-small button-text button-stable button-icon-event stable-900-bg"
......@@ -57,12 +58,12 @@
</div>
<!-- location -->
<ng-include src="'plugins/es/templates/common/item_location_search.html'"
<ng-include src="::'plugins/es/templates/common/item_location_search.html'"
ng-if="entered && !search.geoPoint && options.location.show"
ng-controller="ESSearchPositionItemCtrl" ng-init=""></ng-include>
ng-controller="ESSearchPositionItemCtrl"></ng-include>
<!-- options -->
<ng-include src="'plugins/market/templates/search/lookup_options.html'"></ng-include>
<ng-include src="::'plugins/market/templates/search/lookup_options.html'"></ng-include>
</form>
......
......@@ -24,4 +24,4 @@
ng-options="i as (geoDistanceLabels[i].labelKey | translate:geoDistanceLabels[i].labelParams ) for i in geoDistances track by i">
</select>
</label>
</span>
</div>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment