mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +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 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)
|
||||
.then(response => {
|
||||
if (response.ok) { return response.json(); }
|
||||
@ -201,6 +210,7 @@ export {
|
||||
postRequestor,
|
||||
postResource,
|
||||
getUsers,
|
||||
whoami,
|
||||
getListOrigins,
|
||||
getOrigin,
|
||||
postSocialIssue
|
||||
|
@ -1,42 +1,43 @@
|
||||
<template>
|
||||
<div class="vue-component">
|
||||
<h2><a name="section-40"></a>{{ $t('referrer.title') }}</h2>
|
||||
|
||||
<div class="my-4">
|
||||
<label for="" class="">
|
||||
{{ $t('referrer.label') }}
|
||||
</label>
|
||||
|
||||
<VueMultiselect
|
||||
track-by="id"
|
||||
label="text"
|
||||
:multiple="false"
|
||||
:searchable="true"
|
||||
:placeholder="$t('referrer.placeholder')"
|
||||
@update:model-value="updateReferrer"
|
||||
:model-value="value"
|
||||
:options="options">
|
||||
</VueMultiselect>
|
||||
|
||||
<ul class="record_actions">
|
||||
<li>
|
||||
<button
|
||||
class="sc-button bt-create"
|
||||
type="button"
|
||||
name="button"
|
||||
@click="assignMe">
|
||||
{{ $t('referrer.assign_me') }}
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="vue-component">
|
||||
<h2><a name="section-40"></a>{{ $t('referrer.title') }}</h2>
|
||||
|
||||
<div class="my-4">
|
||||
<label for="" class="">
|
||||
{{ $t('referrer.label') }}
|
||||
</label>
|
||||
|
||||
<VueMultiselect
|
||||
name="selectReferrer"
|
||||
label="text"
|
||||
track-by="id"
|
||||
v-bind:multiple="false"
|
||||
v-bind:searchable="true"
|
||||
v-bind:placeholder="$t('referrer.placeholder')"
|
||||
v-model="value"
|
||||
v-bind:options="options"
|
||||
@select="updateReferrer">
|
||||
</VueMultiselect>
|
||||
|
||||
<ul class="record_actions">
|
||||
<li>
|
||||
<button
|
||||
class="sc-button bt-create"
|
||||
type="button"
|
||||
name="button"
|
||||
@click="assignMe">
|
||||
{{ $t('referrer.assign_me') }}
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import VueMultiselect from 'vue-multiselect';
|
||||
import { getUsers } from '../api';
|
||||
import { getUsers, whoami } from '../api';
|
||||
import { mapState } from 'vuex';
|
||||
|
||||
export default {
|
||||
@ -58,19 +59,20 @@ export default {
|
||||
methods: {
|
||||
getOptions() {
|
||||
getUsers().then(response => new Promise((resolve, reject) => {
|
||||
console.log(response);
|
||||
this.options = response.results;
|
||||
resolve();
|
||||
})).catch(er => this.$store.commit('catchError'), error);
|
||||
}));
|
||||
},
|
||||
updateReferrer(value) {
|
||||
this.$store.dispatch('updateReferrer', this.transformValue(value));
|
||||
},
|
||||
transformValue(value) {
|
||||
let payload = value;
|
||||
return { payload, body, method };
|
||||
//console.log('value', value);
|
||||
this.$store.dispatch('updateReferrer', value);
|
||||
},
|
||||
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) {
|
||||
state.accompanyingCourse.socialIssues = value;
|
||||
},
|
||||
updateReferrer(state, value) {
|
||||
console.log('value', value);
|
||||
state.accompanyingCourse.user = value;
|
||||
},
|
||||
confirmAccompanyingCourse(state, response) {
|
||||
//console.log('### mutation: confirmAccompanyingCourse: response', response);
|
||||
state.accompanyingCourse.step = response.step;
|
||||
@ -187,6 +191,13 @@ let initPromise = getAccompanyingCourse(id)
|
||||
resolve();
|
||||
})).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 }) {
|
||||
//console.log('## action: confirmAccompanyingCourse');
|
||||
confirmAccompanyingCourse(id)
|
||||
|
Loading…
x
Reference in New Issue
Block a user