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

Correctly filters by labels

parent 69458c0e
......@@ -38,6 +38,12 @@ class Issue {
}
}
removeLabels (labels) {
labels.forEach((label) => {
this.removeLabel(label);
});
}
getLists () {
return _.filter(BoardsStore.state.lists, (list) => {
return list.findIssue(this.id);
......
......@@ -54,7 +54,13 @@ class List {
}
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) {
this.loading = true;
......@@ -93,18 +99,12 @@ class List {
});
}
removeIssue (removeIssue, listLabels) {
removeIssue (removeIssue) {
this.issues = _.reject(this.issues, (issue) => {
const matchesRemove = removeIssue.id === issue.id;
if (matchesRemove) {
if (typeof listLabels !== 'undefined') {
listLabels.forEach((listLabel) => {
issue.removeLabel(listLabel);
});
} else {
issue.removeLabel(this.label);
}
issue.removeLabel(this.label);
}
return matchesRemove;
......
......@@ -98,7 +98,10 @@
listTo = this.findList('id', listToId),
issueTo = listTo.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);
// Add to new lists issues if it doesn't already exist
......@@ -112,6 +115,7 @@
issueLists.forEach((list) => {
list.removeIssue(issue);
});
issue.removeLabels(issueLabels);
}
},
findList: function (key, val) {
......
......@@ -304,7 +304,13 @@
isIssueIndex = page === 'projects:issues:index';
isMRIndex = page === 'projects:merge_requests:index';
if (page === 'projects:boards:show') {
BoardsStore.state.filters['label_name'].push(label.title);
if (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();
e.preventDefault();
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