From 62a3180e53362c35a2728334722e509086a1c359 Mon Sep 17 00:00:00 2001 From: James Collins Date: Mon, 27 Feb 2023 23:18:58 +1000 Subject: [PATCH] move date/month to computed --- resources/js/components/SMPanel.vue | 60 ++++++++++++++++------------- 1 file changed, 34 insertions(+), 26 deletions(-) diff --git a/resources/js/components/SMPanel.vue b/resources/js/components/SMPanel.vue index f001b29..de4f6aa 100644 --- a/resources/js/components/SMPanel.vue +++ b/resources/js/components/SMPanel.vue @@ -3,10 +3,10 @@
- {{ new SMDate(date, { format: "yMd" }).format("dd") }} + {{ computedDay }}
- {{ new SMDate(date, { format: "yMd" }).format("MMM") }} + {{ computedMonth }}
{ let str = ""; - // if (props.date.length > 0) { - // if ( - // (props.endDate.length > 0 && - // props.date.substring(0, props.date.indexOf(" ")) != - // props.endDate.substring(0, props.endDate.indexOf(" "))) || - // props.showTime == false - // ) { - // str = new SMDate(props.date, { format: "yMd" }).format( - // "dd/MM/yyyy" - // ); - // if (props.endDate.length > 0) { - // str = - // str + - // " - " + - // new SMDate(props.endDate, { format: "yMd" }).format( - // "dd/MM/yyyy" - // ); - // } - // } else { - // str = new SMDate(props.endDate, { format: "yMd" }).format( - // "dd/MM/yyyy @ h:mm aa" - // ); - // } - // } + if (props.date.length > 0) { + if ( + (props.endDate.length > 0 && + props.date.substring(0, props.date.indexOf(" ")) != + props.endDate.substring(0, props.endDate.indexOf(" "))) || + props.showTime == false + ) { + str = new SMDate(props.date, { format: "yMd" }).format( + "dd/MM/yyyy" + ); + if (props.endDate.length > 0) { + str = + str + + " - " + + new SMDate(props.endDate, { format: "yMd" }).format( + "dd/MM/yyyy" + ); + } + } else { + str = new SMDate(props.endDate, { format: "yMd" }).format( + "dd/MM/yyyy @ h:mm aa" + ); + } + } return str; }); @@ -180,6 +180,14 @@ const computedContent = computed(() => { return excerpt(replaceHtmlEntites(stripHtmlTags(props.content)), 200); }); +const computedDay = computed(() => { + return new SMDate(props.date, { format: "yMd" }).format("dd"); +}); + +const computedMonth = computed(() => { + return new SMDate(props.date, { format: "yMd" }).format("MMM"); +}); + onMounted(async () => { if (props.image && props.image.length > 0 && isUUID(props.image)) { api.get({ url: "/media/{medium}", params: { medium: props.image } })