Skip to content

Commit

Permalink
Group export files by folder, fix #95
Browse files Browse the repository at this point in the history
  • Loading branch information
arildm committed Mar 18, 2024
1 parent 3f02609 commit 31a4e68
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ As this project is a user-facing application, the places in the semantic version

### Changed

- Export files are sorted alphabetically
- Group export files by folder [#95](https://github.com/spraakbanken/mink-frontend/issues/95)

### Fixed

Expand Down
35 changes: 24 additions & 11 deletions src/corpus/exports/CorpusResult.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<script setup lang="ts">
import { computed } from "vue";
import groupBy from "lodash/groupBy";
import useExports from "@/corpus/exports/exports.composable";
import useCorpusIdParam from "@/corpus/corpusIdParam.composable";
import ActionButton from "@/components/ActionButton.vue";
Expand All @@ -17,6 +19,12 @@ const {
getDownloadFilename,
} = useExports(corpusId);
const exportsByFolder = computed(() =>
exports.value
? groupBy(exports.value, (meta) => meta.path.split("/").shift())
: undefined,
);
loadExports();
</script>

Expand Down Expand Up @@ -54,17 +62,22 @@ loadExports();
</tr>
</thead>
<tbody>
<tr v-for="file in exports" :key="file.name">
<td>
<a href="#" @click.prevent="downloadResultFile(file.path)">
<icon :icon="['fas', 'download']" />
{{ file.path }}
</a>
</td>
<td class="text-right whitespace-nowrap">
{{ filesize(file.size) }}
</td>
</tr>
<template v-for="(exports_, folder) in exportsByFolder" :key="folder">
<tr>
<td colspan="2">{{ folder }}/</td>
</tr>
<tr v-for="file in exports_" :key="file.name">
<td class="!pl-6">
<a href="#" @click.prevent="downloadResultFile(file.path)">
<icon :icon="['fas', 'download']" />
{{ file.path.split("/").slice(1).join("/") }}
</a>
</td>
<td class="text-right whitespace-nowrap">
{{ filesize(file.size) }}
</td>
</tr>
</template>
</tbody>
</table>
</LayoutSection>
Expand Down

0 comments on commit 31a4e68

Please sign in to comment.