Skip to content

Commit

Permalink
Merge pull request #640 from karlcow/436/2
Browse files Browse the repository at this point in the history
fix #436 Add namespaces to labels
  • Loading branch information
Mike Taylor committed Jul 29, 2015
2 parents ceb7e30 + c416e2e commit 1d1deea
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion webcompat/static/js/lib/issue-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ issueList.IssueView = Backbone.View.extend({
events: {
'click .js-issue-label': 'labelSearch',
},
_filterRegex: /&*stage=(new|needscontact|needsdiagnosis|contactready|sitewait|closed)&*/i,
_filterRegex: /(stage=(?:new|status-needscontact|status-needsdiagnosis|status-contactready|status-sitewait|status-closed))/ig,
_isLoggedIn: $('body').data('username'),
_loadingIndicator: $('.js-loader'),
_nextButton: $('.js-pagination-next'),
Expand Down
2 changes: 1 addition & 1 deletion webcompat/static/js/lib/labels.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ issues.LabelsView = Backbone.View.extend({
subTemplate: _.template([
'<% _.each(labels, function(label) { %>',
'<span class="Label Label--badge" style="background-color:#<%=label.color%>">',
'<%= label.name %>',
'<%= label.name.replace(/(browser|status)-/, "") %>',
'</span>',
'<% }); %>'].join('')),
render: function() {
Expand Down
14 changes: 14 additions & 0 deletions webcompat/static/js/lib/models/issue.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,20 @@
});
},
updateLabels: function(labelsArray) {
// maybe this should be in a shared config file outside of python/JS
var statusLabels = ['contactready', 'needscontact', 'needsdiagnosis', 'sitewait', ' closed-duplicate', 'closed-fixed', 'closed-invalid'];
var browserLabels = ['chrome', 'firefox', 'ie', 'opera', 'safari', 'vivaldi'];
var osLabels = ['android', 'fxos', 'ios', 'linux', 'mac', 'win']
// we check if we need to append the correct string before sending stuff back
for (var i = labelsArray.length - 1; i >= 0; i--) {
if (statusLabels.indexOf(labelsArray[i]) != -1) {
labelsArray[i] = 'status-'.concat(labelsArray[i])
} else if (browserLabels.indexOf(labelsArray[i]) != -1) {
labelsArray[i] = 'browser-'.concat(labelsArray[i])
} else if (osLabels.indexOf(labelsArray[i]) != -1) {
labelsArray[i] = 'os-'.concat(labelsArray[i])
};
};
var self = this;
if (!$.isArray(labelsArray)) {
return;
Expand Down
2 changes: 1 addition & 1 deletion webcompat/templates/issue-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
</div>
<div class="wc-IssueItem-section">
<span class="wc-IssueItem-label js-issue-label"><% _.each(issue.labels, function(label) { %>
<a href="#" class="wc-Labels" title="Labels : <%= label.name %>"><%= label.name %></a>
<a href="#" class="wc-Labels" title="Labels : <%= label.name.replace(/(browser|status)-/, '') %>"><%= label.name.replace(/(browser|status)-/, '') %></a>
<% }); %></span>
</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions webcompat/templates/issue.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ <h1 class="wc-IssueDetail-title wc-Title--l">
<span class="Label-list">
<% _.each(labels, function(label) { %>
<span class="Label Label--badge" style="background-color:#<%=label.color%>">
<%= label.name %>
<%= label.name.replace(/(browser|status)-/, '') %>
</span>
<% }); %>
</span>
Expand Down Expand Up @@ -123,9 +123,9 @@ <h1 class="wc-IssueDetail-title wc-Title--l">
<% _.each(labels, function(label) { %>
<label class="LabelEditor-item">
<span class="LabelEditor-color" style="background-color:#<%=label.color%>">
<input class="LabelEditor-checkbox" type="checkbox" name="<%= label.name %>" data-color="<%=label.color%>">
<input class="LabelEditor-checkbox" type="checkbox" name="<%= label.name.replace(/(browser|status)-/, '') %>" data-color="<%=label.color%>">
</span>
<span class="LabelEditor-name"><%= label.name %></span>
<span class="LabelEditor-name"><%= label.name.replace(/(browser|status)-/, '') %></span>
</label>
<% }); %>
</div>
Expand Down

0 comments on commit 1d1deea

Please sign in to comment.