diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_api/OnTheFly.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_api/OnTheFly.js index 6adbc7028..c8031da58 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_api/OnTheFly.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_api/OnTheFly.js @@ -27,8 +27,27 @@ const postPerson = (body) => { throw Error('Error with request resource response'); }); }; - -export { - getPerson, - postPerson + +/* +* PATCH an existing person +*/ +const patchPerson = (id, body) => { + const url = `/api/1.0/person/person/${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'); + }); +}; + +export { + getPerson, + postPerson, + patchPerson }; diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue index bf559fd41..1956034cb 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue @@ -163,11 +163,12 @@ export default { resolve(); })); }, - postData() { - postPerson(this.person) + patchData() { + console.log('id', this.id, 'and body', this.person); + patchPerson(this.id, this.person) .then(person => new Promise((resolve, reject) => { this.person = person; - console.log('post person', this.person); + console.log('patch person', this.person); resolve(); })) } diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_api/OnTheFly.js b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_api/OnTheFly.js index ed91ef415..91ea41b7d 100644 --- a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_api/OnTheFly.js +++ b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_api/OnTheFly.js @@ -13,7 +13,7 @@ const getThirdparty = (id) => { }; /* -* POST a new person +* POST a new thirdparty */ const postThirdparty = (body) => { const url = `/api/1.0/thirdparty/thirdparty.json`; @@ -29,8 +29,27 @@ const postThirdparty = (body) => { throw Error('Error with request resource response'); }); }; - -export { - getThirdparty, - postThirdparty -}; \ No newline at end of file + +/* +* PATCH an existing thirdparty +*/ +const patchThirdparty = (id, body) => { + const url = `/api/1.0/thirdparty/thirdparty/${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'); + }); +}; + +export { + getThirdparty, + postThirdparty, + patchThirdparty +}; diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue index 7fc8fd827..d89012afc 100644 --- a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue +++ b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue @@ -55,7 +55,7 @@