mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
Confirm post request, change state step and hide components
This commit is contained in:
parent
050c325195
commit
ae1146c79c
@ -5,8 +5,8 @@
|
|||||||
<social-issue></social-issue>
|
<social-issue></social-issue>
|
||||||
<referrer></referrer>
|
<referrer></referrer>
|
||||||
<resources></resources>
|
<resources></resources>
|
||||||
<comment></comment>
|
<comment v-if="accompanyingCourse.step === 'DRAFT'"></comment>
|
||||||
<confirm></confirm>
|
<confirm v-if="accompanyingCourse.step === 'DRAFT'"></confirm>
|
||||||
<!--test></test-->
|
<!--test></test-->
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -13,18 +13,6 @@ const getAccompanyingCourse = (id) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* Endpoint
|
|
||||||
*/
|
|
||||||
const getSocialIssues = () => {
|
|
||||||
const url = `/api/1.0/person/social-work/social-issue.json`;
|
|
||||||
return fetch(url)
|
|
||||||
.then(response => {
|
|
||||||
if (response.ok) { return response.json(); }
|
|
||||||
throw Error('Error with request resource response');
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Endpoint v.2 chill_api_single_accompanying_course__entity
|
* Endpoint v.2 chill_api_single_accompanying_course__entity
|
||||||
* method PATCH, patch AccompanyingCourse Instance
|
* method PATCH, patch AccompanyingCourse Instance
|
||||||
@ -48,6 +36,33 @@ const patchAccompanyingCourse = (id, body) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Endpoint to change 'DRAFT' step to 'CONFIRMED'
|
||||||
|
*/
|
||||||
|
const confirmAccompanyingCourse = (id) => {
|
||||||
|
const url = `/api/1.0/person/accompanying-course/${id}/confirm.json`
|
||||||
|
return fetch(url, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {'Content-Type': 'application/json;charset=utf-8'}
|
||||||
|
})
|
||||||
|
.then(response => {
|
||||||
|
if (response.ok) { return response.json(); }
|
||||||
|
throw Error('Error with request resource response');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Endpoint
|
||||||
|
*/
|
||||||
|
const getSocialIssues = () => {
|
||||||
|
const url = `/api/1.0/person/social-work/social-issue.json`;
|
||||||
|
return fetch(url)
|
||||||
|
.then(response => {
|
||||||
|
if (response.ok) { return response.json(); }
|
||||||
|
throw Error('Error with request resource response');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Endpoint v.2 chill_api_single_accompanying_course_participation,
|
* Endpoint v.2 chill_api_single_accompanying_course_participation,
|
||||||
* method POST/DELETE, add/close a participation to the accompanyingCourse
|
* method POST/DELETE, add/close a participation to the accompanyingCourse
|
||||||
@ -133,8 +148,9 @@ const postResource = (id, payload, method) => {
|
|||||||
|
|
||||||
export {
|
export {
|
||||||
getAccompanyingCourse,
|
getAccompanyingCourse,
|
||||||
getSocialIssues,
|
|
||||||
patchAccompanyingCourse,
|
patchAccompanyingCourse,
|
||||||
|
confirmAccompanyingCourse,
|
||||||
|
getSocialIssues,
|
||||||
postParticipation,
|
postParticipation,
|
||||||
postRequestor,
|
postRequestor,
|
||||||
postResource,
|
postResource,
|
||||||
|
@ -2,18 +2,18 @@
|
|||||||
<div class="vue-component">
|
<div class="vue-component">
|
||||||
<h3>
|
<h3>
|
||||||
{{ $t('confirm.title') }}
|
{{ $t('confirm.title') }}
|
||||||
<span v-if="accompanyingCourse.step !== 'DRAFT'"
|
|
||||||
class="badge badge-pill badge-primary">
|
|
||||||
{{ $t('course.step.active') }}
|
|
||||||
</span>
|
|
||||||
<span v-else class="badge badge-pill badge-secondary">
|
|
||||||
{{ $t('course.step.draft') }}
|
|
||||||
</span>
|
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
<p v-if="accompanyingCourse.step === 'DRAFT'">
|
<div>
|
||||||
{{ $t('confirm.text_draft') }}
|
<p>
|
||||||
</p>
|
{{ $t('confirm.text_draft') }}
|
||||||
|
<span class="badge badge-pill badge-secondary">{{ $t('course.step.draft') }}</span>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
{{ $t('confirm.text_active') }}
|
||||||
|
<span class="badge badge-pill badge-primary">{{ $t('course.step.active') }}</span>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<dl v-if="accompanyingCourse.closingDate">
|
<dl v-if="accompanyingCourse.closingDate">
|
||||||
<dt>{{ $t('course.closing_date') }}</dt>
|
<dt>{{ $t('course.closing_date') }}</dt>
|
||||||
@ -44,8 +44,15 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
confirmCourse() {
|
confirmCourse() {
|
||||||
console.log('confirmCourse');
|
console.log('@@ CLICK confirmCourse');
|
||||||
|
this.$store.dispatch('confirmAccompanyingCourse');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
div.vue-component > div {
|
||||||
|
margin: 1em;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
@ -14,7 +14,6 @@ const appMessages = {
|
|||||||
status: "État",
|
status: "État",
|
||||||
step: {
|
step: {
|
||||||
draft: "Brouillon",
|
draft: "Brouillon",
|
||||||
open: "Ouvert",
|
|
||||||
active: "En file active"
|
active: "En file active"
|
||||||
},
|
},
|
||||||
open_at: "ouvert le ",
|
open_at: "ouvert le ",
|
||||||
@ -71,8 +70,9 @@ const appMessages = {
|
|||||||
},
|
},
|
||||||
confirm: {
|
confirm: {
|
||||||
title: "Confirmation",
|
title: "Confirmation",
|
||||||
text_draft: "Le parcours est actuellement au statut de brouillon. En validant cette étape, vous lui donnez le statut actif.",
|
text_draft: "Le parcours est actuellement à l'état de ",
|
||||||
ok: "Activer le parcours"
|
text_active: "En validant cette étape, vous lui donnez le statut ",
|
||||||
|
ok: "Confirmer le parcours"
|
||||||
},
|
},
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import 'es6-promise/auto';
|
import 'es6-promise/auto';
|
||||||
import { createStore } from 'vuex';
|
import { createStore } from 'vuex';
|
||||||
import { getAccompanyingCourse,
|
import { getAccompanyingCourse,
|
||||||
patchAccompanyingCourse,
|
patchAccompanyingCourse,
|
||||||
|
confirmAccompanyingCourse,
|
||||||
postParticipation,
|
postParticipation,
|
||||||
postRequestor,
|
postRequestor,
|
||||||
postResource } from '../api';
|
postResource } from '../api';
|
||||||
@ -75,6 +76,10 @@ let initPromise = getAccompanyingCourse(id)
|
|||||||
postFirstComment(state, comment) {
|
postFirstComment(state, comment) {
|
||||||
console.log('### mutation: postFirstComment', comment);
|
console.log('### mutation: postFirstComment', comment);
|
||||||
state.accompanyingCourse.initialComment = comment;
|
state.accompanyingCourse.initialComment = comment;
|
||||||
|
},
|
||||||
|
confirmAccompanyingCourse(state, response) {
|
||||||
|
//console.log('### mutation: confirmAccompanyingCourse: response', response);
|
||||||
|
state.accompanyingCourse.step = response.step;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
@ -168,6 +173,15 @@ let initPromise = getAccompanyingCourse(id)
|
|||||||
commit('postFirstComment', course.initialComment);
|
commit('postFirstComment', course.initialComment);
|
||||||
resolve();
|
resolve();
|
||||||
})).catch((error) => { commit('catchError', error) });
|
})).catch((error) => { commit('catchError', error) });
|
||||||
|
},
|
||||||
|
|
||||||
|
confirmAccompanyingCourse({ commit }) {
|
||||||
|
console.log('## action: confirmAccompanyingCourse');
|
||||||
|
confirmAccompanyingCourse(id)
|
||||||
|
.then(response => new Promise((resolve, reject) => {
|
||||||
|
commit('confirmAccompanyingCourse', response);
|
||||||
|
resolve();
|
||||||
|
})).catch((error) => { commit('catchError', error) });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user