Skip to content

Commit

Permalink
Merge pull request #5025 from manuelmeister/bugfix/router-error-handling
Browse files Browse the repository at this point in the history
Remove unnecessary function calls and this.api bindings in router.js
  • Loading branch information
usu committed Apr 28, 2024
2 parents 203bb5e + d96d7ce commit 82bb060
Show file tree
Hide file tree
Showing 49 changed files with 363 additions and 352 deletions.
4 changes: 2 additions & 2 deletions frontend/src/components/activity/DaySwitcher.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export default {
name: 'DaySwitcher',
components: { AvatarRow },
props: {
camp: { type: Function, required: true },
camp: { type: Object, required: true },
daySelection: { type: Object, required: true },
loading: { type: Boolean },
},
Expand All @@ -104,7 +104,7 @@ export default {
)
},
periods() {
return sortBy(this.camp().periods().items, 'start')
return sortBy(this.camp.periods().items, 'start')
},
},
methods: {
Expand Down
32 changes: 16 additions & 16 deletions frontend/src/components/activity/ScheduleEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ Displays a single scheduleEntry
class="ec-schedule-entry"
toolbar
back
:loaded="!scheduleEntry()._meta.loading && !activity.camp()._meta.loading"
:loaded="!scheduleEntry._meta.loading && !activity.camp()._meta.loading"
:max-width="isPaperDisplaySize ? '944px' : ''"
>
<template #title>
<v-toolbar-title class="font-weight-bold">
<span class="tabular-nums">
{{ scheduleEntry().number }}
{{ scheduleEntry.number }}
</span>
<v-menu
offset-y
Expand All @@ -24,7 +24,7 @@ Displays a single scheduleEntry
>
<template #activator="{ on, attrs }">
<CategoryChip
:schedule-entry="scheduleEntry()"
:schedule-entry="scheduleEntry"
large
dense
v-bind="attrs"
Expand All @@ -37,11 +37,11 @@ Displays a single scheduleEntry
:class="{ 'mdi-spin': categoryChangeState === 'saving' }"
>
<template v-if="categoryChangeState === 'saving'"
>mdi-autorenew</template
>
>mdi-autorenew
</template>
<template v-else-if="categoryChangeState === 'error'"
>mdi-alert</template
>
>mdi-alert
</template>
<template v-else>mdi-chevron-down</template>
</v-icon>
</template>
Expand Down Expand Up @@ -286,13 +286,13 @@ export default {
return {
preferredContentTypes: () => this.preferredContentTypes,
allContentNodes: () => this.contentNodes,
camp: () => this.camp,
camp: this.camp,
isPaperDisplaySize: () => this.isPaperDisplaySize,
}
},
props: {
scheduleEntry: {
type: Function,
type: Object,
required: true,
},
},
Expand All @@ -306,7 +306,7 @@ export default {
},
computed: {
activity() {
return this.scheduleEntry().activity()
return this.scheduleEntry.activity()
},
camp() {
return this.activity.camp()
Expand All @@ -319,7 +319,7 @@ export default {
},
activityName() {
return (
(this.scheduleEntry().number ? this.scheduleEntry().number + ' ' : '') +
(this.scheduleEntry.number ? this.scheduleEntry.number + ' ' : '') +
(this.category.short ? this.category.short + ': ' : '') +
this.activity.title
)
Expand Down Expand Up @@ -347,7 +347,7 @@ export default {
type: 'Activity',
options: {
activity: this.activity._meta.self,
scheduleEntry: this.scheduleEntry()._meta.self,
scheduleEntry: this.scheduleEntry._meta.self,
},
},
],
Expand All @@ -369,11 +369,11 @@ export default {
// reload data every time user navigates to Activity view
async mounted() {
this.loading = true
await this.scheduleEntry().activity()._meta.load // wait if activity is being loaded as part of a collection
await this.scheduleEntry.activity()._meta.load // wait if activity is being loaded as part of a collection
this.loading = false
// to avoid stale data, trigger reload (which includes embedded contentNode data). However, don't await in order to render early with cached data.
this.scheduleEntry().activity().$reload()
this.scheduleEntry.activity().$reload()
},
methods: {
Expand Down Expand Up @@ -410,7 +410,7 @@ export default {
console.warn('clipboard permission not requestable')
}
const scheduleEntry = scheduleEntryRoute(this.scheduleEntry())
const scheduleEntry = scheduleEntryRoute(this.scheduleEntry)
const url = window.location.origin + router.resolve(scheduleEntry).href
await navigator.clipboard.writeText(url)
Expand All @@ -423,7 +423,7 @@ export default {
},
onDelete() {
// redirect to Picasso
this.$router.push(periodRoute(this.scheduleEntry().period()))
this.$router.push(periodRoute(this.scheduleEntry.period()))
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/activity/content/Material.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<ContentNodeCard v-bind="$props">
<material-table
:camp="camp()"
:camp="camp"
:material-node="contentNode"
:layout-mode="layoutMode"
:material-item-collection="materialItemCollection"
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/components/campAdmin/CampActivityProgressLabels.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<slot name="title">
<div class="ec-content-group__title py-1 subtitle-1">
{{ $tc('components.campAdmin.campActivityProgressLabels.title') }}
<DialogActivityProgressLabelCreate v-if="!disabled" :camp="camp()">
<DialogActivityProgressLabelCreate v-if="!disabled" :camp="camp">
<template #activator="{ on }">
<ButtonAdd
color="secondary"
Expand All @@ -19,7 +19,7 @@
</div>
</slot>
<v-skeleton-loader
v-if="camp().progressLabels()._meta.loading"
v-if="camp.progressLabels()._meta.loading"
type="list-item@3"
class="mx-n4"
/>
Expand Down Expand Up @@ -69,7 +69,7 @@
<template v-else>
<api-sortable
v-slot="{ itemPosition, item, on }"
:endpoint="camp().progressLabels()"
:endpoint="camp.progressLabels()"
>
<v-list-item class="px-2 rounded drag-and-drop-handle" v-on="on">
<v-avatar color="rgba(0,0,0,0.12)" class="mr-2" size="32">{{
Expand Down Expand Up @@ -120,15 +120,15 @@ export default {
DialogActivityProgressLabelEdit,
},
props: {
camp: { type: Function, required: true },
camp: { type: Object, required: true },
disabled: { type: Boolean, default: false },
},
data: () => ({
reorder: false,
}),
computed: {
progressLabels() {
return sortBy(this.camp().progressLabels().allItems, (label) => label.position)
return sortBy(this.camp.progressLabels().allItems, (label) => label.position)
},
},
}
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/components/campAdmin/CampAddress.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ Displays address and allows to edit

<template>
<content-group :title="$tc('components.campAdmin.campAddress.title')">
<v-skeleton-loader v-if="camp()._meta.loading" type="article" />
<v-skeleton-loader v-if="camp._meta.loading" type="article" />
<div v-else class="mt-3">
<api-form :entity="camp()" name="camp">
<api-form :entity="camp" name="camp">
<api-text-field path="addressName" :disabled="disabled" />

<api-text-field path="addressStreet" :disabled="disabled" />
Expand All @@ -29,7 +29,7 @@ export default {
components: { ContentGroup, ApiTextField, ApiForm },
props: {
camp: {
type: Function,
type: Object,
required: true,
},
disabled: {
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/components/campAdmin/CampCategories.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<slot name="title">
<div class="ec-content-group__title py-1 subtitle-1">
{{ $tc('components.campAdmin.campCategories.title') }}
<DialogCategoryCreate v-if="!disabled" :camp="camp()">
<DialogCategoryCreate v-if="!disabled" :camp="camp">
<template #activator="{ on }">
<ButtonAdd
color="secondary"
Expand All @@ -19,7 +19,7 @@
</div>
</slot>
<v-skeleton-loader
v-if="camp().categories()._meta.loading"
v-if="camp.categories()._meta.loading"
type="list-item@3"
class="mx-n4"
/>
Expand All @@ -28,7 +28,7 @@
v-for="category in categories.items"
:key="category._meta.self"
class="px-2 rounded"
:to="categoryRoute(camp(), category)"
:to="categoryRoute(camp, category)"
>
<v-list-item-content>
<v-list-item-title>
Expand Down Expand Up @@ -68,15 +68,15 @@ export default {
},
mixins: [dateHelperUTCFormatted],
props: {
camp: { type: Function, required: true },
camp: { type: Object, required: true },
disabled: { type: Boolean, default: false },
},
data() {
return {}
},
computed: {
categories() {
return this.camp().categories()
return this.camp.categories()
},
},
methods: {
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/components/campAdmin/CampConditionalFields.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ Displays fields which don't apply to all camps, but are required for some
<content-group
:title="$tc('components.campAdmin.campConditionalFields.ysCamp.title')"
>
<v-skeleton-loader v-if="camp()._meta.loading" type="article" />
<v-skeleton-loader v-if="camp._meta.loading" type="article" />
<div v-else class="mt-3">
<api-form :entity="camp()" name="camp">
<api-form :entity="camp" name="camp">
<api-text-field path="organizer" :disabled="disabled" />

<api-text-field path="kind" :disabled="disabled" />
Expand All @@ -31,9 +31,9 @@ Displays fields which don't apply to all camps, but are required for some
<content-group
:title="$tc('components.campAdmin.campConditionalFields.course.title')"
>
<v-skeleton-loader v-if="camp()._meta.loading" type="article" />
<v-skeleton-loader v-if="camp._meta.loading" type="article" />
<div v-else class="mt-3">
<api-form :entity="camp()" name="camp">
<api-form :entity="camp" name="camp">
<api-text-field path="courseNumber" :disabled="disabled" />

<api-text-field path="courseKind" :disabled="disabled" />
Expand Down Expand Up @@ -61,7 +61,7 @@ export default {
components: { ContentGroup, ApiTextField, ApiCheckbox, ApiForm },
props: {
camp: {
type: Function,
type: Object,
required: true,
},
disabled: {
Expand Down
12 changes: 6 additions & 6 deletions frontend/src/components/campAdmin/CampDangerZone.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Critical operations on camp
</h2>
</v-expansion-panel-header>
<v-expansion-panel-content>
<v-skeleton-loader v-if="camp()._meta.loading" type="article" />
<v-skeleton-loader v-if="camp._meta.loading" type="article" />
<div v-else>
<v-list class="py-0" color="transparent">
<v-list-item class="px-0">
Expand All @@ -24,8 +24,8 @@ Critical operations on camp
</v-list-item-content>
<v-list-item-action>
<dialog-entity-delete
:entity="camp()"
:submit-enabled="promptText === camp().name"
:entity="camp"
:submit-enabled="promptText === camp.name"
icon="mdi-bomb"
@submit="$router.push({ name: 'camps' })"
>
Expand All @@ -44,14 +44,14 @@ Critical operations on camp
<p class="body-1">
{{
$tc('components.campAdmin.campDangerZone.deleteCamp.explanation', 0, {
campName: camp().name,
campName: camp.name,
})
}}
</p>
<label>
{{
$tc('components.campAdmin.campDangerZone.deleteCamp.label', 0, {
campName: camp().name,
campName: camp.name,
})
}}
<e-text-field v-model="promptText" />
Expand Down Expand Up @@ -79,7 +79,7 @@ export default {
},
props: {
camp: {
type: Function,
type: Object,
required: true,
},
},
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/components/campAdmin/CampMaterialLists.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<slot name="title">
<div class="ec-content-group__title py-1 subtitle-1">
{{ $tc('components.campAdmin.campMaterialLists.title') }}
<dialog-material-list-create v-if="!disabled" :camp="camp()">
<dialog-material-list-create v-if="!disabled" :camp="camp">
<template #activator="{ on }">
<button-add
color="secondary"
Expand All @@ -18,7 +18,7 @@
</dialog-material-list-create>
</div>
</slot>
<v-skeleton-loader v-if="camp().materialLists()._meta.loading" type="article" />
<v-skeleton-loader v-if="camp.materialLists()._meta.loading" type="article" />
<v-list>
<camp-material-lists-item
v-for="materialList in materialLists.allItems"
Expand Down Expand Up @@ -46,15 +46,15 @@ export default {
DialogMaterialListCreate,
},
props: {
camp: { type: Function, required: true },
camp: { type: Object, required: true },
disabled: { type: Boolean, default: false },
},
data() {
return {}
},
computed: {
materialLists() {
return this.camp().materialLists()
return this.camp.materialLists()
},
},
}
Expand Down

0 comments on commit 82bb060

Please sign in to comment.