From 9375c2cf8698224fcfb6f121e9ec75b40153b69d Mon Sep 17 00:00:00 2001 From: nobohan Date: Tue, 8 Jun 2021 21:14:09 +0200 Subject: [PATCH] household address: patch address + add validFrom input --- .../ChillMainExtension.php | 3 +- .../Resources/public/vuejs/_api/AddAddress.js | 29 ++++++++++++++++++- .../public/vuejs/HouseholdAddress/App.vue | 22 ++++++++++++-- .../vuejs/HouseholdAddress/store/index.js | 18 +++++++++++- 4 files changed, 67 insertions(+), 5 deletions(-) diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php index f6d10ec9e..2bb0a32f7 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php @@ -278,7 +278,8 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface, 'methods' => [ Request::METHOD_GET => true, Request::METHOD_POST => true, - Request::METHOD_HEAD => true + Request::METHOD_HEAD => true, + Request::METHOD_PATCH => true ] ], ] diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_api/AddAddress.js b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_api/AddAddress.js index 383ffb25f..80586a42b 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_api/AddAddress.js +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_api/AddAddress.js @@ -82,10 +82,37 @@ const postAddress = (address) => { }); }; + +/* +* Endpoint chill_api_single_address__entity__create +* method PATCH, patch Address Instance +* +* @id integer - id of address +* @body Object - dictionary with changes to post +*/ +const patchAddress = (id, body) => { + console.log('body', body); + const url = `/api/1.0/main/address/${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 { fetchCountries, fetchCities, fetchReferenceAddresses, fetchAddresses, - postAddress + postAddress, + patchAddress }; diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdAddress/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdAddress/App.vue index ca1f81d42..2dcabcd9d 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdAddress/App.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdAddress/App.vue @@ -4,6 +4,11 @@ +
{{ newAddress.text }} @@ -23,7 +28,7 @@