File upload development for form patch

This commit is contained in:
Burak Civan 2021-05-28 10:04:51 +03:00
parent 99d8ea337e
commit d9ba4c47d9
4 changed files with 14 additions and 31 deletions

View File

@ -98,20 +98,6 @@ export default {
[key]: val, [key]: val,
}); });
} }
if(this.$refs.dropzoneWizard) {
if(this.$refs.dropzoneWizard.dropzone.files.length) {
file = this.$refs.dropzoneWizard.dropzone.files[0];
} else {
file = this.$refs.dropzoneWizard.files[0];
}
}
if(plus_data == 'logo') {
Object.assign(data, {
['logo']: file
});
}
if(plus_data == 'type') { if(plus_data == 'type') {
Object.assign(data, { Object.assign(data, {
@ -210,17 +196,16 @@ export default {
for (let [key, val] of formData.entries()) { for (let [key, val] of formData.entries()) {
Object.assign(data_name, { Object.assign(data_name, {
[key]: val, [key]: val,
['logo']: this.$refs.dropzoneWizard.files[1], ['logo']: this.$refs.dropzoneWizard.files[1] ? this.$refs.dropzoneWizard.files[1] : this.$refs.dropzoneWizard.files[0],
['_prefix']: 'company', ['_prefix']: 'company',
['_token']: window.Laravel.csrfToken, ['_token']: window.Laravel.csrfToken,
['_method']: 'PATCH', ['_method']: 'POST',
}); });
} }
formData.appendRecursive(data_name); formData.appendRecursive(data_name);
window.axios({ window.axios({
method: 'PATCH', method: 'POST',
url: url + "/wizard/companies", url: url + "/wizard/companies",
data: formData, data: formData,
headers: { headers: {

View File

@ -12,7 +12,7 @@
<el-step :title="translations.finish.title"></el-step> <el-step :title="translations.finish.title"></el-step>
</el-steps> </el-steps>
</div> </div>
<form id="company-name" ref="form" class="w-100" method="PATCH"> <form ref="form" class="w-100">
<div class="card-body"> <div class="card-body">
<div class="row mb-4"> <div class="row mb-4">
<div class="col-12 mb-4"> <div class="col-12 mb-4">
@ -170,10 +170,4 @@ export default {
}, },
}, },
}; };
</script> </script>
<style scoped>
form {
flex-flow: row wrap;
}
</style>

View File

@ -57,7 +57,7 @@
<base-button type="white" native-type="submit" @click="prev()" <base-button type="white" native-type="submit" @click="prev()"
>{{ translations.finish.previous }}</base-button >{{ translations.finish.previous }}</base-button
> >
<base-button type="success" native-type="submit" @click="finish()" <base-button type="success" native-type="submit" v-if="button_show" @click="finish()"
>{{ translations.finish.go_to_dashboard }}</base-button >{{ translations.finish.go_to_dashboard }}</base-button
> >
</div> </div>
@ -79,9 +79,12 @@ export default {
}, },
created() { created() {
window.axios({ window.axios({
method: 'GET', method: 'PATCH',
url url: url + '/wizard/finish'
}).then(response => { }).then(response => {
if(response.status == "200") {
this.button_show = true;
}
}).catch(error => { }).catch(error => {
@ -99,11 +102,12 @@ export default {
return { return {
active: 3, active: 3,
route_url: url, route_url: url,
button_show: false
}; };
}, },
methods: { methods: {
finish() { finish() {
window.location.href = ""; window.location.href = url;
}, },
prev() { prev() {
if (this.active-- > 2); if (this.active-- > 2);

View File

@ -12,7 +12,7 @@ Route::group(['as' => 'wizard.'], function () {
Route::get('data', 'Wizard\Data@index')->name('data.index'); Route::get('data', 'Wizard\Data@index')->name('data.index');
Route::get('companies', 'Wizard\Companies@edit')->name('companies.edit'); Route::get('companies', 'Wizard\Companies@edit')->name('companies.edit');
Route::patch('companies', 'Wizard\Companies@update')->middleware('dropzone')->name('companies.update'); Route::post('companies', 'Wizard\Companies@update')->middleware('dropzone')->name('companies.update');
Route::get('currencies/{currency}/enable', 'Settings\Currencies@enable')->name('currencies.enable'); Route::get('currencies/{currency}/enable', 'Settings\Currencies@enable')->name('currencies.enable');
Route::get('currencies/{currency}/disable', 'Settings\Currencies@disable')->name('currencies.disable'); Route::get('currencies/{currency}/disable', 'Settings\Currencies@disable')->name('currencies.disable');