Commit decd7d95 authored by Filipa Lacerda's avatar Filipa Lacerda

Moves tabs.js component into a vue file

parent 06df0128
import Vue from 'vue'; import Vue from 'vue';
import modalFilters from './filters'; import modalFilters from './filters';
import './tabs'; import modalTabs from './tabs.vue';
import ModalStore from '../../stores/modal_store'; import ModalStore from '../../stores/modal_store';
import modalMixin from '../../mixins/modal_mixins'; import modalMixin from '../../mixins/modal_mixins';
gl.issueBoards.ModalHeader = Vue.extend({ gl.issueBoards.ModalHeader = Vue.extend({
components: { components: {
'modal-tabs': gl.issueBoards.ModalTabs, modalTabs,
modalFilters, modalFilters,
}, },
mixins: [modalMixin], mixins: [modalMixin],
......
import Vue from 'vue';
import ModalStore from '../../stores/modal_store';
import modalMixin from '../../mixins/modal_mixins';
gl.issueBoards.ModalTabs = Vue.extend({
mixins: [modalMixin],
data() {
return ModalStore.store;
},
computed: {
selectedCount() {
return ModalStore.selectedCount();
},
},
destroyed() {
this.activeTab = 'all';
},
template: `
<div class="top-area prepend-top-10 append-bottom-10">
<ul class="nav-links issues-state-filters">
<li :class="{ 'active': activeTab == 'all' }">
<a
href="#"
role="button"
@click.prevent="changeTab('all')">
Open issues
<span class="badge badge-pill">
{{ issuesCount }}
</span>
</a>
</li>
<li :class="{ 'active': activeTab == 'selected' }">
<a
href="#"
role="button"
@click.prevent="changeTab('selected')">
Selected issues
<span class="badge badge-pill">
{{ selectedCount }}
</span>
</a>
</li>
</ul>
</div>
`,
});
<script>
import ModalStore from '../../stores/modal_store';
import modalMixin from '../../mixins/modal_mixins';
export default {
mixins: [modalMixin],
data() {
return ModalStore.store;
},
computed: {
selectedCount() {
return ModalStore.selectedCount();
},
},
destroyed() {
this.activeTab = 'all';
},
};
</script>
<template>
<div class="top-area prepend-top-10 append-bottom-10">
<ul class="nav-links issues-state-filters">
<li :class="{ 'active': activeTab == 'all' }">
<a
href="#"
role="button"
@click.prevent="changeTab('all')"
>
Open issues
<span class="badge badge-pill">
{{ issuesCount }}
</span>
</a>
</li>
<li :class="{ 'active': activeTab == 'selected' }">
<a
href="#"
role="button"
@click.prevent="changeTab('selected')"
>
Selected issues
<span class="badge badge-pill">
{{ selectedCount }}
</span>
</a>
</li>
</ul>
</div>
</template>
<script> <script>
import Flash from '../../../flash'; import Vue from 'vue';
import { __ } from '../../../locale'; import Flash from '../../../flash';
import { __ } from '../../../locale';
const Store = gl.issueBoards.BoardsStore; const Store = gl.issueBoards.BoardsStore;
export default { export default {
props: { props: {
issue: { issue: {
type: Object, type: Object,
required: true, required: true,
},
list: {
type: Object,
required: true,
},
}, },
list: { computed: {
type: Object, updateUrl() {
required: true, return this.issue.path;
},
}, },
}, methods: {
computed: { removeIssue() {
updateUrl() { const issue = this.issue;
return this.issue.path; const lists = issue.getLists();
}, const listLabelIds = lists.map(list => list.label.id);
},
methods: {
removeIssue() {
const issue = this.issue;
const lists = issue.getLists();
const listLabelIds = lists.map(list => list.label.id);
let labelIds = issue.labels let labelIds = issue.labels.map(label => label.id).filter(id => !listLabelIds.includes(id));
.map(label => label.id) if (labelIds.length === 0) {
.filter(id => !listLabelIds.includes(id)); labelIds = [''];
if (labelIds.length === 0) { }
labelIds = [''];
}
const data = { const data = {
issue: { issue: {
label_ids: labelIds, label_ids: labelIds,
}, },
}; };
// Post the remove data // Post the remove data
Vue.http.patch(this.updateUrl, data).catch(() => { Vue.http.patch(this.updateUrl, data).catch(() => {
Flash(__('Failed to remove issue from board, please try again.')); Flash(__('Failed to remove issue from board, please try again.'));
lists.forEach((list) => { lists.forEach(list => {
list.addIssue(issue); list.addIssue(issue);
});
}); });
});
// Remove from the frontend store // Remove from the frontend store
lists.forEach((list) => { lists.forEach(list => {
list.removeIssue(issue); list.removeIssue(issue);
}); });
Store.detail.issue = {}; Store.detail.issue = {};
},
}, },
}, };
};
</script> </script>
<template> <template>
<div <div
......
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