@nocobase/plugin-data-visualization 0.11.1-alpha.3 → 0.11.1-alpha.5

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.
@@ -240,11 +240,19 @@ const querySchema = {
240
240
  'x-decorator': 'FormItem',
241
241
  'x-component': 'Input',
242
242
  'x-component-props': {
243
- placeholder: '{{t("Alias")}}'
243
+ placeholder: '{{t("Alias")}}',
244
+ style: {
245
+ minWidth: '100px'
246
+ }
244
247
  }
245
248
  }
246
249
  }, {
247
- required: true
250
+ required: true,
251
+ 'x-component-props': {
252
+ style: {
253
+ overflow: 'auto'
254
+ }
255
+ }
248
256
  })
249
257
  }
250
258
  },
@@ -290,7 +298,16 @@ const querySchema = {
290
298
  'x-decorator': 'FormItem',
291
299
  'x-component': 'Input',
292
300
  'x-component-props': {
293
- placeholder: '{{t("Alias")}}'
301
+ placeholder: '{{t("Alias")}}',
302
+ style: {
303
+ minWidth: '100px'
304
+ }
305
+ }
306
+ }
307
+ }, {
308
+ 'x-component-props': {
309
+ style: {
310
+ overflow: 'auto'
294
311
  }
295
312
  }
296
313
  })
@@ -346,12 +363,20 @@ const querySchema = {
346
363
  'x-component': 'Radio.Group',
347
364
  'x-component-props': {
348
365
  defaultValue: 'ASC',
349
- optionType: 'button'
366
+ optionType: 'button',
367
+ style: {
368
+ width: '128px'
369
+ }
350
370
  },
351
371
  enum: ['ASC', 'DESC']
352
372
  }
353
373
  }, {
354
- 'x-reactions': '{{ useOrderReaction }}'
374
+ 'x-reactions': '{{ useOrderReaction }}',
375
+ 'x-component-props': {
376
+ style: {
377
+ overflow: 'auto'
378
+ }
379
+ }
355
380
  })
356
381
  }
357
382
  }
@@ -61,7 +61,8 @@ const _useProps = ({
61
61
  });
62
62
  return _objectSpread(_objectSpread({
63
63
  data,
64
- meta
64
+ meta,
65
+ animation: false
65
66
  }, general), advanced);
66
67
  };
