Skip to content

Commit

Permalink
WIP working on making reactivity work
Browse files Browse the repository at this point in the history
  • Loading branch information
carlobeltrame committed Jun 4, 2024
1 parent ca8965b commit 7c83489
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 0 deletions.
5 changes: 5 additions & 0 deletions frontend/src/components/print/PrintConfigurator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,11 @@ export default {
type: 'Program',
options: {
periods: [period._meta.self],
filter: {
category: [],
responsible: [],
progressLabel: [],
},
},
})
})
Expand Down
82 changes: 82 additions & 0 deletions frontend/src/components/print/config/ProgramConfig.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,61 @@
:label="$tc('components.print.config.programConfig.dayOverview')"
@input="$emit('input')"
/>
<v-dialog
v-model="openFilter"
:fullscreen="$vuetify.breakpoint.smAndDown"
width="1000"
>
<template #activator="{ on, attrs }">
<v-chip
:input-value="openFilter"
outlined
class="align-self-center mt-4"
v-bind="attrs"
v-on="on"
>
<v-icon left size="20">mdi-filter</v-icon>
{{ $tc('components.print.config.programConfig.filterActivities') }}
</v-chip>
</template>
<v-card>
<ScheduleEntryFilters
v-model="options.filter"
class="py-4 justify-center"
:loading-endpoints="loadingEndpoints"
:camp="camp"
/>
</v-card>
</v-dialog>
</div>
</template>

<script>
import ScheduleEntryFilters from '../../program/ScheduleEntryFilters.vue'
export default {
name: 'ProgramConfig',
components: { ScheduleEntryFilters },
props: {
value: { type: Object, required: true },
camp: { type: Object, required: true },
},
data() {
return {
openFilter: false,
filter: this.value.filter || {
category: [],
responsible: [],
progressLabel: [],
},
loadingEndpoints: {
categories: true,
periods: true,
campCollaborations: true,
progressLabels: true,
},
}
},
computed: {
options: {
get() {
Expand All @@ -39,6 +84,15 @@ export default {
}))
},
},
watch: {
'options.filter': {
handler(newVal, oldVal) {
console.log('helloo?', oldVal, newVal)
if (JSON.stringify(newVal) !== JSON.stringify(oldVal)) this.$emit('input')
},
deep: true,
},
},
defaultOptions() {
return {
periods: [],
Expand All @@ -56,6 +110,34 @@ export default {
return knownPeriods.includes(period)
})
if (typeof config.options.dayOverview !== 'boolean') config.options.dayOverview = true
if (!config.options.filter) {
config.options.filter = {
category: [],
responsible: [],
progressLabel: [],
}
}
if (!config.options.filter.category) config.options.filter.category = []
const knownCategories = camp.categories().items.map((c) => c._meta.self)

Check failure on line 121 in frontend/src/components/print/config/ProgramConfig.vue

View workflow job for this annotation

GitHub Actions / Tests: Frontend

src/components/print/__tests__/repairPrintConfig.spec.js > repairConfig > program > adds missing options

TypeError: camp.categories is not a function ❯ repairConfig src/components/print/config/ProgramConfig.vue:121:1 ❯ src/components/print/repairPrintConfig.js:29:14 ❯ Module.repairConfig [as default] src/components/print/repairPrintConfig.js:25:6 ❯ src/components/print/__tests__/repairPrintConfig.spec.js:659:34

Check failure on line 121 in frontend/src/components/print/config/ProgramConfig.vue

View workflow job for this annotation

GitHub Actions / Tests: Frontend

src/components/print/__tests__/repairPrintConfig.spec.js > repairConfig > program > adds missing dayOverview flag

TypeError: camp.categories is not a function ❯ repairConfig src/components/print/config/ProgramConfig.vue:121:1 ❯ src/components/print/repairPrintConfig.js:29:14 ❯ Module.repairConfig [as default] src/components/print/repairPrintConfig.js:25:6 ❯ src/components/print/__tests__/repairPrintConfig.spec.js:695:34

Check failure on line 121 in frontend/src/components/print/config/ProgramConfig.vue

View workflow job for this annotation

GitHub Actions / Tests: Frontend

src/components/print/__tests__/repairPrintConfig.spec.js > repairConfig > program > allows dayOverview false

TypeError: camp.categories is not a function ❯ repairConfig src/components/print/config/ProgramConfig.vue:121:1 ❯ src/components/print/repairPrintConfig.js:29:14 ❯ Module.repairConfig [as default] src/components/print/repairPrintConfig.js:25:6 ❯ src/components/print/__tests__/repairPrintConfig.spec.js:732:34

Check failure on line 121 in frontend/src/components/print/config/ProgramConfig.vue

View workflow job for this annotation

GitHub Actions / Tests: Frontend

src/components/print/__tests__/repairPrintConfig.spec.js > repairConfig > program > allows empty periods

TypeError: camp.categories is not a function ❯ repairConfig src/components/print/config/ProgramConfig.vue:121:1 ❯ src/components/print/repairPrintConfig.js:29:14 ❯ Module.repairConfig [as default] src/components/print/repairPrintConfig.js:25:6 ❯ src/components/print/__tests__/repairPrintConfig.spec.js:766:34

Check failure on line 121 in frontend/src/components/print/config/ProgramConfig.vue

View workflow job for this annotation

GitHub Actions / Tests: Frontend

src/components/print/__tests__/repairPrintConfig.spec.js > repairConfig > program > filters out unknown periods

TypeError: camp.categories is not a function ❯ repairConfig src/components/print/config/ProgramConfig.vue:121:1 ❯ src/components/print/repairPrintConfig.js:29:14 ❯ Module.repairConfig [as default] src/components/print/repairPrintConfig.js:25:6 ❯ src/components/print/__tests__/repairPrintConfig.spec.js:800:34
config.options.filter.category = config.options.filter.category.filter((category) => {
return knownCategories.includes(category)
})
if (!config.options.filter.responsible) config.options.filter.responsible = []
const knownCampCollaborations = camp
.campCollaborations()
.items.map((c) => c._meta.self)
config.options.filter.responsible = config.options.filter.responsible.filter(
(responsible) => {
return knownCampCollaborations.includes(responsible)
}
)
if (!config.options.filter.progressLabel) config.options.filter.progressLabel = []
const knownProgressLabels = camp.progressLabels().items.map((l) => l._meta.self)
config.options.filter.progressLabel = config.options.filter.progressLabel.filter(
(progressLabel) => {
return knownProgressLabels.includes(progressLabel)
}
)
return config
},
}
Expand Down
1 change: 1 addition & 0 deletions frontend/src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@
},
"programConfig": {
"dayOverview": "Tagesübersicht",
"filterActivities": "Aktivitäten filtern",
"periods": "Lagerabschnitt(e)"
},
"storyConfig": {
Expand Down

0 comments on commit 7c83489

Please sign in to comment.