waibu-db 2.21.2 → 2.22.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.
|
@@ -25,7 +25,7 @@ async function table () {
|
|
|
25
25
|
const { groupAttrs } = this.app.waibuMpa
|
|
26
26
|
const { isHtmlLink } = this.app.bajoExtra
|
|
27
27
|
const { getTruncated } = this.app.bajoTemplate
|
|
28
|
-
const { get, omit, set, find, isEmpty, without, merge, intersection } = this.app.lib._
|
|
28
|
+
const { get, omit, set, find, isEmpty, without, merge, intersection, isPlainObject } = this.app.lib._
|
|
29
29
|
const { isSet } = this.app.lib.aneka
|
|
30
30
|
const group = groupAttrs(this.params.attr, ['body', 'head', 'foot'])
|
|
31
31
|
this.params.attr = group._
|
|
@@ -146,7 +146,10 @@ async function table () {
|
|
|
146
146
|
else attr.text = `${noWrap}`
|
|
147
147
|
if (d._immutable) attr.text += ' color:body-tertiary'
|
|
148
148
|
const format = get(schema, `view.format.${f}`)
|
|
149
|
-
if (format)
|
|
149
|
+
if (format) {
|
|
150
|
+
const formatted = await format.call(this, value, d, { params: this.params, req })
|
|
151
|
+
value = isPlainObject(formatted) ? `<a href="${formatted.href}">${formatted.value}</a>` : formatted
|
|
152
|
+
}
|
|
150
153
|
if (['object', 'array'].includes(prop.type) && !isHtmlLink(value)) value = getTruncated(value, 20) // TODO: should be handle by css instead
|
|
151
154
|
if (!get(schema, 'view.noEscape', []).includes(f) && !isHtmlLink(value)) value = escape(value)
|
|
152
155
|
const line = await this.component.buildTag({ tag: 'td', attr, html: value })
|
|
@@ -5,7 +5,7 @@ async function form () {
|
|
|
5
5
|
|
|
6
6
|
return class WdbForm extends WdbBase {
|
|
7
7
|
static async handleRo ({ attr = {}, prop = {}, widget = {} } = {}) {
|
|
8
|
-
return await this.component.buildTag({ tag: 'formPlaintext', attr, selfCosing: true, noEscape: true }, { prop, widget })
|
|
8
|
+
return await this.component.buildTag({ tag: 'formPlaintext', attr, addons: widget.addons, selfCosing: true, noEscape: true }, { prop, widget })
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
static async handleRw ({ attr = {}, prop = {}, widget = {} } = {}) {
|
|
@@ -15,12 +15,11 @@ 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'
|
|
19
18
|
return `<c:${widget.component} ${stringifyAttribs(attr)} />`
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
build = async () => {
|
|
23
|
-
const { get, find, filter, forOwn, isEmpty, omit } = this.app.lib._
|
|
22
|
+
const { get, find, filter, forOwn, isEmpty, omit, isArray } = this.app.lib._
|
|
24
23
|
const { base64JsonEncode } = this.app.waibu
|
|
25
24
|
const body = []
|
|
26
25
|
const xModels = get(this.schema, 'view.x.model', [])
|
|
@@ -51,11 +50,21 @@ async function form () {
|
|
|
51
50
|
attr[`@${o.bind}`] = o.handler
|
|
52
51
|
}
|
|
53
52
|
if (widget.componentOpts) attr['c-opts'] = base64JsonEncode(widget.componentOpts)
|
|
53
|
+
if (prop.virtual) widget.component = 'form-plaintext'
|
|
54
|
+
widget.addons = widget.addons ?? []
|
|
55
|
+
if (!isArray(widget.addons)) widget.addons = [widget.addons]
|
|
56
|
+
for (const ao of widget.addons) {
|
|
57
|
+
const tag = ao.type === 'button' ? 'btn' : 'formInputAddon'
|
|
58
|
+
ao.html = await this.component.buildTag({ tag, attr: ao.attr, html: ao.html })
|
|
59
|
+
ao.position = ao.position ?? 'append'
|
|
60
|
+
}
|
|
61
|
+
let html
|
|
54
62
|
if (widget.component === 'form-plaintext' || this.params.attr.method !== 'POST') {
|
|
55
|
-
|
|
63
|
+
html = await WdbForm.handleRo.call(this, { attr, prop, widget })
|
|
56
64
|
} else {
|
|
57
|
-
|
|
65
|
+
html = await WdbForm.handleRw.call(this, { attr, prop, widget })
|
|
58
66
|
}
|
|
67
|
+
body.push(html)
|
|
59
68
|
}
|
|
60
69
|
body.push('</c:fieldset>')
|
|
61
70
|
}
|
package/package.json
CHANGED
package/wiki/CHANGES.md
CHANGED