1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
import Api from '~/api';
import * as types from './mutation_types';
export const setProjectId = ({ commit }, projectId) => commit(types.SET_PROJECT_ID, projectId);
export const setSelectedMilestones = ({ commit }, selectedMilestones) =>
commit(types.SET_SELECTED_MILESTONES, selectedMilestones);
export const toggleMilestones = ({ commit, state }, selectedMilestone) => {
const removeMilestone = state.selectedMilestones.includes(selectedMilestone);
if (removeMilestone) {
commit(types.REMOVE_SELECTED_MILESTONE, selectedMilestone);
} else {
commit(types.ADD_SELECTED_MILESTONE, selectedMilestone);
}
};
export const search = ({ dispatch, commit }, query) => {
commit(types.SET_QUERY, query);
dispatch('searchMilestones');
};
export const fetchMilestones = ({ commit, state }) => {
commit(types.REQUEST_START);
Api.projectMilestones(state.projectId)
.then(response => {
commit(types.RECEIVE_PROJECT_MILESTONES_SUCCESS, response);
})
.catch(error => {
commit(types.RECEIVE_PROJECT_MILESTONES_ERROR, error);
})
.finally(() => {
commit(types.REQUEST_FINISH);
});
};
export const searchMilestones = ({ commit, state }) => {
commit(types.REQUEST_START);
const options = {
search: state.query,
scope: 'milestones',
};
Api.projectSearch(state.projectId, options)
.then(response => {
commit(types.RECEIVE_PROJECT_MILESTONES_SUCCESS, response);
})
.catch(error => {
commit(types.RECEIVE_PROJECT_MILESTONES_ERROR, error);
})
.finally(() => {
commit(types.REQUEST_FINISH);
});
};
|