Commit b4113dba authored by Phil Hughes's avatar Phil Hughes Committed by Fatih Acet

Uses mixins for repeated functions

parent cf5396d4
...@@ -91,6 +91,7 @@ $(() => { ...@@ -91,6 +91,7 @@ $(() => {
}); });
gl.IssueBoardsModalAddBtn = new Vue({ gl.IssueBoardsModalAddBtn = new Vue({
mixins: [gl.issueBoards.ModalMixins],
el: '#js-add-issues-btn', el: '#js-add-issues-btn',
data: { data: {
modal: ModalStore.store, modal: ModalStore.store,
...@@ -106,7 +107,7 @@ $(() => { ...@@ -106,7 +107,7 @@ $(() => {
class="btn btn-create pull-right prepend-left-10 has-tooltip" class="btn btn-create pull-right prepend-left-10 has-tooltip"
type="button" type="button"
:disabled="disabled" :disabled="disabled"
@click="modal.showAddIssuesModal = true"> @click="toggleModal(true)">
Add issues Add issues
</button> </button>
`, `,
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
const ModalStore = gl.issueBoards.ModalStore; const ModalStore = gl.issueBoards.ModalStore;
gl.issueBoards.ModalEmptyState = Vue.extend({ gl.issueBoards.ModalEmptyState = Vue.extend({
mixins: [gl.issueBoards.ModalMixins],
data() { data() {
return ModalStore.store; return ModalStore.store;
}, },
...@@ -56,7 +57,7 @@ ...@@ -56,7 +57,7 @@
<button <button
type="button" type="button"
class="btn btn-default" class="btn btn-default"
@click="activeTab = 'all'" @click="changeTab('all')"
v-if="activeTab === 'selected'"> v-if="activeTab === 'selected'">
All issues All issues
</button> </button>
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
const ModalStore = gl.issueBoards.ModalStore; const ModalStore = gl.issueBoards.ModalStore;
gl.issueBoards.ModalFooter = Vue.extend({ gl.issueBoards.ModalFooter = Vue.extend({
mixins: [gl.issueBoards.ModalMixins],
data() { data() {
return ModalStore.store; return ModalStore.store;
}, },
...@@ -18,9 +19,6 @@ ...@@ -18,9 +19,6 @@
}, },
}, },
methods: { methods: {
hideModal() {
this.showAddIssuesModal = false;
},
addIssues() { addIssues() {
const list = this.selectedList; const list = this.selectedList;
const selectedIssues = ModalStore.getSelectedIssues(); const selectedIssues = ModalStore.getSelectedIssues();
...@@ -37,7 +35,7 @@ ...@@ -37,7 +35,7 @@
list.issuesSize += 1; list.issuesSize += 1;
}); });
this.hideModal(); this.toggleModal(false);
}, },
}, },
components: { components: {
...@@ -62,7 +60,7 @@ ...@@ -62,7 +60,7 @@
<button <button
class="btn btn-default pull-right" class="btn btn-default pull-right"
type="button" type="button"
@click="hideModal"> @click="toggleModal(false)">
Cancel Cancel
</button> </button>
</footer> </footer>
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
const ModalStore = gl.issueBoards.ModalStore; const ModalStore = gl.issueBoards.ModalStore;
gl.issueBoards.IssuesModalHeader = Vue.extend({ gl.issueBoards.IssuesModalHeader = Vue.extend({
mixins: [gl.issueBoards.ModalMixins],
data() { data() {
return ModalStore.store; return ModalStore.store;
}, },
...@@ -36,7 +37,7 @@ ...@@ -36,7 +37,7 @@
class="close" class="close"
data-dismiss="modal" data-dismiss="modal"
aria-label="Close" aria-label="Close"
@click="showAddIssuesModal = false"> @click="toggleModal(false)">
<span aria-hidden="true">×</span> <span aria-hidden="true">×</span>
</button> </button>
</h2> </h2>
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
const ModalStore = gl.issueBoards.ModalStore; const ModalStore = gl.issueBoards.ModalStore;
gl.issueBoards.ModalTabs = Vue.extend({ gl.issueBoards.ModalTabs = Vue.extend({
mixins: [gl.issueBoards.ModalMixins],
data() { data() {
return ModalStore.store; return ModalStore.store;
}, },
...@@ -21,7 +22,7 @@ ...@@ -21,7 +22,7 @@
<a <a
href="#" href="#"
role="button" role="button"
@click.prevent="activeTab = 'all'"> @click.prevent="changeTab('all')">
<span>All issues</span> <span>All issues</span>
<span class="badge"> <span class="badge">
{{ issuesCount }} {{ issuesCount }}
...@@ -32,7 +33,7 @@ ...@@ -32,7 +33,7 @@
<a <a
href="#" href="#"
role="button" role="button"
@click.prevent="activeTab = 'selected'"> @click.prevent="changeTab('selected')">
<span>Selected issues</span> <span>Selected issues</span>
<span class="badge"> <span class="badge">
{{ selectedCount }} {{ selectedCount }}
......
(() => {
const ModalStore = gl.issueBoards.ModalStore;
gl.issueBoards.ModalMixins = {
methods: {
toggleModal(toggle) {
ModalStore.store.showAddIssuesModal = toggle;
},
changeTab(tab) {
ModalStore.store.activeTab = tab;
},
},
};
})();
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