Create VnTable and use it
gitea/hedera-web/pipeline/pr-4922-vueMigration This commit looks good Details

This commit is contained in:
William Buezas 2024-08-14 09:08:46 -03:00
parent b728ecaf29
commit f36eb1bd88
3 changed files with 82 additions and 62 deletions

View File

@ -0,0 +1,39 @@
<script setup>
import { useI18n } from 'vue-i18n';
const { t } = useI18n();
const props = defineProps({
noDataLabel: {
type: String,
default: ''
},
hideBottom: {
type: Boolean,
default: true
},
rowsPerPageOptions: {
type: Array,
default: () => [0]
}
});
</script>
<template>
<QTable
v-bind="$attrs"
:no-data-label="props.noDataLabel || t('noInvoicesFound')"
:hide-bottom="props.hideBottom"
:rows-per-page-options="props.rowsPerPageOptions"
table-header-class="vnTable-header-default"
>
<slot />
</QTable>
</template>
<style lang="scss">
.vnTable-header-default {
background-color: $accent !important;
color: white;
}
</style>

View File

@ -2,6 +2,8 @@
import { ref, inject, onMounted, computed } from 'vue'; import { ref, inject, onMounted, computed } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import VnTable from 'src/components/ui/VnTable.vue';
const jApi = inject('jApi'); const jApi = inject('jApi');
const { t } = useI18n(); const { t } = useI18n();
@ -53,32 +55,15 @@ onMounted(() => getPackages());
<template> <template>
<QPage class="flex justify-center q-pa-md"> <QPage class="flex justify-center q-pa-md">
<QTable <VnTable
:columns="columns" :columns="columns"
:rows="packages" :rows="packages"
:loading="loading" :loading="loading"
class="q-mt-lg" style="height: max-content; max-width: 100%"
style="max-width: 100%; height: max-content" />
table-header-class="packages-table-header"
hide-bottom
>
<template #body-cell-id="{ row }">
<QTd auto-width @click.stop>
<QBtn flat color="blue">{{ row.id }}</QBtn>
<ItemDescriptorProxy :id="row.id" />
</QTd>
</template>
</QTable>
</QPage> </QPage>
</template> </template>
<style lang="scss">
.packages-table-header {
background-color: $accent !important;
color: white;
}
</style>
<i18n lang="yaml"> <i18n lang="yaml">
en-US: en-US:
agency: Agency agency: Agency

View File

@ -2,6 +2,8 @@
import { ref, onMounted, inject, computed } from 'vue'; import { ref, onMounted, inject, computed } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import VnTable from 'src/components/ui/VnTable.vue';
import { currency } from 'src/lib/filters.js'; import { currency } from 'src/lib/filters.js';
import { date as qdate } from 'quasar'; import { date as qdate } from 'quasar';
import { userStore as useUserStore } from 'stores/user'; import { userStore as useUserStore } from 'stores/user';
@ -80,49 +82,43 @@ onMounted(async () => {
/> />
</Teleport> </Teleport>
<div class="vn-w-sm"> <div class="vn-w-sm">
<QCard> <VnTable
<!-- --> :columns="columns"
<QTable :rows="invoices"
:columns="columns" :hide-header="!invoices.length"
:rows="invoices" >
:no-data-label="t('noInvoicesFound')" <template #body-cell-hasPdf="{ row }">
row-key="id" <QTd
:hide-header="!invoices.length" auto-width
:rows-per-page-options="[0]" @click.stop
> class="flex full-width justify-center items-center"
<template #body-cell-hasPdf="{ row }"> >
<QTd <QBtn
auto-width v-if="row.hasPdf"
@click.stop icon="download"
class="flex full-width justify-center items-center" :href="getInvoiceUrl(row.id)"
target="_blank"
flat
round
> >
<QBtn <QTooltip>
v-if="row.hasPdf" {{ t('downloadInvoicePdf') }}
icon="download" </QTooltip>
:href="getInvoiceUrl(row.id)" </QBtn>
target="_blank" <QIcon
flat v-else
round name="warning"
> :title="t('notDownloadable')"
<QTooltip> color="warning"
{{ t('downloadInvoicePdf') }} size="sm"
</QTooltip> >
</QBtn> <QTooltip>
<QIcon {{ t('requestTheInvoiceToComercial') }}
v-else </QTooltip>
name="warning" </QIcon>
:title="t('notDownloadable')" </QTd>
color="warning" </template>
size="sm" </VnTable>
>
<QTooltip>
{{ t('requestTheInvoiceToComercial') }}
</QTooltip>
</QIcon>
</QTd>
</template>
</QTable>
</QCard>
</div> </div>
</template> </template>