Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UBERF-4302: added footer to Calendar #4033

Merged
merged 1 commit into from
Nov 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions plugins/calendar-resources/src/components/DayCalendar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
export let startFromWeekStart = true
export let weekFormat: 'narrow' | 'short' | 'long' | undefined = displayedDaysCount > 4 ? 'short' : 'long'
export let showHeader: boolean = true
export let showFooter: boolean = true
export let clearCells: boolean = false

const client = getClient()
Expand All @@ -67,11 +68,14 @@
const todayDate = new Date()
const ampm = new Intl.DateTimeFormat([], { hour: 'numeric' }).resolvedOptions().hour12
const getTimeFormat = (hour: number, min: number = 0): string => {
if (min === 0) return ampm ? `${hour > 12 ? hour - 12 : hour}${hour < 12 ? 'am' : 'pm'}` : `${addZero(hour)}:00`
else {
if (min === 0) {
return ampm
? `${hour > 12 ? hour - 12 : hour}${hour < 12 ? 'am' : 'pm'}`
: `${addZero(hour === 24 ? 0 : hour)}:00`
} else {
return ampm
? `${hour > 12 ? hour - 12 : hour}:${addZero(min)}${hour < 12 ? 'am' : 'pm'}`
: `${addZero(hour)}:${addZero(min)}`
: `${addZero(hour === 24 ? 0 : hour)}:${addZero(min)}`
}
}
const rem = (n: number): number => n * fontSize
Expand Down Expand Up @@ -361,6 +365,7 @@
(startTime.mins / 60) * cellHeight +
getGridOffset(startTime.mins)
result.bottom =
(showFooter ? rem(2) + 1 : 0) +
cellHeight * (displayedHours - startHour - endTime.hours - 1) +
((60 - endTime.mins) / 60) * cellHeight +
getGridOffset(endTime.mins, true)
Expand Down Expand Up @@ -847,8 +852,25 @@
}}
/>
{/each}
{#if hourOfDay === displayedHours - startHour - 1}<div class="clear-cell" />{/if}
{#if hourOfDay === displayedHours - startHour - 1}
{#if showFooter}
<div
class="time-cell"
style:grid-column={'time-col 1 / col-start 1'}
style:grid-row={`row-start ${hourOfDay * 2 + 2} / row-start ${hourOfDay * 2 + 4}`}
>
{getTimeFormat(displayedHours - startHour)}
</div>
{:else}
<div class="clear-cell" />
{/if}
{/if}
{/each}
{#if showFooter}
{#each [...Array(displayedDaysCount).keys()] as _}
<div class="footer-cell" />
{/each}
{/if}

{#key [styleAD, calendarWidth, displayedDaysCount, showHeader]}
{#each newEvents.filter((ev) => !ev.allDay) as event, i}
Expand Down Expand Up @@ -970,6 +992,10 @@
top: -0.125rem;
}
}
.footer-cell {
height: 2rem;
background-color: var(--theme-bg-color);
}
}
.empty-cell {
border-left: 1px solid var(--theme-divider-color);
Expand Down