waibu-bootstrap 2.6.2 → 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.
- package/extend/waibuMpa/theme/component/widget/_lib.js +4 -3
- package/extend/waibuMpa/theme/component/widget/form-date.js +2 -2
- package/extend/waibuMpa/theme/component/widget/form-datetime.js +29 -13
- package/extend/waibuMpa/theme/component/widget/form-select-ext.js +13 -4
- package/extend/waibuMpa/theme/component/widget/form-time.js +2 -2
- package/package.json +1 -1
- package/wiki/CHANGES.md +9 -0
|
@@ -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}`)
|
|
@@ -3,8 +3,8 @@ import { css, scripts, inlineScript, handler } from './form-datetime.js'
|
|
|
3
3
|
async function formDate () {
|
|
4
4
|
return class FormDate extends this.app.baseClass.MpaWidget {
|
|
5
5
|
static css = [...super.css, ...css]
|
|
6
|
-
static scripts =
|
|
7
|
-
static inlineScript = inlineScript
|
|
6
|
+
static scripts = scripts
|
|
7
|
+
static inlineScript = inlineScript
|
|
8
8
|
|
|
9
9
|
build = async () => {
|
|
10
10
|
const { set } = this.app.lib._
|
|
@@ -2,16 +2,21 @@ import { buildFormInput } from './_lib.js'
|
|
|
2
2
|
import { build } from './form-input.js'
|
|
3
3
|
|
|
4
4
|
export const css = ['waibuExtra.virtual:/tempusDominus/css/tempus-dominus.min.css']
|
|
5
|
-
export function scripts (
|
|
5
|
+
export function scripts (cls) {
|
|
6
|
+
const { isFunction } = this.app.lib._
|
|
6
7
|
const items = [
|
|
7
8
|
'waibuExtra.virtual:/popperjs/umd/popper.min.js',
|
|
8
9
|
'waibuExtra.virtual:/tempusDominus/js/tempus-dominus.min.js'
|
|
9
10
|
]
|
|
10
|
-
if (req.lang === 'id') items.push('waibuExtra.asset:/js/tempus-dominus-id.js')
|
|
11
|
-
|
|
11
|
+
if (this.req.lang === 'id') items.push('waibuExtra.asset:/js/tempus-dominus-id.js')
|
|
12
|
+
else if (this.req.lang !== 'en-US') items.push(`waibuExtra.virtual:/tempusDominus/locales/${this.req.lang}.js`)
|
|
13
|
+
|
|
14
|
+
if (isFunction(cls.scripts)) return items
|
|
15
|
+
return [...cls.scripts ?? [], ...items]
|
|
12
16
|
}
|
|
13
|
-
export function inlineScript (
|
|
14
|
-
const { jsonStringify } = this.app.waibuMpa
|
|
17
|
+
export function inlineScript (cls) {
|
|
18
|
+
const { jsonStringify } = this.plugin.app.waibuMpa
|
|
19
|
+
const { isFunction } = this.app.lib._
|
|
15
20
|
const opts = {
|
|
16
21
|
display: {
|
|
17
22
|
icons: {
|
|
@@ -28,24 +33,30 @@ export function inlineScript (req) {
|
|
|
28
33
|
components: {
|
|
29
34
|
seconds: true
|
|
30
35
|
},
|
|
31
|
-
theme: req.darkMode ? 'dark' : 'light'
|
|
36
|
+
theme: this.req.darkMode ? 'dark' : 'light'
|
|
32
37
|
},
|
|
33
38
|
localization: {
|
|
34
39
|
format: 'L LTS'
|
|
35
40
|
}
|
|
36
41
|
}
|
|
37
|
-
|
|
38
|
-
|
|
42
|
+
let items = [
|
|
43
|
+
`const tdGlobalOpts = ${jsonStringify(opts, true)}`
|
|
44
|
+
]
|
|
45
|
+
if (this.req.lang !== 'en-US') {
|
|
39
46
|
items.unshift(
|
|
40
|
-
|
|
41
|
-
|
|
47
|
+
`tempusDominus.loadLocale(tempusDominus.locales.${this.req.lang})`,
|
|
48
|
+
`tempusDominus.locale(tempusDominus.locales.${this.req.lang}.name)`
|
|
42
49
|
)
|
|
43
50
|
}
|
|
44
|
-
|
|
51
|
+
items = items.join('\n')
|
|
52
|
+
if (isFunction(cls.inlineScript)) return items
|
|
53
|
+
return (cls.inlineScript ?? '') + '\n' + items
|
|
45
54
|
}
|
|
46
55
|
|
|
47
56
|
export async function handler (opts, params = {}) {
|
|
48
57
|
const { jsonStringify } = this.app.waibuMpa
|
|
58
|
+
const { generateId } = this.app.lib.aneka
|
|
59
|
+
this.params.attr.id = generateId('alpha')
|
|
49
60
|
this.params.attr['x-ref'] = 'self'
|
|
50
61
|
this.params.attr['x-data'] = `{
|
|
51
62
|
instance: null,
|
|
@@ -54,6 +65,11 @@ export async function handler (opts, params = {}) {
|
|
|
54
65
|
this.params.attr['@load.window'] = `
|
|
55
66
|
const options = _.merge({}, tdGlobalOpts, opts ?? {})
|
|
56
67
|
instance = new tempusDominus.TempusDominus($refs.self, options)
|
|
68
|
+
instance.subscribe(tempusDominus.Namespace.events.change, (e) => {
|
|
69
|
+
if (e.type === 'change.td') {
|
|
70
|
+
$dispatch('input', instance.dates.lastPicked.toISOString())
|
|
71
|
+
}
|
|
72
|
+
})
|
|
57
73
|
`
|
|
58
74
|
await build.call(this, buildFormInput, this.params)
|
|
59
75
|
}
|
|
@@ -61,8 +77,8 @@ export async function handler (opts, params = {}) {
|
|
|
61
77
|
async function formDatetime () {
|
|
62
78
|
return class FormDatetime extends this.app.baseClass.MpaWidget {
|
|
63
79
|
static css = [...super.css, ...css]
|
|
64
|
-
static scripts =
|
|
65
|
-
static inlineScript = inlineScript
|
|
80
|
+
static scripts = scripts
|
|
81
|
+
static inlineScript = inlineScript
|
|
66
82
|
|
|
67
83
|
build = async () => {
|
|
68
84
|
const { set } = this.app.lib._
|
|
@@ -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
|
}
|
|
@@ -3,8 +3,8 @@ import { css, scripts, inlineScript, handler } from './form-datetime.js'
|
|
|
3
3
|
async function formTime () {
|
|
4
4
|
return class FormTime extends this.app.baseClass.MpaWidget {
|
|
5
5
|
static css = [...super.css, ...css]
|
|
6
|
-
static scripts =
|
|
7
|
-
static inlineScript = inlineScript
|
|
6
|
+
static scripts = scripts
|
|
7
|
+
static inlineScript = inlineScript
|
|
8
8
|
|
|
9
9
|
build = async () => {
|
|
10
10
|
const { set } = this.app.lib._
|
package/package.json
CHANGED
package/wiki/CHANGES.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 2026-04-07
|
|
4
|
+
|
|
5
|
+
- [2.6.4] Bug fix on widget ```form-select-ext```
|
|
6
|
+
- [2.6.4] Bug fix on ```buildFormSelect()```
|
|
7
|
+
|
|
8
|
+
## 2026-04-01
|
|
9
|
+
|
|
10
|
+
- [2.6.3] Bug fix on widget ```form-datetime```
|
|
11
|
+
|
|
3
12
|
## 2026-03-07
|
|
4
13
|
|
|
5
14
|
- [2.6.2] Bug fix on widget ```app-launcher-trigger```
|