Commit 7e3c8438 authored by Phil Hughes's avatar Phil Hughes Committed by Douglas Barbosa Alexandre

Moved the http call into the service

parent c85df550
......@@ -58,13 +58,7 @@ const boardMilestoneSelect = require('./milestone_select');
methods: {
loadMilestones() {
this.milestoneDropdownOpen = !this.milestoneDropdownOpen;
if (!this.milestones.length) {
this.$http.get(this.milestonePath)
.then((res) => {
this.milestones = res.json();
});
}
BoardService.loadMilestones.call(this);
},
submit() {
gl.boardService.createBoard(this.board)
......
......@@ -18,19 +18,14 @@ module.exports = Vue.extend({
return {
loading: false,
milestones: [],
anyMilestone: {
extraMilestones: [{
id: null,
title: 'Any Milestone',
},
}],
};
},
mounted() {
this.loading = true;
this.$http.get(this.milestonePath)
.then((res) => {
this.milestones = res.json();
this.loading = false;
});
BoardService.loadMilestones.call(this);
},
template: `
<div>
......@@ -42,14 +37,14 @@ module.exports = Vue.extend({
<ul
class="board-milestone-list"
v-if="!loading">
<li>
<li v-for="milestone in extraMilestones">
<a
href="#"
@click.prevent.stop="selectMilestone(anyMilestone)">
@click.prevent.stop="selectMilestone(milestone)">
<i
class="fa fa-check"
v-if="board.milestone_id === anyMilestone.id"></i>
{{ anyMilestone.title }}
v-if="board.milestone_id === milestone.id"></i>
{{ milestone.title }}
</a>
</li>
<li class="divider"></li>
......
......@@ -102,6 +102,16 @@ class BoardService {
return this.issues.bulkUpdate(data);
}
static loadMilestones(path) {
this.loading = true;
return this.$http.get(this.milestonePath)
.then((res) => {
this.milestones = res.json();
this.loading = false;
});
}
}
window.BoardService = BoardService;
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