Skip to content

Commit

Permalink
Merge pull request #966 from traPtitech/feat/add-progress-circular-to…
Browse files Browse the repository at this point in the history
…-calendar

feat:loading-barを追加
  • Loading branch information
mathsuky authored Aug 12, 2024
2 parents 5e749aa + 32726f4 commit 93b66e1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
10 changes: 9 additions & 1 deletion src/components/shared/Calendar.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div>
<v-sheet height="64">
<v-sheet :height="status === 'loading' ? 60 : 64">
<v-toolbar flat>
<v-btn
outlined
Expand Down Expand Up @@ -44,6 +44,11 @@
</v-menu>
</v-toolbar>
</v-sheet>
<v-progress-linear
v-if="status == 'loading'"
indeterminate
color="primary"
></v-progress-linear>
<v-sheet :height="height - 64">
<v-calendar
:ref="calendarRefName"
Expand Down Expand Up @@ -130,6 +135,9 @@ export default class Calendar extends Vue {
@Prop({ type: Array, default: [] })
events!: ResponseEvent[]
@Prop({ type: String, default: 'loading' })
status!: 'loading' | 'loaded' | 'error'
focus = ''
type = 'month'
Expand Down
16 changes: 12 additions & 4 deletions src/pages/Calendar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<calendar
:height="784"
:events="events"
:status="status"
@monthChanged="fetchMonthlyEvents"
/>
</v-col>
Expand All @@ -20,19 +21,26 @@ import api, { ResponseEvent } from '@/api'
},
})
export default class CalendarPage extends Vue {
status: 'loading' | 'loaded' | 'error' = 'loading'
events: ResponseEvent[] = []
async created() {
await this.fetchMonthlyEvents(new Date())
}
async fetchMonthlyEvents(newDate) {
this.status = 'loading'
const startDate = new Date(newDate.getFullYear(), newDate.getMonth(), 1)
const endDate = new Date(newDate.getFullYear(), newDate.getMonth() + 1, 0)
this.events = await api.events.getEvents({
dateBegin: startDate.toISOString(),
dateEnd: endDate.toISOString(),
})
try {
this.events = await api.events.getEvents({
dateBegin: startDate.toISOString(),
dateEnd: endDate.toISOString(),
})
this.status = 'loaded'
} catch (e) {
this.status = 'error'
}
}
}
</script>

0 comments on commit 93b66e1

Please sign in to comment.