debian-mirror-gitlab/app/assets/javascripts/milestones/stores/mutations.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

67 lines
2 KiB
JavaScript
Raw Normal View History

2021-01-03 14:25:43 +05:30
import Vue from 'vue';
import * as types from './mutation_types';
export default {
[types.SET_PROJECT_ID](state, projectId) {
state.projectId = projectId;
},
2021-01-29 00:20:46 +05:30
[types.SET_GROUP_ID](state, groupId) {
state.groupId = groupId;
},
[types.SET_GROUP_MILESTONES_AVAILABLE](state, groupMilestonesAvailable) {
state.groupMilestonesAvailable = groupMilestonesAvailable;
},
2021-01-03 14:25:43 +05:30
[types.SET_SELECTED_MILESTONES](state, selectedMilestones) {
Vue.set(state, 'selectedMilestones', selectedMilestones);
},
2021-01-29 00:20:46 +05:30
[types.CLEAR_SELECTED_MILESTONES](state) {
Vue.set(state, 'selectedMilestones', []);
},
2021-01-03 14:25:43 +05:30
[types.ADD_SELECTED_MILESTONE](state, selectedMilestone) {
state.selectedMilestones.push(selectedMilestone);
},
[types.REMOVE_SELECTED_MILESTONE](state, selectedMilestone) {
const filteredMilestones = state.selectedMilestones.filter(
2021-03-08 18:12:59 +05:30
(milestone) => milestone !== selectedMilestone,
2021-01-03 14:25:43 +05:30
);
Vue.set(state, 'selectedMilestones', filteredMilestones);
},
2021-01-29 00:20:46 +05:30
[types.SET_SEARCH_QUERY](state, searchQuery) {
state.searchQuery = searchQuery;
2021-01-03 14:25:43 +05:30
},
[types.REQUEST_START](state) {
state.requestCount += 1;
},
[types.REQUEST_FINISH](state) {
state.requestCount -= 1;
},
[types.RECEIVE_PROJECT_MILESTONES_SUCCESS](state, response) {
state.matches.projectMilestones = {
2021-01-29 00:20:46 +05:30
list: response.data.map(({ title }) => ({ title })),
2021-11-11 11:23:49 +05:30
totalCount: parseInt(response.headers['x-total'], 10) || response.data.length,
2021-01-03 14:25:43 +05:30
error: null,
};
},
[types.RECEIVE_PROJECT_MILESTONES_ERROR](state, error) {
state.matches.projectMilestones = {
list: [],
totalCount: 0,
error,
};
},
2021-01-29 00:20:46 +05:30
[types.RECEIVE_GROUP_MILESTONES_SUCCESS](state, response) {
state.matches.groupMilestones = {
list: response.data.map(({ title }) => ({ title })),
2021-11-11 11:23:49 +05:30
totalCount: parseInt(response.headers['x-total'], 10) || response.data.length,
2021-01-29 00:20:46 +05:30
error: null,
};
},
[types.RECEIVE_GROUP_MILESTONES_ERROR](state, error) {
state.matches.groupMilestones = {
list: [],
totalCount: 0,
error,
};
},
2021-01-03 14:25:43 +05:30
};