@ditojs/admin 2.2.7-debug.5 → 2.2.7

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.2.7-debug.5",
3
+ "version": "2.2.7",
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",
@@ -82,7 +82,7 @@
82
82
  "vite": "^4.3.1"
83
83
  },
84
84
  "types": "types",
85
- "gitHead": "a7d0c07bd2b065bbd103e9bcd73ecaa91a1f58e8",
85
+ "gitHead": "9636ab2adc6d813af39097fe8d92ce7a00020f93",
86
86
  "scripts": {
87
87
  "build": "vite build",
88
88
  "watch": "yarn build --mode 'development' --watch",
@@ -330,16 +330,6 @@ export default DitoComponent.component('DitoSchema', {
330
330
  }
331
331
  },
332
332
 
333
- watch: {
334
- schema() {
335
- console.log('DitoSchema: schema changed', this.dataPath)
336
- },
337
-
338
- data() {
339
- console.log('DitoSchema: data changed', this.dataPath)
340
- }
341
- },
342
-
343
333
  created() {
344
334
  this._register(true)
345
335
  this.setupSchemaFields()
@@ -15,7 +15,7 @@ import DitoContext from '../DitoContext.js'
15
15
  import EmitterMixin from './EmitterMixin.js'
16
16
  import { isMatchingType, convertType } from '../utils/type.js'
17
17
  import { getResource, getMemberResource } from '../utils/resource.js'
18
- import { reactive } from 'vue'
18
+ import { computed, reactive } from 'vue'
19
19
 
20
20
  // @vue/component
21
21
  export default {
@@ -433,17 +433,25 @@ export default {
433
433
  },
434
434
 
435
435
  setupComputed() {
436
- for (const [key, value] of Object.entries(this.schema.computed || {})) {
437
- const accessor = isFunction(value)
438
- ? { get: value }
439
- : isObject(value) && isFunction(value.get)
440
- ? value
436
+ const getComputedAccessor = ({ get, set }) => {
437
+ const getter = computed(() => get.call(this))
438
+ return {
439
+ get: () => getter.value,
440
+ set: set ? value => set.call(this, value) : undefined
441
+ }
442
+ }
443
+
444
+ for (const [key, item] of Object.entries(this.schema.computed || {})) {
445
+ const accessor = isFunction(item)
446
+ ? getComputedAccessor({ get: item })
447
+ : isObject(item) && isFunction(item.get)
448
+ ? getComputedAccessor(item)
441
449
  : null
442
450
  if (accessor) {
443
451
  Object.defineProperty(this, key, accessor)
444
452
  } else {
445
453
  console.error(
446
- `Invalid computed property definition: ${key}: ${value}`
454
+ `Invalid computed property definition: ${key}: ${item}`
447
455
  )
448
456
  }
449
457
  }
@@ -3,6 +3,7 @@ import ResourceMixin from './ResourceMixin.js'
3
3
  import SchemaParentMixin from '../mixins/SchemaParentMixin.js'
4
4
  import { getSchemaAccessor, getStoreAccessor } from '../utils/accessor.js'
5
5
  import { getMemberResource } from '../utils/resource.js'
6
+ import { replaceRoute } from '../utils/route.js'
6
7
  import {
7
8
  processRouteSchema,
8
9
  processForms,
@@ -25,7 +26,6 @@ import {
25
26
  parseDataPath,
26
27
  normalizeDataPath
27
28
  } from '@ditojs/utils'
28
- import { replaceRoute } from '../utils/route.js'
29
29
 
30
30
  // @vue/component
31
31
  export default {
@@ -44,7 +44,6 @@ export default {
44
44
  data() {
45
45
  return {
46
46
  wrappedPrimitives: null,
47
- ignoreRouteChange: false,
48
47
  unwrappingPrimitives: false
49
48
  }
50
49
  },
@@ -178,9 +177,6 @@ export default {
178
177
  ...query
179
178
  }
180
179
  if (!equals(query, this.$route.query)) {
181
- // Tell the `$route` watcher to ignore the changed triggered here:
182
- // this.ignoreRouteChange = true
183
- // this.$router.replace({ query, hash: this.$route.hash })
184
180
  // Change the route query parameters, but don't trigger a route
185
181
  // change, as that would cause the list to reload.
186
182
  replaceRoute({ query })
@@ -318,10 +314,6 @@ export default {
318
314
 
319
315
  watch: {
320
316
  $route(to, from) {
321
- if (this.ignoreRouteChange) {
322
- this.ignoreRouteChange = false
323
- return
324
- }
325
317
  if (from.path === to.path && from.hash === to.hash) {
326
318
  // Paths and hashes remain the same, so only queries have changed.
327
319
  // Update filter and reload data without clearing.
@@ -69,6 +69,7 @@ export default {
69
69
  : value
70
70
  // eslint-disable-next-line vue/no-mutating-props
71
71
  this.data[this.name] = this.parsedValue
72
+ this.changedValue = undefined
72
73
  }
73
74
  },
74
75
 
@@ -277,6 +278,7 @@ export default {
277
278
 
278
279
  clear() {
279
280
  this.value = null
281
+ this.changedValue = undefined
280
282
  this.onChange()
281
283
  },
282
284
 
@@ -293,7 +295,6 @@ export default {
293
295
  },
294
296
 
295
297
  onInput() {
296
- console.log('onInput()', this.name)
297
298
  this.markDirty()
298
299
  this.emitEvent('input')
299
300
  },
@@ -306,14 +307,10 @@ export default {
306
307
  // For some odd reason, the native change event now sometimes fires
307
308
  // twice on Vue3. Filter out second call.
308
309
  // TODO: Investigate why this happens, and if it's a bug in Vue3.
309
- if (value === this.changedValue) {
310
- console.log('onChange() double', this.name)
311
- return
312
- }
310
+ if (value === this.changedValue) return
313
311
  this.changedValue = value
314
312
  }
315
313
 
316
- console.log('onChange()', this.name, value)
317
314
  this.markDirty()
318
315
  this.emitEvent('change', {
319
316
  // Prevent endless parse recursion:
@@ -195,17 +195,10 @@ export default DitoTypeComponent.register('list', {
195
195
  },
196
196
  set query(query) {
197
197
  const component = getListComponent()
198
- console.log('set query', !!component)
199
198
  if (component) {
200
199
  // Filter out undefined values for comparing with equals()
201
200
  const filter = obj => pickBy(obj, value => value !== undefined)
202
- console.log(
203
- 'set query',
204
- JSON.stringify(filter(query)),
205
- JSON.stringify(filter(component.query))
206
- )
207
201
  if (!equals(filter(query), filter(component.query))) {
208
- console.log('load data')
209
202
  component.query = query
210
203
  component.loadData(false)
211
204
  }
@@ -67,7 +67,6 @@ export const filterComponents = {
67
67
  }
68
68
 
69
69
  export function createFiltersPanel(api, filters, dataPath, proxy) {
70
- console.log('createFiltersPanel()', dataPath)
71
70
  const { sticky, ...filterSchemas } = filters
72
71
  const panel = {
73
72
  type: 'panel',
@@ -110,13 +109,6 @@ export function createFiltersPanel(api, filters, dataPath, proxy) {
110
109
 
111
110
  methods: {
112
111
  applyFilters() {
113
- console.log(
114
- 'applyFilters()',
115
- JSON.stringify({
116
- filters: this.filters,
117
- data: this.data
118
- })
119
- )
120
112
  proxy.query = {
121
113
  ...proxy.query,
122
114
  filter: this.filters,
@@ -126,7 +118,6 @@ export function createFiltersPanel(api, filters, dataPath, proxy) {
126
118
  },
127
119
 
128
120
  clearFilters() {
129
- console.log('clearFilters()')
130
121
  this.resetData()
131
122
  this.applyFilters()
132
123
  }
@@ -212,13 +203,6 @@ function getComponentsForFilter(schema, name) {
212
203
  }
213
204
 
214
205
  function formatFiltersData(schema, data) {
215
- console.log(
216
- 'formatFiltersData()',
217
- JSON.stringify({
218
- data: data ?? null,
219
- schema: schema ? Object.keys(schema.components) : null
220
- })
221
- )
222
206
  const filters = []
223
207
  for (const name in data) {
224
208
  const entry = data[name]
@@ -233,7 +217,6 @@ function formatFiltersData(schema, data) {
233
217
  }
234
218
  }
235
219
  }
236
- console.log('formatFiltersData() =>', filters)
237
220
  return filters
238
221
  }
239
222