Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix schedule entry self delete #4965

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: Function,
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
Loading