Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Chartman123 <[email protected]>
Signed-off-by: Konstantin Myakshin <[email protected]>
  • Loading branch information
Koc and Chartman123 authored Dec 28, 2023
1 parent da853cb commit 00bb4f4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
4 changes: 2 additions & 2 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ This file contains the API-Documentation. For more information on the returned D
- Completely new way of handling access & shares.

### Other API changes
- In API version 2.2 next endpoints were introduced:
- In API version 2.2 the following endpoints were introduced:
- `POST /api/2.2/submissions/link/{fileFormat}` to link form to a file
- `GET /api/2.2/submissions/linkedFile/{hash}` to retrieve linked file
- `POST /api/2.2/submissions/unlink` to unlink form from a file
- In API version 2.2 next endpoints were changed:
- In API version 2.2 the following endpoints were changed:
- `GET /api/v2.1/submissions/export/{hash}` was extended with optional parameter `fileFormat` to export submissions in different formats
- `GET /api/v2.1/submissions/export` was extended with optional parameter `fileFormat` to export submissions to cloud in different formats
- In API version 2.1 the endpoint `/api/v2.1/share/update` was added to update a Share
Expand Down
33 changes: 15 additions & 18 deletions src/views/Results.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,10 @@
</NcButton>

<NcActionButton v-if="!linkedFile.fileId"
type="tertiary-no-background"
:menu-name="t('forms', 'Create spreadsheet')"
:aria-label="t('forms', 'Create spreadsheet')"
@click="onLinkFile"
>
type="tertiary-no-background"
:menu-name="t('forms', 'Create spreadsheet')"
:aria-label="t('forms', 'Create spreadsheet')"
@click="onLinkFile">
<template #icon>
<IconLink :size="20" />
</template>
Expand Down Expand Up @@ -120,9 +119,9 @@

<!-- Action menu for cloud export and deletion -->
<NcActions class="results-menu"
:aria-label="t('forms', 'Options')"
:force-menu="true"
@close="hideSubActions">
:aria-label="t('forms', 'Options')"
:force-menu="true"
@close="hideSubActions">
<template v-if="!isDownloadActionOpened">
<template v-if="linkedFile.fileId">
<NcActionButton :close-after-click="true" @click="onReExport">
Expand Down Expand Up @@ -168,8 +167,7 @@
<NcActionButton :close-after-click="false" @click="hideSubActions">
<template #icon>
<IconChevronLeft :title="t('mail', 'Download')"
:size="20" />
{{ t('forms', 'Download') }}
:size="20" />
</template>
</NcActionButton>

Expand Down Expand Up @@ -224,7 +222,7 @@
import { generateOcsUrl, generateUrl } from '@nextcloud/router'
import { getRequestToken } from '@nextcloud/auth'
import {getFilePickerBuilder, showError, showSuccess, FilePickerType} from '@nextcloud/dialogs'
import { emit } from '@nextcloud/event-bus'
import { getFilePickerBuilder, showError, showSuccess } from '@nextcloud/dialogs'
import axios from '@nextcloud/axios'
import moment from '@nextcloud/moment'
import NcActions from '@nextcloud/vue/dist/Components/NcActions.js'
Expand Down Expand Up @@ -262,17 +260,17 @@ import OcsResponse2Data from '../utils/OcsResponse2Data.js'
import PermissionTypes from '../mixins/PermissionTypes.js'

const SUPPORTED_FILE_FORMATS = {ods : IconTableSvg, csv: IconFileDelimitedSvg, xlsx: IconFileExcelSvg}

const SUPPORTED_FILE_FORMATS = { ods: IconTableSvg, csv: IconFileDelimitedSvg, xlsx: IconFileExcelSvg }
let fileFormat = 'csv'
const picker = getFilePickerBuilder(t('forms', 'Choose spreadsheet location'))
.setMultiSelect(false)
.allowDirectories()
.setButtonFactory((selectedNodes, currentPath, currentView) => {
if (selectedNodes.length === 1) {
const extension = selectedNodes[0].extension.slice(1).toLowerCase();
const extension = selectedNodes[0].extension.slice(1).toLowerCase()
if (SUPPORTED_FILE_FORMATS[extension]) {
return [{
label: t('forms', 'Select {file}', {file: selectedNodes[0].basename}),
label: t('forms', 'Select {file}', { file: selectedNodes[0].basename }),
icon: SUPPORTED_FILE_FORMATS[extension],
callback() {
fileFormat = extension
Expand All @@ -281,8 +279,7 @@ const picker = getFilePickerBuilder(t('forms', 'Choose spreadsheet location'))
}]
}

return [];
}
return []

return [
{
Expand Down Expand Up @@ -398,7 +395,7 @@ export default {
})

this.linkedFile = {fileId: null, path: null, fileFormat: null}
},
this.linkedFile = { fileId: null, path: null, fileFormat: null }
async loadLinkedFile() {
try {
const response = await axios.get(generateOcsUrl(`apps/forms/api/v2/submissions/linkedFile/${this.form.hash}`))
Expand Down Expand Up @@ -473,7 +470,7 @@ export default {
hash: this.form.hash,
path,
fileFormat
})
fileFormat,
showSuccess(t('forms', 'Export successful to {file}', { file: OcsResponse2Data(response) }))
} catch (error) {
logger.error('Error while exporting to Files', { error })
Expand Down

0 comments on commit 00bb4f4

Please sign in to comment.