waibu-mpa 2.13.0 → 2.13.2

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.
@@ -37,6 +37,7 @@
37
37
  "404Title": "Page Not Found",
38
38
  "500Title": "Internal Server Error",
39
39
  "fullscreen": "Fullscreen",
40
+ "_blank_": "",
40
41
  "field": {
41
42
  "session": "Session",
42
43
  "expires": "Expires"
@@ -38,6 +38,7 @@
38
38
  "404Title": "Halaman Tidak Ditemukan",
39
39
  "500Title": "Kesalahan Internal Penyelia",
40
40
  "fullscreen": "Layar Penuh",
41
+ "_blank_": "",
41
42
  "field": {
42
43
  "session": "Sesi",
43
44
  "expires": "Kadaluarsa"
@@ -309,7 +309,8 @@ class Wmpa {
309
309
 
310
310
  parseValue = (value, type) => {
311
311
  try {
312
- if (['integer', 'smallint'].includes(type)) value = parseInt(value)
312
+ if (type === 'boolean') value = value === 'true'
313
+ else if (['integer', 'smallint'].includes(type)) value = parseInt(value)
313
314
  else if (['float', 'double'].includes(type)) value = parseFloat(value)
314
315
  else if (['datetime', 'date', 'time'].includes(type)) value = new Date(Date.parse(value))
315
316
  else if (['array', 'object'].includes(type)) value = JSON.parse(value)
package/index.js CHANGED
@@ -581,7 +581,7 @@ async function factory (pkgName) {
581
581
  v = v.join(kvDelimiter)
582
582
  if (trimValue) v = v.slice(1, v.length - 1)
583
583
  if (v === 'undefined') continue
584
- if (k !== 'content' && v === '') v = true
584
+ if (k !== 'content' && (v === '' || v === 'true')) v = true
585
585
  // check for retainAttrKey on ALL plugins
586
586
  let retain = false
587
587
  for (const name of names) {
@@ -27,11 +27,11 @@ async function meta (options) {
27
27
  await runHook(`${this.ns}.${theme.name}:afterInjectMeta`, { meta: theme.meta, items, req })
28
28
  }
29
29
  // title
30
- const formatter = get(this, 'app.waibuMpa.pageTitleFormat', '%s : %s')
30
+ const format = get(this, 'app.waibuMpa.pageTitleFormat', '%s : %s')
31
31
  const title = page.fullTitle ?? page.title
32
32
  let pageTitle
33
- if (isFunction(formatter)) pageTitle = await formatter.call(this, locals)
34
- else pageTitle = sprintf(formatter, title, this.app.waibuMpa.getAppTitle(req))
33
+ if (isFunction(format)) pageTitle = await format.call(this, locals)
34
+ else pageTitle = sprintf(format, title, this.app.waibuMpa.getAppTitle(req))
35
35
  $('head').append(`<title>${pageTitle}</title>`)
36
36
  // favicon
37
37
  const favicon = this.app.waibuMpa.config.favicon
@@ -207,7 +207,7 @@ async function componentFactory () {
207
207
  * @returns {string} The generated `<option>` elements.
208
208
  */
209
209
  buildOptions = async (params) => {
210
- const { isString, has, omit, find, isPlainObject, isArray, pick, camelCase, get } = this.app.lib._
210
+ const { isString, has, omit, find, isPlainObject, isArray, pick, camelCase, get, isEmpty } = this.app.lib._
211
211
  const { attrToArray } = this.app.waibu
212
212
  const { getMethod, callHandler } = this.app.bajo
213
213
  let prop = {}
@@ -217,7 +217,10 @@ async function componentFactory () {
217
217
  const items = []
218
218
  let input = params.attr.options
219
219
  let values = attrToArray(params.attr.value)
220
- if (!has(params.attr, 'multiple') && values.length > 0) values = [values[0]]
220
+ if (!has(params.attr, 'multiple')) {
221
+ if (values.length > 0) values = [values[0]]
222
+ else if (prop.default) values = [prop.default]
223
+ }
221
224
  let options = []
222
225
  if (isString(input)) {
223
226
  if (getMethod(input, false)) {
@@ -240,10 +243,11 @@ async function componentFactory () {
240
243
  return { value: item, text: (item + '') }
241
244
  })
242
245
  }
246
+ if (!isEmpty(prop) && !prop.required) options.unshift({ value: '', text: '_blank_' })
243
247
  for (const opt of options) {
244
248
  const sel = find(values, v => opt.value === v)
245
249
  const ttext = camelCase(`${prop.name} ${opt.text}`)
246
- items.push(`<option value="${opt.value}"${sel ? ' selected' : ''}>${this.req.te(ttext) ? this.req.t(ttext) : (opt.text ?? opt.value)}</option>`)
250
+ items.push(`<option value="${opt.value}"${sel ? ' selected' : ''}>${this.req.te(ttext) ? this.req.t(ttext) : this.req.t(opt.text)}</option>`)
247
251
  }
248
252
  params.attr = omit(params.attr, ['options'])
249
253
  return items.join('\n')
@@ -1,6 +1,7 @@
1
1
  import path from 'path'
2
2
 
3
3
  async function widgetFactory () {
4
+ const { kebabCase } = this.app.lib._
4
5
  class MpaWidget extends this.app.baseClass.MpaTools {
5
6
  static scripts = []
6
7
  static css = []
@@ -10,6 +11,12 @@ async function widgetFactory () {
10
11
 
11
12
  constructor ({ component = {}, params = {} } = {}) {
12
13
  super(component.plugin)
14
+ const names = kebabCase(this.constructor.name).split('-')
15
+ const alias = names.length > 1 ? names[0] : 'wbs'
16
+ let plugin = this.app.bajo.getPlugin(alias, true)
17
+ if (!plugin) plugin = this.app.waibuBootstrap
18
+ this.plugin = plugin
19
+ this.app = plugin.app
13
20
  this.component = component
14
21
  this.params = params
15
22
  this.block = {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waibu-mpa",
3
- "version": "2.13.0",
3
+ "version": "2.13.2",
4
4
  "description": "MPA support for Waibu Framework",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/wiki/CHANGES.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changes
2
2
 
3
+ ## 2026-04-11
4
+
5
+ - [2.13.2] Bug fix in ```Wmpa.parseValue()```
6
+ - [2.13.2] Bug fix in ```Widget.plugin``` now match the right plugin
7
+
8
+ ## 2026-04-07
9
+
10
+ - [2.13.0] Bug fix in ```component.buildOptions()```
11
+
3
12
  ## 2026-04-02
4
13
 
5
14
  - [2.13.0] Changes in widget's static ```css```, ```scripts``` etc, now can be a function that callable with scope to its component