waibu-db 2.21.2 → 2.21.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.
|
@@ -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