waibu-db 2.16.0 → 2.16.1

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.
@@ -67,16 +67,13 @@ async function btnExport () {
67
67
  let items = []
68
68
  let checker = false
69
69
  const keys = []
70
- const types = []
71
70
  let els = document.querySelectorAll(selector + ' thead th')
72
71
  for (const el of els) {
73
72
  keys.push(this.options.includes('fkey') ? el.innerText : el.dataset.key)
74
- types.push(el.dataset.type)
75
73
  }
76
74
  if (_.isEmpty(keys[0])) {
77
75
  checker = true
78
76
  keys.shift()
79
- types.shift()
80
77
  }
81
78
  els = document.querySelectorAll(selector + ' tbody tr')
82
79
  for (const el of els) {
@@ -85,12 +82,7 @@ async function btnExport () {
85
82
  i = i + ''
86
83
  if (i === '0' && checker) return undefined
87
84
  if (this.options.includes('fvalue')) data.push(v.innerText)
88
- else {
89
- const type = types[parseInt(i)]
90
- let val = wmpa.parseValue(v.dataset.value, type)
91
- if (['datetime', 'date', 'time'].includes(type)) val = val.toISOString()
92
- data.push(val)
93
- }
85
+ else data.push(wmpa.parseValue(v.dataset.value, v.dataset.value))
94
86
  })
95
87
  const item = {}
96
88
  for (const i in keys) {
@@ -28,6 +28,7 @@ async function handleRo (attr = {}, prop = {}, widget = {}) {
28
28
 
29
29
  if (['object', 'array', 'text'].includes(prop.type)) {
30
30
  attr.style = 'min-height: 100px'
31
+ attr.readonly = true
31
32
  return await this.component.buildTag({ tag: 'formTextarea', attr, html: value })
32
33
  }
33
34
  return await this.component.buildTag({ tag: 'formPlaintext', attr, selfCosing: true, noEscape: true })
@@ -134,12 +134,10 @@ async function table () {
134
134
  let prop = find(schema.properties, { name: f })
135
135
  if (!prop) prop = find(schema.view.calcFields, { name: f })
136
136
  if (!prop) continue
137
- let dataValue = d._orig[f] ?? ''
138
- if (!isEmpty(dataValue)) {
139
- if (['datetime'].includes(prop.type)) dataValue = escape(dataValue.toISOString())
140
- if (['string', 'text'].includes(prop.type)) dataValue = escape(dataValue)
141
- if (['array', 'object'].includes(prop.type)) dataValue = escape(JSON.stringify(d[f]))
142
- }
137
+ let dataValue = d._orig[f]
138
+ if (['datetime'].includes(prop.type)) dataValue = escape(dataValue.toISOString())
139
+ else if (['string', 'text'].includes(prop.type)) dataValue = escape(dataValue)
140
+ else if (['array', 'object'].includes(prop.type)) dataValue = escape(JSON.stringify(d[f]))
143
141
  const refName = get(schema, `view.widget.${f}.attr.refName`)
144
142
  let value = this.getRefValue({ field: f, data: d, refName }) ?? d[f]
145
143
  const formatValue = get(schema, `view.formatValue.${f}`)
@@ -1,11 +1,11 @@
1
1
  import { prepCrud, processHandler } from '../util.js'
2
2
 
3
- async function createRecord ({ model, req, reply, body, options = {}, transaction } = {}) {
4
- const { model: mdl, input, opts, attachment, stats, mimeType } = await prepCrud.call(this, { model, req, reply, body, options, args: ['model'], transaction })
3
+ async function createRecord ({ model, req, reply, options = {}, transaction } = {}) {
4
+ const { model: mdl, opts, attachment, stats, mimeType } = await prepCrud.call(this, { model, req, reply, options, args: ['model'], transaction })
5
5
 
6
6
  async function handler (trx) {
7
7
  if (opts.trx === true) opts.trx = trx
8
- const ret = await mdl.createRecord(input, opts)
8
+ const ret = await mdl.createRecord(req.body, { ...opts, partial: true, strict: true })
9
9
  if (attachment) ret.data._attachment = await mdl.findAttachment(ret.data.id, { stats, mimeType })
10
10
  return ret
11
11
  }
@@ -1,7 +1,7 @@
1
1
  import { prepCrud, getOneRecord, processHandler } from '../util.js'
2
2
 
3
3
  async function updateRecord ({ model, req, reply, id, body, options = {}, transaction } = {}) {
4
- const { model: mdl, filter, input, opts, recId, attachment, stats, mimeType } = await prepCrud.call(this, { model, req, reply, body, id, options, args: ['model', 'id'], transaction })
4
+ const { model: mdl, filter, opts, recId, attachment, stats, mimeType } = await prepCrud.call(this, { model, req, reply, id, options, args: ['model', 'id'], transaction })
5
5
  const me = this
6
6
 
7
7
  async function handler (trx) {
@@ -10,7 +10,7 @@ async function updateRecord ({ model, req, reply, id, body, options = {}, transa
10
10
  const resp = await getOneRecord.call(me, mdl, recId, filter, opts)
11
11
  opts._data = resp.data
12
12
  }
13
- const ret = await mdl.updateRecord(recId, input, opts)
13
+ const ret = await mdl.updateRecord(recId, body ?? req.body, { ...opts, partial: true, strict: true })
14
14
  if (attachment) ret.data._attachment = await mdl.findAttachment(id, { stats, mimeType })
15
15
  return ret
16
16
  }
package/lib/util.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export const actions = ['countRecord', 'createAggregate', 'createHistogram', 'createRecord', 'findAllRecord', 'findOneRecord', 'findRecord', 'getRecord', 'removeRecord', 'updateRecord']
2
2
 
3
- export async function prepCrud ({ model, body, id, req, reply, transaction, options = {}, args } = {}) {
3
+ export async function prepCrud ({ model, id, req, reply, transaction, options = {}, args } = {}) {
4
4
  const { isSet } = this.app.lib.aneka
5
5
  const { importModule } = this.app.bajo
6
6
  const { parseFilter } = this.app.waibu
@@ -42,8 +42,6 @@ export async function prepCrud ({ model, body, id, req, reply, transaction, opti
42
42
  model = model ?? pascalCase(params.model)
43
43
  mdl = this.app.dobo.getModel(model)
44
44
  }
45
- const input = await mdl.sanitizeBody({ body: body ?? params.body, partial: true, strict: true })
46
-
47
45
  opts.bboxLatField = req.query[cfgWeb.qsKey.bboxLatField]
48
46
  opts.bboxLngField = req.query[cfgWeb.qsKey.bboxLngField]
49
47
  const filter = parseFilter(req)
@@ -54,7 +52,7 @@ export async function prepCrud ({ model, body, id, req, reply, transaction, opti
54
52
  if (options.limit) filter.limit = options.limit
55
53
  if (options.sort) filter.sort = options.sort
56
54
  if (options.page) filter.page = options.page
57
- return { model: mdl, recId, input, opts, filter, attachment, stats, mimeType }
55
+ return { model: mdl, recId, opts, filter, attachment, stats, mimeType }
58
56
  }
59
57
 
60
58
  export async function getOneRecord (model, id, filter, options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waibu-db",
3
- "version": "2.16.0",
3
+ "version": "2.16.1",
4
4
  "description": "DB Helper",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/wiki/CHANGES.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changes
2
2
 
3
+ ## 2026-04-16
4
+
5
+ - [2.16.1] Bug fix in ```WdbBtnExport``` widget
6
+ - [2.16.1] Bug fix in ```WdbForm``` widget
7
+ - [2.16.1] Bug fix in ```WdbTable``` widget
8
+ - [2.16.1] Bug fix in ```prepCrud()```
9
+ - [2.16.1] Bug fix in ```createRecord()```
10
+ - [2.16.1] Bug fix in ```updateRecord()```
11
+
3
12
  ## 2026-04-13
4
13
 
5
14
  - [2.16.0] Add ```oldData``` propety to ```WdbBase``` widget