-
Notifications
You must be signed in to change notification settings - Fork 49
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
Checklist-Overview with Activities #6026
base: devel
Are you sure you want to change the base?
Changes from 6 commits
336f61f
43c203f
a2ee35f
7ad4b27
29d8c86
ef01370
2698965
c9f5b9e
81d4075
8c7838f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
<template> | ||
<table style="width: 100%; border-spacing: 0" :style="getRowStyle()"> | ||
<tr> | ||
<td colspan="2" style="text-wrap: wrap; line-height: 36px; padding-left: 6px"> | ||
{{ getPositionNumber(checklistItem) }}) | ||
{{ checklistItem.text }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hier könnte man es ähnlich machen wie beim print, dass die der text bis zum textanfang wrapped |
||
</td> | ||
<td style="max-width: 400px; text-align: right"> | ||
<div | ||
v-for="activity in getActivities(checklistItem)" | ||
:key="activity._meta.self" | ||
style="display: inline; text-wrap: nowrap; padding-right: 4px" | ||
> | ||
<ScheduleEntryLinks :activity-promise="activity._meta.load" /> | ||
</div> | ||
</td> | ||
<td style="width: 30px"> | ||
<v-btn | ||
v-if="getActivities(checklistItem).length > 0" | ||
icon | ||
@click="copyToClipboard(checklistItem)" | ||
pmattmann marked this conversation as resolved.
Show resolved
Hide resolved
|
||
> | ||
<v-icon>mdi-content-copy</v-icon> | ||
</v-btn> | ||
</td> | ||
</tr> | ||
<tr | ||
v-for="subItem in sortBy(checklistItem.children().items, (c) => c.position)" | ||
:key="subItem._meta.self" | ||
> | ||
<td style="width: 20px"></td> | ||
<td colspan="3"> | ||
<ChecklistItemTree :checklist-item="subItem" /> | ||
</td> | ||
</tr> | ||
</table> | ||
</template> | ||
|
||
<script> | ||
import { sortBy } from 'lodash' | ||
import ScheduleEntryLinks from '../material/ScheduleEntryLinks.vue' | ||
|
||
export default { | ||
name: 'ChecklistItemTree', | ||
components: { | ||
ScheduleEntryLinks, | ||
}, | ||
props: { | ||
checklistItem: { type: Object, required: true }, | ||
}, | ||
|
||
methods: { | ||
getActivities(checklistItem) { | ||
const camp = checklistItem.checklist().camp() | ||
const activities = camp.activities().items | ||
const checklistNodes = checklistItem.checklistNodes().items | ||
|
||
return activities.filter((a) => | ||
checklistNodes.some((cn) => cn.root().id == a.rootContentNode().id) | ||
) | ||
pmattmann marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
getRowStyle() { | ||
const globalPos = this.getTotalNumberOfItemsAbove(this.checklistItem) | ||
return globalPos % 2 == 0 | ||
? { backgroundColor: '#EEE' } | ||
: { backgroundColor: '#DDD' } | ||
}, | ||
|
||
getTotalNumberOfItemsAbove(checklistItem) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i have the feeling, parts of this can be implemented with computed methods (which update when the dependencies update) |
||
let globalPos = 0 | ||
|
||
if (checklistItem.parent == null) { | ||
const checklist = checklistItem.checklist() | ||
globalPos = checklist | ||
.checklistItems() | ||
.items.filter((c) => c.parent == null) | ||
.filter((c) => c.position < checklistItem.position) | ||
.reduce((cnt, item) => { | ||
return cnt + this.getTotalNumberOfItems(item) | ||
}, 0) | ||
} else { | ||
const parent = checklistItem.parent() | ||
globalPos = | ||
1 + | ||
this.getTotalNumberOfItemsAbove(parent) + | ||
parent | ||
.children() | ||
.items.filter((c) => c.position < checklistItem.position) | ||
.reduce((cnt, item) => { | ||
return cnt + this.getTotalNumberOfItems(item) | ||
}, 0) | ||
} | ||
|
||
return globalPos | ||
}, | ||
|
||
getTotalNumberOfItems(checklistItem) { | ||
return ( | ||
1 + | ||
checklistItem.children().items.reduce((cnt, item) => { | ||
return cnt + this.getTotalNumberOfItems(item) | ||
}, 0) | ||
) | ||
}, | ||
|
||
getPositionNumber(checklistItem) { | ||
if (checklistItem.parent == null) { | ||
return 1 + checklistItem.position | ||
} | ||
|
||
return ( | ||
this.getPositionNumber(checklistItem.parent()) + | ||
'.' + | ||
(1 + checklistItem.position) | ||
) | ||
}, | ||
|
||
copyToClipboard(checklistItem) { | ||
const activities = this.getActivities(checklistItem) | ||
|
||
console.log(activities) | ||
console.log(activities.map((a) => a.scheduleEntries().items)) | ||
|
||
const scheduleEntries = activities | ||
.map((a) => a.scheduleEntries().items) | ||
.reduce(function (items, item) { | ||
return items.concat(item) | ||
}, []) | ||
.map((s) => s.number) | ||
.join(', ') | ||
|
||
navigator.clipboard.writeText(scheduleEntries) | ||
}, | ||
sortBy, | ||
}, | ||
} | ||
</script> | ||
|
||
<style scoped></style> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hier könnte man dann mal noch optimieren, dass wir die listen url herausgeben. (mit filter oder subresource)