Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable29] chore: disable Actions menu when click in an action #4040

Merged
merged 1 commit into from
Nov 25, 2024
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
73 changes: 30 additions & 43 deletions src/Components/Request/RequestPicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,24 @@
<template #icon>
<PlusIcon :size="20" />
</template>
<NcActionButton @click="showModalUploadFromUrl()"
:wide="true">
<NcActionButton :wide="true"
@click="showModalUploadFromUrl()">
<template #icon>
<LinkIcon :size="20" />
</template>
{{ t('libresign', 'Upload from URL') }}
</NcActionButton>
<NcActionButton @click="showFilePicker = true"
:wide="true">
<NcActionButton :wide="true"
@click="showFilePicker = true">
<template #icon>
<FolderIcon :size="20" />
</template>
{{ t('libresign', 'Choose from Files') }}
</NcActionButton>
<NcActionButton @click="uploadFile"
:wide="true">
<NcActionButton :wide="true"
@click="uploadFile">
<template #icon>
<NcLoadingIcon v-if="isUploading" :size="20" />
<UploadIcon v-else :size="20" />
<UploadIcon :size="20" />
</template>
{{ t('libresign', 'Upload') }}
</NcActionButton>
Expand Down Expand Up @@ -136,9 +135,9 @@ export default {
modalUploadFromUrl: false,
uploadUrlErrors: [],
pdfUrl: '',
isUploading: false,
showingFilePicker: false,
loading: false,
openedMenu: false,
}
},
computed: {
Expand All @@ -161,14 +160,6 @@ export default {
return false
}
},
openedMenu: {
get() {
return this.actionsMenuStore.opened === 'global'
},
set(opened) {
this.actionsMenuStore.opened = opened ? 'global' : null
},
},
showFilePicker: {
get() {
return this.showingFilePicker
Expand All @@ -185,37 +176,37 @@ export default {
showModalUploadFromUrl() {
this.actionsMenuStore.opened = false
this.modalUploadFromUrl = true
this.openedMenu = false
this.loading = false
},
closeModalUploadFromUrl() {
this.cleanErrors()
this.uploadUrlErrors = []
this.pdfUrl = ''
this.modalUploadFromUrl = false
},
cleanErrors() {
this.uploadUrlErrors = []
this.loading = false
},
async upload(file) {
try {
const { name: original } = file

const name = original.split('.').slice(0, -1).join('.')

const data = await loadFileToBase64(file)

const res = await filesService.uploadFile({ name, file: data })

this.filesStore.addFile({
nodeId: res.id,
name: res.name,
const data = await loadFileToBase64(file)
await filesService.uploadFile({
name: file.name,
file: data,
})
.then((response) => {
this.filesStore.addFile({
nodeId: response.id,
name: response.name,
})
this.filesStore.selectFile(response.id)
this.loading = false
})
.catch(({ response }) => {
showError(response.data.ocs.data.message)
this.loading = false
})
this.filesStore.selectFile(res.id)
this.cleanErrors()
} catch (err) {
showError(err.response.data.ocs.data.message)
}
},
uploadFile() {
this.loading = true
this.openedMenu = false
const input = document.createElement('input')
input.accept = 'application/pdf'
input.type = 'file'
Expand All @@ -231,11 +222,9 @@ export default {
}

input.click()
this.loading = false
},
async uploadUrl() {
this.loading = true
this.cleanErrors()
await axios.post(generateOcsUrl('/apps/libresign/api/v1/file'), {
file: {
url: this.pdfUrl,
Expand All @@ -251,8 +240,8 @@ export default {
})
.catch(({ response }) => {
this.uploadUrlErrors = [response.data.ocs.data.message]
this.loading = false
})
this.loading = false
},
async handleFileChoose(nodes) {
const path = nodes[0]?.path
Expand All @@ -272,11 +261,9 @@ export default {
name: data.ocs.data.name,
})
this.filesStore.selectFile(data.ocs.data.id)
this.cleanErrors()
})
.catch(({ response }) => {
showError(response.data.ocs.data.message)
this.loading = false
})
},
},
Expand Down
3 changes: 3 additions & 0 deletions src/views/FilesList/FilesList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
<NcEmptyContent v-else-if="!loading && isEmptyDir"
:name="t('libresign', 'There are no documents')"
:description="t('libresign', 'Choose the file to request signatures.')">
<template #action>
<RequestPicker />
</template>
<template #icon>
<FolderIcon />
</template>
Expand Down