Correctly filters by labels

This commit is contained in:
Phil Hughes 2016-08-05 18:27:12 +01:00
parent 69458c0e4a
commit 034f1f07b7
4 changed files with 27 additions and 11 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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) {

View File

@ -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;