Commit 034f1f07 authored by Phil Hughes's avatar Phil Hughes

Correctly filters by labels

parent 69458c0e
...@@ -38,6 +38,12 @@ class Issue { ...@@ -38,6 +38,12 @@ class Issue {
} }
} }
removeLabels (labels) {
labels.forEach((label) => {
this.removeLabel(label);
});
}
getLists () { getLists () {
return _.filter(BoardsStore.state.lists, (list) => { return _.filter(BoardsStore.state.lists, (list) => {
return list.findIssue(this.id); return list.findIssue(this.id);
......
...@@ -54,7 +54,13 @@ class List { ...@@ -54,7 +54,13 @@ class List {
} }
getIssues (emptyIssues = true) { getIssues (emptyIssues = true) {
const data = _.extend({ page: this.page }, this.filters); let data = _.extend({ page: this.page }, this.filters);
if (this.label) {
data.label_name = _.reject(data.label_name, (label) => {
return label === this.label.title;
});
}
if (emptyIssues) { if (emptyIssues) {
this.loading = true; this.loading = true;
...@@ -93,19 +99,13 @@ class List { ...@@ -93,19 +99,13 @@ class List {
}); });
} }
removeIssue (removeIssue, listLabels) { removeIssue (removeIssue) {
this.issues = _.reject(this.issues, (issue) => { this.issues = _.reject(this.issues, (issue) => {
const matchesRemove = removeIssue.id === issue.id; const matchesRemove = removeIssue.id === issue.id;
if (matchesRemove) { if (matchesRemove) {
if (typeof listLabels !== 'undefined') {
listLabels.forEach((listLabel) => {
issue.removeLabel(listLabel);
});
} else {
issue.removeLabel(this.label); issue.removeLabel(this.label);
} }
}
return matchesRemove; return matchesRemove;
}); });
......
...@@ -98,7 +98,10 @@ ...@@ -98,7 +98,10 @@
listTo = this.findList('id', listToId), listTo = this.findList('id', listToId),
issueTo = listTo.findIssue(issueId); issueTo = listTo.findIssue(issueId);
let issue = listFrom.findIssue(issueId); let issue = listFrom.findIssue(issueId);
const issueLists = issue.getLists(); const issueLists = issue.getLists(),
issueLabels = issueLists.map(function (issue) {
return issue.label;
});
listFrom.removeIssue(issue); listFrom.removeIssue(issue);
// Add to new lists issues if it doesn't already exist // Add to new lists issues if it doesn't already exist
...@@ -112,6 +115,7 @@ ...@@ -112,6 +115,7 @@
issueLists.forEach((list) => { issueLists.forEach((list) => {
list.removeIssue(issue); list.removeIssue(issue);
}); });
issue.removeLabels(issueLabels);
} }
}, },
findList: function (key, val) { findList: function (key, val) {
......
...@@ -304,7 +304,13 @@ ...@@ -304,7 +304,13 @@
isIssueIndex = page === 'projects:issues:index'; isIssueIndex = page === 'projects:issues:index';
isMRIndex = page === 'projects:merge_requests:index'; isMRIndex = page === 'projects:merge_requests:index';
if (page === 'projects:boards:show') { if (page === 'projects:boards:show') {
if (label.title) {
BoardsStore.state.filters['label_name'].push(label.title); BoardsStore.state.filters['label_name'].push(label.title);
} else {
var labelIndex = BoardsStore.state.filters['label_name'].indexOf(label.text());
BoardsStore.state.filters['label_name'].splice(labelIndex, 1);
}
BoardsStore.updateFiltersUrl(); BoardsStore.updateFiltersUrl();
e.preventDefault(); e.preventDefault();
return; return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment