Skip to content

Commit

Permalink
wip: Refactor activity management #859
Browse files Browse the repository at this point in the history
  • Loading branch information
cnouguier committed Jul 25, 2024
1 parent be349e1 commit 453f41d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
24 changes: 22 additions & 2 deletions core/client/components/KActivity.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<KPage>
<KPage padding>
<template v-slot:page-content>
<slot />
</template>
Expand All @@ -12,6 +12,7 @@ import logger from 'loglevel'
import config from 'config'
import { useActivity, useLayout } from '../composables'
import KPage from './layout/KPage.vue'
import { Layout } from '../layout'
export default {
components: {
Expand All @@ -25,21 +26,38 @@ export default {
layout: {
type: [Object, Function],
default: () => null
},
mode: {
type: String,
default: null
},
padding: {
type: Boolean,
default: true
}
},
setup (props) {
const keyName = `${_.camelCase(props.name)}Activity`
logger.debug(`[KDK] Reading '${props.name}' activity options with key ${keyName}`)
const options = _.get(config, keyName, {})
const { setCurrentActivity } = useActivity(keyName, options)
const { configureLayout, clearLayout } = useLayout()
const { configureLayout, clearLayout, Layout } = useLayout()
return {
options,
setCurrentActivity,
configureLayout,
clearLayout
}
},
watch: {
mode: {
// [!] cannot be immediate as it is required that the activity is configured first
handler (value) {
logger.debug(`[KDK] Setting layout un '${value}' mode`)
if (value) Layout.setMode(value)
}
}
},
methods: {
async configure () {
logger.debug(`[KDK] Configuring '${this.name}' activity`)
Expand All @@ -54,6 +72,8 @@ export default {
this.configureLayout(_.merge({}, this.options, customLayout), concreteActivity)
// set the current activity
this.setCurrentActivity(concreteActivity)
// apply the mode if needed
if (this.mode) Layout.setMode(this.mode)
}
},
async mounted () {
Expand Down
2 changes: 1 addition & 1 deletion core/client/composables/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function useLayout () {

// expose
return {
layout: Layout,
Layout,
configureLayout,
clearLayout,
...additionalFunctions
Expand Down

0 comments on commit 453f41d

Please sign in to comment.