Company post method development for logo dropzone

This commit is contained in:
Burak Civan 2021-05-26 13:20:37 +03:00
parent d145d41ae6
commit 7adb8c9663
3 changed files with 32 additions and 17 deletions

View File

@ -244,17 +244,17 @@ export default {
download: attachment[0].downloadPath, download: attachment[0].downloadPath,
dropzone: 'edit', dropzone: 'edit',
}; };
this.dropzone.emit("addedfile", mockFile); this.dropzone.emit("addedfile", mockFile);
this.dropzone.options.thumbnail.call(this.dropzone, mockFile, attachment[0].path); this.dropzone.options.thumbnail.call(this.dropzone, mockFile, attachment[0].path);
// Make sure that there is no progress bar, etc... // Make sure that there is no progress bar, etc...
this.dropzone.emit("complete", mockFile); this.dropzone.emit("complete", mockFile);
this.files.forEach(async (attachment) => { this.files.forEach(async (attachment) => {
if (attachment.download) { if (attachment.download) {
attachment.previewElement.querySelector("[data-dz-download]").href = attachment.download; attachment.previewElement.querySelector("[data-dz-download]").href = attachment.download;
attachment.previewElement.querySelector("[data-dz-download]").classList.remove("d-none"); attachment.previewElement.querySelector("[data-dz-download]").classList.remove("d-none");
} }
}); });
if (this.preview == 'single' && attachments.length == 1) { if (this.preview == 'single' && attachments.length == 1) {

View File

@ -83,16 +83,32 @@ export default {
onEditEvent(form_method, form_url, plus_data, form_list, form_id) { onEditEvent(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 = {};
let file = {};
for (let [key, val] of formData.entries()) { for (let [key, val] of formData.entries()) {
Object.assign(data, { Object.assign(data, {
[key]: val, [key]: val,
['type']: 'normal'
}); });
} }
if (!plus_data || plus_data == undefined) { if(this.$refs.dropzoneWizard) {
delete data.type; 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') {
Object.assign(data, {
['type']: 'normal',
});
} }
window.axios({ window.axios({
@ -126,12 +142,13 @@ export default {
for (let [key, val] of formData.entries()) { for (let [key, val] of formData.entries()) {
Object.assign(data, { Object.assign(data, {
[key]: val, [key]: val,
['type']: 'normal'
}); });
} }
if (!plus_data || plus_data == undefined) { if(plus_data == 'type') {
delete data.type; Object.assign(data, {
['type']: 'normal',
});
} }
window.axios({ window.axios({

View File

@ -70,13 +70,12 @@
</div> </div>
<div class="col-6"> <div class="col-6">
<base-input :label="translations.company.logo"> <base-input :label="translations.company.logo">
<keep-alive>
<akaunting-dropzone-file-upload <akaunting-dropzone-file-upload
ref="dropzoneWizard"
preview-classes="single" preview-classes="single"
:attachments="logo" :attachments="logo"
> >
</akaunting-dropzone-file-upload> </akaunting-dropzone-file-upload>
</keep-alive>
</base-input> </base-input>
</div> </div>
</div> </div>
@ -173,8 +172,7 @@ export default {
}, },
onEditSave() { onEditSave() {
this.onEditEvent("PATCH", url + "/wizard/company", "", "", ""); this.onEditEvent("PATCH", url + "/wizard/company", "logo", "", "");
this.$router.push("/wizard/currencies"); this.$router.push("/wizard/currencies");
}, },
}, },