2017-08-17 22:00:37 +05:30
|
|
|
import Vue from 'vue';
|
2018-03-17 18:26:18 +05:30
|
|
|
import Flash from '../../../flash';
|
2018-03-27 19:54:05 +05:30
|
|
|
import { __ } from '../../../locale';
|
2017-09-10 17:25:29 +05:30
|
|
|
import './lists_dropdown';
|
2018-03-17 18:26:18 +05:30
|
|
|
import { pluralize } from '../../../lib/utils/text_utility';
|
2018-10-15 14:42:47 +05:30
|
|
|
import ModalStore from '../../stores/modal_store';
|
|
|
|
import modalMixin from '../../mixins/modal_mixins';
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
gl.issueBoards.ModalFooter = Vue.extend({
|
2018-10-15 14:42:47 +05:30
|
|
|
mixins: [modalMixin],
|
2017-08-17 22:00:37 +05:30
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
modal: ModalStore.store,
|
|
|
|
state: gl.issueBoards.BoardsStore.state,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
submitDisabled() {
|
|
|
|
return !ModalStore.selectedCount();
|
|
|
|
},
|
|
|
|
submitText() {
|
|
|
|
const count = ModalStore.selectedCount();
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
return `Add ${count > 0 ? count : ''} ${pluralize('issue', count)}`;
|
2017-08-17 22:00:37 +05:30
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
addIssues() {
|
2017-09-10 17:25:29 +05:30
|
|
|
const firstListIndex = 1;
|
|
|
|
const list = this.modal.selectedList || this.state.lists[firstListIndex];
|
2017-08-17 22:00:37 +05:30
|
|
|
const selectedIssues = ModalStore.getSelectedIssues();
|
2018-03-17 18:26:18 +05:30
|
|
|
const issueIds = selectedIssues.map(issue => issue.id);
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
// Post the data to the backend
|
|
|
|
gl.boardService.bulkUpdate(issueIds, {
|
|
|
|
add_label_ids: [list.label.id],
|
|
|
|
}).catch(() => {
|
2018-03-27 19:54:05 +05:30
|
|
|
Flash(__('Failed to update issues, please try again.'));
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
selectedIssues.forEach((issue) => {
|
|
|
|
list.removeIssue(issue);
|
|
|
|
list.issuesSize -= 1;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// Add the issues on the frontend
|
|
|
|
selectedIssues.forEach((issue) => {
|
|
|
|
list.addIssue(issue);
|
|
|
|
list.issuesSize += 1;
|
|
|
|
});
|
|
|
|
|
|
|
|
this.toggleModal(false);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
components: {
|
|
|
|
'lists-dropdown': gl.issueBoards.ModalFooterListsDropdown,
|
|
|
|
},
|
|
|
|
template: `
|
|
|
|
<footer
|
|
|
|
class="form-actions add-issues-footer">
|
|
|
|
<div class="pull-left">
|
|
|
|
<button
|
|
|
|
class="btn btn-success"
|
|
|
|
type="button"
|
|
|
|
:disabled="submitDisabled"
|
|
|
|
@click="addIssues">
|
|
|
|
{{ submitText }}
|
|
|
|
</button>
|
|
|
|
<span class="inline add-issues-footer-to-list">
|
|
|
|
to list
|
|
|
|
</span>
|
|
|
|
<lists-dropdown></lists-dropdown>
|
|
|
|
</div>
|
|
|
|
<button
|
|
|
|
class="btn btn-default pull-right"
|
|
|
|
type="button"
|
|
|
|
@click="toggleModal(false)">
|
|
|
|
Cancel
|
|
|
|
</button>
|
|
|
|
</footer>
|
|
|
|
`,
|
|
|
|
});
|