waibu-db 2.20.0 → 2.20.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.
|
@@ -5,11 +5,12 @@ async function btnColumns () {
|
|
|
5
5
|
|
|
6
6
|
return class WdbBtnColumns extends WdbBase {
|
|
7
7
|
build = async () => {
|
|
8
|
-
const { find, get, isEmpty, without } = this.app.lib._
|
|
8
|
+
const { find, get, isEmpty, without, intersection } = this.app.lib._
|
|
9
9
|
const { jsonStringify } = this.app.waibuMpa
|
|
10
10
|
const { req } = this.component
|
|
11
11
|
const qsKey = this.app.waibu.config.qsKey
|
|
12
12
|
const schema = get(this, 'component.locals.schema', {})
|
|
13
|
+
const data = get(this, 'component.locals.list.data', [])
|
|
13
14
|
const count = get(this, 'component.locals.list.count', 0)
|
|
14
15
|
if (count === 0) this.params.attr.triggerDisabled = true
|
|
15
16
|
if (schema.view.disabled.includes('find')) {
|
|
@@ -18,12 +19,13 @@ async function btnColumns () {
|
|
|
18
19
|
}
|
|
19
20
|
let fields = without(get(this, `component.locals._meta.query.${qsKey.fields}`, '').split(','), '')
|
|
20
21
|
if (isEmpty(fields)) fields = without(schema.view.fields, 'id')
|
|
22
|
+
const allFields = data.length > 0 ? intersection(schema.view.fields, Object.keys(data[0])) : []
|
|
21
23
|
const items = []
|
|
22
24
|
this.params.attr.color = this.params.attr.color ?? 'secondary-outline'
|
|
23
25
|
if (isEmpty(this.params.attr.content)) this.params.attr.content = req.t('columns')
|
|
24
26
|
for (const f of schema.view.fields) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
if (allFields.length > 0 && !allFields.includes(f)) continue
|
|
28
|
+
const prop = find(schema.properties, { name: f })
|
|
27
29
|
if (!prop) continue
|
|
28
30
|
const attr = { 'x-model': 'selected', label: req.t(get(schema, `view.label.${f}`, `field.${f}`)), value: f, labelText: 'nowrap' }
|
|
29
31
|
if (fields.includes(f)) attr.checked = true
|
|
@@ -24,7 +24,8 @@ async function table () {
|
|
|
24
24
|
const { escape, attrToArray } = this.app.waibu
|
|
25
25
|
const { groupAttrs } = this.app.waibuMpa
|
|
26
26
|
const { isHtmlLink } = this.app.bajoExtra
|
|
27
|
-
const {
|
|
27
|
+
const { getTruncated } = this.app.bajoTemplate
|
|
28
|
+
const { get, omit, set, find, isEmpty, without, merge, intersection } = this.app.lib._
|
|
28
29
|
const { isSet } = this.app.lib.aneka
|
|
29
30
|
const group = groupAttrs(this.params.attr, ['body', 'head', 'foot'])
|
|
30
31
|
this.params.attr = group._
|
|
@@ -48,6 +49,9 @@ async function table () {
|
|
|
48
49
|
const qsKey = this.app.waibu.config.qsKey
|
|
49
50
|
let fields = without(get(this, `component.locals._meta.query.${qsKey.fields}`, '').split(','), '')
|
|
50
51
|
if (isEmpty(fields)) fields = without(schema.view.fields, 'id')
|
|
52
|
+
if (data.length > 0) {
|
|
53
|
+
fields = intersection(fields, Object.keys(data[0]))
|
|
54
|
+
}
|
|
51
55
|
let sort = this.params.attr.sort ? attrToArray(this.params.attr.sort) : get(this, `component.locals._meta.query.${qsKey.sort}`, '')
|
|
52
56
|
if (isEmpty(sort) && filter.sort) {
|
|
53
57
|
const keys = Object.keys(filter.sort)
|
|
@@ -143,6 +147,7 @@ async function table () {
|
|
|
143
147
|
if (d._immutable) attr.text += ' color:body-tertiary'
|
|
144
148
|
const format = get(schema, `view.format.${f}`)
|
|
145
149
|
if (format) value = await format.call(this, value, d, { params: this.params, req })
|
|
150
|
+
if (['object', 'array'].includes(prop.type) && !isHtmlLink(value)) value = getTruncated(value, 20) // TODO: should be handle by css instead
|
|
146
151
|
if (!get(schema, 'view.noEscape', []).includes(f) && !isHtmlLink(value)) value = escape(value)
|
|
147
152
|
const line = await this.component.buildTag({ tag: 'td', attr, html: value })
|
|
148
153
|
lines.push(line)
|
|
@@ -4,8 +4,8 @@ async function form () {
|
|
|
4
4
|
const WdbBase = await wdbBase.call(this)
|
|
5
5
|
|
|
6
6
|
return class WdbForm extends WdbBase {
|
|
7
|
-
static async handleRo ({ attr = {}, prop = {} } = {}) {
|
|
8
|
-
return await this.component.buildTag({ tag: 'formPlaintext', attr, selfCosing: true, noEscape: true })
|
|
7
|
+
static async handleRo ({ attr = {}, prop = {}, widget = {} } = {}) {
|
|
8
|
+
return await this.component.buildTag({ tag: 'formPlaintext', attr, selfCosing: true, noEscape: true }, { prop, widget })
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
static async handleRw ({ attr = {}, prop = {}, widget = {} } = {}) {
|
|
@@ -44,6 +44,7 @@ async function form () {
|
|
|
44
44
|
if (v === true) attr[k] = true
|
|
45
45
|
else attr[k] = v
|
|
46
46
|
})
|
|
47
|
+
if (['array', 'object'].includes(prop.type)) attr.col = '12-md'
|
|
47
48
|
attr.label = this.component.req.t(attr.label)
|
|
48
49
|
const xon = filter(xOns, { field: widget.name })
|
|
49
50
|
for (const o of xon) {
|
package/index.js
CHANGED
|
@@ -129,9 +129,14 @@ async function factory (pkgName) {
|
|
|
129
129
|
menu.push({
|
|
130
130
|
title: req.t(k),
|
|
131
131
|
children: map(items, item => {
|
|
132
|
+
const params = {
|
|
133
|
+
model: kebabCase(item.name),
|
|
134
|
+
action: 'list'
|
|
135
|
+
}
|
|
132
136
|
return {
|
|
133
137
|
title: camelCase(item.name.slice(plugin.alias.length)),
|
|
134
|
-
href: `waibuAdmin:/${prefix}
|
|
138
|
+
href: `waibuAdmin:/${prefix}/:model/:action`,
|
|
139
|
+
params
|
|
135
140
|
}
|
|
136
141
|
})
|
|
137
142
|
})
|
package/package.json
CHANGED
package/wiki/CHANGES.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 2026-05-22
|
|
4
|
+
|
|
5
|
+
- [2.20.1] Bug fix in admin menu
|
|
6
|
+
- [2.20.1] Bug fix in ```wdb-btn-columns``` widget
|
|
7
|
+
- [2.20.1] Bug fix in ```wdb-data-table``` widget
|
|
8
|
+
- [2.20.1] Bug fix in ```wdb-form``` widget
|
|
9
|
+
|
|
3
10
|
## 2026-05-16
|
|
4
11
|
|
|
5
12
|
- [2.20.0] Change to ```wdb-data-table``` widget to handle immutable rows
|