mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 15:13:50 +00:00
adding show/edit links (prepare modal) + save button
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
import 'es6-promise/auto';
|
||||
import { createStore } from 'vuex';
|
||||
import { getAccompanyingCourse, getParticipations } from '../api/accompanyingCourse';
|
||||
import { getAccompanyingCourse, postParticipation } from '../api/accompanyingCourse';
|
||||
|
||||
const debug = process.env.NODE_ENV !== 'production';
|
||||
|
||||
let promise = getAccompanyingCourse(window.accompanyingCourseId)
|
||||
const id = window.accompanyingCourseId;
|
||||
|
||||
let getDataPromise = getAccompanyingCourse(id)
|
||||
.then(accompanying_course => new Promise((resolve, reject) => {
|
||||
let store = createStore({
|
||||
const store = createStore({
|
||||
strict: debug,
|
||||
state: {
|
||||
accompanying_course: accompanying_course
|
||||
@@ -15,19 +17,36 @@ let promise = getAccompanyingCourse(window.accompanyingCourseId)
|
||||
},
|
||||
mutations: {
|
||||
removeParticipation(state, item) {
|
||||
console.log('remove item', item.id);
|
||||
state.accompanying_course.participations = state.accompanying_course.participations.filter(participation => participation !== item)
|
||||
//console.log('remove item', item.id);
|
||||
state.accompanying_course.participations = state.accompanying_course.participations.filter(
|
||||
participation => participation !== item
|
||||
)
|
||||
},
|
||||
addParticipation(state, item) {
|
||||
console.log('add new item');
|
||||
//console.log('add new item');
|
||||
state.accompanying_course.participations.push(item)
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
}
|
||||
});
|
||||
//console.log('store', store);
|
||||
console.log('store object', store.state.accompanying_course.id);
|
||||
resolve(store);
|
||||
}));
|
||||
|
||||
let postDataPromise = postParticipation(id)
|
||||
.then(participation => new Promise((resolve, reject) => {
|
||||
// get store
|
||||
// use store.actions to post (async way)
|
||||
console.log(store);
|
||||
resolve(store);
|
||||
}));
|
||||
|
||||
export default promise;
|
||||
/*
|
||||
let allPromises = Promise.all([getDataPromise, postDataPromise])
|
||||
.then((values) => {
|
||||
console.log('all promises values', values);
|
||||
});
|
||||
*/
|
||||
|
||||
export { getDataPromise };
|
||||
|
Reference in New Issue
Block a user