|
5 | 5 | class="ec-checklist" |
6 | 6 | toolbar |
7 | 7 | back |
8 | | - :title="checklist.name" |
9 | 8 | > |
| 9 | + <template #title> |
| 10 | + <v-toolbar-title v-if="!editChecklistName" tag="h1" class="font-weight-bold"> |
| 11 | + {{ checklist.name }} |
| 12 | + </v-toolbar-title> |
| 13 | + <v-btn |
| 14 | + v-if="!editChecklistName" |
| 15 | + icon |
| 16 | + class="ml-1 visible-on-hover" |
| 17 | + width="24" |
| 18 | + height="24" |
| 19 | + @click="makeChecklistNameEditable()" |
| 20 | + > |
| 21 | + <v-icon small>mdi-pencil</v-icon> |
| 22 | + </v-btn> |
| 23 | + <api-form v-if="editChecklistName" :entity="checklist" class="mx-2 flex-grow-1"> |
| 24 | + <api-text-field |
| 25 | + path="name" |
| 26 | + :disabled="layoutMode" |
| 27 | + dense |
| 28 | + autofocus |
| 29 | + :auto-save="false" |
| 30 | + @finished="editChecklistName = false" |
| 31 | + /> |
| 32 | + </api-form> |
| 33 | + </template> |
10 | 34 | <template #title-actions> |
11 | 35 | <ChecklistItemCreate :checklist="checklist" /> |
| 36 | + <!-- hamburger menu --> |
| 37 | + <v-menu offset-y> |
| 38 | + <template #activator="{ on, attrs }"> |
| 39 | + <v-btn icon v-bind="attrs" v-on="on"> |
| 40 | + <v-icon>mdi-dots-vertical</v-icon> |
| 41 | + </v-btn> |
| 42 | + </template> |
| 43 | + <v-list> |
| 44 | + <!-- remove checklist --> |
| 45 | + <DialogEntityDelete |
| 46 | + :entity="checklist" |
| 47 | + :error-handler="deleteErrorHandler" |
| 48 | + :success-handler="deleteSuccessHandler" |
| 49 | + > |
| 50 | + <template #activator="{ on }"> |
| 51 | + <v-list-item v-on="on"> |
| 52 | + <v-list-item-icon> |
| 53 | + <v-icon>mdi-delete</v-icon> |
| 54 | + </v-list-item-icon> |
| 55 | + <v-list-item-title> |
| 56 | + {{ $tc('global.button.delete') }} |
| 57 | + </v-list-item-title> |
| 58 | + </v-list-item> |
| 59 | + </template> |
| 60 | + {{ $tc('components.checklist.checklistDetail.deleteWarning') }} |
| 61 | + </DialogEntityDelete> |
| 62 | + </v-list> |
| 63 | + </v-menu> |
12 | 64 | </template> |
13 | 65 | <v-list> |
14 | | - <SortableChecklist :parent="null" :checklist="checklist" /> |
| 66 | + <SortableChecklist |
| 67 | + v-if="checklist && !checklist._meta.deleting" |
| 68 | + :parent="null" |
| 69 | + :checklist="checklist" |
| 70 | + /> |
15 | 71 | </v-list> |
16 | 72 | </content-card> |
17 | 73 | </template> |
|
20 | 76 | import ContentCard from '@/components/layout/ContentCard.vue' |
21 | 77 | import ChecklistItemCreate from '@/components/checklist/ChecklistItemCreate.vue' |
22 | 78 | import SortableChecklist from '@/components/checklist/SortableChecklist.vue' |
| 79 | +import ApiForm from '@/components/form/api/ApiForm.vue' |
| 80 | +import DialogEntityDelete from '@/components/dialog/DialogEntityDelete.vue' |
| 81 | +import { checklistRoute } from '@/router.js' |
23 | 82 |
|
24 | 83 | export default { |
25 | 84 | name: 'ChecklistDetail', |
26 | 85 | components: { |
27 | 86 | SortableChecklist, |
28 | 87 | ChecklistItemCreate, |
29 | 88 | ContentCard, |
| 89 | + ApiForm, |
| 90 | + DialogEntityDelete, |
30 | 91 | }, |
31 | 92 | props: { |
| 93 | + camp: { |
| 94 | + type: Object, |
| 95 | + default: null, |
| 96 | + required: false, |
| 97 | + }, |
32 | 98 | checklist: { |
33 | 99 | type: Object, |
34 | 100 | default: null, |
35 | 101 | required: false, |
36 | 102 | }, |
37 | 103 | }, |
38 | 104 | data() { |
39 | | - return { dragging: false } |
| 105 | + return { dragging: false, editChecklistName: false } |
40 | 106 | }, |
41 | 107 | computed: { |
42 | 108 | items() { |
43 | 109 | return this.checklist.checklistItems().items.filter((item) => !item.parent) |
44 | 110 | }, |
45 | 111 | }, |
| 112 | + methods: { |
| 113 | + makeChecklistNameEditable() { |
| 114 | + this.editChecklistName = true |
| 115 | + }, |
| 116 | + deleteErrorHandler(e) { |
| 117 | + if (e?.response?.status === 422 /* Validation Error */) { |
| 118 | + return this.$tc('components.checklist.checklistDetail.deleteError') |
| 119 | + } |
| 120 | + return null |
| 121 | + }, |
| 122 | + deleteSuccessHandler() { |
| 123 | + // redirect to Checklist overview |
| 124 | + this.$router.replace(checklistRoute(this.camp)) |
| 125 | + }, |
| 126 | + }, |
46 | 127 | } |
47 | 128 | </script> |
0 commit comments