refactor: Minor changes to doc image upload, UI test
This commit is contained in:
parent
11eefe3eee
commit
ccfe4a857c
5 changed files with 18 additions and 12 deletions
|
|
@ -63,11 +63,11 @@ context('FileUploader', () => {
|
|||
});
|
||||
|
||||
cy.get_open_dialog().find('.file-name').should('contain', 'sample_image.jpg');
|
||||
cy.get_open_dialog().find(':nth-child(1) > .file-actions > .file-action-buttons > :nth-child(1)').first().click();
|
||||
cy.get_open_dialog().find('.btn-crop').first().click();
|
||||
cy.get_open_dialog().find('.image-cropper-actions > .btn-primary').should('contain', 'Crop');
|
||||
cy.get_open_dialog().find('.image-cropper-actions > .btn-primary').click();
|
||||
cy.get_open_dialog().find(':nth-child(1) > :nth-child(2) > .optimize-checkbox').first().should('contain', 'Optimize');
|
||||
cy.get_open_dialog().find(':nth-child(1) > :nth-child(2) > .optimize-checkbox').first().click();
|
||||
cy.get_open_dialog().find('.optimize-checkbox').first().should('contain', 'Optimize');
|
||||
cy.get_open_dialog().find('.optimize-checkbox').first().click();
|
||||
|
||||
cy.intercept('POST', '/api/method/upload_file').as('upload_file');
|
||||
cy.get_open_dialog().find('.btn-modal-primary').click();
|
||||
|
|
|
|||
|
|
@ -157,7 +157,15 @@ def upload_file():
|
|||
|
||||
content_type = guess_type(filename)[0]
|
||||
if optimize and content_type.startswith("image/"):
|
||||
content = optimize_image(content, content_type)
|
||||
args = {
|
||||
"content": content,
|
||||
"content_type": content_type
|
||||
}
|
||||
if frappe.form_dict.max_width:
|
||||
args["max_width"] = int(frappe.form_dict.max_width)
|
||||
if frappe.form_dict.max_height:
|
||||
args["max_height"] = int(frappe.form_dict.max_height)
|
||||
content = optimize_image(**args)
|
||||
|
||||
frappe.local.uploaded_file = content
|
||||
frappe.local.uploaded_filename = filename
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@
|
|||
<div v-if="uploaded" v-html="frappe.utils.icon('solid-success', 'lg')"></div>
|
||||
<div v-if="file.failed" v-html="frappe.utils.icon('solid-red', 'lg')"></div>
|
||||
<div class="file-action-buttons">
|
||||
<button v-if="is_cropable" class="btn muted" @click="$emit('toggle_image_cropper')" v-html="frappe.utils.icon('crop', 'md')"></button>
|
||||
<button v-if="is_cropable" class="btn btn-crop muted" @click="$emit('toggle_image_cropper')" v-html="frappe.utils.icon('crop', 'md')"></button>
|
||||
<button v-if="!uploaded && !file.uploading" class="btn muted" @click="$emit('remove')" v-html="frappe.utils.icon('delete', 'md')"></button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -218,11 +218,6 @@ export default {
|
|||
}
|
||||
});
|
||||
}
|
||||
if(this.attach_doc_image) {
|
||||
this.allow_web_link = false;
|
||||
this.allow_take_photo = false;
|
||||
this.google_drive_settings.enabled = false;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
files(newvalue, oldvalue) {
|
||||
|
|
@ -486,6 +481,11 @@ export default {
|
|||
form_data.append('optimize', true);
|
||||
}
|
||||
|
||||
if (this.attach_doc_image) {
|
||||
form_data.append('max_width', 200);
|
||||
form_data.append('max_height', 200);
|
||||
}
|
||||
|
||||
xhr.send(form_data);
|
||||
});
|
||||
},
|
||||
|
|
|
|||
|
|
@ -28,9 +28,7 @@ export default class FileUploader {
|
|||
}
|
||||
|
||||
if (attach_doc_image) {
|
||||
disable_file_browser = true;
|
||||
restrictions.allowed_file_types = ['.jpg', '.png'];
|
||||
this.dialog && this.dialog.footer.addClass('hide');
|
||||
}
|
||||
|
||||
this.$fileuploader = new Vue({
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue