Skip to content
Snippets Groups Projects
Commit b5c3148e authored by Konrad Mohrfeldt's avatar Konrad Mohrfeldt :koala:
Browse files

feat: implement request aggregation for schedule, show and timeslot stores

refs #301
parent 4d7d3dd4
No related branches found
No related tags found
No related merge requests found
......@@ -12,16 +12,21 @@ import { createSteeringURL } from '@/api'
import { steeringAuthInit } from '@/stores/auth'
import { Schedule, ScheduleConflictSolution, ScheduleCreateData } from '@/types'
import { computed } from 'vue'
import { aggregateWithIdsParameter } from '@/util/api'
export const useScheduleStore = defineStore('schedules', () => {
const endpoint = createSteeringURL.prefix('schedules')
const { api, base } = createExtendableAPI<Schedule>(endpoint, steeringAuthInit)
const listOperations = APIListPaginated(api)
const { update } = APIUpdate<Schedule, ScheduleCreateData>(api)
return {
...base,
update,
...listOperations,
...APIRetrieve(api, {
aggregate: aggregateWithIdsParameter(listOperations.listIsolated),
}),
...APICreate<Schedule, ScheduleCreateData>(api),
...APIListPaginated(api),
...APIRetrieve(api),
...APIRemove(api),
}
......
......@@ -17,6 +17,7 @@ import { createSteeringURL } from '@/api'
import { components } from '@/steering-types'
import { steeringAuthInit, useAuthStore, useOnAuthBehaviour } from '@/stores/auth'
import { KeysFrom, Show } from '@/types'
import { aggregateWithIdsParameter } from '@/util/api'
type ReadonlyAttrs = KeysFrom<Show, 'id' | 'createdAt' | 'createdBy' | 'updatedAt' | 'updatedBy'>
type ShowCreateData = Omit<Show, ReadonlyAttrs | 'slug'> & { slug?: string }
......@@ -115,6 +116,7 @@ export const useShowStore = defineStore('shows', () => {
const endpoint = createSteeringURL.prefix('shows')
const { api, base } = createExtendableAPI<Show>(endpoint, steeringAuthInit)
const { selectedShow, selectedShowId } = useSelectedShowBehaviour(api)
const listOperations = APIListPaginated(api)
useRouteSyncBehaviour(selectedShowId, selectedShow)
// Make sure the store contains a list of all shows, which are
......@@ -123,8 +125,10 @@ export const useShowStore = defineStore('shows', () => {
return {
...base,
...APIListPaginated(api),
...APIRetrieve(api),
...listOperations,
...APIRetrieve(api, {
aggregate: aggregateWithIdsParameter(listOperations.listIsolated),
}),
...APICreate<Show, ShowCreateData>(api),
...APIUpdate<Show, ShowUpdateData, ShowPartialUpdateData>(api),
...APIRemove(api),
......
......@@ -11,6 +11,7 @@ import { createSteeringURL } from '@/api'
import { components } from '@/steering-types'
import { steeringAuthInit } from '@/stores/auth'
import { KeysFrom, TimeSlot } from '@/types'
import { aggregateWithIdsParameter } from '@/util/api'
type ReadonlyAttrs = KeysFrom<TimeSlot, 'id'>
type TimeSlotUpdateData = Omit<TimeSlot, ReadonlyAttrs>
......@@ -19,10 +20,13 @@ type TimeSlotPartialUpdateData = components['schemas']['PatchedTimeSlot']
export const useTimeSlotStore = defineStore('timeslots', () => {
const endpoint = createSteeringURL.prefix('timeslots')
const { api, base } = createExtendableAPI<TimeSlot>(endpoint, steeringAuthInit)
const listOperations = APIListPaginated(api)
return {
...base,
...APIListPaginated(api),
...APIRetrieve(api),
...listOperations,
...APIRetrieve(api, {
aggregate: aggregateWithIdsParameter(listOperations.listIsolated),
}),
...APIUpdate<TimeSlot, TimeSlotUpdateData, TimeSlotPartialUpdateData>(api),
...APIRemove(api),
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment