mirror of
https://github.com/hay-kot/homebox.git
synced 2025-07-05 01:58:36 +00:00
fix datetime display issues (again) (#324)
This commit is contained in:
parent
025521431e
commit
cf536393f5
8 changed files with 46 additions and 14 deletions
|
@ -3,16 +3,18 @@
|
|||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
type DateTimeFormat = "relative" | "long" | "short" | "human";
|
||||
import { DateTimeFormat, DateTimeType } from "~~/composables/use-formatters";
|
||||
|
||||
type Props = {
|
||||
date?: Date | string;
|
||||
format?: DateTimeFormat;
|
||||
datetimeType?: DateTimeType;
|
||||
};
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
date: undefined,
|
||||
format: "relative",
|
||||
datetimeType: "date",
|
||||
});
|
||||
|
||||
const value = computed(() => {
|
||||
|
@ -20,6 +22,6 @@
|
|||
return "";
|
||||
}
|
||||
|
||||
return fmtDate(props.date, props.format);
|
||||
return fmtDate(props.date, props.format, props.datetimeType);
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -7,7 +7,11 @@
|
|||
</dt>
|
||||
<dd class="text-sm text-base-content text-start sm:col-span-2">
|
||||
<slot :name="detail.slot || detail.name" v-bind="{ detail }">
|
||||
<DateTime v-if="detail.type == 'date'" :date="detail.text" />
|
||||
<DateTime
|
||||
v-if="detail.type == 'date'"
|
||||
:date="detail.text"
|
||||
:datetime-type="detail.date ? 'date' : 'datetime'"
|
||||
/>
|
||||
<Currency v-else-if="detail.type == 'currency'" :amount="detail.text" />
|
||||
<template v-else-if="detail.type === 'link'">
|
||||
<div class="tooltip tooltip-primary tooltip-right" :data-tip="detail.href">
|
||||
|
|
|
@ -8,6 +8,7 @@ type BaseDetail = {
|
|||
type DateDetail = BaseDetail & {
|
||||
type: "date";
|
||||
text: Date | string;
|
||||
date: boolean;
|
||||
};
|
||||
|
||||
type CurrencyDetail = BaseDetail & {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue