Merge branch 'dev' into feat/add_user_theme_view_controls

This commit is contained in:
lesion
2023-02-03 15:18:16 +01:00
117 changed files with 4890 additions and 2443 deletions

View File

@@ -27,8 +27,11 @@ export default {
name: 'Index',
components: { Event, Announcement, ThemeView },
middleware: 'setup',
async fetch () {
return this.getEvents()
fetch () {
return this.getEvents({
start: this.start,
end: this.end
})
},
activated() {
if (this.$fetchState.timestamp <= Date.now() - 60000) {
@@ -40,15 +43,13 @@ export default {
mdiMagnify, mdiCloseCircle,
isCurrentMonth: true,
now: dayjs().unix(),
date: dayjs.tz().format('YYYY-MM-DD'),
start: dayjs().startOf('month').unix(),
end: null,
searching: false,
tmpEvents: [],
selectedDay: null,
show_recurrent: $store.state.settings.recurrent_event_visible,
storeUnsubscribe: null,
reload_events: 0
}
}
},
head () {
return {
@@ -69,76 +70,77 @@ export default {
}
},
computed: {
...mapState(['settings', 'announcements', 'events']),
...mapState(['settings', 'announcements', 'events', 'filter']),
visibleEvents () {
if (this.searching) {
if (this.filter.query && this.filter.query.length > 2) {
return this.tmpEvents
}
const now = dayjs().unix()
if (this.selectedDay) {
const min = dayjs.tz(this.selectedDay).startOf('day').unix()
const max = dayjs.tz(this.selectedDay).endOf('day').unix()
return this.events.filter(e => (e.start_datetime <= max && (e.end_datetime || e.start_datetime) >= min) && (this.show_recurrent || !e.parentId))
return this.events.filter(e => (e.start_datetime <= max && (e.end_datetime || e.start_datetime) >= min) && (this.filter.show_recurrent || !e.parentId))
} else if (this.isCurrentMonth) {
return this.events.filter(e => ((e.end_datetime ? e.end_datetime > now : e.start_datetime + 3 * 60 * 60 > now) && (this.show_recurrent || !e.parentId)))
return this.events.filter(e => ((e.end_datetime ? e.end_datetime > now : e.start_datetime + 3 * 60 * 60 > now) && (this.filter.show_recurrent || !e.parentId)))
} else {
return this.events.filter(e => this.show_recurrent || !e.parentId)
return this.events.filter(e => this.filter.show_recurrent || !e.parentId)
}
}
},
created () {
this.$root.$on('dayclick', this.dayChange)
this.$root.$on('monthchange', this.monthChange)
this.$root.$on('search', debounce(this.search, 100))
this.$root.$on('layout_loaded', () => {
this.reload_events++
})
this.storeUnsubscribe = this.$store.subscribeAction( { after: (action, state) => {
if (action.type === 'setFilter') {
if (this.filter.query && this.filter.query.length > 2) {
this.search()
} else {
this.tmpEvents = []
this.$fetch()
}
}
}})
// this.$root.$on('search', debounce(this.search, 100))
// this.$root.$on('layout_loaded', () => {
// this.reload_events++
// })
},
destroyed () {
this.$root.$off('dayclick')
this.$root.$off('monthchange')
this.$root.$off('search')
if (typeof this.storeUnsubscribe === 'function') {
this.storeUnsubscribe()
}
},
methods: {
...mapActions(['getEvents']),
async search (query) {
if (query) {
this.tmpEvents = await this.$axios.$get(`/event/search?search=${query}`)
this.searching = true
} else {
this.tmpEvents = null
this.searching = false
}
},
updateEvents () {
return this.getEvents({
start: this.start,
end: this.end,
show_recurrent: true
search: debounce(async function() {
this.tmpEvents = await this.$api.getEvents({
start: 0,
show_recurrent: this.filter.show_recurrent,
show_multidate: this.filter.show_multidate,
query: this.filter.query
})
},
}, 200),
async monthChange ({ year, month }) {
this.$nuxt.$loading.start()
this.$nextTick( async () => {
let isCurrentMonth
// unselect current selected day
this.selectedDay = null
// unselect current selected day
this.selectedDay = null
// check if current month is selected
if (month - 1 === dayjs.tz().month() && year === dayjs.tz().year()) {
this.isCurrentMonth = true
this.start = dayjs().startOf('month').unix()
this.date = dayjs.tz().format('YYYY-MM-DD')
} else {
this.isCurrentMonth = false
this.date = ''
this.start = dayjs().year(year).month(month - 1).startOf('month').unix() // .startOf('week').unix()
}
this.end = dayjs().year(year).month(month).endOf('month').unix() // .endOf('week').unix()
await this.updateEvents()
this.$nuxt.$loading.finish()
})
// check if current month is selected
if (month - 1 === dayjs.tz().month() && year === dayjs.tz().year()) {
isCurrentMonth = true
this.start = dayjs().startOf('month').unix()
} else {
isCurrentMonth = false
this.start = dayjs().year(year).month(month - 1).startOf('month').unix() // .startOf('week').unix()
}
this.end = dayjs().year(year).month(month).endOf('month').unix() // .endOf('week').unix()
await this.$fetch()
this.$nuxt.$loading.finish()
this.$nextTick( () => this.isCurrentMonth = isCurrentMonth)
},
dayChange (day) {