mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
remove store AddPersons module
This commit is contained in:
parent
57c420e9dd
commit
242c2b31a3
@ -1,6 +1,5 @@
|
|||||||
import 'es6-promise/auto';
|
import 'es6-promise/auto';
|
||||||
import { createStore } from 'vuex';
|
import { createStore } from 'vuex';
|
||||||
//import addPersons from './modules/addPersons'
|
|
||||||
import { getAccompanyingCourse, postParticipation } from '../api';
|
import { getAccompanyingCourse, postParticipation } from '../api';
|
||||||
|
|
||||||
const debug = process.env.NODE_ENV !== 'production';
|
const debug = process.env.NODE_ENV !== 'production';
|
||||||
@ -13,7 +12,6 @@ let initPromise = getAccompanyingCourse(id)
|
|||||||
const store = createStore({
|
const store = createStore({
|
||||||
strict: debug,
|
strict: debug,
|
||||||
modules: {
|
modules: {
|
||||||
//addPersons
|
|
||||||
},
|
},
|
||||||
state: {
|
state: {
|
||||||
accompanyingCourse: accompanying_course,
|
accompanyingCourse: accompanying_course,
|
||||||
|
@ -1,72 +0,0 @@
|
|||||||
import { searchPersons } from 'ChillPersonAssets/vuejs/_api/AddPersons';
|
|
||||||
|
|
||||||
|
|
||||||
// initial state
|
|
||||||
const state = {
|
|
||||||
query: "",
|
|
||||||
suggested: [],
|
|
||||||
selected: []
|
|
||||||
}
|
|
||||||
|
|
||||||
// getters
|
|
||||||
const getters = {
|
|
||||||
selectedAndSuggested: state => {
|
|
||||||
const uniqBy = (a, key) => [
|
|
||||||
...new Map(
|
|
||||||
a.map(x => [key(x), x])
|
|
||||||
).values()
|
|
||||||
];
|
|
||||||
let union = [...new Set([
|
|
||||||
...state.suggested.slice().reverse(),
|
|
||||||
...state.selected.slice().reverse(),
|
|
||||||
])];
|
|
||||||
return uniqBy(union, k => k.id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// mutations
|
|
||||||
const mutations = {
|
|
||||||
setQuery(state, query) {
|
|
||||||
state.query = query;
|
|
||||||
},
|
|
||||||
loadSuggestions(state, suggested) {
|
|
||||||
state.suggested = suggested;
|
|
||||||
},
|
|
||||||
updateSelected(state, value) {
|
|
||||||
state.selected = value;
|
|
||||||
},
|
|
||||||
resetState(state, selected) {
|
|
||||||
state.selected = state.selected.filter(value => value !== selected);
|
|
||||||
state.query = "";
|
|
||||||
state.suggested = [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// actions
|
|
||||||
const actions = {
|
|
||||||
setQuery({ commit }, payload) {
|
|
||||||
console.log('## action: setquery: payload', payload);
|
|
||||||
commit('setQuery', payload.query);
|
|
||||||
if (payload.query.length >= 3) {
|
|
||||||
searchPersons(payload)
|
|
||||||
.then(suggested => new Promise((resolve, reject) => {
|
|
||||||
commit('loadSuggestions', suggested.results);
|
|
||||||
resolve();
|
|
||||||
}));
|
|
||||||
} else {
|
|
||||||
commit('loadSuggestions', []);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
updateSelected({ commit }, payload) {
|
|
||||||
//console.log('## action: update selected values: payload', payload);
|
|
||||||
commit('updateSelected', payload);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default {
|
|
||||||
//namespaced: true,
|
|
||||||
state,
|
|
||||||
getters,
|
|
||||||
actions,
|
|
||||||
mutations
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user