gitlab-org--gitlab-foss/app/assets/javascripts/boards/components/sidebar/remove_issue.js

62 lines
1.4 KiB
JavaScript
Raw Normal View History

/* eslint-disable no-new */
/* global Flash */
2017-03-17 13:21:25 -04:00
import Vue from 'vue';
2017-01-30 12:11:08 -05:00
(() => {
const Store = gl.issueBoards.BoardsStore;
window.gl = window.gl || {};
window.gl.issueBoards = window.gl.issueBoards || {};
gl.issueBoards.RemoveIssueBtn = Vue.extend({
props: {
issue: {
type: Object,
required: true,
},
list: {
type: Object,
required: true,
},
},
2017-01-30 12:11:08 -05:00
methods: {
removeIssue() {
const issue = this.issue;
const lists = issue.getLists();
const labelIds = lists.map(list => list.label.id);
2017-01-30 12:11:08 -05:00
// Post the remove data
gl.boardService.bulkUpdate([issue.globalId], {
remove_label_ids: labelIds,
}).catch(() => {
new Flash('Failed to remove issue from board, please try again.', 'alert');
lists.forEach((list) => {
list.addIssue(issue);
});
});
// Remove from the frontend store
lists.forEach((list) => {
list.removeIssue(issue);
});
2017-01-30 12:11:08 -05:00
Store.detail.issue = {};
},
},
template: `
<div
class="block list"
v-if="list.type !== 'closed'">
2017-01-30 12:11:08 -05:00
<button
class="btn btn-default btn-block"
type="button"
@click="removeIssue">
Remove from board
</button>
</div>
`,
});
})();