Set default, delete, update & view identity documents

This commit is contained in:
Fairuz
2021-05-30 22:50:36 +08:00
parent 354a6ffbd8
commit 7be6569900
5 changed files with 109 additions and 24 deletions
@@ -58,6 +58,8 @@ class UpdateAddressLogic extends AbstractControllerLogic
{
try {
//$district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]);
//$object = new AddressObject($request->input('street_one'), $request->input('street_two'), $district->country_id, $district->state_id, $district->id, $request->input('post_code'));
$object = new AddressObject($request->input('company_id'), $request->input('street_one'), $request->input('street_two'), $request->input('city'), $request->input('state'), $request->input('post_code'), $request->input('country'), $request->input('default'), $request->input('billing'));
$this->canUpdateAddress->passes($object);
@@ -12,7 +12,7 @@
<div class="col">
<div class="row">
<div class="col">
<span class="fs-10 muted">{{address.street_one}} {{address.street_two}} {{address.city}} {{address.state}} {{address.post_code}} {{address.country}}</span>
<span class="fs-10 muted">{{address.street_one}} {{address.street_two}} {{address.city}} {{address.state.name}} {{address.post_code}} {{address.country.name}}</span>
</div>
</div>
</div>
@@ -20,7 +20,7 @@
<div class="row h-100">
<div class="col">
<div class="row no-margin">
<div class="col-auto text-right p-t-10 p-b-10 bg-master-lightest m-r-5 ml-auto">
<div class="col-auto text-right p-t-10 p-b-10 bg-master-lightest m-r-5 ml-auto" @click="deleteAddress(address.id)">
<a class="requestModal pointer" data-type="delete">
<div data-toggle="tooltip" title="" data-placement="bottom" class="row link align-items-center justify-content-center" data-original-title="Delete">
<div class="col">
@@ -29,7 +29,7 @@
</div>
</a>
</div>
<div class="col-auto text-right p-t-10 p-b-10 bg-master-lightest">
<div class="col-auto text-right p-t-10 p-b-10 bg-master-lightest" @click="updateAddress(address.id)">
<a class="pointer">
<div data-toggle="tooltip" title="" data-placement="bottom" class="row link align-items-center justify-content-center" data-original-title="Delete">
<div class="col">
@@ -45,29 +45,33 @@
</div>
</div>
<div class="col-4 m-l-15 d-flex align-items-center">
<div class="row align-items-center" :class="[{'requestModal': !address.default}, {'pointer': !address.default}, {'link': !address.default}]" data-type="setDefault">
<div class="col-auto text-right p-t-5 p-b-5" :class="[{'bg-warning-lighter': address.default}, {'bg-master-light': !address.default}]">
<div data-toggle="tooltip" class="row align-items-center justify-content-center" :class="{'link': !address.default}">
<div class="row align-items-center" :class="[{'requestModal': !address.billing}, {'pointer': !address.billing}, {'link': !address.billing}]" data-type="setDefault" @click="!address.billing ? setDefaultAddress() : null">
<div class="col-auto text-right p-t-5 p-b-5" :class="[{'bg-warning-lighter': address.billing}, {'bg-master-light': !address.billing}]">
<div data-toggle="tooltip" class="row align-items-center justify-content-center" :class="{'link': !address.billing}">
<div class="col">
<i class="fa fa-star" :class="[{'text-warning': address.default}, {'text-master': !address.default}]"></i>
<i class="fa fa-star" :class="[{'text-warning': address.billing}, {'text-master': !address.billing}]"></i>
</div>
</div>
</div>
<div class="col bg-white p-t-5 p-b-5">
<small class="fs-12 all-caps bold" :class="[{'text-warning': address.default}, {'text-master': !address.default}]">Default Address</small>
<small class="fs-12 all-caps bold" :class="[{'text-warning': address.billing}, {'text-master': !address.billing}]">Default Address</small>
</div>
</div>
</div>
</div>
</template>
<script>
import FormHandler from '../../../general/mixins/formHandler';
export default {
props: {
'data': {
type: Object,
required: true
}
},
},
data() {
return {
@@ -79,6 +83,20 @@
this.address = this.data;
}
},
methods: {
setDefaultAddress(){
this.submit(route('api.address.default',this.address.id), 'put', this.section, true, true);
},
updateAddress(id){
this.$root.$emit('updateAddressForm', this.address);
},
deleteAddress(id){
this.$root.$emit('deleteAddressConfirm', id);
},
successHandler(){
this.$store.dispatch('reloadList', {'name': "addresslist"});
}
},
mixins: [FormHandler]
}
</script>
@@ -39,7 +39,7 @@
<div class="col">
<div class="row">
<div class="col text-right">
<button type="button" class="btn btn-sm btn-success b-rad-none" @click="submitForm()">Create Billing Address</button>
<button type="button" class="btn btn-sm btn-success b-rad-none" @click="submitForm()">{{(this.type==3)?"Update":"Create"}} Billing Address</button>
</div>
</div>
</div>
@@ -59,17 +59,31 @@
type: Number,
default: 1
},
addressData: {
type: Object,
default: {},
required:false
},
},
watch: {
'id': function() {
this.parameters.company_id = this.id;
},
'addressData': function() {
this.parameters = {
company_id: this.id,
street_one: this.addressData.street_one,
street_two: this.addressData.street_two,
district_id: this.addressData.district.id,
post_code: this.addressData.post_code,
}
}
},
data() {
return {
parameters : {
company_id: this.id,
street_one: '',
street_one: '',
street_two: '',
district_id: '',
post_code: '',
@@ -87,11 +101,19 @@
},
methods:{
submitForm(){
this.submit((this.route('api.address.create')), 'post', 'bookingDetailSection', true, true)
if(this.type==3){
this.submit((this.route('api.address.update',this.addressData.id)), 'put', 'bookingDetailSection', true, true)
}else {
this.submit((this.route('api.address.create')), 'post', 'bookingDetailSection', true, true)
}
},
successHandler(response){
this.type !== 2 ? this.$emit('updateDefaultAddress', response.payload.data) : this.$emit('createdAddress', response.payload.data);
this.resetForm();
if(this.type==3){
console.log('updated??');
}else {
this.type !== 2 ? this.$emit('updateDefaultAddress', response.payload.data) : this.$emit('createdAddress', response.payload.data);
this.resetForm();
}
}
}
}
@@ -1,9 +1,6 @@
<template>
<div class="row align-items-center m-b-10 parentContainer">
<div class="row w-100 m-0 p-0">
<div class="col-auto p-0 pt-2 m-b-10" :style="minWidth">
<div class="h5 m-0">{{this.company_details.name ? this.company_details.name : ""}}</div>
</div>
<div class="col-12 p-0">
<label class="muted" :style="minWidth">Reference</label>
<label>{{this.company_details.reference ? this.company_details.reference : ""}}</label>
@@ -24,6 +21,26 @@
<label class="muted" :style="minWidth">Total Booking</label>
<label>{{this.company_details.bookings ? this.company_details.bookings.length : ""}}</label>
</div>
<div class="row m-b-10">
<div class="col">
<div class="row m-b-5">
<div class="col">
<div class="fs-8 all-caps muted">{{ this.company_details.identification.document_type === 'IDENTITY_CARD' ? 'IC' : 'SSM Registration' }} Document</div>
</div>
</div>
<div class="row no-margin">
<div v-for="file in this.company_details.identification.files" v-bind:key="file.id" class="col-auto no-padding m-r-5">
<document-file-viewer-component :file="file">
<template slot="button">
<div class="icon-thumbnail fs-11 text-white icon-25 bg-primary btn-rounded float-left m-r-5">
<i class="fa fa-file-image-o fs-10"></i>
</div>
</template>
</document-file-viewer-component>
</div>
</div>
</div>
</div>
<div class="col-12 p-0">
<canvas id="booking-chart"></canvas>
</div>
@@ -139,12 +139,19 @@
<div class="row">
<div class="col">
<div class="row">
<div class="col">
<list-component key="2" section="purchaseOrderSection" :endpoint="route('api.address.list')">
<div class="col" v-show="!displayAddressForm">
<list-component key="2" section="addresslist" :endpoint="route('api.address.list')" :options="{'company_id':this.id}">
<template slot="list" slot-scope="{data}">
<address-component :data="data"></address-component>
<address-component :data="data" section="addressListItem"></address-component>
</template>
</list-component>
<modal-component id="deleteAddressModal">
<address-modal-component section="deleteAddressModal" :address_id="this.address_id"></address-modal-component>
</modal-component>
</div>
<div class="col" v-show="this.displayAddressForm">
<div>Address form</div>
<address-form-component :id="parseInt(this.id)" :type="3" :addressData="this.address"></address-form-component>
</div>
</div>
</div>
@@ -157,7 +164,11 @@
<div class="col">
<div class="row">
<div class="col">
wonderful!!
<list-component key="2" section="paymentVerificationSection" :endpoint="route('api.transaction.list')" :options="{'type': 1, 'status': 3,'issuer':this.id}">
<template slot="list" slot-scope="{data}">
<payment-verification-component section="paymentVerificationSection" :data="data" :no_action="true"></payment-verification-component>
</template>
</list-component>
</div>
</div>
</div>
@@ -211,7 +222,10 @@
created_before: '',
created_after: '',
status: ''
}
},
address_id:0,
address:{},
displayAddressForm:false,
}
},
computed: {
@@ -228,12 +242,24 @@
})
}
},
mounted(){
this.$root.$on('deleteAddressConfirm', (id) => {
this.address_id=id;
$("#deleteAddressModal").closest('.modal').modal('show');
});
this.$root.$on('updateAddressForm', (address) => {
console.log(">>>> "+address);
console.log(">>>> "+address.street_one);
this.address=address;
this.displayAddressForm = true;
});
},
watch: {
pendingQueue(inComplete){
if(inComplete){
this.fetchCompany();
}
}
},
},
created(){
this.$store.dispatch('updateListQueue', {'name': this.section});