Skip to content

Commit

Permalink
Add compose sidebar navigation improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
kelanik8 committed Oct 24, 2023
1 parent 84bfc13 commit 8d9b4c8
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
16 changes: 12 additions & 4 deletions client/web/compose/src/components/Namespaces/NamespaceSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,13 @@ import { NoID } from '@cortezaproject/corteza-js'
import { components, filter } from '@cortezaproject/corteza-vue'
import { Portal } from 'portal-vue'
import { VueSelect } from 'vue-select'
const { CSidebarNavItems, CInputSearch } = components
const moduleWrap = (module) => {
const moduleWrap = (module, pageName) => {
return {
page: {
name: 'admin.modules.edit',
name: pageName,
pageID: `module-${module.moduleID}`,
selfID: 'modules',
rootSelfID: 'modules',
Expand All @@ -137,6 +138,7 @@ const moduleWrap = (module) => {
},
}
}
const chartWrap = (chart) => {
return {
page: {
Expand Down Expand Up @@ -230,6 +232,7 @@ export default {
if (this.namespace) {
// If on admin page, show admin pages. Otherwise show public pages
const pages = [...(this.isAdminPage ? this.adminRoutes() : this.publicPageWrap(this.publicRoutes))]
if (!this.query) {
return pages
}
Expand Down Expand Up @@ -347,6 +350,9 @@ export default {
},
adminRoutes () {
const routeName = this.$route.name
const pageName = routeName.startsWith('admin.modules.record') ? 'admin.modules.record.list' : 'admin.modules.edit'
return [
{
page: {
Expand All @@ -358,7 +364,7 @@ export default {
},
children: [],
},
...this.modules.map(moduleWrap),
...this.modules.map((m) => moduleWrap(m, pageName)),
{
page: {
pageID: 'pages',
Expand Down Expand Up @@ -428,9 +434,11 @@ export default {
iconSrc = `${this.$ComposeAPI.baseURL}${src}`
}
const pageName = this.$route.name === 'admin.pages.edit' ? 'admin.pages.edit' : 'admin.pages.builder'
return {
page: {
name: 'admin.pages.builder',
name: pageName,
pageID: `page-${pageID}`,
selfID: selfID !== NoID ? `page-${selfID}` : 'pages',
rootSelfID: 'pages',
Expand Down
24 changes: 20 additions & 4 deletions client/web/compose/src/views/Admin/Modules/Records/List.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ export default {
},
module () {
if (this.$attrs.moduleID) {
return this.getModuleByID(this.$attrs.moduleID)
if (this.$route.params.moduleID) {
return this.getModuleByID(this.$route.params.moduleID)
} else {
return undefined
}
Expand All @@ -102,8 +102,24 @@ export default {
},
},
watch: {
module: {
handler (module) {
if (module) {
const { meta = { ui: {} }, moduleID } = module || {}
let fields = ((meta.ui || {}).admin || {}).fields || []
fields = fields.length ? fields : module.fields
this.block.options.moduleID = moduleID
this.block.options.fields = fields
}
},
},
},
created () {
const { meta = { ui: {} } } = this.module || {}
const { meta = { ui: {} }, moduleID } = this.module || {}
let fields = ((meta.ui || {}).admin || {}).fields || []
fields = fields.length ? fields : this.module.fields
Expand All @@ -112,7 +128,7 @@ export default {
const block = new compose.PageBlockRecordList({
blockIndex: 0,
options: {
moduleID: this.$attrs.moduleID,
moduleID,
fields,
hideRecordReminderButton: true,
hideRecordViewButton: true,
Expand Down

0 comments on commit 8d9b4c8

Please sign in to comment.