Skip to content

Commit

Permalink
Issue #373 - Track params and path state in the Issue model.
Browse files Browse the repository at this point in the history
This way there's wayyyy less string parsing.
  • Loading branch information
Mike Taylor committed Dec 10, 2014
1 parent 38f0867 commit 49e2e13
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions webcompat/static/js/lib/models/issue.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,12 @@ issueList.Issue = issues.Issue.extend({});

issueList.IssueCollection = Backbone.Collection.extend({
model: issueList.Issue,
// TODO(miket): less hard-coding of default params
url: '/api/issues?page=1&per_page=50',
/* the url property is set in issueList.IssueView#fetchAndRenderIssues */
initialize: function() {
// set conservative defaults (first page of all open issues, 50 per page)
this.params = {page: 1, per_page: 50};
this.path = '/api/issues';
},
parse: function(response, jqXHR) {
if (jqXHR.xhr.getResponseHeader('Link') != null) {
//external code can access the parsed header via this.linkHeader
Expand All @@ -123,6 +127,10 @@ issueList.IssueCollection = Backbone.Collection.extend({
return response;
}
},
setURLState: function(path, params) {
this.path = path;
this.params = params;
},
parseHeader: function(linkHeader) {
/* Returns an object like so:
{
Expand Down

0 comments on commit 49e2e13

Please sign in to comment.