feat: add jump to now/day on mobile agenda (#6654)

This commit is contained in:
Nicolas Giard 2023-11-22 09:56:54 -05:00 committed by GitHub
parent 3d44825333
commit b09f6efed3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 68 additions and 18 deletions

View file

@ -1,12 +1,19 @@
<template lang="pug"> <template lang="pug">
.agenda-mobile-bar(v-if='siteStore.viewport < 990') .agenda-mobile-bar(v-if='siteStore.viewport < 990')
n-dropdown(
:options='jumpToDayOptions'
size='huge'
:show-arrow='true'
trigger='click'
@select='jumpToDay'
)
button
i.bi.bi-arrow-down-circle
button(@click='agendaStore.$patch({ filterShown: true })') button(@click='agendaStore.$patch({ filterShown: true })')
i.bi.bi-filter-square-fill.me-2 i.bi.bi-funnel
span Filters
n-badge.ms-2(:value='agendaStore.selectedCatSubs.length', processing) n-badge.ms-2(:value='agendaStore.selectedCatSubs.length', processing)
button(@click='agendaStore.$patch({ calendarShown: true })') button(@click='agendaStore.$patch({ calendarShown: true })')
i.bi.bi-calendar3.me-2 i.bi.bi-calendar3
span Cal
n-dropdown( n-dropdown(
:options='downloadIcsOptions' :options='downloadIcsOptions'
size='huge' size='huge'
@ -15,14 +22,13 @@
@select='downloadIcs' @select='downloadIcs'
) )
button button
i.bi.bi-calendar-check.me-2 i.bi.bi-download
span .ics
button(@click='agendaStore.$patch({ settingsShown: !agendaStore.settingsShown })') button(@click='agendaStore.$patch({ settingsShown: !agendaStore.settingsShown })')
i.bi.bi-gear i.bi.bi-gear
</template> </template>
<script setup> <script setup>
import { h } from 'vue' import { computed, h } from 'vue'
import { import {
NBadge, NBadge,
@ -43,13 +49,34 @@ const message = useMessage()
const agendaStore = useAgendaStore() const agendaStore = useAgendaStore()
const siteStore = useSiteStore() const siteStore = useSiteStore()
// Meeting Days
const jumpToDayOptions = computed(() => {
const days = []
if (agendaStore.isMeetingLive) {
days.push({
label: 'Jump to Now',
key: 'now',
icon: () => h('i', { class: 'bi bi-arrow-down-right-square text-red' })
})
}
for (const day of agendaStore.meetingDays) {
days.push({
label: `Jump to ${day.label}`,
key: day.slug,
icon: () => h('i', { class: 'bi bi-arrow-down-right-square' })
})
}
return days
})
// Download Ics Options // Download Ics Options
const downloadIcsOptions = [ const downloadIcsOptions = [
{ {
label: 'Subscribe... (webcal)', label: 'Subscribe... (webcal)',
key: 'subscribe', key: 'subscribe',
icon: () => h('i', { class: 'bi bi-calendar-week text-blue' }) icon: () => h('i', { class: 'bi bi-calendar-week' })
}, },
{ {
label: 'Download... (.ics)', label: 'Download... (.ics)',
@ -60,6 +87,20 @@ const downloadIcsOptions = [
// METHODS // METHODS
function jumpToDay (dayId) {
if (dayId === 'now') {
const lastEventId = agendaStore.findCurrentEventId()
if (lastEventId) {
document.getElementById(`agenda-rowid-${lastEventId}`)?.scrollIntoView(true)
} else {
message.warning('There is no event happening right now.')
}
} else {
document.getElementById(`agenda-day-${dayId}`)?.scrollIntoView(true)
}
}
function downloadIcs (key) { function downloadIcs (key) {
message.loading('Generating calendar file... Download will begin shortly.') message.loading('Generating calendar file... Download will begin shortly.')
let icsUrl = '' let icsUrl = ''
@ -102,6 +143,8 @@ function downloadIcs (key) {
color: #FFF; color: #FFF;
padding: 0 15px; padding: 0 15px;
transition: all .4s ease; transition: all .4s ease;
text-align: center;
flex: 1 1;
& + button { & + button {
margin-left: 1px; margin-left: 1px;

View file

@ -362,7 +362,7 @@ const meetingEvents = computed(() => {
if (item.links.calendar) { if (item.links.calendar) {
links.push({ links.push({
id: `lnk-${item.id}-calendar`, id: `lnk-${item.id}-calendar`,
label: isMobile.value ? `Calendar (.ics) entry for this session` : `Calendar (.ics) entry for ${item.acronym} session on ${item.adjustedStart.toFormat('fff')}`, label: 'Calendar (.ics) entry for this session',
icon: 'calendar-check', icon: 'calendar-check',
href: item.links.calendar, href: item.links.calendar,
color: 'pink' color: 'pink'

View file

@ -1427,27 +1427,34 @@ test.describe('past - small screens', () => {
// has a bottom mobile bar // has a bottom mobile bar
await expect(page.locator('.agenda-mobile-bar')).toBeVisible() await expect(page.locator('.agenda-mobile-bar')).toBeVisible()
await expect(barBtnLocator).toHaveCount(4) await expect(barBtnLocator).toHaveCount(5)
await expect(barBtnLocator.first()).toContainText('Filters')
await expect(barBtnLocator.nth(1)).toContainText('Cal') // can open the jump to day dropdown
await expect(barBtnLocator.nth(2)).toContainText('.ics') await barBtnLocator.first().click()
await expect(barBtnLocator.last().locator('> *')).toHaveCount(1) const jumpDayDdnLocator = page.locator('.n-dropdown-menu > .n-dropdown-option')
await expect(barBtnLocator.last().locator('> *')).toHaveClass(/bi/) await expect(jumpDayDdnLocator).toHaveCount(7)
for (let idx = 0; idx < 7; idx++) {
const localDateTime = DateTime.fromISO(meetingData.meeting.startDate, { zone: meetingData.meeting.timezone })
.setLocale(BROWSER_LOCALE)
.plus({ days: idx })
.toFormat('ccc LLL d')
await expect(jumpDayDdnLocator.nth(idx)).toContainText(`Jump to ${localDateTime}`)
}
// can open the filters overlay // can open the filters overlay
await barBtnLocator.first().click() await barBtnLocator.nth(1).click()
await expect(page.locator('.agenda-personalize')).toBeVisible() await expect(page.locator('.agenda-personalize')).toBeVisible()
await page.locator('.agenda-personalize .agenda-personalize-actions > button').nth(1).click() await page.locator('.agenda-personalize .agenda-personalize-actions > button').nth(1).click()
await expect(page.locator('.agenda-personalize')).toBeHidden() await expect(page.locator('.agenda-personalize')).toBeHidden()
// can open the calendar view // can open the calendar view
await barBtnLocator.nth(1).click() await barBtnLocator.nth(2).click()
await expect(page.locator('.agenda-calendar')).toBeVisible() await expect(page.locator('.agenda-calendar')).toBeVisible()
await page.locator('.agenda-calendar .agenda-calendar-actions > button').nth(1).click() await page.locator('.agenda-calendar .agenda-calendar-actions > button').nth(1).click()
await expect(page.locator('.agenda-calendar')).toBeHidden() await expect(page.locator('.agenda-calendar')).toBeHidden()
// can open the ics dropdown // can open the ics dropdown
await barBtnLocator.nth(2).click() await barBtnLocator.nth(3).click()
const calDdnLocator = page.locator('.n-dropdown-menu > .n-dropdown-option') const calDdnLocator = page.locator('.n-dropdown-menu > .n-dropdown-option')
await expect(calDdnLocator).toHaveCount(2) await expect(calDdnLocator).toHaveCount(2)
await expect(calDdnLocator.first()).toContainText('Subscribe') await expect(calDdnLocator.first()).toContainText('Subscribe')