Skip to content

Commit a7c9eda

Browse files
authored
Merge pull request #21727 from itisAliRH/btable-to-gtable-export-record-table
Migrate ExportRecordTable from BTable to GTable
2 parents 03a765f + b59c25d commit a7c9eda

File tree

2 files changed

+30
-17
lines changed

2 files changed

+30
-17
lines changed

client/src/components/Common/ExportRecordTable.vue

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ import {
88
faSpinner,
99
} from "@fortawesome/free-solid-svg-icons";
1010
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
11-
import { BTable } from "bootstrap-vue";
11+
12+
import type { TableField } from "@/components/Common/GTable.types";
1213
1314
import type { ExportRecord } from "./models/exportRecordModel";
1415
1516
import GButton from "@/components/BaseComponents/GButton.vue";
1617
import GButtonGroup from "@/components/BaseComponents/GButtonGroup.vue";
18+
import GTable from "@/components/Common/GTable.vue";
1719
1820
interface Props {
1921
records: ExportRecord[];
@@ -26,13 +28,13 @@ const emit = defineEmits<{
2628
(e: "onCopyDownloadLink", record: ExportRecord): void;
2729
}>();
2830
29-
const fields = [
31+
const fields: TableField[] = [
3032
{ key: "elapsedTime", label: "Exported" },
3133
{ key: "format", label: "Format" },
3234
{ key: "expires", label: "Expires" },
33-
{ key: "isUpToDate", label: "Up to date", class: "text-center" },
34-
{ key: "isReady", label: "Ready", class: "text-center" },
35-
{ key: "actions", label: "Actions" },
35+
{ key: "isUpToDate", label: "Up to date", align: "center" },
36+
{ key: "isReady", label: "Ready", align: "center" },
37+
{ key: "actions", label: "Actions", align: "center" },
3638
];
3739
3840
async function reimportObject(record: ExportRecord) {
@@ -49,9 +51,9 @@ function copyDownloadLink(record: ExportRecord) {
4951
</script>
5052

5153
<template>
52-
<BTable :items="props.records" :fields="fields">
54+
<GTable :items="props.records" :fields="fields">
5355
<template v-slot:cell(elapsedTime)="row">
54-
<span :title="row.item.date">{{ row.value }}</span>
56+
<span :title="row.item.date.toLocaleString()">{{ row.value }}</span>
5557
</template>
5658

5759
<template v-slot:cell(format)="row">
@@ -61,7 +63,7 @@ function copyDownloadLink(record: ExportRecord) {
6163
<template v-slot:cell(expires)="row">
6264
<span v-if="row.item.hasExpired">Expired</span>
6365

64-
<span v-else-if="row.item.expirationDate" :title="row.item.expirationDate">
66+
<span v-else-if="row.item.expirationDate" :title="row.item.expirationDate.toLocaleString()">
6567
{{ row.item.expirationElapsedTime }}
6668
</span>
6769

@@ -131,5 +133,5 @@ function copyDownloadLink(record: ExportRecord) {
131133
</GButton>
132134
</GButtonGroup>
133135
</template>
134-
</BTable>
136+
</GTable>
135137
</template>

client/src/components/Common/GTable.vue

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ interface Props {
155155
156156
const props = withDefaults(defineProps<Props>(), {
157157
id: () => useUid("g-table-").value,
158-
actions: () => [],
158+
actions: undefined,
159159
bordered: false,
160160
clickableRows: false,
161161
containerClass: "",
@@ -291,7 +291,17 @@ function getCellValue(item: T, field: TableField) {
291291
}
292292
293293
/**
294-
* Get alignment class for a field
294+
* Get text alignment class for header labels
295+
*/
296+
function getTextAlignmentClass(align?: FieldAlignment) {
297+
if (!align || align === "left") {
298+
return "";
299+
}
300+
return `text-${align}`;
301+
}
302+
303+
/**
304+
* Get alignment class for body cells
295305
*/
296306
function getAlignmentClass(align?: FieldAlignment) {
297307
if (!align || align === "left") {
@@ -378,22 +388,23 @@ const getCellId = (tableId: string, fieldKey: string, index: number) => `g-table
378388
:key="field.key"
379389
:class="[
380390
field.headerClass,
381-
getAlignmentClass(field.align),
382391
{ 'g-table-sortable': field.sortable },
383392
{ 'g-table-sorted': sortBy === field.key },
384393
{ 'hide-on-small': field.hideOnSmall },
385394
]"
386395
:style="field.width ? { width: field.width } : undefined"
387396
@click="onHeaderClick(field)">
388-
<div class="d-flex align-items-center justify-content-between">
389-
<slot :name="`head(${field.key})`" :field="field">
390-
<span>{{ field.label || field.key }}</span>
391-
</slot>
397+
<div class="d-flex align-items-center">
398+
<div class="flex-grow-1" :class="getTextAlignmentClass(field.align)">
399+
<slot :name="`head(${field.key})`" :field="field">
400+
{{ field.label || field.key }}
401+
</slot>
402+
</div>
392403
<FontAwesomeIcon
393404
v-if="field.sortable && getSortIcon(field)"
394405
:icon="getSortIcon(field)"
395406
:class="{ 'text-muted': sortBy !== field.key }"
396-
class="ml-1" />
407+
class="ml-1 flex-shrink-0" />
397408
</div>
398409
</th>
399410

0 commit comments

Comments
 (0)