From 65b548ccdbf906a8a3f646feb7d62556c9af2f03 Mon Sep 17 00:00:00 2001 From: "Duong (Danny) Luu" <51145179+lcduong@users.noreply.github.com> Date: Fri, 11 Oct 2024 19:21:34 +0700 Subject: [PATCH] Implement timezone feature on schedule/session page similar with Talk systems (#243) * use the same ico with eventyay-talk * update base path for webapp using basePath from config file * implement timezone on schedule/session page * add key for v-for --------- Co-authored-by: odkhang --- webapp/src/views/schedule/index.vue | 31 +++++- webapp/src/views/schedule/sessions/index.vue | 103 ++++++++++++------- 2 files changed, 90 insertions(+), 44 deletions(-) diff --git a/webapp/src/views/schedule/index.vue b/webapp/src/views/schedule/index.vue index 77df69a7..035980b5 100644 --- a/webapp/src/views/schedule/index.vue +++ b/webapp/src/views/schedule/index.vue @@ -2,7 +2,7 @@ .c-schedule template(v-if="schedule") div.filter-actions - app-dropdown(v-for="item in filter", className="schedule") + app-dropdown(v-for="item in filter", :key="item.refKey", className="schedule") template(slot="toggler") span {{item.title}} app-dropdown-content(className="schedule") @@ -15,6 +15,12 @@ :class="onlyFavs ? ['active'] : []") {{favs.length}} bunt-button.bunt-ripple-ink(@click="resetAllFiltered", icon="filter-off") + + template(v-if="!inEventTimezone") + bunt-select.timezone-item(name="timezone", :options="[{id: schedule.timezone, label: schedule.timezone}, {id: userTimezone, label: userTimezone}]", v-model="currentTimezone", @blur="saveTimezone") + template(v-else) + div.timezone-label.timezone-item.bunt-tab-header-item {{ schedule.timezone }} + .export.dropdown bunt-progress-circular.export-spinner(v-if="isExporting", size="small") custom-dropdown(name="calendar-add1" @@ -24,7 +30,7 @@ @input="makeExport") bunt-tabs.days(v-if="days && days.length > 1", :active-tab="currentDay.toISOString()", ref="tabs", v-scrollbar.x="") - bunt-tab(v-for="day in days", :id="day.toISOString()", :header="moment(day).format('dddd DD. MMMM')", @selected="changeDay(day)") + bunt-tab(v-for="day in days", :key="day.toISOString()", :id="day.toISOString()", :header="moment(day).format('dddd DD. MMMM')", @selected="changeDay(day)") .scroll-parent(ref="scrollParent", v-scrollbar.x.y="") grid-schedule(v-if="$mq.above['m']", :sessions="sessions", @@ -135,7 +141,9 @@ export default { isExporting: false, error: null, defaultFilter: defaultFilter, - onlyFavs: false + onlyFavs: false, + userTimezone: null, + currentTimezone: null, } }, computed: { @@ -195,7 +203,12 @@ export default { filter.tracks.data = this.filterItemsByLanguage(this?.schedule?.tracks) return filter - } + }, + inEventTimezone() { + if (!this.schedule?.talks?.length) return false + const example = this.schedule.talks[0].start + return moment.tz(example, this.userTimezone).format('Z') === moment.tz(example, this.schedule.timezone).format('Z') + }, }, watch: { tracksFilter: { @@ -207,6 +220,10 @@ export default { deep: true } }, + async created() { + this.userTimezone = moment.tz.guess() + this.currentTimezone = localStorage.getItem('userTimezone') + }, methods: { changeDay(day) { if (day.isSame(this.currentDay)) return @@ -284,6 +301,9 @@ export default { resetOnlyFavs() { this.onlyFavs = false }, + saveTimezone() { + localStorage.setItem('userTimezone', this.currentTimezone) + }, } } @@ -372,4 +392,7 @@ export default { .export-spinner padding-top: 22px !important margin-right: 10px + .bunt-select + .bunt-input + height: auto !important diff --git a/webapp/src/views/schedule/sessions/index.vue b/webapp/src/views/schedule/sessions/index.vue index 71130fc6..af234aad 100644 --- a/webapp/src/views/schedule/sessions/index.vue +++ b/webapp/src/views/schedule/sessions/index.vue @@ -1,45 +1,51 @@ @@ -357,4 +377,7 @@ export default { .export-spinner padding-top: 22px !important margin-right: 10px + .bunt-select + .bunt-input + height: auto !important