@ditojs/admin 2.6.8 → 2.6.10

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.
@@ -39,7 +39,7 @@
39
39
  DitoDraggable(
40
40
  tag="tbody"
41
41
  :modelValue="updateOrder(sourceSchema, listData, paginationRange)"
42
- :options="getSortableOptions(false)"
42
+ :options="getSortableOptions()"
43
43
  :draggable="draggable"
44
44
  @update:modelValue="value => (listData = value)"
45
45
  )
@@ -78,7 +78,7 @@
78
78
  :dataPath="getDataPath(index)"
79
79
  :data="item"
80
80
  :meta="nestedMeta"
81
- :store="getChildStore(getItemUid(schema, item), index)"
81
+ :store="getItemStore(schema, item, index)"
82
82
  :disabled="disabled || isLoading"
83
83
  :collapsed="collapsed"
84
84
  :collapsible="collapsible"
@@ -115,7 +115,7 @@
115
115
  :dataPath="getDataPath(index)"
116
116
  :data="item"
117
117
  :meta="nestedMeta"
118
- :store="getChildStore(getItemUid(schema, item), index)"
118
+ :store="getItemStore(schema, item, index)"
119
119
  @delete="deleteItem(item, index)"
120
120
  )
121
121
  //- Render create buttons inside table when not in a single component view:
@@ -161,6 +161,7 @@ import {
161
161
  import { createFiltersPanel } from '../utils/filter.js'
162
162
  import { appendDataPath } from '../utils/data.js'
163
163
  import { pickBy, equals, hyphenate } from '@ditojs/utils'
164
+ import { computed } from 'vue'
164
165
 
165
166
  // @vue/component
166
167
  export default DitoTypeComponent.register('list', {
@@ -171,28 +172,22 @@ export default DitoTypeComponent.register('list', {
171
172
  return type
172
173
  },
173
174
 
174
- getPanelSchema(api, schema, dataPath, schemaComponent) {
175
+ getPanelSchema(api, schema, dataPath, component) {
175
176
  const { filters } = schema
176
177
  // See if this list component wants to display a filter panel, and if so,
177
178
  // create the panel schema for it through `getFiltersPanel()`.
178
179
  if (filters) {
179
- // At the time of the creation of the panel schema, the schemaComponent is
180
- // not filled yet, so we can't get the target component (dataPath) right
181
- // away. Use a proxy and a getter instead, to get around this:
182
- const getListComponent = () =>
183
- schemaComponent.getComponentByDataPath(
184
- dataPath,
185
- component => component.type === 'list'
186
- )
180
+ return createFiltersPanel(
181
+ api,
182
+ filters,
183
+ dataPath,
184
+ // Pass a computed value to get / set the query, see getFiltersPanel()
185
+ computed({
186
+ get() {
187
+ return component.query
188
+ },
187
189
 
188
- return createFiltersPanel(api, filters, dataPath, {
189
- // Create a simple proxy to get / set the query, see getFiltersPanel()
190
- get query() {
191
- return getListComponent()?.query
192
- },
193
- set query(query) {
194
- const component = getListComponent()
195
- if (component) {
190
+ set(query) {
196
191
  // Filter out undefined values for comparing with equals()
197
192
  const filter = obj => pickBy(obj, value => value !== undefined)
198
193
  if (!equals(filter(query), filter(component.query))) {
@@ -200,8 +195,8 @@ export default DitoTypeComponent.register('list', {
200
195
  component.loadData(false)
201
196
  }
202
197
  }
203
- }
204
- })
198
+ })
199
+ )
205
200
  }
206
201
  },
207
202
 
@@ -35,7 +35,7 @@
35
35
  DitoDraggable(
36
36
  v-model="files"
37
37
  tag="tbody"
38
- :options="getSortableOptions(false)"
38
+ :options="getSortableOptions()"
39
39
  :draggable="draggable"
40
40
  )
41
41
  template(
@@ -43,7 +43,7 @@
43
43
  )
44
44
  tr(
45
45
  v-for="(file, index) in files"
46
- :key="file.key"
46
+ :key="file.name"
47
47
  )
48
48
  td(
49
49
  v-if="render"
@@ -63,7 +63,7 @@ export const filterComponents = {
63
63
  }
64
64
  }
65
65
 
66
- export function createFiltersPanel(api, filters, dataPath, proxy) {
66
+ export function createFiltersPanel(api, filters, dataPath, query) {
67
67
  const { sticky, ...filterSchemas } = filters
68
68
  const panel = {
69
69
  type: 'panel',
@@ -80,7 +80,7 @@ export function createFiltersPanel(api, filters, dataPath, proxy) {
80
80
  data() {
81
81
  return parseFiltersData(
82
82
  panel,
83
- proxy.query
83
+ query.value
84
84
  )
85
85
  },
86
86
 
@@ -106,8 +106,8 @@ export function createFiltersPanel(api, filters, dataPath, proxy) {
106
106
 
107
107
  methods: {
108
108
  applyFilters() {
109
- proxy.query = {
110
- ...proxy.query,
109
+ query.value = {
110
+ ...query.value,
111
111
  filter: this.filters,
112
112
  // Clear pagination when applying or clearing filters:
113
113
  page: undefined
@@ -283,25 +283,24 @@ export async function processSchemaComponent(
283
283
  ])
284
284
  }
285
285
 
286
- export async function processView(component, api, schema, name, menuLevel = 0) {
286
+ export async function processView(component, api, schema, name, fullPath = '') {
287
287
  processSchemaDefaults(api, schema)
288
+ processRouteSchema(api, schema, name, fullPath)
288
289
  let children = []
289
290
  if (isView(schema)) {
290
- processRouteSchema(api, schema, name)
291
291
  await processNestedSchemas(api, schema)
292
292
  await processSchemaComponents(api, schema, children)
293
293
  } else if (isMenu(schema)) {
294
- processRouteSchema(api, schema, name)
295
294
  children = await Promise.all(
296
295
  Object.entries(schema.items).map(async ([name, item]) =>
297
- processView(component, api, item, name, menuLevel + 1)
296
+ processView(component, api, item, name, schema.fullPath)
298
297
  )
299
298
  )
300
299
  } else {
301
300
  throw new Error(`Invalid view schema: '${getSchemaIdentifier(schema)}'`)
302
301
  }
303
302
  return {
304
- path: menuLevel === 0 ? `/${schema.path}` : schema.path,
303
+ path: schema.fullPath,
305
304
  children,
306
305
  component,
307
306
  meta: {
@@ -343,10 +342,13 @@ export function processNestedSchemaDefaults(api, schema) {
343
342
  })
344
343
  }
345
344
 
346
- export function processRouteSchema(api, schema, name) {
345
+ export function processRouteSchema(api, schema, name, fullPath = null) {
347
346
  // Used for view and source schemas, see SourceMixin.
348
347
  schema.name ??= name
349
348
  schema.path ??= api.normalizePath(name)
349
+ if (fullPath !== null) {
350
+ schema.fullPath = `${fullPath}/${schema.path}`
351
+ }
350
352
  }
351
353
 
352
354
  export async function processForms(api, schema, level) {
@@ -466,8 +468,8 @@ export function getViewEditPath(schema, id, context) {
466
468
  const view = getViewSchema(schema, context)
467
469
  if (view) {
468
470
  const path = isSingleComponentView(view)
469
- ? `/${view.path}`
470
- : `/${view.path}/${view.path}`
471
+ ? view.fullPath
472
+ : `${view.fullPath}/${view.path}`
471
473
  return `${path}/${id}`
472
474
  }
473
475
  return null
@@ -1028,14 +1030,14 @@ export function getAllPanelEntries(
1028
1030
  api,
1029
1031
  schema,
1030
1032
  dataPath = null,
1031
- schemaComponent = null,
1033
+ component = null,
1032
1034
  tabComponent = null
1033
1035
  ) {
1034
1036
  const panelSchema = getTypeOptions(schema)?.getPanelSchema?.(
1035
1037
  api,
1036
1038
  schema,
1037
1039
  dataPath,
1038
- schemaComponent
1040
+ component
1039
1041
  )
1040
1042
  const panelEntries = panelSchema
1041
1043
  ? [getPanelEntry(panelSchema, dataPath, tabComponent)]