mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
AddAddress option buttonType: component manage button in edit or create context
This commit is contained in:
@@ -4,12 +4,12 @@
|
||||
*
|
||||
* @id integer - id of accompanyingCourse
|
||||
*/
|
||||
const getAccompanyingCourse = (id) => {
|
||||
const getAccompanyingCourse = (id) => {
|
||||
const url = `/api/1.0/person/accompanying-course/${id}.json`;
|
||||
return fetch(url)
|
||||
.then(response => {
|
||||
if (response.ok) { return response.json(); }
|
||||
throw Error('Error with request resource response');
|
||||
throw Error('Error with request resource response');
|
||||
});
|
||||
};
|
||||
|
||||
@@ -20,8 +20,8 @@ const getAccompanyingCourse = (id) => {
|
||||
* @id integer - id of accompanyingCourse
|
||||
* @body Object - dictionary with changes to post
|
||||
*/
|
||||
const patchAccompanyingCourse = (id, body) => {
|
||||
console.log('body', body);
|
||||
const patchAccompanyingCourse = (id, body) => {
|
||||
//console.log('body', body);
|
||||
const url = `/api/1.0/person/accompanying-course/${id}.json`;
|
||||
return fetch(url, {
|
||||
method: 'PATCH',
|
||||
@@ -32,7 +32,7 @@ const patchAccompanyingCourse = (id, body) => {
|
||||
})
|
||||
.then(response => {
|
||||
if (response.ok) { return response.json(); }
|
||||
throw Error('Error with request resource response');
|
||||
throw Error('Error with request resource response');
|
||||
});
|
||||
};
|
||||
|
||||
@@ -47,24 +47,24 @@ const confirmAccompanyingCourse = (id) => {
|
||||
})
|
||||
.then(response => {
|
||||
if (response.ok) { return response.json(); }
|
||||
throw Error('Error with request resource response');
|
||||
throw Error('Error with request resource response');
|
||||
});
|
||||
};
|
||||
|
||||
/*
|
||||
* Endpoint
|
||||
* 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');
|
||||
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
|
||||
*
|
||||
* @id integer - id of accompanyingCourse
|
||||
@@ -83,12 +83,12 @@ const postParticipation = (id, payload, method) => {
|
||||
})
|
||||
.then(response => {
|
||||
if (response.ok) { return response.json(); }
|
||||
throw Error('Error with request resource response');
|
||||
throw Error('Error with request resource response');
|
||||
});
|
||||
};
|
||||
|
||||
/*
|
||||
* Endpoint v.2 chill_api_single_accompanying_course_requestor,
|
||||
* Endpoint v.2 chill_api_single_accompanying_course_requestor,
|
||||
* method POST/DELETE, add/close a requestor to the accompanyingCourse
|
||||
*
|
||||
* @id integer - id of accompanyingCourse
|
||||
@@ -109,12 +109,12 @@ const postRequestor = (id, payload, method) => {
|
||||
})
|
||||
.then(response => {
|
||||
if (response.ok) { return response.json(); }
|
||||
throw Error('Error with request resource response');
|
||||
throw Error('Error with request resource response');
|
||||
});
|
||||
};
|
||||
|
||||
/*
|
||||
* Endpoint v.2 chill_api_single_accompanying_course_resource,
|
||||
* Endpoint v.2 chill_api_single_accompanying_course_resource,
|
||||
* method POST/DELETE, add/remove a resource to the accompanyingCourse
|
||||
*
|
||||
* @id integer - id of accompanyingCourse
|
||||
@@ -126,11 +126,11 @@ const postResource = (id, payload, method) => {
|
||||
const body = { type: "accompanying_period_resource" };
|
||||
switch (method) {
|
||||
case 'DELETE':
|
||||
body['id'] = payload.id;
|
||||
body['id'] = payload.id;
|
||||
break;
|
||||
default:
|
||||
body['resource'] = { type: payload.type, id: payload.id };
|
||||
}
|
||||
}
|
||||
//console.log('body', body);
|
||||
const url = `/api/1.0/person/accompanying-course/${id}/resource.json`;
|
||||
return fetch(url, {
|
||||
@@ -142,7 +142,7 @@ const postResource = (id, payload, method) => {
|
||||
})
|
||||
.then(response => {
|
||||
if (response.ok) { return response.json(); }
|
||||
throw Error('Error with request resource response');
|
||||
throw Error('Error with request resource response');
|
||||
});
|
||||
};
|
||||
|
||||
@@ -150,7 +150,7 @@ const postResource = (id, payload, method) => {
|
||||
* Endpoint to Add/remove SocialIssue
|
||||
*/
|
||||
const postSocialIssue = (id, body, method) => {
|
||||
//console.log('api body and method', body, method);
|
||||
//console.log('api body and method', body, method);
|
||||
const url = `/api/1.0/person/accompanying-course/${id}/socialissue.json`;
|
||||
return fetch(url, {
|
||||
method: method,
|
||||
@@ -161,7 +161,7 @@ const postSocialIssue = (id, body, method) => {
|
||||
})
|
||||
.then(response => {
|
||||
if (response.ok) { return response.json(); }
|
||||
throw Error('Error with request resource response');
|
||||
throw Error('Error with request resource response');
|
||||
});
|
||||
};
|
||||
|
||||
@@ -170,7 +170,7 @@ const getUsers = () => {
|
||||
return fetch(url)
|
||||
.then(response => {
|
||||
if (response.ok) { return response.json(); }
|
||||
throw Error('Error with request resource response');
|
||||
throw Error('Error with request resource response');
|
||||
});
|
||||
};
|
||||
|
||||
@@ -179,7 +179,7 @@ const whoami = () => {
|
||||
return fetch(url)
|
||||
.then(response => {
|
||||
if (response.ok) { return response.json(); }
|
||||
throw Error('Error with request resource response');
|
||||
throw Error('Error with request resource response');
|
||||
});
|
||||
};
|
||||
|
||||
@@ -188,11 +188,11 @@ const getListOrigins = () => {
|
||||
return fetch(url)
|
||||
.then(response => {
|
||||
if (response.ok) { return response.json(); }
|
||||
throw Error('Error with request resource response');
|
||||
throw Error('Error with request resource response');
|
||||
});
|
||||
}
|
||||
|
||||
export {
|
||||
export {
|
||||
getAccompanyingCourse,
|
||||
patchAccompanyingCourse,
|
||||
confirmAccompanyingCourse,
|
||||
|
@@ -32,7 +32,7 @@
|
||||
ref="addAddress">
|
||||
</add-address>
|
||||
</li>
|
||||
<li v-if="isContextEdit && isPersonLocation">
|
||||
<li v-if="isPersonLocation">
|
||||
<button
|
||||
class="btn btn-remove"
|
||||
@click="removeAddress"
|
||||
@@ -112,10 +112,6 @@ export default {
|
||||
}
|
||||
this.$store.commit('setAddressContext', context);
|
||||
},
|
||||
initAddressOptions() {
|
||||
// here button.type is a contextual option
|
||||
this.$refs.addAddress.$data.default.button.type = this.isContextEdit ? 'btn-update' : '';
|
||||
},
|
||||
removeAddress() {
|
||||
console.log('remove address');
|
||||
let payload = {
|
||||
@@ -133,11 +129,11 @@ export default {
|
||||
let payload = this.$refs.addAddress.submitNewAddress();
|
||||
payload['locationStatusTo'] = 'address'; // <== temporary, not none, not person
|
||||
this.$store.dispatch('updateLocation', payload);
|
||||
this.$store.commit('setEditContextTrue');
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.initAddressContext();
|
||||
this.initAddressOptions();
|
||||
|
||||
console.log('ac.locationStatus', this.accompanyingCourse.locationStatus);
|
||||
console.log('ac.location (temporary location)', this.accompanyingCourse.location);
|
||||
|
@@ -104,6 +104,10 @@ let initPromise = getAccompanyingCourse(id)
|
||||
state.accompanyingCourse.location = r.location;
|
||||
state.accompanyingCourse.locationStatus = r.locationStatus;
|
||||
state.accompanyingCourse.personLocation = r.personLocation;
|
||||
},
|
||||
setEditContextTrue(state) {
|
||||
console.log('### mutation: set edit context = true');
|
||||
state.addressContext.edit = true;
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
@@ -221,9 +225,8 @@ let initPromise = getAccompanyingCourse(id)
|
||||
resolve();
|
||||
})).catch((error) => { commit('catchError', error) });
|
||||
},
|
||||
/////
|
||||
updateLocation({ commit }, payload) {
|
||||
console.log('## action: updateLocation', payload);
|
||||
console.log('## action: updateLocation', payload.locationStatusTo);
|
||||
let body = { 'type': payload.entity, 'id': payload.entityId };
|
||||
let location = {};
|
||||
if (payload.locationStatusTo === 'person') { // patch for person address (don't remove addressLocation)
|
||||
@@ -246,7 +249,6 @@ let initPromise = getAccompanyingCourse(id)
|
||||
resolve();
|
||||
})).catch((error) => { commit('catchError', error) });
|
||||
},
|
||||
/////
|
||||
confirmAccompanyingCourse({ commit }) {
|
||||
//console.log('## action: confirmAccompanyingCourse');
|
||||
confirmAccompanyingCourse(id)
|
||||
|
@@ -19,7 +19,7 @@
|
||||
<div class="accompanyingcourse-resume">
|
||||
|
||||
{% if 'DRAFT' == accompanyingCourse.step %}
|
||||
<div class="col-8 alert alert-danger flash_message mb-5">
|
||||
<div class="alert alert-danger flash_message mb-5">
|
||||
<span>
|
||||
{{ 'This accompanying course is still a draft'|trans }}
|
||||
<a href="{{ path('chill_person_accompanying_course_edit', { 'accompanying_period_id': accompanyingCourse.id } ) }}">
|
||||
|
@@ -8,7 +8,6 @@
|
||||
* backUrl twig route: path('route', {parameters})
|
||||
* modalTitle twig translated chain
|
||||
* buttonText twig translated chain
|
||||
* buttonType chill class like 'btn-update'
|
||||
* buttonSize bootstrap class like 'btn-sm'
|
||||
|
||||
#}
|
||||
@@ -52,10 +51,6 @@
|
||||
window.buttonText = '{{ buttonText|trans|e('js') }}';
|
||||
{% endif %}
|
||||
|
||||
{% if buttonType is defined %}
|
||||
window.buttonType = '{{ buttonType|e('js') }}';
|
||||
{% endif %}
|
||||
|
||||
{% if buttonSize is defined %}
|
||||
window.buttonSize = '{{ buttonSize|e('js') }}';
|
||||
{% endif %}
|
||||
|
@@ -206,7 +206,6 @@ This view should receive those arguments:
|
||||
address_id: person.lastAddress.id,
|
||||
backUrl: path('chill_person_view', { 'person_id': person.id }),
|
||||
modalTitle: 'Edit address', buttonText: 'Edit address',
|
||||
buttonType: 'btn-update',
|
||||
buttonSize: 'btn-sm',
|
||||
buttonDisplayText: false
|
||||
} %}
|
||||
|
Reference in New Issue
Block a user