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 Jan 16, 2025
1 parent 11484b2 commit 658dbda
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions core/client/components/KActivity.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<script>
import _ from 'lodash'
import logger from 'loglevel'
import config from 'config'
import { useActivity, useLayout } from '../composables'
import KPage from './layout/KPage.vue'
Expand All @@ -20,6 +19,13 @@ export default {
type: String,
required: true
},
options: {
type: Object,
default: () => {},
validator: (value) => {
return _.isObject(value)
}
},
layout: {
type: [Object, Function],
default: () => null
Expand All @@ -32,13 +38,11 @@ export default {
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 { Layout, configureLayout, clearLayout, setLayoutMode } = useLayout()
const { setCurrentActivity, options: activityOptions } = useActivity(keyName, props.options)
const { configureLayout, clearLayout, setLayoutMode } = useLayout()
return {
options,
activityOptions,
setCurrentActivity,
Layout,
configureLayout,
clearLayout,
setLayoutMode
Expand All @@ -64,14 +68,11 @@ export default {
if (typeof this.layout === 'function') customLayout = await this.layout()
else customLayout = this.layout
}
this.configureLayout(_.merge({}, this.options, customLayout), concreteActivity)
this.configureLayout(_.merge({}, this.activityOptions, customLayout), concreteActivity)
// set the current activity
this.setCurrentActivity(concreteActivity)
// apply the mode if needed
if (this.mode) this.setLayoutMode(this.mode)
},
getOptions () {
return this.options
}
},
async mounted () {
Expand Down

0 comments on commit 658dbda

Please sign in to comment.