waibu-db 2.18.1 → 2.18.2

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.
@@ -23,7 +23,7 @@ async function table () {
23
23
  const { req } = this.component
24
24
  const { escape, attrToArray } = this.app.waibu
25
25
  const { groupAttrs } = this.app.waibuMpa
26
- const { get, omit, set, find, isEmpty, without, merge } = this.app.lib._
26
+ const { get, omit, set, find, isEmpty, without, merge, isString } = this.app.lib._
27
27
  const group = groupAttrs(this.params.attr, ['body', 'head', 'foot'])
28
28
  this.params.attr = group._
29
29
  const prettyUrl = this.params.attr.prettyUrl
@@ -133,6 +133,10 @@ async function table () {
133
133
  let value = this.getRefValue({ field: f, data: d, refName }) ?? get(d, `_fmt.${f}`, d[f])
134
134
  if (!get(schema, 'view.noEscape', []).includes(f)) value = escape(value)
135
135
  const attr = { dataValue, dataKey: prop.name, dataType: prop.type }
136
+ if (isString(d[f]) && d[f].startsWith('<a ')) {
137
+ delete attr.dataValue
138
+ value = d[f]
139
+ }
136
140
  if (!disableds.includes('get')) attr.style = { cursor: 'pointer' }
137
141
  const formatCell = get(schema, `view.formatCell.${f}`)
138
142
  if (formatCell) merge(attr, await formatCell.call(this, value, d, { params: this.params, req }))
@@ -15,6 +15,7 @@ async function form () {
15
15
  if (has(attr, 'name') && !has(attr, 'value')) {
16
16
  attr.value = widget.component === 'form-plaintext' ? get(this, `oldData.${attr.name}`, attr.dataValue) : attr.dataValue
17
17
  }
18
+ if (prop.virtual) widget.component = 'form-plaintext'
18
19
  return `<c:${widget.component} ${stringifyAttribs(attr)} />`
19
20
  }
20
21
 
@@ -30,9 +31,9 @@ async function form () {
30
31
  body.push(`<c:fieldset ${this.schema.view.card === false ? '' : 'card'} ${l.name[0] !== '_' ? ('t:legend="' + l.name + '"') : ''} grid-gutter="2">`)
31
32
  for (const f of fields) {
32
33
  const widget = this.schema.view.widget[f]
33
- let prop = find(this.schema.properties, { name: f })
34
- if (!prop) prop = find(this.schema.view.calcFields, { name: f })
34
+ const prop = find(this.schema.properties, { name: f })
35
35
  if (!prop) continue
36
+ if (['dobo:image'].includes(prop.feature)) continue
36
37
  const attr = {
37
38
  'x-ref': widget.name,
38
39
  labelFloating: true,
@@ -2,10 +2,8 @@ import { attachmentHandler, notFoundTpl } from './helper.js'
2
2
 
3
3
  async function editHandler ({ req, reply, model, id, params = {}, template, addOnsHandler, templateDisabled = 'waibuDb.template:/disabled.html', options = {} } = {}) {
4
4
  const { pascalCase } = this.app.lib.aneka
5
- const { getPluginDataDir } = this.app.bajo
6
5
  const { updateRecord, getRecord, getSchemaExt } = this.app.waibuDb
7
6
  const { buildUrl } = this.app.waibuMpa
8
- const { fs } = this.app.lib
9
7
  const { defaultsDeep } = this.app.lib.aneka
10
8
  const { merge, isEmpty, omit, cloneDeep, isArray, isPlainObject } = this.app.lib._
11
9
  const opts = merge({}, options.modelOpts)
@@ -34,12 +32,12 @@ async function editHandler ({ req, reply, model, id, params = {}, template, addO
34
32
  req.body._value = JSON.parse(req.body._value)
35
33
  } catch (err) {}
36
34
  if (req.body._action === 'removeatt' && !isEmpty(req.body._value)) {
37
- const root = `${getPluginDataDir('dobo')}/attachment`
38
35
  for (const item of req.body._value) {
39
36
  try {
40
- const file = `${root}/${item}`
41
- await fs.unlink(file)
42
- } catch (err) {}
37
+ const [,,, field, fname] = item.split('/')
38
+ await mdl.removeAttachment(id, field, fname)
39
+ } catch (err) {
40
+ }
43
41
  }
44
42
  if (req && req.flash) req.flash('notify', req.t('attachmentRemoved'))
45
43
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waibu-db",
3
- "version": "2.18.1",
3
+ "version": "2.18.2",
4
4
  "description": "DB Helper",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/wiki/CHANGES.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changes
2
2
 
3
+ ## 2026-05-02
4
+
5
+ - [2.18.2] Bug fix in ```wdb-data-table``` widget
6
+ - [2.18.2] Bug fix in ```wdb-form``` widget
7
+
3
8
  ## 2026-04-25
4
9
 
5
10
  - [2.18.0] Change options to format value using the new key set by dobo