Skip to content

Feature/activity load selected checklist items as collection #7199

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

Merged
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
2 changes: 1 addition & 1 deletion api/src/Entity/ChecklistItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
normalizationContext: ['groups' => ['read']],
order: ['checklist.id', 'id'],
)]
#[ApiFilter(filterClass: SearchFilter::class, properties: ['checklist', 'checklist.camp'])]
#[ApiFilter(filterClass: SearchFilter::class, properties: ['checklist', 'checklist.camp', 'checklistNodes'])]
#[ORM\Entity(repositoryClass: ChecklistItemRepository::class)]
#[ORM\UniqueConstraint(name: 'checklistitem_checklistid_parentid_position_unique', columns: ['checklistid', 'parentid', 'position'])]
class ChecklistItem extends BaseEntity implements BelongsToCampInterface, CopyFromPrototypeInterface, HasParentInterface {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ public function testAddChecklistItemForMember() {
$this->assertJsonContains([
'_links' => [
'checklistItems' => [
1 => [
'href' => '/checklist_items/'.$checklistItemId,
],
'href' => '/checklist_items?checklistNodes=%2Fcontent_node%2Fchecklist_nodes%2F'.$this->defaultEntity->getId(),
],
],
]);
Expand All @@ -59,9 +57,7 @@ public function testAddChecklistItemForManager() {
$this->assertJsonContains([
'_links' => [
'checklistItems' => [
1 => [
'href' => '/checklist_items/'.$checklistItemId,
],
'href' => '/checklist_items?checklistNodes=%2Fcontent_node%2Fchecklist_nodes%2F'.$this->defaultEntity->getId(),
],
],
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
"items": [
{
"_links": {
"checklistItems": [],
"checklistItems": {
"href": "escaped_value"
},
"children": [],
"contentType": {
"href": "escaped_value"
Expand All @@ -27,11 +29,9 @@
},
{
"_links": {
"checklistItems": [
{
"href": "escaped_value"
}
],
"checklistItems": {
"href": "escaped_value"
},
"children": [],
"contentType": {
"href": "escaped_value"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@
},
{
"_links": {
"checklistItems": [],
"checklistItems": {
"href": "escaped_value"
},
"children": [],
"contentType": {
"href": "escaped_value"
Expand All @@ -107,11 +109,9 @@
},
{
"_links": {
"checklistItems": [
{
"href": "escaped_value"
}
],
"checklistItems": {
"href": "escaped_value"
},
"children": [],
"contentType": {
"href": "escaped_value"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,9 @@
},
{
"_links": {
"checklistItems": [
{
"href": "escaped_value"
}
],
"checklistItems": {
"href": "escaped_value"
},
"children": [],
"contentType": {
"href": "escaped_value"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"_links": {
"checklistItems": [],
"checklistItems": {
"href": "escaped_value"
},
"children": [],
"contentType": {
"href": "escaped_value"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25606,6 +25606,18 @@ paths:
schema:
type: string
style: form
-
allowEmptyValue: false
allowReserved: false
deprecated: false
description: ''
explode: false
in: query
name: checklistNodes
required: false
schema:
type: string
style: form
-
allowEmptyValue: false
allowReserved: false
Expand All @@ -25620,6 +25632,20 @@ paths:
type: string
type: array
style: form
-
allowEmptyValue: false
allowReserved: false
deprecated: false
description: ''
explode: true
in: query
name: 'checklistNodes[]'
required: false
schema:
items:
type: string
type: array
style: form
-
allowEmptyValue: false
allowReserved: false
Expand Down Expand Up @@ -26197,6 +26223,18 @@ paths:
schema:
type: string
style: form
-
allowEmptyValue: false
allowReserved: false
deprecated: false
description: ''
explode: false
in: query
name: checklistNodes
required: false
schema:
type: string
style: form
-
allowEmptyValue: false
allowReserved: false
Expand All @@ -26211,6 +26249,20 @@ paths:
type: string
type: array
style: form
-
allowEmptyValue: false
allowReserved: false
deprecated: false
description: ''
explode: true
in: query
name: 'checklistNodes[]'
required: false
schema:
items:
type: string
type: array
style: form
-
allowEmptyValue: false
allowReserved: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"templated": true
},
"checklistItems": {
"href": "/checklist_items{/id}{?checklist,checklist[],checklist.camp,checklist.camp[]}",
"href": "/checklist_items{/id}{?checklist,checklist[],checklist.camp,checklist.camp[],checklistNodes,checklistNodes[]}",
"templated": true
},
"checklistNodes": {
Expand Down
65 changes: 37 additions & 28 deletions frontend/src/components/checklist/ChecklistItemParent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,43 +66,52 @@ export default {
props: {
checklistItem: { type: Object, required: true },
depth: { type: Number, required: true },
allChecklistNodes: { type: Array, required: true },
},
data() {
return {
checklistNodes: [],
activities: [],
}
},
computed: {
activities() {
const camp = this.checklistItem.checklist().camp()
const activities = camp.activities().items
watch: {
checklistItem: {
async handler(checklistItem) {
const camp = checklistItem.checklist().camp()

await camp.activities()._meta.load
const activities = await Promise.all(
camp.activities().items.map(async (a) => ({
activity: a,
rootContentNodeUri: await a.$href('rootContentNode'),
}))
)

// Activities ordered first ScheduleEntry start-time
return sortBy(
activities.filter((a) =>
this.checklistNodes.some((cn) => cn.root().id === a.rootContentNode().id)
),
(activity) =>
activity
.scheduleEntries()
.items.map(
(s) =>
`${s.dayNumber}`.padStart(3, '0') +
`${s.scheduleEntryNumber}`.padStart(3, '0')
const checklistNodes = await Promise.all(
checklistItem.checklistNodes().items.map(async (cn) => ({
checklistNode: cn,
rootUri: await cn.$href('root'),
}))
)

// Activities ordered by first ScheduleEntry start time
const res = sortBy(
activities
.filter((a) =>
checklistNodes.some((cn) => cn.rootUri == a.rootContentNodeUri)
)
.reduce((p, v) => (p < v ? p : v))
)
},
},
watch: {
allChecklistNodes: {
immediate: true,
handler(allChecklistNodes) {
this.checklistNodes = allChecklistNodes.filter((cn) =>
cn.checklistItems().items.some((ci) => ci.id === this.checklistItem.id)
.map((a) => a.activity),
(activity) =>
activity
.scheduleEntries()
.items.map(
(s) =>
`${s.dayNumber}`.padStart(3, '0') +
`${s.scheduleEntryNumber}`.padStart(3, '0')
)
.reduce((p, v) => (p < v ? p : v))
)
this.activities = res
},
immediate: true,
},
},

Expand Down
15 changes: 4 additions & 11 deletions frontend/src/views/camp/checklistOverview/ChecklistOverview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
:key="value?._meta.self"
:checklist-item="value"
:depth="depth"
:all-checklist-nodes="allChecklistNodes"
/>
</tbody>
</table>
Expand All @@ -42,7 +41,6 @@ export default {
data() {
return {
loading: true,
allChecklistNodes: [],
indexedChecklistItems: {},
}
},
Expand Down Expand Up @@ -72,20 +70,13 @@ export default {
await Promise.all([
this.camp.categories()._meta.load,
this.camp.activities().$reload(),
this.api
.get()
.checklistNodes({ camp: this.camp._meta.self })
.$reload()
.then((cns) => {
this.allChecklistNodes = cns.items
}),
this.api.get().checklistNodes({ camp: this.camp._meta.self }).$reload(),
this.api
.get()
.checklistItems({ 'checklist.camp': this.camp._meta.self })
.$reload()
.then(({ items }) => {
this.processChecklistItems(items)
this.loading = false
}),
this.api
.get()
Expand All @@ -94,7 +85,9 @@ export default {
camp: this.camp._meta.self,
})
.$loadItems(),
])
]).then(() => {
this.loading = false
})
},
methods: {
processChecklistItems(items) {
Expand Down
Loading