From bcfeb49275fd24b35064c482fc36433e3fe79e23 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Thu, 18 Jul 2024 00:14:19 +0800 Subject: [PATCH] update address extra fields --- .../ControllersLogic/UpdateAddressLogic.php | 12 +-- .../addresses/forms/AddressFormComponent.vue | 93 +++++++++---------- .../validation/addressFormValidation.js | 29 +----- 3 files changed, 55 insertions(+), 79 deletions(-) diff --git a/app/Classes/Modules/Addresses/ControllersLogic/UpdateAddressLogic.php b/app/Classes/Modules/Addresses/ControllersLogic/UpdateAddressLogic.php index e9adfea1..6c7a46be 100644 --- a/app/Classes/Modules/Addresses/ControllersLogic/UpdateAddressLogic.php +++ b/app/Classes/Modules/Addresses/ControllersLogic/UpdateAddressLogic.php @@ -112,14 +112,14 @@ class UpdateAddressLogic extends AbstractControllerLogic } $addressExtraFields = [ - 'property_type' => $request->input('property_type'), - 'tools_required_unload' => $request->input('tools_required_unload'), - 'pickup_time_from' => $request->input('pickup_time_from'), - 'pickup_time_to' => $request->input('pickup_time_to'), - 'receive_goods_after_hours' => $request->input('receive_goods_after_hours'), - 'receive_goods_on_weekend' => $request->input('receive_goods_on_weekend'), + 'property_type' => $request->input('property_type'), + 'additional_request' => $request->input('additional_request'), + 'receive_goods_working_hours' => $request->input('receive_goods_working_hours'), + 'receive_goods_after_hours' => $request->input('receive_goods_after_hours'), + 'receive_goods_on_saturday' => $request->input('receive_goods_on_saturday'), ]; + $address->addressExtraFields()->delete(); $addressExtraFieldsObject = new RemarkObject(json_encode($addressExtraFields), Auth()->user()->id, RemarkTypes::ADDRESS_EXTRA_COLUMNS); $this->createRemarkProcessor->execute($address, $addressExtraFieldsObject); diff --git a/resources/assets/vue/components/addresses/forms/AddressFormComponent.vue b/resources/assets/vue/components/addresses/forms/AddressFormComponent.vue index 02a80f12..be04b733 100644 --- a/resources/assets/vue/components/addresses/forms/AddressFormComponent.vue +++ b/resources/assets/vue/components/addresses/forms/AddressFormComponent.vue @@ -128,50 +128,51 @@
-
- Please choose a value between 9:00 AM and 4:00 PM only. - - - - -
-
- Please choose a value between 3:00 PM and 8:00 PM only. - - - - -
-
-
-
-
-
- -

Available to receive after working hours

-
-
-
-
-
-
- -

Available to receive goods on weekend

-
-
-
-
-
-
+
-
- - - +
+
+
+
+ +
+
+
+
+ +

Working Hours (9am-6pm)

+
+
+
+
+
+
+ +

After Working Hours

+
+
+
+
+
+
+ +

On Saturday

+
+
+
+
+
+
+
+
+
+ + +
@@ -220,11 +221,10 @@ phone: '', person_in_charge: '', property_type: '', - tools_required_unload: [], - pickup_time_from: '', - pickup_time_to: '', + additional_request: '', + receive_goods_working_hours: false, receive_goods_after_hours: false, - receive_goods_on_weekend: false, + receive_goods_on_saturday: false, } } @@ -241,11 +241,10 @@ this.parameters.person_in_charge = this.data.contact ? this.data.contact.reference : ''; this.parameters.remark = this.data.remark ? this.data.remark.content : ''; this.parameters.property_type = this.data.property_type ? this.data.property_type : ''; - this.parameters.tools_required_unload = this.data.tools_required_unload ? this.data.tools_required_unload : []; - this.parameters.pickup_time_from = this.data.pickup_time_from ? this.data.pickup_time_from : ''; - this.parameters.pickup_time_to = this.data.pickup_time_to ? this.data.pickup_time_to : ''; + this.parameters.additional_request = this.data.additional_request ? this.data.additional_request : ''; + this.parameters.receive_goods_working_hours = this.data.receive_goods_working_hours ? this.data.receive_goods_working_hours : false; this.parameters.receive_goods_after_hours = this.data.receive_goods_after_hours ? this.data.receive_goods_after_hours : false; - this.parameters.receive_goods_on_weekend = this.data.receive_goods_on_weekend ? this.data.receive_goods_on_weekend : false; + this.parameters.receive_goods_on_saturday = this.data.receive_goods_on_saturday ? this.data.receive_goods_on_saturday : false; } }, watch: { diff --git a/resources/assets/vue/general/mixins/addresses/validation/addressFormValidation.js b/resources/assets/vue/general/mixins/addresses/validation/addressFormValidation.js index ab56bc18..c2778a26 100644 --- a/resources/assets/vue/general/mixins/addresses/validation/addressFormValidation.js +++ b/resources/assets/vue/general/mixins/addresses/validation/addressFormValidation.js @@ -1,18 +1,5 @@ -import { required, requiredIf, numeric, helpers } from "vuelidate/lib/validators"; -import addressFormHandler from '../addressFormHandler'; - -const timeValidator = (time, type) => - helpers.withParams({ type, time }, value => { - if (!value) return true; // if there's no value, consider it valid - - const [valHours, valMinutes] = value.split(':').map(Number); - const [timeHours, timeMinutes] = time.split(':').map(Number); - - return type === 'minTime' - ? valHours > timeHours || (valHours === timeHours && valMinutes >= timeMinutes) - : valHours < timeHours || (valHours === timeHours && valMinutes <= timeMinutes); - }); - +import { required, requiredIf, numeric } from "vuelidate/lib/validators"; +import addressFormHandler from '../addressFormHandler' export default { validations: { parameters: { @@ -34,17 +21,7 @@ export default { phone: {required, numeric}, person_in_charge: { required }, property_type: { required }, - tools_required_unload: { required }, - pickup_time_from: { - required, - minTime: timeValidator('09:00', 'minTime'), - maxTime: timeValidator('16:00', 'maxTime') - }, - pickup_time_to: { - required, - minTime: timeValidator('15:00', 'minTime'), - maxTime: timeValidator('20:00', 'maxTime') - } + additional_request: { }, } }, mixins: [addressFormHandler]