Testing result fixed

This commit is contained in:
Burak Civan 2021-05-29 08:15:18 +03:00
parent 0a9d80ca1b
commit 4230997598
4 changed files with 89 additions and 110 deletions

View File

@ -51,7 +51,7 @@
:title="translations.company.financial_start" :title="translations.company.financial_start"
data-name="financial_start" data-name="financial_start"
:placeholder="translations.company.financial_start" :placeholder="translations.company.financial_start"
prepend-icon="fas fa-calendar" icon="fas fa-calendar"
:date-config="{ :date-config="{
dateFormat: 'd-m', dateFormat: 'd-m',
allowInput: true, allowInput: true,
@ -84,6 +84,7 @@
:v-model="logo" :v-model="logo"
> >
</akaunting-dropzone-file-upload> </akaunting-dropzone-file-upload>
<div class="invalid-feedback d-block">The logo must be a file of type: pdf, jpeg, jpg, png.</div>
</div> </div>
</div> </div>
</div> </div>
@ -93,7 +94,7 @@
<base-button <base-button
id="button" id="button"
type="success" type="success"
native-type="submit" native-type="button"
@click="onEditSave()" @click="onEditSave()"
>{{ translations.company.save }}</base-button >{{ translations.company.save }}</base-button
> >
@ -170,8 +171,68 @@ export default {
}, },
onEditSave() { onEditSave() {
this.onEditCompany(); FormData.prototype.appendRecursive = function (data, wrapper = null) {
this.$router.push("/wizard/currencies"); for (var name in data) {
if (name == "previewElement" || name == "previewTemplate") {
continue;
}
if (wrapper) {
if (
(typeof data[name] == "object" || Array.isArray(data[name])) &&
data[name] instanceof File != true &&
data[name] instanceof Blob != true
) {
this.appendRecursive(data[name], wrapper + "[" + name + "]");
} else {
this.append(wrapper + "[" + name + "]", data[name]);
}
} else {
if (
(typeof data[name] == "object" || Array.isArray(data[name])) &&
data[name] instanceof File != true &&
data[name] instanceof Blob != true
) {
this.appendRecursive(data[name], name);
} else {
this.append(name, data[name]);
}
}
}
};
const formData = new FormData(this.$refs["form"]);
let data_name = {};
for (let [key, val] of formData.entries()) {
Object.assign(data_name, {
[key]: val,
["logo"]: this.$refs.dropzoneWizard.files[1]
? this.$refs.dropzoneWizard.files[1]
: this.$refs.dropzoneWizard.files[0],
["_prefix"]: "company",
["_token"]: window.Laravel.csrfToken,
["_method"]: "POST",
});
}
formData.appendRecursive(data_name);
window
.axios({
method: "POST",
url: url + "/wizard/companies",
data: formData,
headers: {
"X-CSRF-TOKEN": window.Laravel.csrfToken,
"X-Requested-With": "XMLHttpRequest",
"Content-Type": "multipart/form-data",
},
})
.then((response) => {
this.onSuccessMessage(response);
this.$router.push("/wizard/currencies");
}, this)
.catch((error) => {
}, this);
}, },
next() { next() {

View File

@ -389,7 +389,7 @@ export default {
}, },
onEditForm(item) { onEditForm(item) {
this.onEditItemEvent( this.onSubmitEvent(
"PATCH", "PATCH",
url + "/wizard/currencies/" + item.id, url + "/wizard/currencies/" + item.id,
"", "",

View File

@ -282,7 +282,7 @@ export default {
}, },
onEditForm(item) { onEditForm(item) {
this.onEditItemEvent( this.onSubmitEvent(
"PATCH", "PATCH",
url + "/wizard/taxes/" + item.id, url + "/wizard/taxes/" + item.id,
"type", "type",

View File

@ -95,7 +95,7 @@ export default {
}); });
}, },
onEditItemEvent(form_method, form_url, plus_data, form_list, form_id) { onSubmitEvent(form_method, form_url, plus_data, form_list, form_id) {
const formData = new FormData(this.$refs["form"]); const formData = new FormData(this.$refs["form"]);
const data = {}; const data = {};
@ -110,61 +110,34 @@ export default {
['type']: 'normal', ['type']: 'normal',
}); });
} }
window.axios({ window.axios({
method: form_method, method: form_method,
url: form_url, url: form_url,
data: data, data: data,
}) })
.then(response => { .then(response => {
if (form_list.length) { if(form_list.length && form_list.length != undefined) {
form_list.forEach(item => { if(form_method == 'POST') {
if (item.id == form_id) { form_list.push({
item.name = response.data.data.name; "id": response.data.data.id,
item.code = response.data.data.code; "name": response.data.data.name,
item.rate = response.data.data.rate; "code": response.data.data.code,
item.type = plus_data == undefined ? 'normal' : '' "rate": response.data.data.rate,
} "enabled": response.data.data.enabled != undefined ? response.data.data.enabled : 'true'
}); });
}
if(form_method == 'PATCH') {
form_list.forEach(item => {
if (item.id == form_id) {
item.name = response.data.data.name;
item.code = response.data.data.code;
item.rate = response.data.data.rate;
}
});
}
} }
this.onSuccessMessage(response);
}, this)
.catch(error => {
this.onFailError(error)
}, this);
},
onSubmitEvent(form_method, form_url, plus_data, form_list) {
const formData = new FormData(this.$refs["form"]);
const data = {};
for (let [key, val] of formData.entries()) {
Object.assign(data, {
[key]: val,
});
}
if(plus_data == 'type') {
Object.assign(data, {
['type']: 'normal',
});
}
window.axios({
method: form_method,
url: form_url,
data: data,
})
.then(response => {
form_list.push({
"id": response.data.data.id,
"name": response.data.data.name,
"code": response.data.data.code,
"rate": response.data.data.rate,
"enabled": response.data.data.enabled != undefined ? response.data.data.enabled : 'true'
});
this.onSuccessMessage(response); this.onSuccessMessage(response);
}, this) }, this)
.catch(error => { .catch(error => {
@ -172,61 +145,6 @@ export default {
}, this); }, this);
}, },
onEditCompany() {
FormData.prototype.appendRecursive = function(data, wrapper = null) {
for(var name in data) {
if (name == "previewElement" || name == "previewTemplate") {
continue;
}
if (wrapper) {
if ((typeof data[name] == 'object' || Array.isArray(data[name])) && ((data[name] instanceof File != true ) && (data[name] instanceof Blob != true))) {
this.appendRecursive(data[name], wrapper + '[' + name + ']');
} else {
this.append(wrapper + '[' + name + ']', data[name]);
}
} else {
if ((typeof data[name] == 'object' || Array.isArray(data[name])) && ((data[name] instanceof File != true ) && (data[name] instanceof Blob != true))) {
this.appendRecursive(data[name], name);
} else {
this.append(name, data[name]);
}
}
}
}
const formData = new FormData(this.$refs["form"]);
let data_name = {};
for (let [key, val] of formData.entries()) {
Object.assign(data_name, {
[key]: val,
['logo']: this.$refs.dropzoneWizard.files[1] ? this.$refs.dropzoneWizard.files[1] : this.$refs.dropzoneWizard.files[0],
['_prefix']: 'company',
['_token']: window.Laravel.csrfToken,
['_method']: 'POST',
});
}
formData.appendRecursive(data_name);
window.axios({
method: 'POST',
url: url + "/wizard/companies",
data: formData,
headers: {
'X-CSRF-TOKEN': window.Laravel.csrfToken,
'X-Requested-With': 'XMLHttpRequest',
'Content-Type': 'multipart/form-data'
}
})
.then(response => {
this.onSuccessMessage(response);
}, this)
.catch(error => {
this.onFailError(error)
}, this);
},
onEjetItem(event, form_list, event_id) { onEjetItem(event, form_list, event_id) {
form_list.forEach(function (item, index) { form_list.forEach(function (item, index) {
if (item.id == event_id) { if (item.id == event_id) {