Compare commits

..

5 Commits

Author SHA1 Message Date
Aqqil Azman 6094bf03ca added vue multi-select component "address-extra-details-component" 2024-06-21 10:41:45 +08:00
Aqqil Azman c58886eeff initial commit, vue multi-select for Address extra details 2024-06-21 10:41:10 +08:00
edmondlang 4a9ac3de02 Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into address-extra-fields 2024-06-20 10:03:57 +08:00
edmondlang 1e6fafef28 make address line 2 required 2024-06-20 10:02:15 +08:00
edmondlang 9d0924c674 address extra fields 2024-06-12 12:02:31 +08:00
12 changed files with 157 additions and 86 deletions
@@ -15,6 +15,7 @@ use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
use App\Classes\Modules\Remarks\Processors\CreateRemarkProcessor;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\RemarkTypes;
use App\Http\Resources\AddressResource;
use App\Models\Address;
use ErrorException;
@@ -100,6 +101,16 @@ class CreateAddressLogic extends AbstractControllerLogic
$this->createRemarkProcessor->execute($address, $remarkObject);
}
$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'),
];
$addressExtraFieldsObject = new RemarkObject(json_encode($addressExtraFields), Auth()->user()->id, RemarkTypes::ADDRESS_EXTRA_COLUMNS);
$this->createRemarkProcessor->execute($address, $addressExtraFieldsObject);
return $this->resourceResponse(new AddressResource($address));
}
@@ -15,6 +15,7 @@ use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
use App\Classes\Modules\Remarks\Processors\CreateRemarkProcessor;
use App\Classes\ValueObjects\Constants\AddressType;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\RemarkTypes;
use App\Http\Resources\AddressResource;
use App\Models\Address;
use Illuminate\Http\JsonResponse;
@@ -102,6 +103,16 @@ class UpdateAddressLogic extends AbstractControllerLogic
$this->createRemarkProcessor->execute($address, $remarkObject);
}
$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'),
];
$addressExtraFieldsObject = new RemarkObject(json_encode($addressExtraFields), Auth()->user()->id, RemarkTypes::ADDRESS_EXTRA_COLUMNS);
$this->createRemarkProcessor->execute($address, $addressExtraFieldsObject);
return $this->resourceResponse(new AddressResource($address));
}
@@ -13,10 +13,14 @@ class RemarkObject implements DataTransferObject
/** @var string*/
private $content;
public function __construct(string $content, int $commenterID)
/** @var int|null */
private $type;
public function __construct(string $content, int $commenterID, int $type = null)
{
$this->commenterID = $commenterID;
$this->content = $content;
$this->type = $type;
}
/**
@@ -35,4 +39,12 @@ class RemarkObject implements DataTransferObject
return $this->content;
}
/**
* @return int|null
*/
public function getType(): ?int
{
return $this->type;
}
}
@@ -24,6 +24,7 @@ class CreatesRemark extends AbstractUpdateRelationshipRecord
$model->commenter_id = $object->getCommenterId();
$model->content = $object->getContent();
$model->type = $object->getType();
return $this->handler($remarkable->remarks(), $model);
@@ -10,4 +10,6 @@ final class RemarkTypes
public const EXTERNAL = 1;
}
public const ADDRESS_EXTRA_COLUMNS = 2;
}
+8
View File
@@ -27,6 +27,9 @@ class AddressResource extends JsonResource
$outstationPostcodeConstant = $outstationPostcodeConstantObject->isEmpty() ? [] : (array)$outstationPostcodeConstantObject->first()->value;
in_array((String)$this->postcode, $outstationPostcodeConstant) ? $postcodeArea = 'OUTSTATION_POSTCODE' : null;
$extrafields = json_decode($this->addressExtraFields->first());
$extrafields = $extrafields ? (isset($extrafields->content) ? json_decode($extrafields->content) : null) : null;
return [
'id' => $this->id,
'reference' => $this->reference,
@@ -43,6 +46,11 @@ class AddressResource extends JsonResource
'contact' => new ContactResource($this->contacts->first()),
'remark' => new RemarkResource($this->remarks->first()),
'type' => $this->type,
'extrafields' => $extrafields,
'property_type' => $extrafields ? $extrafields->property_type : null,
'tools_required_unload' => $extrafields ? $extrafields->tools_required_unload : null,
'pickup_time_from' => $extrafields ? $extrafields->pickup_time_from : null,
'pickup_time_to' => $extrafields ? $extrafields->pickup_time_to : null,
$this->mergeWhen($this->relationLoaded('owner'), [
'owner' => $this->when($this->owner instanceof Order, [
'reference' => $this->owner->reference,
+9
View File
@@ -4,6 +4,7 @@ namespace App\Models;
use App\Classes\General\Interfaces\Contactable;
use App\Classes\General\Interfaces\Remarkable;
use App\Classes\ValueObjects\Constants\RemarkTypes;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasOne;
@@ -89,4 +90,12 @@ class Address extends AbstractModel implements Contactable, Remarkable
{
return $this->morphMany(Remark::class, 'owner');
}
/**
* @return MorphMany
*/
public function addressExtraFields(): MorphMany
{
return $this->morphMany(Remark::class, 'owner')->where('type', RemarkTypes::ADDRESS_EXTRA_COLUMNS);
}
}
@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddTypeToRemarksTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('remarks', function (Blueprint $table) {
$table->string('type')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('remarks', function (Blueprint $table) {
$table->dropColumn('type');
});
}
}
-1
View File
@@ -31,7 +31,6 @@
"vue": "^2.6.10",
"vue-avatar": "^2.1.8",
"vue-debounce": "^2.6.0",
"vue-multi-select": "^4.6.0",
"vue-template-compiler": "^2.6.10",
"vue-the-mask": "^0.11.1",
"vuelidate": "^0.7.4",
@@ -3,7 +3,6 @@
<label class="text-primary">卸货工具 Tools required to unload goods</label>
<vue-multi-select
ref="multiSelect"
v-model="values"
:options="options"
:btnLabel="btnLabel"
@open="open"
@@ -3,14 +3,6 @@
<div class="col">
<div class="row" v-if="![7,8].includes($store.getters.getCompanyModuleType)">
<div class="col">
<div class="row m-b-15">
<div class="col">
<validation-wrapper-component :validator="$v.parameters.reference">
<label>Address Reference/Label</label>
<input class="form-control" name="reference" v-model="parameters.reference">
</validation-wrapper-component>
</div>
</div>
<div class="row m-b-15">
<div class="col">
<validation-wrapper-component :validator="$v.parameters.street_one">
@@ -41,6 +33,14 @@
</validation-wrapper-component>
</div>
</div>
<div class="row m-b-15">
<div class="col">
<validation-wrapper-component :validator="$v.parameters.reference">
<label>Address Name / Label</label>
<input class="form-control" name="reference" v-model="parameters.reference" placeholder="E.g. Home Address">
</validation-wrapper-component>
</div>
</div>
<div class="row">
<div class="col">
<div class="row">
@@ -59,51 +59,6 @@
</validation-wrapper-component>
</div>
</div>
<div class="row m-b-15">
<div class="col">
<validation-wrapper-component :validator="$v.parameters.remark">
<label>Delivery Remark</label>
<input class="form-control" name="remark" v-model="parameters.remark">
</validation-wrapper-component>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="row m-b-15">
<div class="col-12 col-md pr-md-1 pb-3 pb-md-0">
<validation-wrapper-component :validator="$v.parameters.pickup_time">
<label>收货时间 Available Hours</label>
<input type="time" class="form-control" name="pickup_time" v-model="parameters.pickup_time">
</validation-wrapper-component>
</div>
<div class="col-12 col-md pl-md-1">
<validation-wrapper-component :validator="$v.parameters.latest_pickup_time">
<label>最晚收货时间 Latest Available Hours</label>
<input type="time" class="form-control" name="latest_pickup_time" v-model="parameters.latest_pickup_time">
</validation-wrapper-component>
</div>
</div>
<div class="row m-b-15">
<div class="col-12 col-md pr-md-1 pb-3 pb-md-0">
<validation-wrapper-component selectable class="m-b-15" :validator="$v.parameters.property_type">
<label class="text-primary">房型 Receiver's Property Type</label>
<select-component :options="propertyOptions" v-model="parameters.property_type"></select-component>
</validation-wrapper-component>
</div>
<div class="col-12 col-md pl-md-1 ">
<tools-required-component></tools-required-component>
</div>
</div>
<div class="col no-padding">
<div class="row">
<div class="col"></div>
<div class="col-12 col-sm-7">
<h6 class="text-right fs-12 text-danger m-b-15 text-right">**kindly reply within 2 hours while warehouse contact to arrange for delivery, otherwise, reschedule of delivery date will apply.</h6>
</div>
</div>
</div>
</div>
@@ -162,14 +117,48 @@
</validation-wrapper-component>
</div>
</div>
<div class="row m-b-15">
<div class="col">
<validation-wrapper-component :validator="$v.parameters.remark">
<label>Remark</label>
<input class="form-control" name="remark" v-model="parameters.remark">
</validation-wrapper-component>
</div>
</div>
</div>
</div>
<div class="row m-b-15">
<div class="col">
<validation-wrapper-component :validator="$v.parameters.remark">
<label>Delivery Remark</label>
<input class="form-control" name="remark" v-model="parameters.remark">
</validation-wrapper-component>
</div>
</div>
<div class="row m-b-15">
<div class="col-12 col-md pr-md-1 pb-3 pb-md-0">
<validation-wrapper-component :validator="$v.parameters.pickup_time_from">
<label>收货时间从 Available Hours From</label>
<input type="time" class="form-control" name="pickup_time" v-model="parameters.pickup_time_from">
</validation-wrapper-component>
</div>
<div class="col-12 col-md pl-md-1">
<validation-wrapper-component :validator="$v.parameters.pickup_time_to">
<label>最晚收货时间 Available Hours To</label>
<input type="time" class="form-control" name="latest_pickup_time" v-model="parameters.pickup_time_to">
</validation-wrapper-component>
</div>
</div>
<div class="row m-b-15">
<div class="col-12 col-md pr-md-1 pb-3 pb-md-0">
<validation-wrapper-component selectable :validator="$v.parameters.property_type">
<label>房型 Receiver's property type</label>
<select-component :options="['住家Landed house', '公寓Condominium (Drop on lobby only)', '工厂Factory', '店面Shop', '商场Shopping Mall (Drop on loading bay only)', 'Others']" v-model="parameters.property_type"></select-component>
</validation-wrapper-component>
</div>
<div class="col-12 col-md pl-md-1 pb-3 pb-md-0">
<!-- <validation-wrapper-component selectable :validator="$v.parameters.tools_required_unload">
<label>卸货工具 Tools require to unload goods</label>
<select-component :options="['Manpower', 'Forklift', 'None of above']" v-model="parameters.tools_required_unload"></select-component>
</validation-wrapper-component> -->
<address-extra-details-component v-model="parameters.tools_required_unload"></address-extra-details-component>
</div>
</div>
<div class="row justify-content-center allign-items-center">
<div class="col-12 col-sm-7">
<h6 class="text-center fs-12 text-danger">**kindly reply within 2 hours while warehouse contact to arrange for delivery, otherwise, reschedule of delivery date will apply</h6>
</div>
</div>
<div class="row">
@@ -191,7 +180,7 @@
props: {
id: {
type: Number,
required: true
// required: true
},
type: {
type: Number,
@@ -211,19 +200,12 @@
remark: '',
phone: '',
person_in_charge: '',
pickup_time: '',
latest_pickup_time: '',
property_type: '',
tools_required: '',
},
propertyOptions: [
{ id: 1, text: '住家-Landed house' },
{ id: 2, text: '公寓-Condominium (Drop on lobby only)' },
{ id: 3, text: '工厂-Factory' },
{ id: 4, text: '店面-Shop' },
{ id: 5, text: '商场-Shopping Mall (Drop on loading bay only)' },
{ id: 6, text: 'Others' },
],
tools_required_unload: '',
pickup_time_from: '',
pickup_time_to: '',
}
}
},
created(){
@@ -237,12 +219,16 @@
this.parameters.phone = this.data.contact ? this.data.contact.phone : '';
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 : '';
}
},
watch: {
'id': function () {
this.parameters.company_module_id = this.id;
}
},
},
methods:{
submitForm(){
@@ -10,19 +10,20 @@ export default {
},
street_one: { required },
street_two: {
required: requiredIf(function(){
return [7,8].includes(this.$store.getters.getCompanyModuleType);
})
required
// required: requiredIf(function(){
// return [7,8].includes(this.$store.getters.getCompanyModuleType);
// })
},
district_id: { required },
post_code: { required },
remark: {},
phone: {required, numeric},
person_in_charge: { required },
pickup_time: { required },
latest_pickup_time: { required },
property_type: {},
tools_required: {},
property_type: { required },
tools_required_unload: { required },
pickup_time_from: { required },
pickup_time_to: { required },
}
},
mixins: [addressFormHandler]