summaryrefslogtreecommitdiffstats
path: root/apps/files
diff options
context:
space:
mode:
authorBenjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>2024-04-17 11:28:50 +0200
committerGitHub <noreply@github.com>2024-04-17 11:28:50 +0200
commit75935b83da94a9d0c835d4065d541ba5649d8283 (patch)
treed731871a80b7f32efe37693dce756c4624c1085d /apps/files
parent5dde6512e05f5778b4afe74e3a2770c3d56f0beb (diff)
parentc7c7b5bb1927105272b71345ce7ee597aa4bb342 (diff)
downloadnextcloud-server-75935b83da94a9d0c835d4065d541ba5649d8283.tar.gz
nextcloud-server-75935b83da94a9d0c835d4065d541ba5649d8283.zip
Merge pull request #44803 from nextcloud/fix/smartpicker-file-picker
Diffstat (limited to 'apps/files')
-rw-r--r--apps/files/src/views/FileReferencePickerElement.vue41
1 files changed, 25 insertions, 16 deletions
diff --git a/apps/files/src/views/FileReferencePickerElement.vue b/apps/files/src/views/FileReferencePickerElement.vue
index b139c5e79a1..48296279543 100644
--- a/apps/files/src/views/FileReferencePickerElement.vue
+++ b/apps/files/src/views/FileReferencePickerElement.vue
@@ -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)
+ }
},
},
}