address field detailed (city, zip_code, state, country)

This commit is contained in:
Cihan Şentürk
2021-09-03 11:43:55 +03:00
parent 04a4e869e3
commit ebeb8df1da
91 changed files with 15509 additions and 181 deletions

View File

@ -13,6 +13,11 @@
{{ company.address }}
</th>
</tr>
<tr v-if="company_data.locations">
<th class="text-right p-0">
{{ company_data.locations }}
</th>
</tr>
<tr v-if="company.tax_number">
<th class="text-right p-0">
{{ taxNumberText }}: {{ company.tax_number }}
@ -53,190 +58,216 @@ import AkauntingDate from './AkauntingDate';
import Form from './../plugins/form';
export default {
name: 'akaunting-company-edit',
name: 'akaunting-company-edit',
components: {
[Select.name]: Select,
[Option.name]: Option,
[OptionGroup.name]: OptionGroup,
[ColorPicker.name]: ColorPicker,
AkauntingModalAddNew,
AkauntingModal,
AkauntingMoney,
AkauntingRadioGroup,
AkauntingSelect,
AkauntingDate,
},
props: {
buttonText: {
type: String,
default: 'Edit your business address ',
description: 'Input placeholder'
},
taxNumberText: {
type: String,
default: 'Tax Number',
description: 'Input placeholder'
},
companyId: {
type: String,
default: '',
description: 'Contact search route'
},
company: {
type: Object,
default: {},
description: 'Company object'
},
companyForm: {
type: Object,
default: function () {
return {
text: 'Add New Item',
show: false,
buttons: {}
};
components: {
[Select.name]: Select,
[Option.name]: Option,
[OptionGroup.name]: OptionGroup,
[ColorPicker.name]: ColorPicker,
AkauntingModalAddNew,
AkauntingModal,
AkauntingMoney,
AkauntingRadioGroup,
AkauntingSelect,
AkauntingDate,
},
props: {
buttonText: {
type: String,
default: 'Edit your business address ',
description: 'Input placeholder'
},
taxNumberText: {
type: String,
default: 'Tax Number',
description: 'Input placeholder'
},
companyId: {
type: String,
default: '',
description: 'Contact search route'
},
company: {
type: Object,
default: {},
description: 'Company object'
},
countryText: {
type: [Array, Object],
},
companyForm: {
type: Object,
default: function () {
return {
text: 'Add New Item',
show: false,
buttons: {}
};
},
description: "Selectbox Add New Item Feature"
},
description: "Selectbox Add New Item Feature"
},
},
data() {
return {
form: {},
company_form: {
text: this.companyForm.text,
show: false,
path: url + '/modals/companies/' + this.companyId + '/edit',
buttons: this.companyForm.buttons,
},
company_html: '',
};
},
data() {
return {
form: {},
company_form: {
text: this.companyForm.text,
show: false,
path: url + '/modals/companies/' + this.companyId + '/edit',
buttons: this.companyForm.buttons,
},
company_html: '',
company_data: this.company,
};
},
methods: {
// Edit Company information
onEditCompany() {
let company_form = this.company_form;
methods: {
// Edit Company information
onEditCompany() {
let company_form = this.company_form;
window.axios.get(company_form.path)
.then(response => {
company_form.show = true;
company_form.html = response.data.html;
window.axios.get(company_form.path)
.then(response => {
company_form.show = true;
company_form.html = response.data.html;
this.company_html = Vue.component('add-new-component', function (resolve, reject) {
resolve({
template: '<div><akaunting-modal-add-new :show="company_form.show" @submit="onSubmit" @cancel="onCancel" :buttons="company_form.buttons" :title="company_form.text" :is_component=true :message="company_form.html"></akaunting-modal-add-new></div>',
this.company_html = Vue.component('add-new-component', function (resolve, reject) {
resolve({
template: '<div><akaunting-modal-add-new :show="company_form.show" @submit="onSubmit" @cancel="onCancel" :buttons="company_form.buttons" :title="company_form.text" :is_component=true :message="company_form.html"></akaunting-modal-add-new></div>',
components: {
AkauntingModalAddNew,
},
components: {
AkauntingModalAddNew,
},
data: function () {
return {
company_form: company_form,
data: function () {
return {
company_form: company_form,
}
},
methods: {
onSubmit(event) {
this.$emit('submit', event);
},
onCancel(event) {
this.$emit('cancel', event);
}
},
}
})
}, this);
})
.catch(e => {
console.log(e);
})
.finally(function () {
// always executed
});
},
methods: {
onSubmit(event) {
this.$emit('submit', event);
},
onSubmit(event) {
this.form = event;
onCancel(event) {
this.$emit('cancel', event);
}
}
})
}, this);
})
.catch(e => {
console.log(e);
})
.finally(function () {
// always executed
});
},
this.loading = true;
onSubmit(event) {
this.form = event;
let data = this.form.data();
this.loading = true;
let data = this.form.data();
FormData.prototype.appendRecursive = function(data, wrapper = null) {
for(var name in data) {
if (wrapper) {
if ((typeof data[name] == 'object' || data[name].constructor === Array) && ((data[name] instanceof File != true ) && (data[name] instanceof Blob != true))) {
this.appendRecursive(data[name], wrapper + '[' + name + ']');
FormData.prototype.appendRecursive = function(data, wrapper = null) {
for(var name in data) {
if (wrapper) {
if ((typeof data[name] == 'object' || data[name].constructor === Array) && ((data[name] instanceof File != true ) && (data[name] instanceof Blob != true))) {
this.appendRecursive(data[name], wrapper + '[' + name + ']');
} else {
this.append(wrapper + '[' + name + ']', data[name]);
}
} else {
this.append(wrapper + '[' + name + ']', data[name]);
}
} else {
if ((typeof data[name] == 'object' || data[name].constructor === Array) && ((data[name] instanceof File != true ) && (data[name] instanceof Blob != true))) {
this.appendRecursive(data[name], name);
} else {
this.append(name, data[name]);
if ((typeof data[name] == 'object' || data[name].constructor === Array) && ((data[name] instanceof File != true ) && (data[name] instanceof Blob != true))) {
this.appendRecursive(data[name], name);
} else {
this.append(name, data[name]);
}
}
}
}
};
};
let form_data = new FormData();
form_data.appendRecursive(data);
let form_data = new FormData();
form_data.appendRecursive(data);
window.axios({
method: this.form.method,
url: this.form.action,
data: form_data,
headers: {
'X-CSRF-TOKEN': window.Laravel.csrfToken,
'X-Requested-With': 'XMLHttpRequest',
'Content-Type': 'multipart/form-data'
}
})
.then(response => {
this.form.loading = false;
window.axios({
method: this.form.method,
url: this.form.action,
data: form_data,
headers: {
'X-CSRF-TOKEN': window.Laravel.csrfToken,
'X-Requested-With': 'XMLHttpRequest',
'Content-Type': 'multipart/form-data'
}
})
.then(response => {
this.form.loading = false;
if (response.data.success) {
let data = this.form.data();
if (response.data.success) {
let data = this.form.data();
this.company.name = data.name;
this.company.email = data.email;
this.company.tax_number = data.tax_number;
this.company.phone = data.phone;
this.company.address = data.address;
this.company.name = data.name;
this.company.email = data.email;
this.company.tax_number = data.tax_number;
this.company.phone = data.phone;
this.company.address = data.address;
this.company_form.show = false;
this.company_form.show = false;
this.company_form.html = '';
this.company_html = null;
this.company_form.html = '';
this.company_html = null;
this.$emit('changed', data);
this.$emit('changed', data);
let documentClasses = document.body.classList;
let documentClasses = document.body.classList;
documentClasses.remove("modal-open");
}
})
.catch(error => {
this.form.loading = false;
console.log(error);
this.company_html = error.message;
});
documentClasses.remove("modal-open");
}
})
.catch(error => {
this.form.loading = false;
console.log(error);
this.company_html = error.message;
});
},
onCancel() {
this.company_form.show = false;
this.company_form.html = null;
this.company_html = null;
let documentClasses = document.body.classList;
documentClasses.remove("modal-open");
},
},
onCancel() {
this.company_form.show = false;
this.company_form.html = null;
this.company_html = null;
created() {
let locations = [];
let documentClasses = document.body.classList;
if (this.company.city) {
locations.push(this.company.city);
}
documentClasses.remove("modal-open");
if (this.company.zip_code) {
locations.push(this.company.zip_code);
}
if (this.company.state) {
locations.push(this.company.state);
}
if (this.company.country) {
locations.push(this.countryText[this.company.country])
}
this.company.locations = locations.join(', ');
},
},
};
</script>

View File

@ -19,7 +19,7 @@
v-html="error">
</div>
</div>
<div class="aka-select-menu" v-if="show.contact_list">
<div class="aka-select-search-container">
<span class="aka-prefixed-input aka-prefixed-input--fluid">
@ -30,11 +30,11 @@
</span>
</div>
<input
<input
type="text"
data-input="true"
class="form-control"
autocapitalize="default" autocorrect="ON"
autocapitalize="default" autocorrect="ON"
:placeholder="placeholder"
:ref="'input-contact-field-' + _uid"
v-model="search"
@ -44,7 +44,7 @@
</div>
</span>
</div>
<ul class="aka-select-menu-options">
<div class="aka-select-menu-option" v-for="(contact, index) in sortContacts" :key="index" @click="onContactSeleted(index, contact.id)">
<div>
@ -60,7 +60,7 @@
</div>
</div>
</ul>
<div class="aka-select-footer" tabindex="0" @click="onContactCreate">
<span>
<i class="fas fa-plus"></i> {{ createNewContactText }}
@ -69,7 +69,7 @@
</div>
</div>
</div>
<div v-else class="document-contact-with-contact-bill-to">
<div>
<span class="aka-text aka-text--block-label">{{ contactInfoText }}</span>
@ -83,11 +83,16 @@
<strong class="d-block">{{ contact.name }}</strong>
</th>
</tr>
<tr>
<tr v-if="contact.address">
<th class="p-0" style="text-align:left; white-space: normal;">
{{ contact.address }}
</th>
</tr>
<tr v-if="contact.locations">
<th class="p-0" style="text-align:left; white-space: normal;">
{{ contact.locations }}
</th>
</tr>
<tr v-if="contact.tax_number">
<th class="p-0" style="text-align:left;">
{{ taxNumberText }}: {{ contact.tax_number }}
@ -188,7 +193,12 @@ export default {
phone: '',
website: '',
address: '',
reference: ''
city: '',
zip_code:'',
state:'',
country:'',
country_name:'',
reference: ''
};
},
description: 'List of Contacts'
@ -198,6 +208,7 @@ export default {
default: () => [],
description: 'List of Contacts'
},
addNew: {
type: Object,
default: function () {
@ -230,6 +241,10 @@ export default {
default: 'Bill to',
description: ""
},
countryText: {
type: [Array, Object],
default: () => [],
},
taxNumberText: {
type: String,
default: 'Tax number',
@ -269,6 +284,7 @@ export default {
buttons: this.addNew.buttons,
},
add_new_html: '',
country_text_data: this.countryText,
};
},
@ -295,7 +311,12 @@ export default {
phone: '',
website: '',
address: '',
reference: ''
city: '',
zip_code: '',
state: '',
country: '',
countryname: '',
reference: ''
});
},
@ -320,7 +341,12 @@ export default {
phone: (contact.phone) ? contact.phone : '',
website: (contact.website) ? contact.website : '',
address: (contact.address) ? contact.address : '',
reference: (contact.reference) ? contact.reference : ''
city: (contact.city) ? contact.city : '',
zip_code: (contact.zip_code) ? contact.zip_code : '',
state: (contact.state) ? contact.state : '',
country: (contact.country) ? contact.country : '',
country_name: (contact.country_name) ? contact.country_name : '',
reference: (contact.reference) ? contact.reference : ''
});
}, this);
})
@ -335,6 +361,26 @@ export default {
this.contact_list.forEach(function (contact, index) {
if (contact_id == contact.id) {
this.contact = contact;
let locations = [];
if (this.contact.city) {
locations.push(this.contact.city);
}
if (this.contact.zip_code) {
locations.push(this.contact.zip_code);
}
if (this.contact.state) {
locations.push(this.contact.state);
}
if (this.contact.country) {
locations.push(this.country_text_data[this.contact.country]);
}
this.contact.locations = locations.join(', ');
}
}, this);
@ -566,7 +612,12 @@ export default {
phone: '',
website: '',
address: '',
reference: ''
city: '',
zip_code: '',
state: '',
country: '',
country_name: '',
reference: ''
});
index++;
@ -586,8 +637,34 @@ export default {
phone: (contact.phone) ? contact.phone : '',
website: (contact.website) ? contact.website : '',
address: (contact.address) ? contact.address : '',
reference: (contact.reference) ? contact.reference : ''
city: (contact.city) ? contact.city : '',
zip_code: (contact.zip_code) ? contact.zip_code : '',
state: (contact.state) ? contact.state : '',
country: (contact.country) ? contact.country : '',
country_name: (contact.country_name) ? contact.country_name : '',
reference: (contact.reference) ? contact.reference : ''
});
let locations = [];
if (contact.city) {
locations.push(contact.city);
}
if (contact.zip_code) {
locations.push(contact.zip_code);
}
if (contact.state) {
locations.push(contact.state);
}
if (contact.country) {
locations.push(this.country_text_data[contact.country])
}
this.contact.locations = locations.join(', ');
}, this);
}