dobo 2.22.0 → 2.22.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.
@@ -1,5 +1,15 @@
1
1
  import path from 'path'
2
2
 
3
+ async function handler (val, rec, opts) {
4
+ const atts = await this.listAttachment({ id: rec.id })
5
+ if (atts.length === 0) return
6
+ let items = atts.filter(att => att.mimeType.startsWith('image/'))
7
+ if (opts.asLink && this.app.waibu) items = items.map(f => `<a href="${f.url}">${opts.baseName ? path.basename(f.file) : f.file}</a>`)
8
+ else if (opts.baseName) items = items.map(f => path.basename(f.file))
9
+ if (opts.single) return items[0]
10
+ return opts.returnAsArray ? items : items.join(', ')
11
+ }
12
+
3
13
  async function image (opts = {}) {
4
14
  opts.field = opts.field ?? 'image'
5
15
  opts.baseName = opts.baseName ?? true
@@ -10,13 +20,10 @@ async function image (opts = {}) {
10
20
  type: 'string',
11
21
  virtual: true,
12
22
  getValue: async function (val, rec) {
13
- const atts = await this.listAttachment({ id: rec.id })
14
- if (atts.length === 0) return
15
- let items = atts.filter(att => att.mimeType.startsWith('image/'))
16
- if (opts.withLink && this.app.waibu) items = items.map(f => `<a href="${f.url}">${opts.baseName ? path.basename(f.file) : f.file}</a>`)
17
- else if (opts.baseName) items = items.map(f => path.basename(f.file))
18
- if (opts.single) return items[0]
19
- return items
23
+ return await handler.call(this, val, rec, { ...opts, asLink: false })
24
+ },
25
+ format: async function (val, rec) {
26
+ return await handler.call(this, val, rec, { ...opts, asLink: true })
20
27
  }
21
28
  }
22
29
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dobo",
3
- "version": "2.22.0",
3
+ "version": "2.22.1",
4
4
  "description": "DBMS for Bajo Framework",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/wiki/CHANGES.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changes
2
2
 
3
+ ## 2026-05-03
4
+
5
+ - [2.22.1] Bug fix in ```dobo:image``` feature
6
+
3
7
  ## 2026-05-02
4
8
 
5
9
  - [2.22.0] Add auto thumbnail creation when image attachment is uploaded