waibu-db 2.16.2 → 2.16.3

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.
@@ -1,3 +1,5 @@
1
+ <% if (schema && schema.attachment) { %>
1
2
  <c:fieldset <%= schema.view.card === false ? '' : 'card' %> t:legend="attachment" grid-gutter="3">
2
3
  <!-- include waibuDb.partial:/crud/_list-attachment.html|<%= JSON.stringify({ readonly: true }) %> -->
3
4
  </c:fieldset>
5
+ <% } %>
@@ -11,11 +11,11 @@ async function form () {
11
11
  static async handleRw ({ attr = {}, prop = {}, widget = {} } = {}) {
12
12
  const { get, has } = this.app.lib._
13
13
  const { stringifyAttribs } = this.app.waibuMpa
14
- if (has(attr, 'name') && !has(attr, 'value')) {
15
- attr.value = widget.component === 'form-plaintext' ? get(this, `oldData.${attr.name}`, attr.dataValue) : attr.dataValue
16
- }
17
14
  attr.dataType = prop.type
18
15
  const cmp = prop.ref ? 'wdb-lookup-select' : widget.component
16
+ if (has(attr, 'name') && !has(attr, 'value')) {
17
+ attr.value = cmp === 'form-plaintext' ? get(this, `oldData.${attr.name}`, attr.dataValue) : attr.dataValue
18
+ }
19
19
  return `<c:${cmp} ${stringifyAttribs(attr)} />`
20
20
  }
21
21
 
@@ -127,9 +127,9 @@ async function table () {
127
127
  if (!prop) prop = find(schema.view.calcFields, { name: f })
128
128
  if (!prop) continue
129
129
  let dataValue = d._orig[f]
130
- if (['datetime'].includes(prop.type)) dataValue = escape(dataValue.toISOString())
130
+ if (['datetime'].includes(prop.type) && dataValue) dataValue = escape(dataValue.toISOString())
131
131
  else if (['string', 'text'].includes(prop.type)) dataValue = escape(dataValue)
132
- else if (['array', 'object'].includes(prop.type)) dataValue = escape(JSON.stringify(d[f]))
132
+ else if (['array', 'object'].includes(prop.type)) dataValue = escape(JSON.stringify(dataValue))
133
133
  const refName = get(schema, `view.widget.${f}.attr.refName`)
134
134
  let value = this.getRefValue({ field: f, data: d, refName }) ?? d[f]
135
135
  const formatValue = get(schema, `view.formatValue.${f}`)
@@ -13,11 +13,17 @@ async function addHandler ({ req, reply, model, params = {}, template, addOnsHan
13
13
  opts.fields = schema.view.fields
14
14
  delete req.query.query
15
15
  let def = {}
16
- if (req.method === 'GET' && req.query.mode === 'clone' && req.query.id) {
17
- const resp = await getRecord({ model, req, id: req.query.id, options: { fields: map(schema.properties, 'name'), ...opts } })
18
- def = omit(resp.data._orig, ['id', 'createdAt', 'updatedAt'])
16
+ if (req.method === 'GET') {
17
+ const omitted = ['id', 'createdAt', 'updatedAt']
18
+ if (req.query.mode === 'clone' && req.query.id) {
19
+ const resp = await getRecord({ model, req, id: req.query.id, options: { fields: map(schema.properties, 'name'), ...opts } })
20
+ def = omit(resp.data._orig, omitted)
21
+ } else {
22
+ const picked = map(schema.properties, 'name')
23
+ def = omit(pick(req.query, picked), omitted)
24
+ }
19
25
  }
20
- let form = defaultsDeep(req.body, def)
26
+ let form = defaultsDeep({}, req.body, def)
21
27
  let error
22
28
  let resp
23
29
  if (req.method === 'POST') {
@@ -27,7 +27,7 @@ async function editHandler ({ req, reply, model, id, params = {}, template, addO
27
27
  for (const k in def) {
28
28
  if (isArray(def[k]) || isPlainObject(def[k])) def[k] = JSON.stringify(def[k])
29
29
  }
30
- form = defaultsDeep(req.body, def)
30
+ form = defaultsDeep({}, req.body, def)
31
31
  if (req.method !== 'GET') {
32
32
  form = omit(form, ['_action', '_value'])
33
33
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waibu-db",
3
- "version": "2.16.2",
3
+ "version": "2.16.3",
4
4
  "description": "DB Helper",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/wiki/CHANGES.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changes
2
2
 
3
+ ## 2026-04-18
4
+
5
+ - [2.16.3] Bug fix in ```WdbForm``` widget
6
+ - [2.16.3] Bug fix in ```WdbTable``` widget
7
+ - [2.16.3] Bug fix in ```add-handler.js``` module
8
+ - [2.16.3] Bug fix in ```edit-handler.js``` module
9
+
3
10
  ## 2026-04-17
4
11
 
5
12
  - [2.16.2] Bug fix in ```WdbTable``` widget