Skip to content

Commit

Permalink
fix: Adjust the button of export files
Browse files Browse the repository at this point in the history
  • Loading branch information
mariana-morais committed Mar 1, 2024
1 parent e69385a commit 094ce9c
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/files/arquivo_teste.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Nome,Endereço
Teste,Teste
Binary file added src/files/arquivo_teste.pdf
Binary file not shown.
40 changes: 36 additions & 4 deletions src/views/dashboards/Dashboard/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,25 @@
<span class="dashboard__button-title">Filtros</span>
</button>
</section>
<button class="dashboard__button">
<span class="dashboard__button-title">Exportar</span>
<unnnic-icon icon="expand_more" size="md" clickable />
</button>
<unnnic-dropdown>
<template #trigger>
<button class="dashboard__button">
<span class="dashboard__button-title">Exportar</span>
<unnnic-icon icon="expand_more" size="md" clickable />
</button>
</template>

<unnnic-dropdown-item>
<span @click="downloadCSV">
<p class="dashboard__dropdown-item">Exportar em CSV</p>
</span>
</unnnic-dropdown-item>
<unnnic-dropdown-item>
<span @click="downloadPDF">
<p class="dashboard__dropdown-item">Exportar em PDF</p>
</span>
</unnnic-dropdown-item>
</unnnic-dropdown>
</section>
</header>
<section class="dashboard__widgets" v-if="firstSection">
Expand Down Expand Up @@ -128,6 +143,18 @@ export default {
handleCrumbClick(crumb) {
this.$router.push(crumb.path);
},
downloadCSV() {
const link = document.createElement('a');
link.href = '/src/files/arquivo_teste.csv';
link.setAttribute('download', 'arquivo_teste.csv');
link.click();
},
downloadPDF() {
const link = document.createElement('a');
link.href = '/src/files/arquivo_teste.pdf';
link.setAttribute('download', 'arquivo_teste.pdf');
link.click();
},
},
mounted() {
const cardTitle = this.$route.query.title;
Expand Down Expand Up @@ -200,6 +227,9 @@ export default {
&__button-title {
font-size: $unnnic-font-size-body-lg;
}
&__dropdown-item {
width: max-content;
}
&__widgets {
height: 100%;
Expand Down Expand Up @@ -253,6 +283,8 @@ export default {
font-size: $unnnic-font-size-body-lg;
}
&__table {
height: 100%;
margin-top: $unnnic-spacing-sm;
}
}
Expand Down

0 comments on commit 094ce9c

Please sign in to comment.