Skip to content

Commit

Permalink
Fix schedule entry self delete
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelmeister committed Dec 25, 2024
1 parent 753a760 commit ff819e3
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 8 deletions.
37 changes: 33 additions & 4 deletions frontend/src/components/activity/ScheduleEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,11 @@ Displays a single scheduleEntry
<table>
<thead>
<tr>
<th scope="col" class="text-right pb-2 pr-4">
<th
v-if="category.numberingStyle !== '-'"
scope="col"
class="text-right pb-2 pr-4"
>
{{ $tc('entity.scheduleEntry.fields.nr') }}
</th>
<th scope="col" class="text-left pb-2 pr-4">
Expand All @@ -184,8 +188,20 @@ Displays a single scheduleEntry
v-for="scheduleEntryItem in scheduleEntries"
:key="scheduleEntryItem._meta.self"
>
<th class="text-right tabular-nums pb-2 pr-4">
{{ scheduleEntryItem.number }}
<th
v-if="category.numberingStyle !== '-'"
class="text-right tabular-nums pb-2 pr-4"
>
<RouterLink
v-if="scheduleEntryItem._meta.self !== scheduleEntry()._meta.self"
:to="scheduleEntryRoute(scheduleEntryItem)"
class="e-title-link"
>
{{ scheduleEntryItem.number }}
</RouterLink>
<template v-else>
{{ scheduleEntryItem.number }}
</template>
</th>
<td class="text-left tabular-nums pb-2 pr-4">
{{
Expand All @@ -196,7 +212,19 @@ Displays a single scheduleEntry
{{ dateShort(scheduleEntryItem.start) }}
</td>
<td class="text-left tabular-nums pb-2 pr-0">
{{ rangeLongEnd(scheduleEntryItem.start, scheduleEntryItem.end) }}
<RouterLink
v-if="
category.numberingStyle === '-' &&
scheduleEntryItem._meta.self !== scheduleEntry()._meta.self
"
:to="scheduleEntryRoute(scheduleEntryItem)"
class="e-title-link"
>
{{ rangeLongEnd(scheduleEntryItem.start, scheduleEntryItem.end) }}
</RouterLink>
<template v-else>
{{ rangeLongEnd(scheduleEntryItem.start, scheduleEntryItem.end) }}
</template>
</td>
</tr>
</tbody>
Expand Down Expand Up @@ -404,6 +432,7 @@ export default {
this.$toast.error(errorToMultiLineToast(e))
})
},
scheduleEntryRoute,
countContentNodes(contentType) {
return this.contentNodes.items.filter((cn) => {
return cn.contentType().id === contentType.id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
</template>
<DialogActivityForm
:activity="entityData"
:current-schedule-entry="scheduleEntry"
:period="scheduleEntry.period"
:hide-location="hideHeaderFields"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<FormScheduleEntryList
v-if="activity.scheduleEntries"
:schedule-entries="activity.scheduleEntries"
:current-schedule-entry="currentScheduleEntry"
:period="period"
:periods="camp.periods().items"
/>
Expand Down Expand Up @@ -69,6 +70,10 @@ export default {
type: Object,
required: true,
},
currentScheduleEntry: {
type: Object,
required: true,
},
autoselectTitle: {
type: Boolean,
default: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
</v-col>

<v-col cols="1" class="pt-3 text-center">
<button-delete v-if="!isLastItem" icon-only @click="$emit('delete')" />
<button-delete v-if="deletable" icon-only @click="$emit('delete')" />
</v-col>
</v-row>
</v-container>
Expand Down Expand Up @@ -82,9 +82,9 @@ export default {
},
// true if current item is the last scheduleEntry
isLastItem: {
deletable: {
type: Boolean,
required: true,
required: false,
},
},
data() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@
class="transition-list-item pa-0 mb-4"
:schedule-entry="scheduleEntry"
:periods="periods"
:is-last-item="scheduleEntriesWithoutDeleted.length === 1"
:deletable="
scheduleEntriesWithoutDeleted.length > 1 &&
($route.name !== 'activity' ||
scheduleEntry.self !== currentScheduleEntry._meta.self)
"
@delete="deleteEntry(scheduleEntry)"
/>
</transition-group>
Expand All @@ -47,6 +51,11 @@ export default {
required: true,
},
currentScheduleEntry: {
type: Object,
required: true,
},
// all available periods
periods: {
type: Array,
Expand Down

0 comments on commit ff819e3

Please sign in to comment.