Skip to content

Commit

Permalink
fix: use file picker component directly
Browse files Browse the repository at this point in the history
Signed-off-by: Elizabeth Danzberger <[email protected]>
  • Loading branch information
elzody committed Sep 9, 2024
1 parent 03c0631 commit fd4b1f3
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions src/view/DocumentTargetPicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
</template>

<script>
import { getFilePickerBuilder } from '@nextcloud/dialogs'
import { FilePickerVue as FilePicker } from '@nextcloud/dialogs/filepicker.js'
import { spawnDialog } from '@nextcloud/dialogs'
import { generateUrl, generateOcsUrl } from '@nextcloud/router'
import axios from '@nextcloud/axios'
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
Expand Down Expand Up @@ -87,26 +88,34 @@ export default {
window.removeEventListener('click', this.onWindowClick)
},
methods: {
t,
onWindowClick(e) {
if (e.target.tagName === 'A' && e.target.classList.contains('oc-dialog-close')) {
this.$emit('cancel')
}
},
async openFilePicker() {
await getFilePickerBuilder(t('files', 'Select file or folder to link to'))
.setMimeTypeFilter(getCapabilities().mimetypes)
.addButton({
label: t('richdocuments', 'Insert image'),
const filePickerButtons = [
{
label: t('richdocuments', 'Select file'),
callback: (files) => {
const file = files[0]
this.fileId = file.fileid
this.filePath = file.path
this.fetchReferences()
},
})
.setContainer(this.$refs.picker)
.build()
.pick()
type: 'primary',
},
]
spawnDialog(FilePicker, {
name: t('files', 'Select file or folder to link to'),
multiselect: false,
mimetypeFilter: getCapabilities().mimetypes,
allowPickDirectory: false,
buttons: filePickerButtons,
container: '.office-target-picker',
})
},
setTarget(entry) {
this.target = entry.id
Expand Down

0 comments on commit fd4b1f3

Please sign in to comment.