waibu-bootstrap 2.9.0 → 2.9.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.
|
@@ -6,6 +6,14 @@ async function getInputAttr (group, formControl = true, ro) {
|
|
|
6
6
|
const { req } = this.component
|
|
7
7
|
const { escape } = this.app.waibu
|
|
8
8
|
|
|
9
|
+
const buildOptions = (v, prop) => {
|
|
10
|
+
if (isString(v)) v = { value: v, text: v }
|
|
11
|
+
const { camelCase } = this.app.lib._
|
|
12
|
+
const key = camelCase(`${prop.name} ${v.text}`)
|
|
13
|
+
if (req.te(key)) v.text = req.t(key)
|
|
14
|
+
return v
|
|
15
|
+
}
|
|
16
|
+
|
|
9
17
|
if (formControl) group._.class.push('form-control')
|
|
10
18
|
const attr = omit(group._, ['hint', 'label', 'wrapper'])
|
|
11
19
|
if (has(attr, 'name') && !has(attr, 'value')) {
|
|
@@ -14,20 +22,17 @@ async function getInputAttr (group, formControl = true, ro) {
|
|
|
14
22
|
const prop = this.getProp(attr.name)
|
|
15
23
|
attr.dataType = attr.dataType ?? prop.type
|
|
16
24
|
attr.dataValue = this.formData[attr.name]
|
|
17
|
-
if (isPlainObject(attr.dataValue) || isArray(attr.dataValue)) attr.dataValue = JSON.stringify(attr.dataValue)
|
|
18
|
-
// attr.value = escape(get(this.formData, `_fmt.${attr.name}`, attr.dataValue))
|
|
19
|
-
attr.dataValue = escape(attr.dataValue)
|
|
20
|
-
attr.value = attr.dataValue
|
|
21
25
|
if (prop.values) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
attr.
|
|
26
|
+
attr.options = (isString(prop.values) ? await callHandler(prop.values) : [...prop.values]).map(v => buildOptions(v, prop))
|
|
27
|
+
} else if (isPlainObject(attr.dataValue)) {
|
|
28
|
+
attr.dataValue = JSON.stringify(attr.dataValue)
|
|
29
|
+
attr.value = attr.dataValue
|
|
30
|
+
} else if (isArray(attr.dataValue)) {
|
|
31
|
+
attr.options = attr.dataValue.map(v => buildOptions(v, prop))
|
|
32
|
+
} else {
|
|
33
|
+
attr.value = attr.dataValue
|
|
30
34
|
}
|
|
35
|
+
attr.dataValue = escape(attr.dataValue)
|
|
31
36
|
}
|
|
32
37
|
}
|
|
33
38
|
if (sizes.includes(attr.size) && formControl) attr.class.push(`form-control-${attr.size}`)
|
|
@@ -133,6 +138,7 @@ export async function buildFormSelect (group, params) {
|
|
|
133
138
|
const { $ } = this.component
|
|
134
139
|
const { unescape } = this.app.waibu
|
|
135
140
|
let attr = await getInputAttr.call(this, group, false)
|
|
141
|
+
if (attr.remoteUrl) delete attr.options
|
|
136
142
|
try {
|
|
137
143
|
attr.dataValue = JSON.parse(unescape(attr.dataValue)).join('|')
|
|
138
144
|
} catch (err) {}
|
|
@@ -25,13 +25,20 @@ async function formSelectExt () {
|
|
|
25
25
|
this.params.attr.id = this.params.attr.id ?? generateId('alpha')
|
|
26
26
|
this.params.attr['x-ref'] = xref
|
|
27
27
|
const xData = ['instance: null', 'value: null']
|
|
28
|
-
const plugins =
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (this.params.attr.
|
|
32
|
-
if (this.params.attr.
|
|
28
|
+
const plugins = {
|
|
29
|
+
drag_drop: {}
|
|
30
|
+
}
|
|
31
|
+
if (!this.params.attr.noDropdownInput) plugins.dropdown_input = {}
|
|
32
|
+
// if (this.params.attr.removeBtn) plugins.remove_button = {}
|
|
33
|
+
if (this.params.attr.clearBtn) plugins.clear_button = {}
|
|
34
|
+
if (this.params.attr.optgroupColumns) plugins.optgroup_columns = {}
|
|
35
|
+
if (this.params.attr.multiple) {
|
|
36
|
+
plugins.checkbox_options = {}
|
|
37
|
+
plugins.clear_button = {}
|
|
38
|
+
}
|
|
33
39
|
if (this.params.attr.noCaret) this.params.attr.class.push('no-caret') // TODO: no caret remove caret on ALL instances, need to make it instance specific
|
|
34
40
|
let opts = { plugins }
|
|
41
|
+
if (this.params.attr.allowCreate) opts.create = true
|
|
35
42
|
let cOpts = {}
|
|
36
43
|
if (this.params.attr.cOpts) {
|
|
37
44
|
try {
|
|
@@ -124,6 +131,11 @@ async function formSelectExt () {
|
|
|
124
131
|
})
|
|
125
132
|
}
|
|
126
133
|
`
|
|
134
|
+
} else {
|
|
135
|
+
text += `if (!_.isEmpty(this.value)) {
|
|
136
|
+
if (!_.isArray(this.value)) this.value = [this.value]
|
|
137
|
+
this.instance.setValue(this.value)
|
|
138
|
+
}`
|
|
127
139
|
}
|
|
128
140
|
text += '}'
|
|
129
141
|
xData.push(text)
|
|
@@ -131,6 +143,7 @@ async function formSelectExt () {
|
|
|
131
143
|
// this.params.attr['@load.window'] = 'onLoad()'
|
|
132
144
|
this.params.attr['x-init'] = 'onLoad()'
|
|
133
145
|
await build.call(this, buildFormSelect, this.params)
|
|
146
|
+
/*
|
|
134
147
|
let options = []
|
|
135
148
|
if (this.params.attr.options) {
|
|
136
149
|
try {
|
|
@@ -140,6 +153,7 @@ async function formSelectExt () {
|
|
|
140
153
|
}
|
|
141
154
|
}
|
|
142
155
|
if (options.length > 0) this.params.attr.options = options
|
|
156
|
+
*/
|
|
143
157
|
this.params.attr = omit(this.params.attr, ['noDropdownInput', 'removeBtn', 'clearBtn', 'c-opts', 'remoteUrl', 'remoteSearchField', 'remoteLabelField', 'remoteValueField', 'remoteQuery', 'remoteApiKey'])
|
|
144
158
|
}
|
|
145
159
|
}
|
package/package.json
CHANGED