waibu-db 2.19.0 → 2.20.0

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.
@@ -140,6 +140,7 @@ async function table () {
140
140
  const noWrap = this.isNoWrap(f, schema, group.body.nowrap) ? 'nowrap' : ''
141
141
  if (this.isRightAligned(f, schema)) attr.text = `align:end ${noWrap}`
142
142
  else attr.text = `${noWrap}`
143
+ if (d._immutable) attr.text += ' color:body-tertiary'
143
144
  const format = get(schema, `view.format.${f}`)
144
145
  if (format) value = await format.call(this, value, d, { params: this.params, req })
145
146
  if (!get(schema, 'view.noEscape', []).includes(f) && !isHtmlLink(value)) value = escape(value)
@@ -21,7 +21,7 @@ async function lookupSelect () {
21
21
  }
22
22
 
23
23
  this.params.attr.url = this.params.attr.url ?? `waibuDb.restapi:/lookup/${kebabCase(ref.model)}`
24
- const keys = ['url', 'searchField', 'labelField', 'valueField']
24
+ const keys = ['url', 'searchField', 'labelField', 'valueField', 'allowCreate']
25
25
  const attr = omit(this.params.attr, keys)
26
26
  for (const k of keys) {
27
27
  attr[camelCase(`remote ${k}`)] = this.params.attr[k] ?? ref[k] ?? ref.field
@@ -37,6 +37,7 @@ function getCommons (action, schema, ext, options = {}) {
37
37
  if (schema.disabled.length > 0) schema.view.disabled.push(...schema.disabled)
38
38
  let fields = []
39
39
  for (const f of forFields) {
40
+ if (['_immutable'].includes(f)) continue
40
41
  if (allFields.includes(f)) fields.push(f)
41
42
  }
42
43
  fields = uniq(without(fields, ...hidden))
@@ -95,10 +96,11 @@ function applyLayout (action, schema, ext) {
95
96
  const prop = find(schema.properties, { name: f })
96
97
  if (!prop) continue
97
98
  const result = schema.view.widget[f] ?? {}
99
+ const orgCmp = result.component
98
100
  result.name = result.name ?? f
99
101
  result.attr = defaultsDeep(result.attr, { col: '4-md', label: `field.${f}` })
100
102
  const orgCol = result.attr.col
101
- if (!prop.ref && ['array', 'object', 'text'].includes(prop.type)) {
103
+ if (!prop.ref && ['object', 'text'].includes(prop.type)) {
102
104
  result.attr.col = '12'
103
105
  result.component = 'form-textarea'
104
106
  result.attr.rows = '3'
@@ -107,26 +109,28 @@ function applyLayout (action, schema, ext) {
107
109
  result.component = 'form-plaintext'
108
110
  result.attr.col = orgCol
109
111
  } else {
112
+ if (prop.type === 'array') {
113
+ result.component = 'form-select-ext'
114
+ result.attr.multiple = true
115
+ result.attr.allowCreate = true
116
+ }
117
+ if (prop.type === 'boolean') {
118
+ result.component = orgCmp ?? 'form-select'
119
+ result.attr.options = 'false:no;true:yes'
120
+ }
110
121
  if (prop.ref) {
111
- result.component = result.component ?? 'wdb-lookup-select'
122
+ result.component = orgCmp ?? 'wdb-lookup-select'
112
123
  if (prop.type === 'array') {
113
124
  result.attr.multiple = true
114
- result.attr.removeBtn = true
115
125
  }
116
126
  }
117
- if (prop.type === 'boolean') {
118
- result.component = result.component ?? 'form-select'
119
- result.attr.options = 'false:no;true:yes'
120
- }
121
127
  if (prop.values) {
122
- const orgCmp = result.component
123
128
  result.component = orgCmp ?? 'form-select'
124
129
  if (prop.type === 'array') {
125
130
  result.component = 'form-select-ext'
126
131
  result.attr.multiple = true
127
- result.attr.col = orgCol
128
132
  result.attr.removeBtn = true
129
- delete result.attr.rows
133
+ delete result.attr.allowCreate
130
134
  }
131
135
  if (typeof prop.values === 'string') result.attr.options = prop.values
132
136
  else result.attr.options = prop.values.map(item => `${item.value}:${item.text}`).join(';')
package/lib/util.js CHANGED
@@ -78,7 +78,7 @@ export async function processHandler ({ action, model, handler, options } = {})
78
78
  }
79
79
 
80
80
  try {
81
- if (options.trx === true) return await model.transaction(handler)
81
+ if (options.trx === true) return await model.transaction(handler, action, options)
82
82
  return await handler()
83
83
  } catch (err) {
84
84
  if (options.suppressError.includes(action)) return suppressedReturn.call(this, err)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waibu-db",
3
- "version": "2.19.0",
3
+ "version": "2.20.0",
4
4
  "description": "DB Helper",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/wiki/CHANGES.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changes
2
2
 
3
+ ## 2026-05-16
4
+
5
+ - [2.20.0] Change to ```wdb-data-table``` widget to handle immutable rows
6
+ - [2.20.0] Change to ```wdb-lookup-select``` widget to allow new value creation
7
+ - [2.20.0] Change to ```getSchemaExt()``` to allow auto widget creation
8
+
3
9
  ## 2026-05-11
4
10
 
5
11
  - [2.19.0] Updates to match ```dobo@2.23.0``` specs