waibu-bootstrap 2.6.3 → 2.6.4
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.
|
@@ -28,8 +28,8 @@ async function getInputAttr (group, formControl = true, ro) {
|
|
|
28
28
|
else attr.dataValue = val
|
|
29
29
|
if (ro) {
|
|
30
30
|
if (attr.ref) {
|
|
31
|
-
const [ref,
|
|
32
|
-
attr.value = get(this, `component.locals.form._ref.${ref}.${
|
|
31
|
+
const [ref, field = 'id'] = attr.ref.split(':')
|
|
32
|
+
attr.value = get(this, `component.locals.form._ref.${ref}.${field}`, val)
|
|
33
33
|
} else if (attr.dataType === 'boolean') attr.value = req.t(val ? 'true' : 'false')
|
|
34
34
|
else if (has(attr, 'name') === 'lat') attr.value = escape(req.format(val, attr.dataType, { latitude: true }))
|
|
35
35
|
else if (has(attr, 'name') === 'lng') attr.value = escape(req.format(val, attr.dataType, { longitude: true }))
|
|
@@ -151,9 +151,10 @@ export async function buildFormTextarea (group, params) {
|
|
|
151
151
|
|
|
152
152
|
export async function buildFormSelect (group, params) {
|
|
153
153
|
const { omit, trim } = this.app.lib._
|
|
154
|
+
const { isSet } = this.app.lib.aneka
|
|
154
155
|
const { $ } = this.component
|
|
155
156
|
let attr = await getInputAttr.call(this, group, false)
|
|
156
|
-
attr.value = attr.value + ''
|
|
157
|
+
attr.value = isSet(attr.value) ? (attr.value + '') : undefined
|
|
157
158
|
attr.class.push('form-select')
|
|
158
159
|
let html = params.html
|
|
159
160
|
if (sizes.includes(attr.size)) attr.class.push(`form-select-${attr.size}`)
|
|
@@ -14,7 +14,7 @@ async function formSelectExt () {
|
|
|
14
14
|
|
|
15
15
|
build = async () => {
|
|
16
16
|
const { generateId } = this.app.lib.aneka
|
|
17
|
-
const { omit, merge, has } = this.app.lib._
|
|
17
|
+
const { omit, merge, has, isString } = this.app.lib._
|
|
18
18
|
const { routePath } = this.app.waibu
|
|
19
19
|
const { jsonStringify, groupAttrs } = this.app.waibuMpa
|
|
20
20
|
const { base64JsonDecode } = this.app.waibu
|
|
@@ -55,6 +55,13 @@ async function formSelectExt () {
|
|
|
55
55
|
group.remote.searchField = group.remote.searchField ?? 'id'
|
|
56
56
|
group.remote.labelField = group.remote.labelField ?? 'id'
|
|
57
57
|
group.remote.valueField = group.remote.valueField ?? 'id'
|
|
58
|
+
let query = `${group.remote.searchField}:~\\'{searchItem}\\'`
|
|
59
|
+
if (isString(group.remote.query)) {
|
|
60
|
+
const q = base64JsonDecode(group.remote.query)
|
|
61
|
+
const u = new URLSearchParams()
|
|
62
|
+
u.set('q', JSON.stringify(q))
|
|
63
|
+
query = u.toString().slice(2)
|
|
64
|
+
}
|
|
58
65
|
if (has(group.remote, 'apiKey')) {
|
|
59
66
|
if (group.remote.apiKey === true) fetchOpts.headers.Authorization = `Bearer ${apiKey}` // TODO: get it from wmpa
|
|
60
67
|
else fetchOpts.headers.Authorization = `Bearer ${group.remote.apiKey}`
|
|
@@ -63,8 +70,9 @@ async function formSelectExt () {
|
|
|
63
70
|
searchField: '${group.remote.searchField}',
|
|
64
71
|
labelField: '${group.remote.labelField}',
|
|
65
72
|
valueField: '${group.remote.valueField}',
|
|
66
|
-
load: (
|
|
67
|
-
|
|
73
|
+
load: (search, callback) => {
|
|
74
|
+
const query = '${query}'.replace('{searchItem}', search).replace('%7BsearchItem%7D', search)
|
|
75
|
+
fetch('${group.remote.url}?query=' + query, ${jsonStringify(fetchOpts, true)})
|
|
68
76
|
.then(resp => resp.json())
|
|
69
77
|
.then(json => {
|
|
70
78
|
callback(json.data)
|
|
@@ -88,6 +96,7 @@ async function formSelectExt () {
|
|
|
88
96
|
const opts = ${opts}
|
|
89
97
|
this.instance = new TomSelect($refs.${xref}, opts)
|
|
90
98
|
const val = $refs.${xref}.dataset.value
|
|
99
|
+
console.log(val)
|
|
91
100
|
if (!_.isEmpty(val)) {
|
|
92
101
|
this.value = val.split('|')
|
|
93
102
|
}
|
|
@@ -131,7 +140,7 @@ async function formSelectExt () {
|
|
|
131
140
|
// this.params.attr['@load.window'] = 'onLoad()'
|
|
132
141
|
this.params.attr['x-init'] = 'onLoad()'
|
|
133
142
|
if (options.length > 0) this.params.attr.options = options
|
|
134
|
-
this.params.attr = omit(this.params.attr, ['noDropdownInput', 'removeBtn', 'clearBtn', 'c-opts', 'remoteUrl', 'remoteSearchField', 'remoteLabelField', 'remoteValueField'])
|
|
143
|
+
this.params.attr = omit(this.params.attr, ['noDropdownInput', 'removeBtn', 'clearBtn', 'c-opts', 'remoteUrl', 'remoteSearchField', 'remoteLabelField', 'remoteValueField', 'remoteQuery', 'remoteApiKey'])
|
|
135
144
|
await build.call(this, buildFormSelect, this.params)
|
|
136
145
|
}
|
|
137
146
|
}
|
package/package.json
CHANGED