Skip to content

Commit

Permalink
Fix some of code review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Konstantin Myakshin <[email protected]>
  • Loading branch information
Koc committed Oct 23, 2023
1 parent 328a0bd commit 9cb08e7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
7 changes: 4 additions & 3 deletions lib/Controller/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
use OCP\AppFramework\OCS\OCSBadRequestException;
use OCP\AppFramework\OCS\OCSException;
use OCP\AppFramework\OCS\OCSForbiddenException;
use OCP\AppFramework\OCS\OCSNotFoundException;
use OCP\AppFramework\OCSController;
use OCP\Files\NotPermittedException;
use OCP\IL10N;
Expand Down Expand Up @@ -1091,7 +1092,7 @@ public function exportSubmissions(string $hash, string $fileFormat): DataDownloa
$form = $this->formMapper->findByHash($hash);
} catch (IMapperException $e) {
$this->logger->debug('Could not find form');
throw new OCSBadRequestException();
throw new OCSNotFoundException();
}

if (!$this->formsService->canSeeResults($form)) {
Expand Down Expand Up @@ -1135,7 +1136,7 @@ public function exportSubmissionsToCloud(string $hash, string $path, string $fil
$form = $this->formMapper->findByHash($hash);
} catch (IMapperException $e) {
$this->logger->debug('Could not find form');
throw new OCSBadRequestException();
throw new OCSNotFoundException();
}

if (!$this->formsService->canSeeResults($form)) {
Expand Down Expand Up @@ -1213,7 +1214,7 @@ public function linkFile(string $hash, string $path, string $fileFormat): DataRe
$form = $this->formMapper->findByHash($hash);
} catch (IMapperException $e) {
$this->logger->debug('Could not find form');
throw new OCSBadRequestException();
throw new OCSNotFoundException();
}
if ($form->getOwnerId() !== $this->currentUser->getUID()) {
$this->logger->debug('This form is not owned by the current user');
Expand Down
2 changes: 1 addition & 1 deletion lib/Migration/Version030200Date20231001200100.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* @copyright Copyright (c) 2023 Ferdinand Thiessen <[email protected]>
*
* @author Ferdinand Thiessen <[email protected]>
* @author Kostiantyn Miakshyn <[email protected]>
*
* @license GNU AGPL version 3 or any later version
*
Expand Down
4 changes: 4 additions & 0 deletions lib/Service/SubmissionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,10 @@ public function getFileName(Form $form, string $fileFormat): string
return str_replace(mb_str_split(\OCP\Constants::FILENAME_INVALID_CHARS), '-', $fileName);
}

/**
* @param array<int, string> $header
* @param array<int, string> $data
*/
private function exportData(array $header, array $data, string $fileFormat, ?File $file = null): string
{
if (!in_array($fileFormat, self::SUPPORTED_EXPORT_FORMATS)) {
Expand Down
18 changes: 9 additions & 9 deletions src/views/Results.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,21 +87,21 @@
<template #icon>
<IconFileDelimited :size="20" />
</template>
{{ t('forms', 'CSV') }}
CSV
</NcActionButton>

<NcActionButton :close-after-click="true" @click="onLinkFile('ods')">
<template #icon>
<IconTable :size="20" />
</template>
{{ t('forms', 'ODS') }}
ODS
</NcActionButton>

<NcActionButton :close-after-click="true" @click="onLinkFile('xlsx')">
<template #icon>
<IconFileExcel :size="20" />
</template>
{{ t('forms', 'XSLX') }}
XSLX
</NcActionButton>
</NcActions>

Expand Down Expand Up @@ -131,21 +131,21 @@
<template #icon>
<IconFileDelimited :size="20" />
</template>
{{ t('forms', 'CSV') }}
CSV
</NcActionButton>

<NcActionButton :close-after-click="true" @click="onStoreToFiles('ods')">
<template #icon>
<IconTable :size="20" />
</template>
{{ t('forms', 'ODS') }}
ODS
</NcActionButton>

<NcActionButton :close-after-click="true" @click="onStoreToFiles('xlsx')">
<template #icon>
<IconFileExcel :size="20" />
</template>
{{ t('forms', 'XSLX') }}
XSLX
</NcActionButton>
</NcActionButtonGroup>

Expand All @@ -156,21 +156,21 @@
<template #icon>
<IconFileDelimited :size="20" />
</template>
{{ t('forms', 'CSV') }}
CSV
</NcActionButton>

<NcActionButton :close-after-click="true" @click="onDownloadFile('ods')">
<template #icon>
<IconTable :size="20" />
</template>
{{ t('forms', 'ODS') }}
ODS
</NcActionButton>

<NcActionButton :close-after-click="true" @click="onDownloadFile('xlsx')">
<template #icon>
<IconFileExcel :size="20" />
</template>
{{ t('forms', 'XSLX') }}
XSLX
</NcActionButton>
</NcActionButtonGroup>

Expand Down

0 comments on commit 9cb08e7

Please sign in to comment.