mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
requestor logic, is_anonymous patch request
This commit is contained in:
parent
0d6a339b53
commit
4fb487dcef
@ -13,6 +13,29 @@ const getAccompanyingCourse = (id) => {
|
||||
});
|
||||
};
|
||||
|
||||
/*
|
||||
* Endpoint v.2 chill_api_single_accompanying_course__entity
|
||||
* method PATCH, patch AccompanyingCourse Instance
|
||||
*
|
||||
* @id integer - id of accompanyingCourse
|
||||
* @body Object - dictionary with changes to post
|
||||
*/
|
||||
const patchAccompanyingCourse = (id, body) => {
|
||||
console.log('body', body);
|
||||
const url = `/api/1.0/person/accompanying-course/${id}.json`;
|
||||
return fetch(url, {
|
||||
method: 'PATCH',
|
||||
headers: {
|
||||
'Content-Type': 'application/json;charset=utf-8'
|
||||
},
|
||||
body: JSON.stringify(body)
|
||||
})
|
||||
.then(response => {
|
||||
if (response.ok) { return response.json(); }
|
||||
throw Error('Error with request resource response');
|
||||
});
|
||||
};
|
||||
|
||||
/*
|
||||
* Endpoint v.2 chill_api_single_accompanying_course_participation,
|
||||
* method POST/DELETE, add/close a participation to the accompanyingCourse
|
||||
@ -50,7 +73,7 @@ const postRequestor = (id, payload, method) => {
|
||||
const typeId = `${payload.result.type}_id`;
|
||||
body[typeId] = payload.result[typeId];
|
||||
};
|
||||
console.log(body);
|
||||
console.log('body', body);
|
||||
const url = `/api/1.0/person/accompanying-course/${id}/requestor.json`;
|
||||
return fetch(url, {
|
||||
method: method,
|
||||
@ -66,7 +89,8 @@ const postRequestor = (id, payload, method) => {
|
||||
};
|
||||
|
||||
export {
|
||||
getAccompanyingCourse,
|
||||
getAccompanyingCourse,
|
||||
patchAccompanyingCourse,
|
||||
postParticipation,
|
||||
postRequestor
|
||||
};
|
||||
|
@ -4,48 +4,47 @@
|
||||
<h3>{{ $t('requestor.title') }}</h3>
|
||||
|
||||
<div v-if="accompanyingCourse.requestor">
|
||||
<label>
|
||||
<input type="checkbox" v-model="isAnonymous" :value="value" />
|
||||
{{ $t('requestor.is_anonymous') }}
|
||||
</label>
|
||||
|
||||
<dt>{{ $t('requestor.type') }}</dt>
|
||||
<dd>{{ accompanyingCourse.requestor.type }}</dd>
|
||||
<dd>{{ accompanyingCourse.requestor.type }}</dd>
|
||||
<dt>{{ $t('requestor.text') }}</dt>
|
||||
<dd>{{ accompanyingCourse.requestor.text }}</dd>
|
||||
<dt>{{ $t('requestor.anonymous') }}</dt>
|
||||
<dd>{{ accompanyingCourse.requestorAnonymous }}</dd>
|
||||
<dd>{{ accompanyingCourse.requestor.text }}</dd>
|
||||
<dt>{{ $t('requestor.is_anonymous') }}</dt>
|
||||
<dd>{{ accompanyingCourse.requestorAnonymous }}</dd>
|
||||
|
||||
<div v-if="accompanyingCourse.requestor.type === 'person'">
|
||||
<dt>{{ $t('requestor.person_id') }}</dt>
|
||||
<dd>{{ accompanyingCourse.requestor.person_id }}</dd>
|
||||
<dd>{{ accompanyingCourse.requestor.person_id }}</dd>
|
||||
<dt>{{ $t('requestor.birthdate') }}</dt>
|
||||
<dd>{{ $d(accompanyingCourse.requestor.birthdate.datetime, 'short') }}</dd>
|
||||
<dd>{{ $d(accompanyingCourse.requestor.birthdate.datetime, 'short') }}</dd>
|
||||
<dt>{{ $t('requestor.center') }}</dt>
|
||||
<dd>{{ accompanyingCourse.requestor.center.name }}</dd>
|
||||
<dd>{{ accompanyingCourse.requestor.center.name }}</dd>
|
||||
<dt>{{ $t('requestor.firstName') }}</dt>
|
||||
<dd>{{ accompanyingCourse.requestor.firstName }}</dd>
|
||||
<dd>{{ accompanyingCourse.requestor.firstName }}</dd>
|
||||
<dt>{{ $t('requestor.lastName') }}</dt>
|
||||
<dd>{{ accompanyingCourse.requestor.lastName }}</dd>
|
||||
<dd>{{ accompanyingCourse.requestor.lastName }}</dd>
|
||||
<dt>{{ $t('requestor.phonenumber') }}</dt>
|
||||
<dd>{{ accompanyingCourse.requestor.phonenumber }}</dd>
|
||||
<dd>{{ accompanyingCourse.requestor.phonenumber }}</dd>
|
||||
<dt>{{ $t('requestor.mobilenumber') }}</dt>
|
||||
<dd>{{ accompanyingCourse.requestor.mobilenumber }}</dd>
|
||||
<dd>{{ accompanyingCourse.requestor.mobilenumber }}</dd>
|
||||
<dt>{{ $t('requestor.altNames') }}</dt>
|
||||
<dd>{{ accompanyingCourse.requestor.altNames }}</dd>
|
||||
<dd>{{ accompanyingCourse.requestor.altNames }}</dd>
|
||||
</div>
|
||||
|
||||
<div v-if="accompanyingCourse.requestor.type === 'thirdparty'">
|
||||
<dt>{{ $t('requestor.person_id') }}</dt>
|
||||
<dd>{{ accompanyingCourse.requestor.thirdparty_id }}</dd>
|
||||
<dd>{{ accompanyingCourse.requestor.thirdparty_id }}</dd>
|
||||
<dt>{{ $t('requestor.address') }}</dt>
|
||||
<dd>{{ accompanyingCourse.requestor.address.text }}</dd>
|
||||
<dd>{{ accompanyingCourse.requestor.address.text }}</dd>
|
||||
<dt>{{ $t('requestor.location') }}</dt>
|
||||
<dd>{{ accompanyingCourse.requestor.address.postcode.name }}</dd>
|
||||
<dd>{{ accompanyingCourse.requestor.address.postcode.name }}</dd>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<label>
|
||||
<input type="checkbox" v-model="isAnonymous" :value="value" />
|
||||
{{ $t('requestor.is_anonymous') }}
|
||||
</label>
|
||||
|
||||
<button v-if="accompanyingCourse.requestor !== null"
|
||||
class="sc-button bt-remove"
|
||||
:title="$t('action.remove')"
|
||||
|
@ -1,6 +1,9 @@
|
||||
import 'es6-promise/auto';
|
||||
import { createStore } from 'vuex';
|
||||
import { getAccompanyingCourse, postParticipation, postRequestor } from '../api';
|
||||
import { getAccompanyingCourse,
|
||||
patchAccompanyingCourse,
|
||||
postParticipation,
|
||||
postRequestor } from '../api';
|
||||
|
||||
const debug = process.env.NODE_ENV !== 'production';
|
||||
const id = window.accompanyingCourseId;
|
||||
@ -35,11 +38,16 @@ let initPromise = getAccompanyingCourse(id)
|
||||
state.accompanyingCourse.participations.push(participation);
|
||||
},
|
||||
removeRequestor(state) {
|
||||
console.log('### mutation: removeRequestor');
|
||||
state.accompanyingCourse.requestor = null;
|
||||
},
|
||||
addRequestor(state, requestor) {
|
||||
console.log(requestor);
|
||||
console.log('### mutation: addRequestor', requestor);
|
||||
state.accompanyingCourse.requestor = requestor;
|
||||
},
|
||||
requestorIsAnonymous(state, value) {
|
||||
console.log('### mutation: requestorIsAnonymous', value);
|
||||
state.accompanyingCourse.requestorAnonymous = value;
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
@ -69,9 +77,11 @@ let initPromise = getAccompanyingCourse(id)
|
||||
});
|
||||
},
|
||||
removeRequestor({ commit }) {
|
||||
console.log('## action: fetch post requestor');
|
||||
postRequestor(id, null, 'DELETE')
|
||||
.then(requestor => new Promise((resolve, reject) => {
|
||||
commit('removeRequestor');
|
||||
commit('requestorIsAnonymous', false);
|
||||
resolve();
|
||||
}))
|
||||
.catch((error) => {
|
||||
@ -79,7 +89,7 @@ let initPromise = getAccompanyingCourse(id)
|
||||
});
|
||||
},
|
||||
addRequestor({ commit }, payload) {
|
||||
console.log(payload);
|
||||
console.log('## action: fetch post requestor: payload', payload);
|
||||
postRequestor(id, payload, 'POST')
|
||||
.then(requestor => new Promise((resolve, reject) => {
|
||||
commit('addRequestor', requestor);
|
||||
@ -90,7 +100,15 @@ let initPromise = getAccompanyingCourse(id)
|
||||
});
|
||||
},
|
||||
requestorIsAnonymous({ commit }, payload) {
|
||||
console.log('payload', payload);
|
||||
console.log('## action: fetch patch AccompanyingCourse: payload', payload);
|
||||
patchAccompanyingCourse(id, { requestorAnonymous: payload })
|
||||
.then(course => new Promise((resolve, reject) => {
|
||||
commit('requestorIsAnonymous', course.requestorAnonymous)
|
||||
resolve();
|
||||
}))
|
||||
.catch((error) => {
|
||||
state.errorMsg.push(error.message);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user