-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6031 from usu/feat/activity-list
feat(print): activity list for courses
- Loading branch information
Showing
18 changed files
with
524 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
frontend/src/components/print/config/ActivityListConfig.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<template> | ||
<div> | ||
<e-select | ||
v-model="options.periods" | ||
:items="periods" | ||
:label="$tc('print.config.periods')" | ||
multiple | ||
:filled="false" | ||
@input="$emit('input')" | ||
/> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: 'ActivityListConfig', | ||
props: { | ||
value: { type: Object, required: true }, | ||
camp: { type: Object, required: true }, | ||
}, | ||
computed: { | ||
options: { | ||
get() { | ||
return this.value | ||
}, | ||
set(v) { | ||
this.$emit('input', v) | ||
}, | ||
}, | ||
periods() { | ||
return this.camp.periods().items.map((p) => ({ | ||
value: p._meta.self, | ||
text: p.description, | ||
})) | ||
}, | ||
}, | ||
defaultOptions() { | ||
return { | ||
periods: [], | ||
} | ||
}, | ||
design: { | ||
multiple: true, | ||
}, | ||
repairConfig(config, camp) { | ||
if (!config.options) config.options = {} | ||
if (!config.options.periods) config.options.periods = [] | ||
const knownPeriods = camp.periods().items.map((p) => p._meta.self) | ||
config.options.periods = config.options.periods.filter((period) => { | ||
return knownPeriods.includes(period) | ||
}) | ||
return config | ||
}, | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<template> | ||
<div class="tw-break-after-page"> | ||
<h1 | ||
:id="`content_${index}_period_${period.id}`" | ||
class="tw-text-center tw-font-semibold tw-mb-6" | ||
> | ||
{{ $t('print.activityList.title') }}: | ||
{{ period.description }} | ||
</h1> | ||
|
||
<generic-error-message v-if="error" :error="error" /> | ||
|
||
<activity-list-schedule-entry | ||
v-for="scheduleEntry in data.scheduleEntries" | ||
:key="scheduleEntry.id" | ||
:schedule-entry="scheduleEntry" | ||
:content-types="data.contentTypes" | ||
:content-nodes="data.contentNodes" | ||
:index="index" | ||
/> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
const props = defineProps({ | ||
camp: { type: Object, required: true }, | ||
period: { | ||
type: Object, | ||
required: true, | ||
}, | ||
contentTypeNames: { | ||
type: Array, | ||
required: true, | ||
}, | ||
index: { type: Number, required: true }, | ||
}) | ||
const { $api } = useNuxtApp() | ||
const { data, error } = await useAsyncData( | ||
`ActivityListPeriod-${props.period._meta.self}`, | ||
async () => { | ||
const allContentTypes = (await $api.get().contentTypes().$loadItems()).items | ||
const contentTypes = props.contentTypeNames.map((contentTypeName) => | ||
allContentTypes.find((contentType) => contentType.name === contentTypeName) | ||
) | ||
const contentNodePromises = contentTypes.map((contentType) => | ||
$api | ||
.get() | ||
.contentNodes({ | ||
period: props.period._meta.self, | ||
contentType: contentType._meta.self, | ||
}) | ||
.$loadItems() | ||
) | ||
const contentNodes = await Promise.all(contentNodePromises) | ||
const [scheduleEntries] = await Promise.all([ | ||
props.period.scheduleEntries().$loadItems(), | ||
]) | ||
return { | ||
scheduleEntries: scheduleEntries.items, | ||
contentNodes, | ||
contentTypes, | ||
} | ||
} | ||
) | ||
</script> |
Oops, something went wrong.