mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
vue accompanyingcourse: ending referrer subcomponent
This commit is contained in:
parent
196f709065
commit
d3ac8d8ceb
@ -166,7 +166,16 @@ const postSocialIssue = (id, body, method) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const getUsers = () => {
|
const getUsers = () => {
|
||||||
const url = `/api/1.0/...json`;
|
const url = `/api/1.0/main/user.json`;
|
||||||
|
return fetch(url)
|
||||||
|
.then(response => {
|
||||||
|
if (response.ok) { return response.json(); }
|
||||||
|
throw Error('Error with request resource response');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const whoami = () => {
|
||||||
|
const url = `/api/1.0/main/whoami.json`;
|
||||||
return fetch(url)
|
return fetch(url)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (response.ok) { return response.json(); }
|
if (response.ok) { return response.json(); }
|
||||||
@ -201,6 +210,7 @@ export {
|
|||||||
postRequestor,
|
postRequestor,
|
||||||
postResource,
|
postResource,
|
||||||
getUsers,
|
getUsers,
|
||||||
|
whoami,
|
||||||
getListOrigins,
|
getListOrigins,
|
||||||
getOrigin,
|
getOrigin,
|
||||||
postSocialIssue
|
postSocialIssue
|
||||||
|
@ -1,42 +1,43 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="vue-component">
|
<div class="vue-component">
|
||||||
<h2><a name="section-40"></a>{{ $t('referrer.title') }}</h2>
|
<h2><a name="section-40"></a>{{ $t('referrer.title') }}</h2>
|
||||||
|
|
||||||
<div class="my-4">
|
<div class="my-4">
|
||||||
<label for="" class="">
|
<label for="" class="">
|
||||||
{{ $t('referrer.label') }}
|
{{ $t('referrer.label') }}
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<VueMultiselect
|
<VueMultiselect
|
||||||
track-by="id"
|
name="selectReferrer"
|
||||||
label="text"
|
label="text"
|
||||||
:multiple="false"
|
track-by="id"
|
||||||
:searchable="true"
|
v-bind:multiple="false"
|
||||||
:placeholder="$t('referrer.placeholder')"
|
v-bind:searchable="true"
|
||||||
@update:model-value="updateReferrer"
|
v-bind:placeholder="$t('referrer.placeholder')"
|
||||||
:model-value="value"
|
v-model="value"
|
||||||
:options="options">
|
v-bind:options="options"
|
||||||
</VueMultiselect>
|
@select="updateReferrer">
|
||||||
|
</VueMultiselect>
|
||||||
<ul class="record_actions">
|
|
||||||
<li>
|
<ul class="record_actions">
|
||||||
<button
|
<li>
|
||||||
class="sc-button bt-create"
|
<button
|
||||||
type="button"
|
class="sc-button bt-create"
|
||||||
name="button"
|
type="button"
|
||||||
@click="assignMe">
|
name="button"
|
||||||
{{ $t('referrer.assign_me') }}
|
@click="assignMe">
|
||||||
</button>
|
{{ $t('referrer.assign_me') }}
|
||||||
</li>
|
</button>
|
||||||
</ul>
|
</li>
|
||||||
|
</ul>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import VueMultiselect from 'vue-multiselect';
|
import VueMultiselect from 'vue-multiselect';
|
||||||
import { getUsers } from '../api';
|
import { getUsers, whoami } from '../api';
|
||||||
import { mapState } from 'vuex';
|
import { mapState } from 'vuex';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -58,19 +59,20 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
getOptions() {
|
getOptions() {
|
||||||
getUsers().then(response => new Promise((resolve, reject) => {
|
getUsers().then(response => new Promise((resolve, reject) => {
|
||||||
console.log(response);
|
this.options = response.results;
|
||||||
resolve();
|
resolve();
|
||||||
})).catch(er => this.$store.commit('catchError'), error);
|
}));
|
||||||
},
|
},
|
||||||
updateReferrer(value) {
|
updateReferrer(value) {
|
||||||
this.$store.dispatch('updateReferrer', this.transformValue(value));
|
//console.log('value', value);
|
||||||
},
|
this.$store.dispatch('updateReferrer', value);
|
||||||
transformValue(value) {
|
|
||||||
let payload = value;
|
|
||||||
return { payload, body, method };
|
|
||||||
},
|
},
|
||||||
assignMe() {
|
assignMe() {
|
||||||
console.log('assign me');
|
//console.log('assign me');
|
||||||
|
whoami().then(me => new Promise((resolve, reject) => {
|
||||||
|
this.$store.dispatch('updateReferrer', me);
|
||||||
|
resolve();
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,6 +81,10 @@ let initPromise = getAccompanyingCourse(id)
|
|||||||
updateSocialIssues(state, value) {
|
updateSocialIssues(state, value) {
|
||||||
state.accompanyingCourse.socialIssues = value;
|
state.accompanyingCourse.socialIssues = value;
|
||||||
},
|
},
|
||||||
|
updateReferrer(state, value) {
|
||||||
|
console.log('value', value);
|
||||||
|
state.accompanyingCourse.user = value;
|
||||||
|
},
|
||||||
confirmAccompanyingCourse(state, response) {
|
confirmAccompanyingCourse(state, response) {
|
||||||
//console.log('### mutation: confirmAccompanyingCourse: response', response);
|
//console.log('### mutation: confirmAccompanyingCourse: response', response);
|
||||||
state.accompanyingCourse.step = response.step;
|
state.accompanyingCourse.step = response.step;
|
||||||
@ -187,6 +191,13 @@ let initPromise = getAccompanyingCourse(id)
|
|||||||
resolve();
|
resolve();
|
||||||
})).catch((error) => { commit('catchError', error) });
|
})).catch((error) => { commit('catchError', error) });
|
||||||
},
|
},
|
||||||
|
updateReferrer({ commit }, payload) {
|
||||||
|
patchAccompanyingCourse(id, { type: "accompanying_period", user: { id: payload.id, type: payload.type } })
|
||||||
|
.then(course => new Promise((resolve, reject) => {
|
||||||
|
commit('updateReferrer', course.user);
|
||||||
|
resolve();
|
||||||
|
})).catch((error) => { commit('catchError', error) });
|
||||||
|
},
|
||||||
confirmAccompanyingCourse({ commit }) {
|
confirmAccompanyingCourse({ commit }) {
|
||||||
//console.log('## action: confirmAccompanyingCourse');
|
//console.log('## action: confirmAccompanyingCourse');
|
||||||
confirmAccompanyingCourse(id)
|
confirmAccompanyingCourse(id)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user