Correctly filters by labels
This commit is contained in:
parent
69458c0e4a
commit
034f1f07b7
4 changed files with 27 additions and 11 deletions
|
@ -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,19 +99,13 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
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') {
|
||||
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;
|
||||
|
|
Loading…
Reference in a new issue