Skip to content

Commit

Permalink
frontend/api: add camp filter on days for Dashboard.vue
Browse files Browse the repository at this point in the history
That it's possible to load all days of a camp in one request.
  • Loading branch information
BacLuc committed Nov 20, 2023
1 parent 1be70aa commit c6e9dc8
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
2 changes: 1 addition & 1 deletion api/src/Entity/Day.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
normalizationContext: ['groups' => ['read']],
order: ['period.start', 'dayOffset']
)]
#[ApiFilter(filterClass: SearchFilter::class, properties: ['period'])]
#[ApiFilter(filterClass: SearchFilter::class, properties: ['period', 'period.camp'])]
#[UniqueEntity(fields: ['period', 'dayOffset'])]
#[ORM\Entity(repositoryClass: DayRepository::class)]
#[ORM\UniqueConstraint(name: 'offset_period_idx', columns: ['periodId', 'dayOffset'])]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21462,6 +21462,32 @@ paths:
schema:
type: string
style: form
-
allowEmptyValue: true
allowReserved: false
deprecated: false
description: ''
explode: false
in: query
name: period.camp
required: false
schema:
type: string
style: form
-
allowEmptyValue: true
allowReserved: false
deprecated: false
description: ''
explode: true
in: query
name: 'period.camp[]'
required: false
schema:
items:
type: string
type: array
style: form
-
allowEmptyValue: true
allowReserved: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"templated": true
},
"days": {
"href": "\/days{\/id}{?period,period[]}",
"href": "\/days{\/id}{?period,period[],period.camp,period.camp[]}",
"templated": true
},
"invitations": {
Expand Down
7 changes: 1 addition & 6 deletions frontend/src/views/camp/Dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -404,12 +404,7 @@ export default {
const { categories, periods, collaborators, progressLabels } =
await loadAndProcessCollections(this.camp())
await Promise.all(
this.camp()
.periods()
.items.map((period) => period._meta.self)
.map((periodHref) => this.api.get().days({ period: periodHref }))
)
await this.api.get().days({ 'period.camp': this.camp()._meta.self })
const queryFilters = processRouteQuery(this.$route.query)
const { period, responsible, category, progressLabel } = {
Expand Down

0 comments on commit c6e9dc8

Please sign in to comment.