Skip to content

Commit 07f41b8

Browse files
author
Mike Taylor
committed
Issue #372 - Use $.param to build params in updateIssues method
squash me with the updateIssues commit
1 parent d8684c7 commit 07f41b8

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

webcompat/static/js/lib/issue-list.js

+13-4
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,10 @@ issueList.IssueView = Backbone.View.extend({
300300
wcEvents.trigger('flash:error', {message: message, timeout: timeout});
301301
});
302302
},
303+
getPageLimit: function() {
304+
// slice 5 to get to the N of "Show N"
305+
return {'per_page': $('.js-dropdown-pagination .js-dropdown-toggle').text().trim().slice(5)};
306+
},
303307
render: function(issues) {
304308
this.$el.html(this.template({
305309
issues: issues.toJSON()
@@ -371,16 +375,21 @@ issueList.IssueView = Backbone.View.extend({
371375
// update the collection instance url property and fetch the issues.
372376
var labelCategories = ['closed', 'contactready', 'needsdiagnosis', 'sitewait'];
373377

378+
//TODO(miket): make generic getModelParams method which can get the latest state
379+
var paramsBag = $.extend({page: 1}, this.getPageLimit());
380+
var params = $.param(paramsBag);
381+
374382
// note: if query is the empty string, it will load all issues from the
375383
// '/api/issues' endpoint (which I think we want).
376384
if (category && category.query) {
377-
this.issues.url = '/api/issues/search?q=' + category.query + '&page=1';
385+
params = $.param($.extend(paramsBag, {q: category.query}));
386+
this.issues.url = '/api/issues/search?' + params;
378387
} else if (_.contains(labelCategories, category)) {
379-
this.issues.url = '/api/issues/category/' + category + '?page=1';
388+
this.issues.url = '/api/issues/category/' + category + '?' + params;
380389
} else if (category === "untriaged") {
381-
this.issues.url = '/api/issues/search/untriaged?page=1';
390+
this.issues.url = '/api/issues/search/untriaged?' + params;
382391
} else {
383-
this.issues.url = '/api/issues?page=1';
392+
this.issues.url = '/api/issues?' + params;
384393
}
385394
this.fetchAndRenderIssues();
386395
},

0 commit comments

Comments
 (0)