feat: allow adding other methods of file upload

This commit is contained in:
Safwan Samsudeen 2025-08-12 13:58:25 +05:30
parent acb7f82732
commit 35b65bc792
2 changed files with 15 additions and 0 deletions

View file

@ -163,6 +163,12 @@
</svg>
<div class="mt-1">{{ __("Google Drive") }}</div>
</button>
<template v-for="option in other_options">
<button class="btn btn-file-upload" @click="option.action">
<svg v-if="option.icon" v-html="option.icon" width="30" height="30" />
<div class="mt-1">{{ option.label }}</div>
</button>
</template>
</div>
<div class="mt-3 text-center" v-if="upload_notes">
{{ upload_notes }}
@ -291,6 +297,9 @@ const props = defineProps({
allow_google_drive: {
default: true,
},
other_options: {
default: () => [],
},
});
// variables

View file

@ -65,6 +65,7 @@ class FileUploader {
allow_toggle_private,
allow_toggle_optimize,
allow_google_drive,
other_options: this.get_extra_options(),
});
SetVueGlobals(app);
this.uploader = app.mount(this.wrapper);
@ -126,6 +127,11 @@ class FileUploader {
return this.uploader.upload_files(this.dialog);
}
get_extra_options() {
// Defaults to empty list, can be overriden externally
return [];
}
make_dialog(title) {
this.dialog = new frappe.ui.Dialog({
title: title || __("Upload"),