waibu-db 1.1.13 → 1.1.15

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.13",
3
+ "version": "1.1.15",
4
4
  "description": "DB Helper",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -24,22 +24,13 @@ async function echarts () {
24
24
  build = async () => {
25
25
  const { generateId } = this.plugin.app.bajo
26
26
  const { base64JsonDecode, jsonStringify } = this.plugin.app.waibuMpa
27
- const { merge, cloneDeep } = this.plugin.app.bajo.lib._
27
+ const { merge, cloneDeep, omit } = 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
- this.params.attr['@resize.window.debounce.500ms'] = `
31
- if (chart) {
32
- chart.resize()
33
- }
34
- `
30
+ this.params.attr['x-bind'] = 'resize'
35
31
  let option = cloneDeep(this.defOption)
36
32
  if (this.params.attr.option === true) this.params.attr.option = 'e30='
37
33
  if (this.params.attr.option) option = merge(option, base64JsonDecode(this.params.attr.option))
38
- this.params.attr['x-init'] = `
39
- $watch('option', val => {
40
- if (chart) chart.setOption(val)
41
- })
42
- `
43
34
  this.params.append = `
44
35
  <script>
45
36
  document.addEventListener('alpine:init', () => {
@@ -50,16 +41,27 @@ async function echarts () {
50
41
  const el = document.getElementById('${this.params.attr.id}')
51
42
  chart = echarts.init(el, null, { renderer: 'canvas' })
52
43
  chart.setOption(this.option)
44
+ this.$watch('option', val => {
45
+ chart.setOption(val)
46
+ })
53
47
  },
54
48
  get chart () {
55
49
  return chart
56
50
  },
51
+ resize: {
52
+ ['@resize.window.debounce.500ms']() {
53
+ if (chart) {
54
+ chart.resize()
55
+ }
56
+ }
57
+ },
57
58
  option: ${jsonStringify(option, true)}
58
59
  }
59
60
  })
60
61
  })
61
62
  </script>
62
63
  `
64
+ this.params.attr = omit(this.params.attr, ['option'])
63
65
  }
64
66
  }
65
67
  }
@@ -50,7 +50,7 @@ async function table () {
50
50
  if (isEmpty(fields)) fields = schema.view.fields
51
51
  if (!isEmpty(schema.view.hidden)) fields = without(fields, ...schema.view.hidden)
52
52
  let sort = this.params.attr.sort ? attrToArray(this.params.attr.sort) : get(this, `component.locals._meta.query.${qsKey.sort}`, '')
53
- if (isEmpty(sort)) {
53
+ if (isEmpty(sort) && filter.sort) {
54
54
  const keys = Object.keys(filter.sort)
55
55
  if (keys.length > 0) sort = `${keys[0]}:${filter.sort[keys[0]]}`
56
56
  }
@@ -130,9 +130,11 @@ async function table () {
130
130
  if (!prop) prop = find(schema.view.calcFields, { name: f })
131
131
  if (!prop) continue
132
132
  let dataValue = d[f] ?? ''
133
- if (['datetime'].includes(prop.type)) dataValue = escape(dataValue.toISOString())
134
- if (['string', 'text'].includes(prop.type)) dataValue = escape(dataValue)
135
- if (['array', 'object'].includes(prop.type)) dataValue = escape(JSON.stringify(d[f]))
133
+ if (!isEmpty(dataValue)) {
134
+ if (['datetime'].includes(prop.type)) dataValue = escape(dataValue.toISOString())
135
+ if (['string', 'text'].includes(prop.type)) dataValue = escape(dataValue)
136
+ if (['array', 'object'].includes(prop.type)) dataValue = escape(JSON.stringify(d[f]))
137
+ }
136
138
  let value = fd[f]
137
139
  if (prop.type === 'boolean') {
138
140
  value = (await this.component.buildTag({ tag: 'icon', attr: { name: `circle${d[f] ? 'Check' : ''}` } })) +