waibu-db 2.12.6 → 2.13.0

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.
@@ -0,0 +1,10 @@
1
+ <% if ((list.warnings ?? []).length > 0) { %>
2
+ <c:div padding="all-3">
3
+ <c:div><%= _t('warning') %>:</c:div>
4
+ <c:ul>
5
+ <% list.warnings.forEach(warning => { %>
6
+ <c:li><%= warning %></c:li>
7
+ <% }) %>
8
+ </c:ul>
9
+ </c:div>
10
+ <% } %>
@@ -1,4 +1,5 @@
1
1
  <!-- include waibuDb.partial:/crud/_list-btns.html -->
2
2
  <c:wdb-table id="main-table" border body-divider strip responsive margin="top-3"/>
3
3
  <!-- include waibuDb.partial:/crud/_list-footer.html -->
4
- <!-- include waibuDb.partial:/crud/_addons.html -->
4
+ <!-- include waibuDb.partial:/crud/_addons.html -->
5
+ <!-- include waibuDb.partial:/crud/_list-warnings.html -->
@@ -33,7 +33,7 @@ async function form () {
33
33
  attr.push(`@${o.bind}="${o.handler}"`)
34
34
  }
35
35
  if (w.componentOpts) attr.push(`c-opts="${base64JsonEncode(w.componentOpts)}"`)
36
- if (schema.view.valueFormatter[f] && this.params.attr.method !== 'POST') {
36
+ if (schema.view.valueFormatter[f] && (w.component === 'form-plaintext' || this.params.attr.method !== 'POST')) {
37
37
  const value = await schema.view.valueFormatter[f].call(this, data[f], data, { req })
38
38
  body.push(`<c:${w.component} ${w.attr.label ? ('t:label="' + w.attr.label + '"') : ''} value="${value}" label-floating name="${w.name}" ${attr.join(' ')} />`)
39
39
  } else {
@@ -6,7 +6,8 @@ async function addHandler ({ req, reply, model, params = {}, template, addOnsHan
6
6
  const { pick, map, merge, omit } = this.app.lib._
7
7
  const opts = merge({}, options.modelOpts)
8
8
  model = pascalCase(model ?? req.params.model)
9
- const { schema } = await getSchemaExt(model, 'add', merge({ args: [req] }, { params }, options))
9
+ const mdl = this.app.dobo.getModel(model)
10
+ const { schema } = await getSchemaExt(model, 'add', merge({ args: [{ req, model: mdl }] }, { params }, options))
10
11
  if (schema.disabled.includes('create')) return await reply.view(templateDisabled, { action: 'add' })
11
12
  // req.query.attachment = true
12
13
  opts.fields = schema.view.fields
@@ -5,7 +5,8 @@ async function deleteHandler ({ req, reply, model, params = {}, templateDisabled
5
5
  const { reduce, merge } = this.app.lib._
6
6
  const opts = merge({}, options.modelOpts)
7
7
  model = pascalCase(model ?? req.params.model)
8
- const { schema } = await getSchemaExt(model, 'delete', merge({ args: [req] }, { params }, options))
8
+ const mdl = this.app.dobo.getModel(model)
9
+ const { schema } = await getSchemaExt(model, 'delete', merge({ args: [{ req, model: mdl }] }, { params }, options))
9
10
  if (schema.disabled.includes('remove')) return await reply.view(templateDisabled, { action: 'delete' })
10
11
  opts.fields = schema.view.fields
11
12
  delete req.query.query
@@ -6,7 +6,8 @@ async function detailsHandler ({ req, reply, model, params = {}, id, template, a
6
6
  const { merge, isEmpty } = this.app.lib._
7
7
  const opts = merge({ refs: '*' }, options.modelOpts)
8
8
  model = pascalCase(model ?? req.params.model)
9
- const { schema } = await getSchemaExt(model, 'details', merge({ args: [req] }, { params }, options))
9
+ const mdl = this.app.dobo.getModel(model)
10
+ const { schema } = await getSchemaExt(model, 'details', merge({ args: [{ req, model: mdl }] }, { params }, options))
10
11
  if (schema.disabled.includes('get')) return await reply.view(templateDisabled, { action: 'details' })
11
12
  // req.query.attachment = true
12
13
  opts.fields = schema.view.fields
@@ -13,7 +13,8 @@ async function editHandler ({ req, reply, model, id, params = {}, template, addO
13
13
  let resp
14
14
  let form
15
15
  model = pascalCase(model ?? req.params.model)
16
- const { schema } = await getSchemaExt(model, 'edit', merge({ args: [req] }, { params }, options))
16
+ const mdl = this.app.dobo.getModel(model)
17
+ const { schema } = await getSchemaExt(model, 'edit', merge({ args: [{ req, model: mdl }] }, { params }, options))
17
18
  if (schema.disabled.includes('update')) return await reply.view(templateDisabled, { action: 'edit' })
18
19
  // req.query.attachment = true
19
20
  opts.fields = schema.view.fields
@@ -9,7 +9,8 @@ async function exportHandler ({ req, reply, model, params = {}, templateDisabled
9
9
  const { buildUrl } = this.app.waibuMpa
10
10
  const { pushDownload } = getPlugin('sumba')
11
11
  model = pascalCase(model ?? req.params.model)
12
- const { schema } = await getSchemaExt(model, 'add', merge({ args: [req] }, { params }, options))
12
+ const mdl = this.app.dobo.getModel(model)
13
+ const { schema } = await getSchemaExt(model, 'add', merge({ args: [{ req, model: mdl }] }, { params }, options))
13
14
  if (schema.disabled.includes('find')) return await reply.view(templateDisabled, { action: 'list' })
14
15
  const data = await prepCrud.call(getPlugin('waibuDb'), { model, req, reply, args: ['model'] })
15
16
  data.opts = omit(data.opts, ['req', 'reply'])
@@ -6,7 +6,8 @@ async function listHandler ({ req, reply, model, template, params = {}, addOnsHa
6
6
 
7
7
  const opts = merge({}, { count: true, refs: '*' }, options.modelOpts)
8
8
  model = pascalCase(model ?? req.params.model)
9
- const { schema } = await getSchemaExt(model, 'list', merge({ args: [req] }, { params }, options))
9
+ const mdl = this.app.dobo.getModel(model)
10
+ const { schema } = await getSchemaExt(model, 'list', merge({ args: [{ req, model: mdl }] }, { params }, options))
10
11
  if (schema.disabled.includes('find')) return await reply.view(templateDisabled, { action: 'list' })
11
12
  for (const key of ['sort', 'limit', 'fields']) {
12
13
  const sessKey = `wdb${model}${upperFirst(key)}`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waibu-db",
3
- "version": "2.12.6",
3
+ "version": "2.13.0",
4
4
  "description": "DB Helper",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/wiki/CHANGES.md CHANGED
@@ -3,6 +3,9 @@
3
3
  ## 2026-04-02
4
4
 
5
5
  - [2.12.6] Bug fix in ```wdb-query``` widget
6
+ - [2.13.0] Add warnings template
7
+ - [2.13.0] Changes in all crud handlers, now the first parameter is an object of ```req``` and ```model```
8
+ - [2.13.0] Bug fix in ```wdb-form``` widget
6
9
 
7
10
  ## 2026-04-01
8
11