waibu-mpa 2.18.0 → 2.18.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.
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
5
5
|
<link rel="stylesheet" href="<%= _routePath('waibuMpa.virtual:/purecss/pure-min.css') %>" />
|
|
6
|
-
<link rel="stylesheet" href="<%= _routePath('waibuMpa.
|
|
6
|
+
<link rel="stylesheet" href="<%= _routePath('waibuMpa.asset:/css/default.css') %>" />
|
|
7
7
|
<title><%= _t('internalServerError') %></title>
|
|
8
8
|
</head>
|
|
9
9
|
<body>
|
|
@@ -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/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)
|
|
@@ -23,24 +23,25 @@ async function pageEndFactory () {
|
|
|
23
23
|
let tc = ''
|
|
24
24
|
if (!this.params.attr.noToastContainer && widget.toastStack && widget.toast) {
|
|
25
25
|
const toasts = []
|
|
26
|
-
if (get(locals, 'error')
|
|
26
|
+
if (get(locals, 'error')) {
|
|
27
27
|
const details = get(locals.error, 'details', [])
|
|
28
|
+
const attr = {
|
|
29
|
+
border: 'side:all width:0',
|
|
30
|
+
text: 'background:danger'
|
|
31
|
+
}
|
|
28
32
|
if (details.length > 0) {
|
|
33
|
+
attr.title = req.t(locals.error.title ?? locals.error.orgMessage ?? locals.error.message)
|
|
29
34
|
const list = [`<ul class="m-0 ${details.length === 1 ? 'list-unstyled' : ''}">`]
|
|
30
35
|
for (const d of details) {
|
|
31
36
|
const field = req.t(`field.${d.field}`)
|
|
32
|
-
list.push(`<li><strong>${field}:</strong> ${d.error}</li>`)
|
|
37
|
+
list.push(`<li><strong>${field}:</strong> ${req.t(d.error)}</li>`)
|
|
33
38
|
}
|
|
34
39
|
list.push('</ul>')
|
|
35
|
-
const attr = {
|
|
36
|
-
border: 'side:all width:0',
|
|
37
|
-
text: 'background:danger',
|
|
38
|
-
title: req.t(locals.error.orgMessage ?? locals.error.message)
|
|
39
|
-
}
|
|
40
40
|
toasts.push(await this.component.buildTag({ tag: 'toast', attr, html: list.join('\n') }))
|
|
41
41
|
} else if (!(locals._meta.statusCode === 404 || locals._meta.statusCode >= 500)) {
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
if (locals.error.title) attr.title = req.t(locals.error.title)
|
|
43
|
+
attr.noHide = true
|
|
44
|
+
toasts.push(await this.component.buildTag({ tag: 'toast', attr, html: req.t(locals.error.orgMessage ?? locals.error.message) }))
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
47
|
const notifications = get(locals, '_meta.flash.notify', [])
|
package/lib/error-handler.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import notFoundHandler from './not-found-handler.js'
|
|
2
2
|
|
|
3
3
|
async function errorHandler (err, req, reply) {
|
|
4
|
-
const { resolveTemplate } = this.app.bajoTemplate
|
|
4
|
+
const { resolveTemplate, compile } = this.app.bajoTemplate
|
|
5
|
+
const { fs } = this.app.lib
|
|
5
6
|
err.statusCode = err.statusCode ?? 500
|
|
6
7
|
reply.code(err.statusCode)
|
|
7
8
|
reply.header('Content-Type', `text/html; charset=${this.config.page.charset}`)
|
|
@@ -19,7 +20,13 @@ async function errorHandler (err, req, reply) {
|
|
|
19
20
|
} catch (err) {
|
|
20
21
|
tpl = `${this.ns}.template:/500.html`
|
|
21
22
|
}
|
|
22
|
-
|
|
23
|
+
try {
|
|
24
|
+
return await reply.view(tpl, { error: err }, { noFlash: true })
|
|
25
|
+
} catch (err) {
|
|
26
|
+
// only going here if something happened in reply.view
|
|
27
|
+
const content = fs.readFileSync(resolveTemplate(tpl).file, 'utf8')
|
|
28
|
+
return await compile(content, { error: err })
|
|
29
|
+
}
|
|
23
30
|
}
|
|
24
31
|
|
|
25
32
|
export default errorHandler
|
package/package.json
CHANGED
package/wiki/CHANGES.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 2026-06-05
|
|
4
|
+
|
|
5
|
+
- [2.18.2] Bug fix in ```error-handler.js```
|
|
6
|
+
- [2.18.2] Bug fix in ```page-end``` widget
|
|
7
|
+
|
|
8
|
+
## 2026-06-04
|
|
9
|
+
|
|
10
|
+
- [2.18.1] Bug fix in ```component.buildTag()```
|
|
11
|
+
|
|
3
12
|
## 2026-06-03
|
|
4
13
|
|
|
5
14
|
- [2.18.0] Populate ```widget.model``` if available
|