waibu-db 2.23.1 → 2.24.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.
@@ -23,7 +23,7 @@
23
23
  </c:grid-col>
24
24
  <c:grid-col col="6-lg" flex="justify-content:end-lg align-items:center">
25
25
  <% if (!_getSetting('waibuDb:/control/wdbBtnDelete/disabled')) { %>
26
- <c:wdb-btn-delete href="<%= _getSetting('waibuDb:/control/wdbBtnDelete/href', 'undefined') %>" />
26
+ <c:wdb-btn-delete href="<%= _getSetting('waibuDb:/control/wdbBtnDelete/href', 'undefined') %>" <%= _.get(form, '_immutable.0') === '*' ? 'disabled' : '' %>/>
27
27
  <% } %>
28
28
  </c:grid-col>
29
29
  </c:grid-row>
@@ -17,13 +17,13 @@
17
17
  </c:grid-col>
18
18
  <c:grid-col col="6-lg" flex="justify-content:end-lg align-items:center">
19
19
  <% if (!_getSetting('waibuDb:/control/wdbBtnDelete/disabled')) { %>
20
- <c:wdb-btn-delete href="<%= _getSetting('waibuDb:/control/wdbBtnDelete/href', 'undefined') %>"/>
20
+ <c:wdb-btn-delete href="<%= _getSetting('waibuDb:/control/wdbBtnDelete/href', 'undefined') %>" <%= _.get(form, '_immutable.0') === '*' ? 'disabled' : '' %>/>
21
21
  <% } %>
22
22
  <% if (!_getSetting('waibuDb:/control/wdbBtnReset/disabled')) { %>
23
- <c:btn type="reset" color="secondary" t:content="reset" margin="start-2"/>
23
+ <c:btn type="reset" color="secondary" t:content="reset" margin="start-2" <%= _.get(form, '_immutable.0') === '*' ? 'disabled' : '' %>/>
24
24
  <% } %>
25
25
  <% if (!_getSetting('waibuDb:/control/wdbBtnSubmit/disabled')) { %>
26
- <c:btn type="submit" color="primary" t:content="submit" margin="start-2"/>
26
+ <c:btn type="submit" color="primary" t:content="submit" margin="start-2" <%= _.get(form, '_immutable.0') === '*' ? 'disabled' : '' %>/>
27
27
  <% } %>
28
28
  </c:grid-col>
29
29
  </c:grid-row>
@@ -0,0 +1,4 @@
1
+ [
2
+ "/**/*",
3
+ "restapi:/**/*"
4
+ ]
@@ -5,12 +5,11 @@ async function btnColumns () {
5
5
 
6
6
  return class WdbBtnColumns extends WdbBase {
7
7
  build = async () => {
8
- const { find, get, isEmpty, without, intersection } = this.app.lib._
8
+ const { get, isEmpty, without } = this.app.lib._
9
9
  const { jsonStringify } = this.app.waibuMpa
10
10
  const { req } = this.component
11
11
  const qsKey = this.app.waibu.config.qsKey
12
12
  const schema = get(this, 'component.locals.schema', {})
13
- const data = get(this, 'component.locals.list.data', [])
14
13
  const count = get(this, 'component.locals.list.count', 0)
15
14
  if (count === 0) this.params.attr.triggerDisabled = true
16
15
  if (schema.view.disabled.includes('find')) {
@@ -19,13 +18,12 @@ async function btnColumns () {
19
18
  }
20
19
  let fields = without(get(this, `component.locals._meta.query.${qsKey.fields}`, '').split(','), '')
21
20
  if (isEmpty(fields)) fields = without(schema.view.fields, 'id')
22
- const allFields = data.length > 0 ? intersection(schema.view.fields, Object.keys(data[0])) : []
23
21
  const items = []
24
22
  this.params.attr.color = this.params.attr.color ?? 'secondary-outline'
25
23
  if (isEmpty(this.params.attr.content)) this.params.attr.content = req.t('columns')
26
24
  for (const f of schema.view.fields) {
27
- if (allFields.length > 0 && !allFields.includes(f)) continue
28
- const prop = find(schema.properties, { name: f })
25
+ // if (allFields.length > 0 && !allFields.includes(f)) continue
26
+ const prop = schema.properties.find(p => p.name === f && !p.virtual)
29
27
  if (!prop) continue
30
28
  const attr = { 'x-model': 'selected', label: req.t(get(schema, `view.label.${f}`, `field.${f}`)), value: f, labelText: 'nowrap' }
31
29
  if (fields.includes(f)) attr.checked = true
@@ -144,7 +144,10 @@ async function table () {
144
144
  const noWrap = this.isNoWrap(f, schema, group.body.nowrap) ? 'nowrap' : ''
145
145
  if (this.isRightAligned(f, schema)) attr.text = `align:end ${noWrap}`
146
146
  else attr.text = `${noWrap}`
147
- if (d._immutable) attr.text += ' color:body-tertiary'
147
+ if (d._immutable && d._immutable.length > 0) {
148
+ if (d._immutable[0] === '*' || d._immutable.includes(f)) attr.text += ' color:body-tertiary'
149
+ }
150
+ if (f === 'id') attr.text += ' color:body-tertiary'
148
151
  const format = get(schema, `view.format.${f}`)
149
152
  if (format) {
150
153
  const formatted = await format.call(this, value, d, { params: this.params, req })
@@ -52,6 +52,8 @@ async function form () {
52
52
  }
53
53
  if (widget.componentOpts) attr['c-opts'] = base64JsonEncode(widget.componentOpts)
54
54
  if (prop.virtual) widget.component = 'form-plaintext'
55
+ const immutable = get(this, 'formData._immutable') || []
56
+ if ((immutable.length === 1 && immutable[0] === '*') || immutable.includes(prop.name)) widget.component = 'form-plaintext'
55
57
  widget.addons = widget.addons ?? []
56
58
  if (!isArray(widget.addons)) widget.addons = [widget.addons]
57
59
  for (const ao of widget.addons) {
package/lib/util.js CHANGED
@@ -53,6 +53,7 @@ export async function prepCrud ({ model, id, req, reply, transaction, options =
53
53
  if (options.limit) filter.limit = options.limit
54
54
  if (options.sort) filter.sort = options.sort
55
55
  if (options.page) filter.page = options.page
56
+ if (opts.fields && opts.fields.length > 0 && mdl.hasProperty('_immutable')) opts.fields.push('_immutable')
56
57
  return { model: mdl, recId, opts, filter, attachment, stats, mimeType }
57
58
  }
58
59
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waibu-db",
3
- "version": "2.23.1",
3
+ "version": "2.24.1",
4
4
  "description": "DB Helper",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/wiki/CHANGES.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changes
2
2
 
3
+ ## 2026-06-11
4
+
5
+ - [2.24.1] Bug fix in ```wdb-form``` widget
6
+ - [2.24.1] Bug fix in ```_details-btns.html``` partial
7
+
8
+ ## 2026-06-10
9
+
10
+ - [2.24.0] Add secure routes declaration
11
+ - [2.24.0] Bug fix in ```wdb-btn-columns``` widget
12
+ - [2.24.0] Add support for ```sumba:immutable``` feature
13
+
3
14
  ## 2026-06-05
4
15
 
5
16
  - [2.23.1] Add ```form``` widget