Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions apps/files/src/reference-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@
*/

import Vue from 'vue'
import { getRequestToken } from '@nextcloud/auth'
import { translate as t } from '@nextcloud/l10n'

import { registerWidget, registerCustomPickerElement, NcCustomPickerRenderResult } from '@nextcloud/vue/dist/Components/NcRichText.js'

import FileWidget from './views/ReferenceFileWidget.vue'
import FileReferencePickerElement from './views/FileReferencePickerElement.vue'

// eslint-disable-next-line camelcase
__webpack_nonce__ = btoa(getRequestToken())

Vue.mixin({
methods: {
t,
Expand Down
81 changes: 18 additions & 63 deletions apps/files/src/views/FileReferencePickerElement.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
- @copyright Copyright (c) 2023 Julius Härtl <[email protected]>
-
- @author Julius Härtl <[email protected]>
- @author Ferdinand Thiessen <[email protected]>
-
- @license GNU AGPL version 3 or any later version
-
Expand All @@ -20,15 +21,20 @@
-->

<template>
<div ref="picker" class="reference-file-picker" />
<FilePicker :buttons="buttons"
:container="null"
:name="t('files', 'Select file or folder to link to')"
:multiselect="false"
@close="$emit('cancel')" />
</template>

<script>
import { FilePickerType } from '@nextcloud/dialogs'
import { FilePickerVue } from '@nextcloud/dialogs'
import { generateUrl } from '@nextcloud/router'
export default {
name: 'FileReferencePickerElement',
components: {
FilePicker: FilePickerVue,
},
props: {
providerId: {
Expand All @@ -40,38 +46,18 @@ export default {
default: false,
},
},
mounted() {
this.openFilePicker()
window.addEventListener('click', this.onWindowClick)
},
beforeDestroy() {
window.removeEventListener('click', this.onWindowClick)
},
methods: {
onWindowClick(e) {
if (e.target.tagName === 'A' && e.target.classList.contains('oc-dialog-close')) {
this.$emit('cancel')
}
},
async openFilePicker() {
OC.dialogs.filepicker(
t('files', 'Select file or folder to link to'),
(file) => {
const client = OC.Files.getClient()
client.getFileInfo(file).then((_status, fileInfo) => {
this.submit(fileInfo.id)
})
},
false, // multiselect
[], // mime filter
false, // modal
FilePickerType.Choose, // type
'',
data() {
return {
buttons: [
{
target: this.$refs.picker,
label: t('files', 'Choose'),
type: 'primary',
callback: (node) => this.submit(node.fileid),
},
)
},
],
}
},
methods: {
submit(fileId) {
const fileLink = window.location.protocol + '//' + window.location.host
+ generateUrl('/f/{fileId}', { fileId })
Expand All @@ -80,34 +66,3 @@ export default {
},
}
</script>

<style scoped lang="scss">
.reference-file-picker {
flex-grow: 1;
padding: 12px 16px 16px 16px;

&:deep(.oc-dialog) {
transform: none !important;
box-shadow: none !important;
flex-grow: 1 !important;
position: static !important;
width: 100% !important;
height: auto !important;
padding: 0 !important;
max-width: initial;

.oc-dialog-close {
display: none;
}

.oc-dialog-buttonrow.onebutton.aside {
position: absolute;
padding: 12px 32px;
}

.oc-dialog-content {
max-width: 100% !important;
}
}
}
</style>
4 changes: 2 additions & 2 deletions dist/core-common.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-common.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files-reference-files.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-reference-files.js.map

Large diffs are not rendered by default.