waibu-db 2.9.0 → 2.10.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.
|
@@ -21,7 +21,7 @@ async function table () {
|
|
|
21
21
|
return get(schema, 'view.noWrap', []).includes(field)
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
_defFormatter = async ({ req, key, value, data, schema }) => {
|
|
24
|
+
_defFormatter = async ({ req, key, value, data, schema, params }) => {
|
|
25
25
|
const { get, find, camelCase, isEmpty } = this.app.lib._
|
|
26
26
|
const { escape } = this.app.waibu
|
|
27
27
|
const prop = find(schema.properties, { name: key })
|
|
@@ -34,7 +34,7 @@ async function table () {
|
|
|
34
34
|
const item = find(values, { value }) ?? {}
|
|
35
35
|
const ttext = camelCase(`${prop.name} ${item.text}`)
|
|
36
36
|
value = escape(req.format(!isEmpty(item) ? (req.te(ttext) ? req.t(ttext) : item.text) : value, prop.type))
|
|
37
|
-
if (item) value += ` <sup><a href="#" title="${req.t('dataValue')}: ${data[key]}">*</a></sup>`
|
|
37
|
+
if (item && !params.attr.noDataValueRef) value += ` <sup><a href="#" title="${req.t('dataValue')}: ${data[key]}">*</a></sup>`
|
|
38
38
|
} else if (['string', 'text'].includes(prop.type)) {
|
|
39
39
|
if (!get(schema, 'view.noEscape', []).includes(key)) value = escape(value)
|
|
40
40
|
}
|
|
@@ -175,8 +175,8 @@ async function table () {
|
|
|
175
175
|
if (item) value = req.t(item[lookup.field ?? 'name'])
|
|
176
176
|
}
|
|
177
177
|
const formatter = get(schema, `view.formatter.${f}`)
|
|
178
|
-
if (formatter) value = await formatter.call(this, value, d)
|
|
179
|
-
else value = await this._defFormatter({ req, key: f, schema, value, data: d })
|
|
178
|
+
if (formatter) value = await formatter.call(this, value, d, { params: this.params })
|
|
179
|
+
else value = await this._defFormatter({ req, key: f, schema, value, data: d, params: this.params })
|
|
180
180
|
const line = await this.component.buildTag({ tag: 'td', attr, html: value })
|
|
181
181
|
lines.push(line)
|
|
182
182
|
}
|
package/index.js
CHANGED
|
@@ -184,7 +184,7 @@ async function factory (pkgName) {
|
|
|
184
184
|
const unitSys = get(req, 'site.setting.sumba.unitSys')
|
|
185
185
|
const timeZone = get(req, 'site.setting.sumba.timeZone', this.app.bajo.config.intl.format.datetime.timeZone)
|
|
186
186
|
for (const f of fields) {
|
|
187
|
-
if (f === '
|
|
187
|
+
if (f === '_ref') continue
|
|
188
188
|
let prop = find(schema.properties, { name: f })
|
|
189
189
|
if (!prop) prop = find(schema.view.calcFields, { name: f })
|
|
190
190
|
if (!prop) continue
|
package/lib/util.js
CHANGED
|
@@ -54,10 +54,12 @@ export async function prepCrud ({ model, body, id, req, reply, transaction, opti
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
export async function getOneRecord (model, id, filter, options) {
|
|
57
|
-
const { cloneDeep } = this.app.lib._
|
|
57
|
+
const { cloneDeep, pick } = this.app.lib._
|
|
58
58
|
let query = cloneDeep(filter.query || {})
|
|
59
59
|
query = { $and: [query, { id }] }
|
|
60
|
-
const
|
|
60
|
+
const opts = pick(options, ['forceNoHidden', 'trx', 'req', 'refs'])
|
|
61
|
+
opts.dataOnly = true
|
|
62
|
+
const data = await model.findOneRecord({ query }, opts)
|
|
61
63
|
if (!data && options.throwNotFound) throw this.error('_notFound')
|
|
62
64
|
return data
|
|
63
65
|
}
|
package/package.json
CHANGED
package/wiki/CHANGES.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 2026-03-22
|
|
4
|
+
|
|
5
|
+
- [2.10.1] Bug fix in reference records
|
|
6
|
+
|
|
7
|
+
## 2026-03-19
|
|
8
|
+
|
|
9
|
+
- [2.10.0] Data value tooltip can now be turned off with ```no-data-value-ref```
|
|
10
|
+
|
|
3
11
|
## 2026-03-15
|
|
4
12
|
|
|
5
13
|
- [2.9.0] Add ability to overwrite ```base``` through ```options```
|