waibu-mpa 2.17.1 → 2.18.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.
- package/lib/build-page/replace-tag.js +0 -5
- package/lib/build-routes.js +7 -5
- package/lib/class/component.js +2 -0
- package/lib/class/widget.js +1 -0
- package/package.json +1 -1
- package/wiki/CHANGES.md +9 -0
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
async function replace ({ el, cmp = {}, opts = {} } = {}) {
|
|
2
2
|
const { parseAttribs, stringifyAttribs } = this.app.waibuMpa
|
|
3
3
|
const { isEmpty, camelCase } = this.app.lib._
|
|
4
|
-
const { reply } = opts
|
|
5
4
|
|
|
6
5
|
const tag = camelCase(el.name.slice(cmp.namespace.length))
|
|
7
6
|
const html = cmp.$(el).html()
|
|
8
7
|
const attr = parseAttribs(el.attribs)
|
|
9
|
-
if (reply) {
|
|
10
|
-
reply.ctags = reply.ctags ?? []
|
|
11
|
-
if (!reply.ctags.includes(tag)) reply.ctags.push(tag)
|
|
12
|
-
}
|
|
13
8
|
attr.octag = tag
|
|
14
9
|
const params = { tag, attr, html, el, opts }
|
|
15
10
|
const result = await cmp.buildTag(params)
|
package/lib/build-routes.js
CHANGED
|
@@ -3,7 +3,7 @@ import path from 'path'
|
|
|
3
3
|
export async function build ({ files, pathPrefix, dir, ns, cfg, parent, urlPrefix, subRoute }) {
|
|
4
4
|
const { defaultsDeep, parseObject } = this.app.lib.aneka
|
|
5
5
|
const { importModule, readJson } = this.app.bajo
|
|
6
|
-
const { isFunction, isPlainObject, pick, last, camelCase, omit } = this.app.lib._
|
|
6
|
+
const { isFunction, isPlainObject, pick, last, camelCase, omit, trimEnd } = this.app.lib._
|
|
7
7
|
const { titleize } = this.app.lib.aneka
|
|
8
8
|
const { getPluginPrefix } = this.app.waibu
|
|
9
9
|
const mergeRouteHooks = await importModule('waibu:/lib/webapp-scope/merge-route-hooks.js')
|
|
@@ -11,7 +11,9 @@ export async function build ({ files, pathPrefix, dir, ns, cfg, parent, urlPrefi
|
|
|
11
11
|
const me = this
|
|
12
12
|
for (const f of files) {
|
|
13
13
|
const ext = path.extname(f)
|
|
14
|
-
const
|
|
14
|
+
const urls = f.slice(0, f.length - ext.length).replace(`${dir}/extend/${pathPrefix}`, '').replaceAll('@', ':').split('/')
|
|
15
|
+
if (last(urls) === 'index') urls.pop()
|
|
16
|
+
const url = urls.join('/')
|
|
15
17
|
let mod
|
|
16
18
|
if (ext === '.js') mod = await importModule(f)
|
|
17
19
|
else if (ext === '.json') mod = await readJson(f)
|
|
@@ -21,11 +23,10 @@ export async function build ({ files, pathPrefix, dir, ns, cfg, parent, urlPrefi
|
|
|
21
23
|
else if (isPlainObject(mod)) mod = [mod]
|
|
22
24
|
for (let m of mod) {
|
|
23
25
|
const mhandler = m.handler // parseObject has problem with function
|
|
24
|
-
const murl = m.url
|
|
26
|
+
const murl = m.url // same as above
|
|
25
27
|
m = parseObject(omit(m, ['handler', 'url'], { parseValue: true }))
|
|
26
|
-
m.handler = mhandler
|
|
27
28
|
m.url = murl
|
|
28
|
-
|
|
29
|
+
m.handler = mhandler
|
|
29
30
|
m.url = m.url ?? url
|
|
30
31
|
if (isFunction(m.url)) m.url = await m.url.call(this)
|
|
31
32
|
if (m.redirect) {
|
|
@@ -45,6 +46,7 @@ export async function build ({ files, pathPrefix, dir, ns, cfg, parent, urlPrefi
|
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
48
|
if (urlPrefix) m.url = `/${urlPrefix}/${m.url}`
|
|
49
|
+
m.url = trimEnd(m.url, '/')
|
|
48
50
|
m.method = m.method ?? 'GET'
|
|
49
51
|
await mergeRouteHooks.call(me, m)
|
|
50
52
|
m.config = m.config ?? {}
|
package/lib/class/component.js
CHANGED
|
@@ -94,6 +94,8 @@ async function componentFactory () {
|
|
|
94
94
|
const { escape } = this.app.waibu
|
|
95
95
|
const { isEmpty, merge, uniq, without } = this.app.lib._
|
|
96
96
|
params.ctag = params.tag
|
|
97
|
+
this.reply.ctags = this.reply.ctags ?? []
|
|
98
|
+
if (!this.reply.ctags.includes(params.ctag)) this.reply.ctags.push(params.ctag)
|
|
97
99
|
const method = this.getMethod(params)
|
|
98
100
|
if (opts.attr) params.attr = merge({}, opts.attr, params.attr)
|
|
99
101
|
this.normalizeAttr(params)
|
package/lib/class/widget.js
CHANGED
|
@@ -26,6 +26,7 @@ async function widgetFactory () {
|
|
|
26
26
|
this.formData = get(this, `component.locals.${this.params.attr.keyLocals ?? 'form'}`, {})
|
|
27
27
|
this.oldData = get(this, `component.locals.${this.params.attr.keyOldData ?? 'oldData'}`, {})
|
|
28
28
|
this.schema = get(this, `component.locals.${this.params.attr.keySchema ?? 'schema'}`, {})
|
|
29
|
+
if (this.schema.name) this.model = this.app.dobo.getModel(this.schema.name)
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
_parseBase64Attr = (text, defValue = {}) => {
|
package/package.json
CHANGED
package/wiki/CHANGES.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 2026-06-04
|
|
4
|
+
|
|
5
|
+
- [2.18.1] Bug fix in ```component.buildTag()```
|
|
6
|
+
|
|
7
|
+
## 2026-06-03
|
|
8
|
+
|
|
9
|
+
- [2.18.0] Populate ```widget.model``` if available
|
|
10
|
+
- [2.18.0] If route's url ends with ```index```, rewrite url to use it's folder instead
|
|
11
|
+
|
|
3
12
|
## 2026-06-01
|
|
4
13
|
|
|
5
14
|
- [2.17.1] Bug fix in ```component.buildTag()```
|