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

Checklist-Overview with Activities #6026

Open
wants to merge 10 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 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
2 changes: 2 additions & 0 deletions api/src/Entity/ChecklistItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ class ChecklistItem extends BaseEntity implements BelongsToCampInterface, CopyFr
/**
* All ChecklistNodes that have selected this ChecklistItem.
*/
#[ApiProperty(example: '["/checklist_items/1a2b3c4d"]')]
#[Groups(['read'])]
#[Assert\Count(
exactly: 0,
exactMessage: 'It\'s not possible to delete a checklist item as long as checklist nodes are referencing it.',
Expand Down
2 changes: 1 addition & 1 deletion api/tests/Api/ChecklistItems/CreateChecklistItemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ public function getExampleReadPayload($attributes = [], $except = []) {
ChecklistItem::class,
Get::class,
$attributes,
['parent', 'checklist'],
['parent', 'checklist', 'checklistNodes'],
$except
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"checklist": {
"href": "escaped_value"
},
"checklistNodes": [],
"children": [],
"parent": "escaped_value",
"self": {
Expand All @@ -21,6 +22,7 @@
"checklist": {
"href": "escaped_value"
},
"checklistNodes": [],
"children": [],
"parent": "escaped_value",
"self": {
Expand All @@ -36,8 +38,11 @@
"checklist": {
"href": "escaped_value"
},
"checklistNodes": [],
"children": [],
"parent": "escaped_value",
"parent": {
"href": "escaped_value"
},
"self": {
"href": "escaped_value"
}
Expand All @@ -51,10 +56,13 @@
"checklist": {
"href": "escaped_value"
},
"children": [],
"parent": {
"href": "escaped_value"
},
"checklistNodes": [],
"children": [
Copy link
Contributor

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)

{
"href": "escaped_value"
}
],
"parent": "escaped_value",
"self": {
"href": "escaped_value"
}
Expand All @@ -68,12 +76,15 @@
"checklist": {
"href": "escaped_value"
},
"checklistNodes": [],
"children": [
{
"href": "escaped_value"
}
],
"parent": "escaped_value",
"parent": {
"href": "escaped_value"
},
"self": {
"href": "escaped_value"
}
Expand All @@ -87,14 +98,13 @@
"checklist": {
"href": "escaped_value"
},
"children": [
"checklistNodes": [
{
"href": "escaped_value"
}
],
"parent": {
"href": "escaped_value"
},
"children": [],
"parent": "escaped_value",
"self": {
"href": "escaped_value"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
"checklist": {
"href": "escaped_value"
},
"checklistNodes": [
{
"href": "escaped_value"
}
],
"children": [],
"parent": "escaped_value",
"self": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7925,6 +7925,14 @@ components:
example: /checklists/1a2b3c4d
format: iri-reference
type: string
checklistNodes:
description: 'All ChecklistNodes that have selected this ChecklistItem.'
example: '["/checklist_items/1a2b3c4d"]'
items:
example: 'https://example.com/'
format: iri-reference
type: string
type: array
children:
description: 'All ChecklistItems that are direct children of this ChecklistItem.'
example: '["/checklist_items/1a2b3c4d"]'
Expand Down Expand Up @@ -7962,6 +7970,7 @@ components:
type: string
required:
- checklist
- checklistNodes
- children
- position
- text
Expand Down Expand Up @@ -8068,12 +8077,15 @@ components:
properties:
checklist:
properties: { data: { properties: { id: { format: iri-reference, type: string }, type: { type: string } }, type: object } }
checklistNodes:
properties: { data: { items: { properties: { id: { format: iri-reference, type: string }, type: { type: string } }, type: object }, type: array } }
children:
properties: { data: { items: { properties: { id: { format: iri-reference, type: string }, type: { type: string } }, type: object }, type: array } }
parent:
properties: { data: { properties: { id: { format: iri-reference, type: string }, type: { type: string } }, type: object } }
required:
- checklist
- checklistNodes
- children
type: object
type:
Expand All @@ -8094,6 +8106,8 @@ components:
$ref: '#/components/schemas/ChecklistItem.jsonapi'
-
$ref: '#/components/schemas/ChecklistItem.jsonapi'
-
$ref: '#/components/schemas/ChecklistItem.jsonapi'
readOnly: true
type: array
type: object
Expand All @@ -8117,6 +8131,14 @@ components:
example: /checklists/1a2b3c4d
format: iri-reference
type: string
checklistNodes:
description: 'All ChecklistNodes that have selected this ChecklistItem.'
example: '["/checklist_items/1a2b3c4d"]'
items:
example: 'https://example.com/'
format: iri-reference
type: string
type: array
children:
description: 'All ChecklistItems that are direct children of this ChecklistItem.'
example: '["/checklist_items/1a2b3c4d"]'
Expand Down Expand Up @@ -8154,6 +8176,7 @@ components:
type: string
required:
- checklist
- checklistNodes
- children
- position
- text
Expand Down Expand Up @@ -8237,6 +8260,14 @@ components:
example: /checklists/1a2b3c4d
format: iri-reference
type: string
checklistNodes:
description: 'All ChecklistNodes that have selected this ChecklistItem.'
example: '["/checklist_items/1a2b3c4d"]'
items:
example: 'https://example.com/'
format: iri-reference
type: string
type: array
children:
description: 'All ChecklistItems that are direct children of this ChecklistItem.'
example: '["/checklist_items/1a2b3c4d"]'
Expand Down Expand Up @@ -8274,6 +8305,7 @@ components:
type: string
required:
- checklist
- checklistNodes
- children
- position
- text
Expand Down
139 changes: 139 additions & 0 deletions frontend/src/components/checklist/ChecklistItemTree.vue
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 }}
Copy link
Contributor

Choose a reason for hiding this comment

The 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) {
Copy link
Contributor

Choose a reason for hiding this comment

The 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>
4 changes: 4 additions & 0 deletions frontend/src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,9 @@
"reminderLockedMove": "Ziehen zum Verschieben ist nur im entsperrten Modus möglich.",
"title": "Grobprogramm"
},
"checklist": {
"title": "Checklist-Übersicht"
},
"dashboard": {
"activities": "Aktivitäten",
"columns": {
Expand Down Expand Up @@ -707,6 +710,7 @@
"navTopbar": {
"admin": "Admin",
"campIsLoading": "Lager wird geladen",
"checklist": "Checklist",
"material": "Material",
"print": "Drucken",
"program": "Programm",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,7 @@
"desktop": {
"navTopbar": {
"admin": "Admin",
"checklist": "Checklist",
"campIsLoading": "Camp is loading",
"material": "Materials",
"print": "Print",
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,11 @@ export default new Router({
redirectToPeriod(to, from, next, 'camp/period/program')
},
},
{
path: 'checklist',
name: 'camp/checklist',
component: () => import('./views/camp/Checklist.vue'),
},
{
path: 'story/period/:periodId/:periodTitle?',
name: 'camp/period/story',
Expand Down Expand Up @@ -711,6 +716,7 @@ export function checklistFromRoute(route) {

function getContentLayout(route) {
switch (route.name) {
case 'camp/checklist':
case 'camp/period/program':
case 'camp/admin/print':
case 'camp/admin/activity/category':
Expand Down
Loading
Loading