Skip to content

Commit dbb32fc

Browse files
author
Mike Taylor
committed
Issue #372 - DropdownView model now has paramKey and paramValue, rather than combined.
1 parent 7c1aaef commit dbb32fc

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

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

+11-5
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,16 @@ issueList.DropdownView = Backbone.View.extend({
3333
},
3434
selectDropdownOption: function(e) {
3535
var option = $(e.target);
36+
var paramKey = option.data('paramKey');
37+
var paramValue = option.data('paramValue');
3638
option.addClass('is-active')
3739
.siblings().removeClass('is-active');
3840

3941
// TODO: persist in localStorage for page refreshes?
4042
this.updateDropdownTitle(option);
4143

4244
// fire an event so other views can react to dropdown changes
43-
wcEvents.trigger('dropdown:change', {params: option.data('params')});
45+
wcEvents.trigger('dropdown:change', {params: {key: paramKey, value: paramValue}});
4446
e.preventDefault();
4547
},
4648
updateDropdownTitle: function(optionElm) {
@@ -60,6 +62,7 @@ issueList.FilterView = Backbone.View.extend({
6062

6163
issueList.events.on('filter:activate', _.bind(this.toggleFilter, this));
6264

65+
// TODO(miket): update with paramKey & paramValue
6366
var options = [
6467
{title: "View all open issues", params: ""},
6568
{title: "View all issues", params: "filter=all"}
@@ -181,12 +184,13 @@ issueList.SortingView = Backbone.View.extend({
181184
this.paginationModel = new Backbone.Model({
182185
dropdownTitle: "Show 50",
183186
dropdownOptions: [
184-
{title: "Show 25", params: "per_page=25"},
185-
{title: "Show 50", params: "per_page=50"},
186-
{title: "Show 100", params: "per_page=100"}
187+
{title: "Show 25", paramKey: "per_page", paramValue: "25"},
188+
{title: "Show 50", paramKey: "per_page", paramValue: "50"},
189+
{title: "Show 100", paramKey: "per_page", paramValue: "100"}
187190
]
188191
});
189192

193+
// TODO(miket): update model to have paramKey and paramValue
190194
this.sortModel = new Backbone.Model({
191195
dropdownTitle: "Newest",
192196
dropdownOptions: [
@@ -375,12 +379,14 @@ issueList.IssueView = Backbone.View.extend({
375379
this.fetchAndRenderIssues();
376380
},
377381
updateModelParams: function(data) {
382+
var dataParams = data.params.key + '=' + data.params.value;
378383
var modelUrl = this.issues.url.split('?');
379384
var modelPath = modelUrl[0];
380385
var modelParams = modelUrl[1];
386+
381387
// merge old params with passed in param data
382388
// $.extend will update existing object keys, and add new ones
383-
var newParams = $.extend($.deparam(modelParams), $.deparam(data.params));
389+
var newParams = $.extend($.deparam(modelParams), $.deparam(dataParams));
384390

385391
// construct new model URL and re-request issues
386392
this.issues.url = modelPath + '?' + $.param(newParams);

webcompat/templates/issue-list.html

+3-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ <h2 class="wc-margin-bottom">Issues</h2>
114114
<ul class="Dropdown-content js-dropdown-options" aria-hidden="false">
115115
<% _.each(dropdownOptions, function(option) { %>
116116
<li class="Dropdown-item">
117-
<a href="#" class="Dropdown-link" data-params="<%= option.params %>"><%= option.title %></a>
117+
<a href="#" class="Dropdown-link" data-param-key="<%= option.paramKey %>" data-param-value="<%= option.paramValue %>">
118+
<%= option.title %>
119+
</a>
118120
</li>
119121
<% }); %>
120122
</ul>

0 commit comments

Comments
 (0)