@ditojs/admin 2.69.0 → 2.71.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ditojs/admin",
3
- "version": "2.69.0",
3
+ "version": "2.71.0",
4
4
  "type": "module",
5
5
  "description": "Dito.js Admin is a schema based admin interface for Dito.js Server, featuring auto-generated views and forms and built with Vue.js",
6
6
  "repository": "https://github.com/ditojs/dito/tree/master/packages/admin",
@@ -42,8 +42,8 @@
42
42
  "not ie_mob > 0"
43
43
  ],
44
44
  "dependencies": {
45
- "@ditojs/ui": "^2.69.0",
46
- "@ditojs/utils": "^2.69.0",
45
+ "@ditojs/ui": "^2.71.0",
46
+ "@ditojs/utils": "^2.71.0",
47
47
  "@kyvg/vue3-notification": "^3.4.2",
48
48
  "@lk77/vue3-color": "^3.0.6",
49
49
  "@tiptap/core": "^3.14.0",
@@ -89,9 +89,9 @@
89
89
  "vue-upload-component": "^3.1.17"
90
90
  },
91
91
  "devDependencies": {
92
- "@ditojs/build": "^2.69.0",
92
+ "@ditojs/build": "^2.71.0",
93
93
  "typescript": "^5.9.3",
94
94
  "vite": "^7.3.0"
95
95
  },
96
- "gitHead": "a2b28ad175cd3280ceadd394c74ba67e12da03af"
96
+ "gitHead": "e5a095c7c44de8b6c84994d744612f0fce19eae2"
97
97
  }
@@ -7,7 +7,7 @@ ul.dito-menu(
7
7
  v-for="item in items"
8
8
  )
9
9
  template(
10
- v-if="shouldRenderSchema(item)"
10
+ v-if="shouldShowItem(item)"
11
11
  )
12
12
  a.dito-link(
13
13
  :href="getItemHref(item)"
@@ -45,6 +45,15 @@ export default DitoComponent.component('DitoMenu', {
45
45
  },
46
46
 
47
47
  methods: {
48
+ shouldShowItem(item) {
49
+ return (
50
+ this.shouldRenderSchema(item) && (
51
+ !item.items ||
52
+ Object.values(item.items).some(this.shouldRenderSchema)
53
+ )
54
+ )
55
+ },
56
+
48
57
  onResize({ contentRect: { width } }) {
49
58
  if (width) {
50
59
  this.width = width
@@ -14,7 +14,7 @@
14
14
 
15
15
  <script>
16
16
  import DitoComponent from '../DitoComponent.js'
17
- import { asArray, stripTags } from '@ditojs/utils'
17
+ import { asArray, stripHtml } from '@ditojs/utils'
18
18
 
19
19
  // @vue/component
20
20
  export default DitoComponent.component('DitoNotifications', {
@@ -48,7 +48,7 @@ export default DitoComponent.component('DitoNotifications', {
48
48
  // eslint-disable-next-line no-console
49
49
  console[log](
50
50
  ...[
51
- stripTags(text),
51
+ stripHtml(text),
52
52
  ...(type === 'error' && error ? [error] : [])
53
53
  ]
54
54
  )
@@ -52,7 +52,8 @@ import DitoDialog from './DitoDialog.vue'
52
52
  import {
53
53
  processView,
54
54
  resolveViews,
55
- processSchemaComponents
55
+ processSchemaComponents,
56
+ shouldRenderSchema
56
57
  } from '../utils/schema.js'
57
58
 
58
59
  // @vue/component
@@ -410,14 +411,18 @@ export default DitoComponent.component('DitoRoot', {
410
411
  // new routes, and restore the current path.
411
412
  const { fullPath } = this.$route
412
413
  this.removeRoutes?.()
413
- this.removeRoutes = addRoutes(this.$router, [
414
- {
415
- name: 'root',
416
- path: '/',
417
- components: {}
418
- },
419
- ...routes.flat()
420
- ])
414
+ this.removeRoutes = addRoutes(
415
+ this.$router,
416
+ [
417
+ {
418
+ name: 'root',
419
+ path: '/',
420
+ components: {}
421
+ },
422
+ ...routes.flat()
423
+ ],
424
+ this.context
425
+ )
421
426
  this.$router.replace(fullPath)
422
427
  },
423
428
 
@@ -429,13 +434,26 @@ export default DitoComponent.component('DitoRoot', {
429
434
 
430
435
  let dialogId = 0
431
436
 
432
- function addRoutes(router, routes) {
437
+ function addRoutes(router, routes, context) {
433
438
  const removers = []
434
439
  for (const route of routes) {
435
- const remove = router.addRoute(route)
436
- removers.push(remove)
440
+ removers.push(
441
+ router.addRoute(route)
442
+ )
437
443
  }
438
444
 
445
+ removers.push(
446
+ // Add navigation guard to check if: conditions
447
+ router.beforeEach((to, from, next) => {
448
+ for (const record of to.matched) {
449
+ if (!shouldRenderSchema(record.meta.schema, context)) {
450
+ return next('/')
451
+ }
452
+ }
453
+ next()
454
+ })
455
+ )
456
+
439
457
  return () => {
440
458
  for (const remove of removers) {
441
459
  remove()