Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlfredo Sumaran <alfredo@gitlab.com>2017-05-11 04:24:31 +0300
committerAlfredo Sumaran <alfredo@gitlab.com>2017-05-11 04:24:31 +0300
commit8064a400a83cfbf8e5f22b29d722fac7883b0217 (patch)
tree87adf41eb164120299377c05a055c5092369d29d /app/assets/javascripts/filterable_list.js
parent312d02ad6db5b38b7c393f9a84a73e9ead4adfe0 (diff)
Add support to filter groups by filter options
Diffstat (limited to 'app/assets/javascripts/filterable_list.js')
-rw-r--r--app/assets/javascripts/filterable_list.js17
1 files changed, 13 insertions, 4 deletions
diff --git a/app/assets/javascripts/filterable_list.js b/app/assets/javascripts/filterable_list.js
index 2c366abe1cf..c25987e6c36 100644
--- a/app/assets/javascripts/filterable_list.js
+++ b/app/assets/javascripts/filterable_list.js
@@ -12,7 +12,10 @@ export default class FilterableList {
}
initSearch() {
- this.debounceFilter = _.debounce(this.filterResults.bind(this), 500);
+ // Wrap to prevent passing event arguments to .filterResults;
+ this.debounceFilter = _.debounce(() => {
+ this.filterResults();
+ }, 500);
this.unbindEvents();
this.bindEvents();
@@ -26,13 +29,15 @@ export default class FilterableList {
this.listFilterElement.removeEventListener('input', this.debounceFilter);
}
- filterResults() {
+ filterResults(url, data) {
+ const endpoint = url || this.filterForm.getAttribute('action');
+ const additionalData = data || $(this.filterForm).serialize();
$(this.listHolderElement).fadeTo(250, 0.5);
return $.ajax({
- url: this.filterForm.getAttribute('action'),
- data: $(this.filterForm).serialize(),
+ url: endpoint,
+ data: additionalData,
type: 'GET',
dataType: 'json',
context: this,
@@ -42,6 +47,10 @@ export default class FilterableList {
}
onFilterSuccess(data) {
+ if (data.html) {
+ this.listHolderElement.innerHTML = data.html;
+ }
+
// Change url so if user reload a page - search results are saved
return window.history.replaceState({
page: this.filterUrl,