fix(files): Allow to pick directories using the file reference picker

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
pull/44803/head
Ferdinand Thiessen 2 months ago
parent 45e601f8f2
commit b0a0b5b827
No known key found for this signature in database
GPG Key ID: 45FAE7268762B400

@ -21,11 +21,12 @@
-->
<template>
<FilePicker :buttons="buttons"
<FilePicker allow-pick-directory
:buttons="buttons"
:container="null"
:name="t('files', 'Select file or folder to link to')"
:multiselect="false"
@close="$emit('cancel')" />
@close="onClose" />
</template>
<script>
@ -48,24 +49,32 @@ export default {
default: false,
},
},
data() {
return {
buttons: [
{
label: t('files', 'Choose'),
type: 'primary',
callback: (nodes) => {
logger.debug('FileReferencePicker - Nodes picked', { nodes })
this.submit(nodes[0].fileid)
},
setup() {
// Buttons to show
const buttons = [
{
label: t('files', 'Choose'),
type: 'primary',
callback: (nodes) => {
logger.debug('FileReferencePicker - Nodes picked', { nodes })
},
],
},
]
return {
buttons,
}
},
methods: {
submit(fileId) {
const fileLink = `${window.location.protocol}//${window.location.host}${generateUrl('/f/{fileId}', { fileId })}`
this.$emit('submit', fileLink)
onClose(selectedNodes) {
if (!selectedNodes || selectedNodes.length === 0) {
this.$emit('cancel')
} else {
const fileLink = `${window.location.protocol}//${window.location.host}${generateUrl('/f/{fileId}', { fileId: selectedNodes[0].fileid })}`
this.$emit('submit', fileLink)
}
},
},
}

Loading…
Cancel
Save