waibu-db 1.1.9 → 1.1.10

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waibu-db",
3
- "version": "1.1.9",
3
+ "version": "1.1.10",
4
4
  "description": "DB Helper",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -7,11 +7,13 @@ function getCommons (action, schema, ext, opts = {}) {
7
7
  const label = get(ext, `view.${action}.label`, get(ext, 'common.label', {}))
8
8
  const card = get(ext, `view.${action}.card`, get(ext, 'common.card', true))
9
9
  const hidden = get(ext, `view.${action}.hidden`, get(ext, 'common.hidden', []))
10
+ const disabled = get(ext, `view.${action}.disabled`, get(ext, 'common.disabled', []))
11
+ const aggregate = get(ext, `view.${action}.stat.aggregate`, get(ext, 'common.stat.aggregate', []))
10
12
  hidden.push(...schema.hidden, ...(opts.hidden ?? []))
11
13
  const allFields = without(map(schema.properties, 'name'), ...hidden)
12
14
  const forFields = get(ext, `view.${action}.fields`, get(ext, 'common.fields', allFields))
13
- set(schema, 'view.stat.aggregate', get(ext, `view.${action}.stat.aggregate`, get(ext, 'common.stat.aggregate', [])))
14
- set(schema, 'view.disabled', get(ext, 'disabled', []))
15
+ set(schema, 'view.stat.aggregate', aggregate)
16
+ set(schema, 'view.disabled', disabled)
15
17
  if (schema.disabled.length > 0) schema.view.disabled.push(...schema.disabled)
16
18
  let fields = []
17
19
  for (const f of forFields) {
@@ -19,6 +21,10 @@ function getCommons (action, schema, ext, opts = {}) {
19
21
  }
20
22
  fields = uniq(without(fields, ...hidden))
21
23
  if (action !== 'add' && !fields.includes('id')) fields.unshift('id')
24
+ let noWrap = get(ext, `view.${action}.noWrap`, get(ext, 'common.noWrap', true))
25
+ if (noWrap === true) noWrap = fields
26
+ else if (noWrap === false) noWrap = []
27
+ set(schema, 'view.noWrap', noWrap)
22
28
  return { fields, allFields, label, card }
23
29
  }
24
30
 
@@ -10,7 +10,7 @@ async function btnDelete () {
10
10
  const { isEmpty, get } = this.plugin.app.bajo.lib._
11
11
  this.params.noTag = true
12
12
  const schema = get(this, 'component.locals.schema', {})
13
- if (schema.view.disabled.includes('delete')) {
13
+ if (schema.view.disabled.includes('remove')) {
14
14
  this.params.html = ''
15
15
  return
16
16
  }
@@ -22,9 +22,9 @@ async function echarts () {
22
22
  }
23
23
 
24
24
  build = async () => {
25
- const { defaultsDeep, generateId } = this.plugin.app.bajo
25
+ const { generateId } = this.plugin.app.bajo
26
26
  const { base64JsonDecode, jsonStringify } = this.plugin.app.waibuMpa
27
- const { cloneDeep } = this.plugin.app.bajo.lib._
27
+ const { merge, cloneDeep } = this.plugin.app.bajo.lib._
28
28
  this.params.attr.id = generateId('alpha')
29
29
  this.params.attr['x-data'] = `chart${this.params.attr.id}`
30
30
  this.params.attr['@resize.window.debounce.500ms'] = `
@@ -34,7 +34,7 @@ async function echarts () {
34
34
  `
35
35
  let option = cloneDeep(this.defOption)
36
36
  if (this.params.attr.option === true) this.params.attr.option = 'e30='
37
- if (this.params.attr.option) option = defaultsDeep(base64JsonDecode(this.params.attr.option), this.defOption)
37
+ if (this.params.attr.option) option = merge(option, base64JsonDecode(this.params.attr.option))
38
38
  this.params.attr['x-init'] = `
39
39
  $watch('option', val => {
40
40
  if (chart) chart.setOption(val)
@@ -91,6 +91,7 @@ async function table () {
91
91
  head = await this.component.buildTag({ tag: 'div', attr: { flex: 'justify-content:between align-items:end' }, html: content.join('\n') })
92
92
  }
93
93
  let text = this.params.attr.headerNowrap ? '' : 'nowrap'
94
+ if (text === '' && this.isNoWrap(f, schema, group.body.nowrap)) text = 'nowrap'
94
95
  if (this.isRightAligned(f, schema)) text += ' align:end'
95
96
  const attr = { dataKey: f, dataType: prop.type, text }
96
97
  items.push(await this.component.buildTag({ tag: 'th', attr, html: head }))
@@ -146,11 +147,9 @@ async function table () {
146
147
  if (!disableds.includes('get')) attr.style = { cursor: 'pointer' }
147
148
  const cellFormatter = get(schema, `view.cellFormatter.${f}`)
148
149
  if (cellFormatter) merge(attr, await cellFormatter(dataValue, d))
149
- if (!['object', 'array'].includes(prop.type)) {
150
- const noWrap = this.isNoWrap(f, schema, group.body.nowrap) ? 'nowrap' : ''
151
- if (this.isRightAligned(f, schema)) attr.text = `align:end ${noWrap}`
152
- else attr.text = noWrap
153
- }
150
+ const noWrap = this.isNoWrap(f, schema, group.body.nowrap) ? 'nowrap' : ''
151
+ if (this.isRightAligned(f, schema)) attr.text = `align:end ${noWrap}`
152
+ else attr.text = noWrap
154
153
  const lookup = get(schema, `view.lookup.${f}`)
155
154
  if (lookup) {
156
155
  const item = find(lookup.values, set({}, lookup.id ?? 'id', value))