Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow bloodhound rateLimitWait params to be settable in gmf #3343

Merged
merged 3 commits into from
Jan 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions contribs/gmf/apps/desktop/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@
gmf-search-coordinatesprojections="mainCtrl.searchCoordinatesProjections"
gmf-search-colorchooser="false"
gmf-search-placeholder="{{'Search…'|translate}}"
gmf-search-delay="mainCtrl.searchDelay"
gmf-search-clearbutton="true">
</gmf-search>
<div class="gmf-app-map-bottom-controls">
Expand Down
6 changes: 6 additions & 0 deletions contribs/gmf/apps/desktop/js/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ app.DesktopController = function($scope, $injector) {
}
}, $scope, $injector);

/**
* @type {number}
* @export
*/
this.searchDelay = 50;

/**
* @type {Array.<string>}
* @export
Expand Down
1 change: 1 addition & 0 deletions contribs/gmf/apps/desktop_alt/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@
gmf-search-coordinatesprojections="mainCtrl.searchCoordinatesProjections"
gmf-search-colorchooser="true"
gmf-search-placeholder="{{'Search…'|translate}}"
gmf-search-delay="mainCtrl.searchDelay"
gmf-search-clearbutton="true">
</gmf-search>
<div class="gmf-app-map-bottom-controls">
Expand Down
6 changes: 6 additions & 0 deletions contribs/gmf/apps/desktop_alt/js/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ app.AlternativeDesktopController = function($scope, $injector, ngeoFile, gettext
*/
this.searchCoordinatesProjections = ['EPSG:21781', 'EPSG:2056', 'EPSG:4326'];

/**
* @type {number}
* @export
*/
this.searchDelay = 500;

/**
* @type {boolean}
* @export
Expand Down
3 changes: 2 additions & 1 deletion contribs/gmf/apps/mobile/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
gmf-search-clearbutton="true"
gmf-search-placeholder="{{'Search…'|translate}}"
gmf-search-coordinatesprojections="mainCtrl.searchCoordinatesProjections"
gmf-search-listeners="::mainCtrl.searchListeners">
gmf-search-listeners="::mainCtrl.searchListeners"
gmf-search-delay="mainCtrl.searchDelay">
</gmf-search>
<button class="gmf-mobile-nav-trigger gmf-mobile-nav-right-trigger"
ng-click="mainCtrl.toggleRightNavVisibility()">
Expand Down
6 changes: 6 additions & 0 deletions contribs/gmf/apps/mobile/js/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ app.MobileController = function($scope, $injector) {
{name: 'srtm', unit: 'm'}
];

/**
* @type {number}
* @export
*/
this.searchDelay = 50;

/**
* @type {Array.<string>}
* @export
Expand Down
3 changes: 2 additions & 1 deletion contribs/gmf/apps/mobile_alt/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
gmf-search-clearbutton="true"
gmf-search-placeholder="{{'Search…'|translate}}"
gmf-search-coordinatesprojections="mainCtrl.searchCoordinatesProjections"
gmf-search-listeners="::mainCtrl.searchListeners">
gmf-search-listeners="::mainCtrl.searchListeners"
gmf-search-delay="mainCtrl.searchDelay">
</gmf-search>
<button class="gmf-mobile-nav-trigger gmf-mobile-nav-right-trigger"
ng-click="mainCtrl.toggleRightNavVisibility()">
Expand Down
6 changes: 6 additions & 0 deletions contribs/gmf/apps/mobile_alt/js/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ app.AlternativeMobileController = function($scope, $injector) {
{name: 'srtm', unit: 'm'}
];

/**
* @type {number}
* @export
*/
this.searchDelay = 50;

/**
* @type {Array.<string>}
* @export
Expand Down
4 changes: 3 additions & 1 deletion contribs/gmf/examples/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@
gmf-search-colorchooser="true"
gmf-search-placeholder="Search for « Laus » for example…"
gmf-search-clearbutton="true"
gmf-search-on-init="ctrl.searchIsReady()">
gmf-search-on-init="ctrl.searchIsReady()"
gmf-search-delay="50">
</gmf-search>
<p id="desc">This example shows how to use the <code>gmf-search</code> directive, which
is based on Twitter's <code>typeahead</code> component.</p>
Expand Down Expand Up @@ -192,6 +193,7 @@
var gmfModule = angular.module('gmf');
gmfModule.constant('defaultTheme', 'Demo');
gmfModule.constant('angularLocaleScript', '../build/angular-locale_{{locale}}.js');
gmfModule.constant('fulltextsearchUrl', 'https://geomapfish-demo.camptocamp.net/2.2/wsgi/fulltextsearch?limit=30&partitionlimit=5&interface=desktop');
</script>
</body>
</html>
14 changes: 12 additions & 2 deletions contribs/gmf/src/directives/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ gmf.module.value('gmfSearchTemplateUrl',
* gmf-search-styles="ctrl.searchStyles"
* gmf-search-datasources="ctrl.searchDatasources"
* gmf-search-coordinatesprojections="ctrl.searchCoordinatesProjections"
* gmf-search-delay="mainCtrl.searchDelay"
* gmf-search-clearbutton="true">
* </gmf-search>
* <script>
Expand All @@ -81,7 +82,8 @@ gmf.module.value('gmfSearchTemplateUrl',
* gmf-search-styles="ctrl.searchStyles"
* gmf-search-datasources="ctrl.searchDatasources"
* gmf-search-coordinatesprojections="ctrl.searchCoordinatesProjections"
* gmf-search-clearbutton="true">
* gmf-search-clearbutton="true"
* gmf-search-delay="mainCtrl.searchDelay"
* gmf-search-colorchooser="true">
* </gmf-search>
* <script>
Expand Down Expand Up @@ -110,6 +112,7 @@ gmf.module.value('gmfSearchTemplateUrl',
* defined in ol3). If not provided, only the map's view projection
* format will be supported.
* @htmlAttribute {boolean} gmf-search-clearbutton The clear button.
* @htmlAttribute {boolean} gmf-search-delay The bloodhound request delay.
* @htmlAttribute {boolean} gmf-search-colorchooser Whether to let the user
* change the style of the feature on the map. Default is false.
* @htmlAttribute {ngeox.SearchDirectiveListeners} gmf-search-listeners
Expand Down Expand Up @@ -138,6 +141,7 @@ gmf.searchDirective = function(gmfSearchTemplateUrl) {
'coordinatesProjections': '=?gmfSearchCoordinatesprojections',
'additionalListeners': '=gmfSearchListeners',
'maxZoom': '<gmfSearchMaxzoom',
'delay': '<gmfSearchDelay',
'onInitCallback': '&?gmfSearchOnInit'
},
controller: 'GmfSearchController as ctrl',
Expand Down Expand Up @@ -298,6 +302,12 @@ gmf.SearchController = function($scope, $compile, $timeout, $injector, gettextCa
*/
this.placeholder;

/**
* @type {number}
* @export
*/
this.delay = parseInt(this.scope_['delay'], 10) || 50;

/**
* The maximum zoom we will zoom on result.
* @type {number}
Expand Down Expand Up @@ -635,7 +645,7 @@ gmf.SearchController.prototype.createAndInitBloodhound_ = function(config,
gmf.SearchController.prototype.getBloodhoudRemoteOptions_ = function() {
const gettextCatalog = this.gettextCatalog_;
return {
rateLimitWait: 50,
rateLimitWait: this.delay,
prepare(query, settings) {
const url = settings.url;
const lang = gettextCatalog.currentLanguage;
Expand Down