67
68
  const G2PlotLibrary = {
@@ -73,7 +74,7 @@ const G2PlotLibrary = {
73
74
  useProps: _useProps,
74
75
  reference: {
75
76
  title: 'Line Chart',
76
- link: 'https://g2plot.antv.antgroup.com/api/plots/bar'
77
+ link: 'https://g2plot.antv.antgroup.com/api/plots/line'
77
78
  }
78
79
  },
79
80
  area: {
@@ -49,15 +49,19 @@ const parseFieldAndAssociations = (ctx, params) => {
49
49
  name = _selected$field[1];
50
50
  }
51
51
  let field = underscored ? (0, _database().snakeCase)(name) : name;
52
- let type = (_fields$get = fields.get(name)) === null || _fields$get === void 0 ? void 0 : _fields$get.type;
52
+ let fieldType = (_fields$get = fields.get(name)) === null || _fields$get === void 0 ? void 0 : _fields$get.type;
53
53
  if (target) {
54
- var _fields$get2;
54
+ var _targetFields$get, _fields$get2;
55
+ const targetField = fields.get(target);
56
+ const targetCollection = ctx.db.getCollection(targetField.target);
57
+ const targetFields = targetCollection.fields;
58
+ fieldType = (_targetFields$get = targetFields.get(name)) === null || _targetFields$get === void 0 ? void 0 : _targetFields$get.type;
55
59
  field = `${target}.${field}`;
56
60
  name = `${target}.${name}`;
57
- type = (_fields$get2 = fields.get(target)) === null || _fields$get2 === void 0 ? void 0 : _fields$get2.type;
61
+ const targetType = (_fields$get2 = fields.get(target)) === null || _fields$get2 === void 0 ? void 0 : _fields$get2.type;
58
62
  if (!models[target]) {
59
63
  models[target] = {
60
- type
64
+ type: targetType
61
65
  };
62
66
  }
63
67
  } else {
@@ -66,7 +70,7 @@ const parseFieldAndAssociations = (ctx, params) => {
66
70
  return _objectSpread(_objectSpread({}, selected), {}, {
67
71
  field,
68
72
  name,
69
- type,
73
+ type: fieldType,
70
74
  alias: selected.alias || name
71
75
  });
72
76
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-data-visualization",
3
- "version": "0.11.1-alpha.3",
3
+ "version": "0.11.1-alpha.5",
4
4
  "displayName": "Data Visualization",
5
5
  "displayName.zh-CN": "数据可视化",
6
6
  "description": "Provides business intelligence and data visualization features",
@@ -13,23 +13,23 @@
13
13
  },
14
14
  "devDependencies": {
15
15
  "@ant-design/icons": "^5.1.4",
16
- "@formily/antd-v5": "1.1.0-beta.4",
17
- "@formily/core": "2.2.26",
18
- "@formily/react": "2.2.26",
19
- "@formily/shared": "2.2.26",
20
- "@nocobase/actions": "0.11.1-alpha.3",
21
- "@nocobase/cache": "0.11.1-alpha.3",
22
- "@nocobase/client": "0.11.1-alpha.3",
23
- "@nocobase/database": "0.11.1-alpha.3",
24
- "@nocobase/server": "0.11.1-alpha.3",
25
- "@nocobase/test": "0.11.1-alpha.3",
26
- "@nocobase/utils": "0.11.1-alpha.3",
27
- "@testing-library/react": "^12.1.5",
16
+ "@formily/antd-v5": "^1.1.0",
17
+ "@formily/core": "^2.2.27",
18
+ "@formily/react": "^2.2.27",
19
+ "@formily/shared": "^2.2.27",
20
+ "@nocobase/actions": "0.11.1-alpha.5",
21
+ "@nocobase/cache": "0.11.1-alpha.5",
22
+ "@nocobase/client": "0.11.1-alpha.5",
23
+ "@nocobase/database": "0.11.1-alpha.5",
24
+ "@nocobase/server": "0.11.1-alpha.5",
25
+ "@nocobase/test": "0.11.1-alpha.5",
26
+ "@nocobase/utils": "0.11.1-alpha.5",
27
+ "@testing-library/react": "^14.0.0",
28
28
  "antd": "^5.6.4",
29
29
  "lodash": "^4.17.21",
30
30
  "react": "^18.2.0",
31
31
  "react-i18next": "^11.15.1",
32
32
  "vitest": "^0.33.0"
33
33
  },
34
- "gitHead": "5ed3bd7d5b16bd38d268961b34875d5cd45799ef"
34
+ "gitHead": "1dcfd15a7d95a40b0a2f60e1de19ec574066fb20"
35
35
  }
@@ -1,5 +1,5 @@
1
1
  import * as client from '@nocobase/client';
2
- // import { renderHook } from '@testing-library/react';
2
+ import { renderHook } from '@testing-library/react';
3
3
  import { vi } from 'vitest';
4
4
  import formatters from '../block/formatters';
5
5
  import transformers from '../block/transformers';
@@ -13,8 +13,7 @@ import {
13
13
  useTransformers,
14
14
  } from '../hooks';
15
15
 
16
- // TODO: 为了暂时解决很多 Warning 的问题把 `@testing-library/react` 降级到了 12.x 所以不支持 `renderHook`,等到再次升级到 14.x 时再把 skip 去掉
17
- describe.skip('hooks', () => {
16
+ describe('hooks', () => {
18
17
  beforeEach(() => {
19
18
  vi.spyOn(client, 'useCollectionManager').mockReturnValue({
20
19
  getCollectionFields: (name: string) =>
@@ -219,10 +219,20 @@ export const querySchema: ISchema = {
219
219
  'x-component': 'Input',
220
220
  'x-component-props': {
221
221
  placeholder: '{{t("Alias")}}',
222
+ style: {
223
+ minWidth: '100px',
224
+ },
225
+ },
226
+ },
227
+ },
228
+ {
229
+ required: true,
230
+ 'x-component-props': {
231
+ style: {
232
+ overflow: 'auto',
222
233
  },
223
234
  },
224
235
  },
225
- { required: true },
226
236
  ),
227
237
  },
228
238
  },
@@ -234,44 +244,56 @@ export const querySchema: ISchema = {
234
244
  key: 'dimensions',
235
245
  },
236
246
  properties: {
237
- dimensions: getArraySchema({
238
- field: {
239
- type: 'string',
240
- 'x-decorator': 'FormItem',
241
- 'x-component': 'Cascader',
242
- 'x-component-props': {
243
- placeholder: '{{t("Field")}}',
244
- fieldNames: {
245
- label: 'title',
246
- value: 'name',
247
- children: 'children',
247
+ dimensions: getArraySchema(
248
+ {
249
+ field: {
250
+ type: 'string',
251
+ 'x-decorator': 'FormItem',
252
+ 'x-component': 'Cascader',
253
+ 'x-component-props': {
254
+ placeholder: '{{t("Field")}}',
255
+ fieldNames: {
256
+ label: 'title',
257
+ value: 'name',
258
+ children: 'children',
259
+ },
248
260
  },
261
+ enum: '{{ fieldOptions }}',
262
+ required: true,
249
263
  },
250
- enum: '{{ fieldOptions }}',
251
- required: true,
252
- },
253
- format: {
254
- type: 'string',
255
- 'x-decorator': 'FormItem',
256
- 'x-component': 'Select',
257
- 'x-component-props': {
258
- placeholder: '{{t("Format")}}',
259
- style: {
260
- maxWidth: '120px',
264
+ format: {
265
+ type: 'string',
266
+ 'x-decorator': 'FormItem',
267
+ 'x-component': 'Select',
268
+ 'x-component-props': {
269
+ placeholder: '{{t("Format")}}',
270
+ style: {
271
+ maxWidth: '120px',
272
+ },
273
+ },
274
+ 'x-reactions': '{{ useFormatterOptions }}',
275
+ 'x-visible': '{{ $self.dataSource && $self.dataSource.length }}',
276
+ },
277
+ alias: {
278
+ type: 'string',
279
+ 'x-decorator': 'FormItem',
280
+ 'x-component': 'Input',
281
+ 'x-component-props': {
282
+ placeholder: '{{t("Alias")}}',
283
+ style: {
284
+ minWidth: '100px',
285
+ },
261
286
  },
262
287
  },
263
- 'x-reactions': '{{ useFormatterOptions }}',
264
- 'x-visible': '{{ $self.dataSource && $self.dataSource.length }}',
265
288
  },
266
- alias: {
267
- type: 'string',
268
- 'x-decorator': 'FormItem',
269
- 'x-component': 'Input',
289
+ {
270
290
  'x-component-props': {
271
- placeholder: '{{t("Alias")}}',
291
+ style: {
292
+ overflow: 'auto',
293
+ },
272
294
  },
273
295
  },
274
- }),
296
+ ),
275
297
  },
276
298
  },
277
299
  pane3: {
@@ -325,12 +347,20 @@ export const querySchema: ISchema = {
325
347
  'x-component-props': {
326
348
  defaultValue: 'ASC',
327
349
  optionType: 'button',
350
+ style: {
351
+ width: '128px',
352
+ },
328
353
  },
329
354
  enum: ['ASC', 'DESC'],
330
355
  },
331
356
  },
332
357
  {
333
358
  'x-reactions': '{{ useOrderReaction }}',
359
+ 'x-component-props': {
360
+ style: {
361
+ overflow: 'auto',
362
+ },
363
+ },
334
364
  },
335
365
  ),
336
366
  },
@@ -42,6 +42,7 @@ const useProps: usePropsFunc = ({ data, fieldProps, general, advanced }) => {
42
42
  return {
43
43
  data,
44
44
  meta,
45
+ animation: false,
45
46
  ...general,
46
47
  ...advanced,
47
48
  };
@@ -56,7 +57,7 @@ export const G2PlotLibrary: Charts = {
56
57
  useProps,
57
58
  reference: {
58
59
  title: 'Line Chart',
59
- link: 'https://g2plot.antv.antgroup.com/api/plots/bar',
60
+ link: 'https://g2plot.antv.antgroup.com/api/plots/line',
60
61
  },
61
62
  },
62
63
  area: {
@@ -1,6 +1,6 @@
1
1
  import { Context, Next } from '@nocobase/actions';
2
2
  import { Cache } from '@nocobase/cache';
3
- import { FilterParser, snakeCase } from '@nocobase/database';
3
+ import { Field, FilterParser, snakeCase } from '@nocobase/database';
4
4
  import ChartsV2Plugin from '../plugin';
5
5
  import { formatter } from './formatter';
6
6
 
@@ -65,13 +65,17 @@ export const parseFieldAndAssociations = (ctx: Context, params: QueryParams) =>
65
65
  [target, name] = selected.field;
66
66
  }
67
67
  let field = underscored ? snakeCase(name) : name;
68
- let type = fields.get(name)?.type;
68
+ let fieldType = fields.get(name)?.type;
69
69
  if (target) {
70
+ const targetField = fields.get(target) as Field;
71
+ const targetCollection = ctx.db.getCollection(targetField.target);
72
+ const targetFields = targetCollection.fields;
73
+ fieldType = targetFields.get(name)?.type;
70
74
  field = `${target}.${field}`;
71
75
  name = `${target}.${name}`;
72
- type = fields.get(target)?.type;
76
+ const targetType = fields.get(target)?.type;
73
77
  if (!models[target]) {
74
- models[target] = { type };
78
+ models[target] = { type: targetType };
75
79
  }
76
80
  } else {
77
81
  field = `${collectionName}.${field}`;
@@ -80,7 +84,7 @@ export const parseFieldAndAssociations = (ctx: Context, params: QueryParams) =>
80
84
  ...selected,
81
85
  field,
82
86
  name,
83
- type,
87
+ type: fieldType,
84
88
  alias: selected.alias || name,
85
89
  };
86
90
  };
@@ -247,18 +251,8 @@ export const cacheWrap = async (
247
251
  };
248
252
 
249
253
  export const query = async (ctx: Context, next: Next) => {
250
- const {
251
- uid,
252
- collection,
253
- measures,
254
- dimensions,
255
- orders,
256
- filter,
257
- limit,
258
- sql,
259
- cache: cacheConfig,
260
- refresh,
261
- } = ctx.action.params.values as QueryParams;
254
+ const { uid, collection, measures, dimensions, orders, filter, limit, sql, cache: cacheConfig, refresh } = ctx.action
255
+ .params.values as QueryParams;
262
256
  const roleName = ctx.state.currentRole || 'anonymous';
263
257
  const can = ctx.app.acl.can({ role: roleName, resource: collection, action: 'list' });
264
258
  if (!can && roleName !== 'root') {