Skip to content

Commit fcecf54

Browse files
Merge pull request #8126 from carlobeltrame/client-print-checklist-fix
Fix checklist node in client print
2 parents 2abad79 + f0fcb69 commit fcecf54

File tree

3 files changed

+36
-11
lines changed

3 files changed

+36
-11
lines changed

pdf/src/campPrint/scheduleEntry/ScheduleEntry.vue

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,21 @@ export default {
1818
name: 'ScheduleEntry',
1919
components: { ScheduleEntryTitle, ContentNode },
2020
extends: PdfComponent,
21+
provide() {
22+
return {
23+
camp: this.camp,
24+
}
25+
},
2126
props: {
2227
scheduleEntry: { type: Object, required: true },
2328
},
2429
computed: {
2530
activity() {
2631
return this.scheduleEntry.activity()
2732
},
33+
camp() {
34+
return this.activity.camp()
35+
},
2836
},
2937
}
3038
</script>

pdf/src/campPrint/scheduleEntry/contentNode/Checklist.vue

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<script setup>
2020
import uniqWith from 'lodash-es/uniqWith.js'
2121
import sortBy from 'lodash-es/sortBy.js'
22+
import { inject } from 'vue'
2223
2324
const props = defineProps({
2425
contentNode: { type: Object, required: true },
@@ -31,18 +32,27 @@ function calculateItemNumber(item) {
3132
3233
return calculateItemNumber(item.parent()) + '.' + (item.position + 1)
3334
}
34-
const items = props.contentNode.checklistItems().items.map((item) => {
35-
const number = calculateItemNumber(item)
36-
return {
37-
...item,
38-
number,
39-
}
40-
})
35+
36+
const camp = inject('camp')
37+
const allChecklists = camp.checklists().items
38+
const allItems = allChecklists.flatMap((checklist) => checklist.checklistItems().items)
39+
const items = allItems
40+
.filter((item) => {
41+
const connectedChecklistNodes = item
42+
.checklistNodes()
43+
.items.map((checklistNode) => checklistNode._meta.self)
44+
return connectedChecklistNodes.includes(props.contentNode._meta.self)
45+
})
46+
.map((item) => {
47+
const number = calculateItemNumber(item)
48+
return {
49+
...item,
50+
number,
51+
}
52+
})
4153
4254
const checklists = uniqWith(
43-
props.contentNode
44-
.checklistItems()
45-
.items.map((checklistItem) => checklistItem.checklist()),
55+
items.map((checklistItem) => checklistItem.checklist()),
4656
function (checklist1, checklist2) {
4757
return checklist1._meta.self === checklist2._meta.self
4858
}

pdf/src/prepareInMainThread.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,14 @@ export async function prepareInMainThread(config) {
9393
}),
9494
camp.materialLists().$loadItems(),
9595
config.apiGet().contentTypes().$loadItems(),
96-
camp.checklists().$loadItems(),
96+
camp
97+
.checklists()
98+
.$loadItems()
99+
.then((checklists) => {
100+
return Promise.all(
101+
checklists.items.map((checklist) => checklist.checklistItems()._meta.load)
102+
)
103+
}),
97104
config
98105
.apiGet()
99106
.checklistItems({

0 commit comments

Comments
 (0)