diff options
author | Denys Mishunov <dmishunov@gitlab.com> | 2019-07-05 01:30:34 +0300 |
---|---|---|
committer | Denys Mishunov <dmishunov@gitlab.com> | 2019-07-05 13:50:50 +0300 |
commit | 352d535849e31e7defd0ce0e70fe3543f7282a17 (patch) | |
tree | 27c755dbc70c4bb5c591f3ca27191d10efcd0777 /app/assets/javascripts | |
parent | f845a081e336621e991587f88ee7d8ce6d012e21 (diff) |
Fixed back navigation for projects filter
Filterable list now sends request to filter the projects list
explicitly with `json` extension to avoid breakage when navigating back
from a project to the filtered project's list.
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r-- | app/assets/javascripts/filterable_list.js | 6 | ||||
-rw-r--r-- | app/assets/javascripts/projects/projects_filterable_list.js | 7 | ||||
-rw-r--r-- | app/assets/javascripts/projects_list.js | 4 |
3 files changed, 13 insertions, 4 deletions
diff --git a/app/assets/javascripts/filterable_list.js b/app/assets/javascripts/filterable_list.js index 64b09c8b62c..77080691dcb 100644 --- a/app/assets/javascripts/filterable_list.js +++ b/app/assets/javascripts/filterable_list.js @@ -17,11 +17,13 @@ export default class FilterableList { } getFilterEndpoint() { - return `${this.filterForm.getAttribute('action')}?${$(this.filterForm).serialize()}`; + return this.getPagePath(); } getPagePath() { - return this.getFilterEndpoint(); + const action = this.filterForm.getAttribute('action'); + const params = $(this.filterForm).serialize(); + return `${action}${action.indexOf('?') > 0 ? '&' : '?'}${params}`; } initSearch() { diff --git a/app/assets/javascripts/projects/projects_filterable_list.js b/app/assets/javascripts/projects/projects_filterable_list.js new file mode 100644 index 00000000000..433c894e668 --- /dev/null +++ b/app/assets/javascripts/projects/projects_filterable_list.js @@ -0,0 +1,7 @@ +import FilterableList from '~/filterable_list'; + +export default class ProjectsFilterableList extends FilterableList { + getFilterEndpoint() { + return this.getPagePath().replace('/projects?', '/projects.json?'); + } +} diff --git a/app/assets/javascripts/projects_list.js b/app/assets/javascripts/projects_list.js index c67d59d2be5..913b62ba26d 100644 --- a/app/assets/javascripts/projects_list.js +++ b/app/assets/javascripts/projects_list.js @@ -1,4 +1,4 @@ -import FilterableList from './filterable_list'; +import ProjectsFilterableList from './projects/projects_filterable_list'; /** * Makes search request for projects when user types a value in the search input. @@ -11,7 +11,7 @@ export default class ProjectsList { const holder = document.querySelector('.js-projects-list-holder'); if (form && filter && holder) { - const list = new FilterableList(form, filter, holder); + const list = new ProjectsFilterableList(form, filter, holder); list.initSearch(); } } |