dtable-statistic 4.0.10 → 4.0.12

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.
@@ -86,7 +86,7 @@ var NewTableDialog = /*#__PURE__*/function (_React$Component) {
86
86
  autoFocus: false
87
87
  }, /*#__PURE__*/React.createElement(ModalHeader, {
88
88
  toggle: this.toggle
89
- }, intl.get('New_Table')), /*#__PURE__*/React.createElement(ModalBody, null, /*#__PURE__*/React.createElement(Form, null, /*#__PURE__*/React.createElement(FormGroup, null, /*#__PURE__*/React.createElement(Label, {
89
+ }, intl.get('New_table')), /*#__PURE__*/React.createElement(ModalBody, null, /*#__PURE__*/React.createElement(Form, null, /*#__PURE__*/React.createElement(FormGroup, null, /*#__PURE__*/React.createElement(Label, {
90
90
  for: "tableName"
91
91
  }, intl.get('Name')), /*#__PURE__*/React.createElement(Input, {
92
92
  id: "tableName",
@@ -138,8 +138,8 @@ var de = {
138
138
  'Oct': 'Okt',
139
139
  'Nov': 'Nov',
140
140
  'Dec': 'Dez',
141
- 'Enter_date': 'Enter date',
142
- 'Please_select': 'Please select',
141
+ 'Enter_date': 'Datum eingeben',
142
+ 'Please_select': 'Bitte auswählen',
143
143
  'Total': 'Gesamt',
144
144
  'Amount': 'Menge',
145
145
  'Empty': 'Leer',
@@ -237,7 +237,9 @@ var de = {
237
237
  'Add_new_stack': 'Neuen Stapel hinzufügen',
238
238
  'Chart_type': 'Diagrammtyp',
239
239
  'Edit_type': 'Typ ändern',
240
- 'Update_to_a_table': 'Update to a table',
240
+ 'New_table': 'New table',
241
+ 'Select_table': 'Tabelle auswählen',
242
+ 'Update_to_a_table': 'Aktualisierung in eine Tabelle',
241
243
  'Export_to_a_new_table': 'In neue Tabelle exportieren'
242
244
  };
243
245
  export default de;
@@ -237,6 +237,8 @@ var en = {
237
237
  'Add_new_stack': 'Add new stack',
238
238
  'Chart_type': 'Chart type',
239
239
  'Edit_type': 'Edit type',
240
+ 'New_table': 'New table',
241
+ 'Select_table': 'Select table',
240
242
  'Update_to_a_table': 'Update to a table',
241
243
  'Export_to_a_new_table': 'Export to a new table'
242
244
  };
@@ -138,8 +138,8 @@ var fr = {
138
138
  'Oct': 'octobre',
139
139
  'Nov': 'novembre',
140
140
  'Dec': 'décembre',
141
- 'Enter_date': 'Enter date',
142
- 'Please_select': 'Please select',
141
+ 'Enter_date': 'Entrer une date',
142
+ 'Please_select': 'Veuillez sélectionner',
143
143
  'Total': 'Total',
144
144
  'Amount': 'Nombre',
145
145
  'Empty': 'Vide',
@@ -237,7 +237,9 @@ var fr = {
237
237
  'Add_new_stack': 'Ajouter une nouvelle pile',
238
238
  'Chart_type': 'Type de diagramme',
239
239
  'Edit_type': 'Modifier le type',
240
- 'Update_to_a_table': 'Update to a table',
240
+ 'New_table': 'New table',
241
+ 'Select_table': 'Sélectionner un tableau',
242
+ 'Update_to_a_table': 'Mettre à jour vers un tableau',
241
243
  'Export_to_a_new_table': 'Exporter dans un nouveau tableau'
242
244
  };
243
245
  export default fr;
@@ -50,7 +50,7 @@ var zh_CN = {
50
50
  'Style_settings': '样式设置',
51
51
  'Untitled': '未命名',
52
52
  'Settings': '设置',
53
- 'Table': '表格',
53
+ 'Table': '子表',
54
54
  'Views': '视图',
55
55
  'Display_title': '显示标题',
56
56
  'X-axis': 'X 轴',
@@ -237,6 +237,8 @@ var zh_CN = {
237
237
  'Add_new_stack': '添加新的堆叠',
238
238
  'Chart_type': '图表类型',
239
239
  'Edit_type': '编辑类型',
240
+ 'New_table': '新建表',
241
+ 'Select_table': '选择子表',
240
242
  'Update_to_a_table': '更新到子表',
241
243
  'Export_to_a_new_table': '导出到新的子表'
242
244
  };
@@ -101,8 +101,7 @@ var StatList = /*#__PURE__*/function (_Component) {
101
101
  return;
102
102
  }
103
103
  var _exportStatisticToTab = exportStatisticToTable({
104
- statisticalResult: _this.statisticalResult4Export,
105
- t: intl
104
+ statisticalResult: _this.statisticalResult4Export
106
105
  }),
107
106
  columns = _exportStatisticToTab.columns,
108
107
  rows = _exportStatisticToTab.rows;
@@ -142,8 +141,7 @@ var StatList = /*#__PURE__*/function (_Component) {
142
141
  }
143
142
  var _updateStatisticToTab = updateStatisticToTable({
144
143
  updateTable: updateTable,
145
- statisticalResult: _this.statisticalResult4Update,
146
- t: intl
144
+ statisticalResult: _this.statisticalResult4Update
147
145
  }),
148
146
  newRows = _updateStatisticToTab.newRows,
149
147
  updatedRows = _updateStatisticToTab.updatedRows,
@@ -1,15 +1,21 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
2
  import dayjs from 'dayjs';
3
+ import intl from 'react-intl-universal';
3
4
  import { getOption, getCollaborator, getNumberDisplayString, isNumber, CellType, FORMULA_RESULT_TYPE, FORMULA_COLUMN_TYPES, isDateColumn, TableUtils } from 'dtable-store';
4
5
  import { isCellValueChanged } from './cell-value';
5
6
  import { getSelectColumnOptions, getDateColumnFormat } from './column';
6
7
  import { getKnownCreatorByEmail } from './collaborator';
7
8
  import { EMPTY_NAME } from '../constants';
9
+ var isEmptyName = function isEmptyName(title) {
10
+ return title === null || title === '';
11
+ };
8
12
  var isSummaryDateColumn = function isSummaryDateColumn(summaryColumn) {
9
13
  if (!summaryColumn) return false;
10
14
  var type = summaryColumn.type;
11
15
  return type !== CellType.LINK && isDateColumn(summaryColumn);
12
16
  };
17
+
18
+ // eslint-disable-next-line
13
19
  var getTableValueDisplayName = function getTableValueDisplayName(value, column) {
14
20
  var _ref = column || {},
15
21
  type = _ref.type,
@@ -92,8 +98,7 @@ var getValidValueForColumn = function getValidValueForColumn(column, value) {
92
98
  };
93
99
  var getUpdatedOneDimensionStatisticTableResultToTable = function getUpdatedOneDimensionStatisticTableResultToTable(_ref3) {
94
100
  var updateTable = _ref3.updateTable,
95
- statisticalResult = _ref3.statisticalResult,
96
- t = _ref3.t;
101
+ statisticalResult = _ref3.statisticalResult;
97
102
  var pivotResult = statisticalResult.pivotResult,
98
103
  groupbyColumn = statisticalResult.groupbyColumn,
99
104
  statisticTableColumns = statisticalResult.statisticTableColumns;
@@ -111,13 +116,14 @@ var getUpdatedOneDimensionStatisticTableResultToTable = function getUpdatedOneDi
111
116
 
112
117
  // one dimension table no summary columns
113
118
  if (pivot_columns.length < 2) {
114
- columnMap['total'] = TableUtils.getTableColumnByName(updateTable, t('Total'));
119
+ columnMap['total'] = TableUtils.getTableColumnByName(updateTable, intl.get('Total'));
115
120
 
116
121
  // updated rows
117
122
  pivot_rows.forEach(function (item) {
118
123
  var name = item.name,
124
+ original_name = item.original_name,
119
125
  total = item.total;
120
- var groupName = name === null ? t(EMPTY_NAME) : getTableValueDisplayName(name, groupbyColumn);
126
+ var groupName = isEmptyName(original_name) ? intl.get(EMPTY_NAME) : name;
121
127
  var row = tableRows.find(function (row) {
122
128
  return row[nameColumn.key] === groupName;
123
129
  });
@@ -170,10 +176,11 @@ var getUpdatedOneDimensionStatisticTableResultToTable = function getUpdatedOneDi
170
176
  var nameColumnKey = nameColumn.key;
171
177
  pivot_rows.forEach(function (item) {
172
178
  var name = item.name,
179
+ original_name = item.original_name,
173
180
  total = item.total;
174
- var groupName = name === null ? t(EMPTY_NAME) : getTableValueDisplayName(name, groupbyColumn);
181
+ var groupName = isEmptyName(original_name) ? intl.get(EMPTY_NAME) : name;
175
182
  var row = tableRows.find(function (row) {
176
- return row[nameColumnKey] === name;
183
+ return row[nameColumnKey] === groupName;
177
184
  });
178
185
  if (row) {
179
186
  var updateRow = {};
@@ -215,11 +222,9 @@ var getUpdatedOneDimensionStatisticTableResultToTable = function getUpdatedOneDi
215
222
  };
216
223
  var getUpdatedTwoDimensionStatisticTableResultToTable = function getUpdatedTwoDimensionStatisticTableResultToTable(_ref4) {
217
224
  var updateTable = _ref4.updateTable,
218
- statisticalResult = _ref4.statisticalResult,
219
- t = _ref4.t;
225
+ statisticalResult = _ref4.statisticalResult;
220
226
  var pivotResult = statisticalResult.pivotResult,
221
- groupbyColumn = statisticalResult.groupbyColumn,
222
- columnGroupbyColumn = statisticalResult.columnGroupbyColumn;
227
+ groupbyColumn = statisticalResult.groupbyColumn;
223
228
  var nameColumn = TableUtils.getTableColumnByName(updateTable, groupbyColumn.name);
224
229
  if (!nameColumn) return {};
225
230
  var pivot_rows = pivotResult.pivot_rows,
@@ -233,19 +238,23 @@ var getUpdatedTwoDimensionStatisticTableResultToTable = function getUpdatedTwoDi
233
238
 
234
239
  // updated columns
235
240
  Array.isArray(pivot_columns) && pivot_columns.forEach(function (item) {
236
- var key = item.key;
237
- var columnName = key === null ? t(EMPTY_NAME) : getTableValueDisplayName(key, columnGroupbyColumn);
241
+ var key = item.key,
242
+ original_key = item.original_key;
243
+ var columnName = isEmptyName(original_key) ? intl.get(EMPTY_NAME) : key;
238
244
  columnMap[columnName] = TableUtils.getTableColumnByName(updateTable, columnName);
239
245
  });
240
- columnMap['total'] = TableUtils.getTableColumnByName(updateTable, t('Total'));
246
+ columnMap['total'] = TableUtils.getTableColumnByName(updateTable, intl.get('Total'));
241
247
 
242
248
  // updated rows
243
249
  var _loop = function _loop(i) {
244
250
  var pivotRow = pivot_rows[i];
245
251
  var name = pivotRow.name,
252
+ original_name = pivotRow.original_name,
246
253
  cells = pivotRow.cells,
247
254
  total = pivotRow.total;
248
- name = name === null ? t(EMPTY_NAME) : getTableValueDisplayName(name, groupbyColumn);
255
+ if (isEmptyName(original_name)) {
256
+ name = intl.get(EMPTY_NAME);
257
+ }
249
258
  var nameColumnKey = nameColumn.key;
250
259
  var row = tableRows.find(function (row) {
251
260
  return row[nameColumnKey] === name;
@@ -258,15 +267,15 @@ var getUpdatedTwoDimensionStatisticTableResultToTable = function getUpdatedTwoDi
258
267
  var validTotalCellValue = getValidValueForColumn(totalColumn, total);
259
268
  if (totalColumn && isCellValueChanged(row[totalColumn.key], validTotalCellValue, totalColumn.type)) {
260
269
  updatedRow[totalColumn.key] = validTotalCellValue;
261
- oldRow = row[totalColumn.key];
270
+ oldRow[totalColumn.key] = row[totalColumn.key];
262
271
  }
263
272
  Object.keys(cells).forEach(function (key) {
264
- var columnName = key === null ? t(EMPTY_NAME) : getTableValueDisplayName(key, columnGroupbyColumn);
273
+ var columnName = isEmptyName(key) ? intl.get(EMPTY_NAME) : key;
265
274
  var column = columnMap[columnName];
266
275
  var validCellValue = getValidValueForColumn(column, cells[key].total);
267
276
  if (column && isCellValueChanged(row[column.key], validCellValue, column.type)) {
268
277
  updatedRow[column.key] = validCellValue;
269
- oldRow = row[column.key];
278
+ oldRow[column.key] = row[column.key];
270
279
  }
271
280
  });
272
281
  if (Object.keys(updatedRow).length > 0) {
@@ -283,7 +292,7 @@ var getUpdatedTwoDimensionStatisticTableResultToTable = function getUpdatedTwoDi
283
292
  newRow[totalColumn.key] = getValidValueForColumn(totalColumn, name);
284
293
  }
285
294
  Object.keys(cells).forEach(function (key) {
286
- var columnName = key === null ? t(EMPTY_NAME) : getTableValueDisplayName(key, columnGroupbyColumn);
295
+ var columnName = isEmptyName(key) ? intl.get(EMPTY_NAME) : key;
287
296
  var column = columnMap[columnName];
288
297
  if (column) {
289
298
  newRow[column.key] = getValidValueForColumn(column, cells[key].total);
@@ -306,6 +315,19 @@ var getUpdatedTwoDimensionStatisticTableResultToTable = function getUpdatedTwoDi
306
315
  };
307
316
 
308
317
  /**
318
+ * statisticalResult: {
319
+ * columnGroupbyColumn: null,
320
+ * groupbyColumn: null,
321
+ * pivotResult: {
322
+ * pivot_columns: [],
323
+ * pivot_rows: [
324
+ * { name: 'xxx', original_name: 'xxx', total }
325
+ * ]
326
+ * },
327
+ * statisticTableColumns: null,
328
+ * summaryColumn: null,
329
+ * }
330
+ *
309
331
  * @return {
310
332
  * columns: [
311
333
  * {
@@ -324,8 +346,7 @@ var getUpdatedTwoDimensionStatisticTableResultToTable = function getUpdatedTwoDi
324
346
  * }
325
347
  */
326
348
  export var exportStatisticToTable = function exportStatisticToTable(_ref5) {
327
- var statisticalResult = _ref5.statisticalResult,
328
- t = _ref5.t;
349
+ var statisticalResult = _ref5.statisticalResult;
329
350
  var pivotResult = statisticalResult.pivotResult,
330
351
  groupbyColumn = statisticalResult.groupbyColumn,
331
352
  columnGroupbyColumn = statisticalResult.columnGroupbyColumn;
@@ -335,19 +356,16 @@ export var exportStatisticToTable = function exportStatisticToTable(_ref5) {
335
356
  // two dimension table
336
357
  if (columnGroupbyColumn) {
337
358
  return getTwoDimensionStatisticTableResultToTable({
338
- statisticalResult: statisticalResult,
339
- t: t
359
+ statisticalResult: statisticalResult
340
360
  });
341
361
  }
342
362
  if (!Array.isArray(pivot_columns)) return {};
343
363
  return getOneDimensionStatisticTableResultToTable({
344
- statisticalResult: statisticalResult,
345
- t: t
364
+ statisticalResult: statisticalResult
346
365
  });
347
366
  };
348
367
  export var getOneDimensionStatisticTableResultToTable = function getOneDimensionStatisticTableResultToTable(_ref6) {
349
- var statisticalResult = _ref6.statisticalResult,
350
- t = _ref6.t;
368
+ var statisticalResult = _ref6.statisticalResult;
351
369
  var pivotResult = statisticalResult.pivotResult,
352
370
  groupbyColumn = statisticalResult.groupbyColumn,
353
371
  statisticTableColumns = statisticalResult.statisticTableColumns,
@@ -407,7 +425,7 @@ export var getOneDimensionStatisticTableResultToTable = function getOneDimension
407
425
  // total column
408
426
  var totalColumn = {
409
427
  type: _isDateSummaryColumn ? CellType.DATE : CellType.NUMBER,
410
- name: t('Total'),
428
+ name: intl.get('Total'),
411
429
  data: columnData
412
430
  };
413
431
  columns.push(totalColumn);
@@ -416,13 +434,14 @@ export var getOneDimensionStatisticTableResultToTable = function getOneDimension
416
434
  pivot_rows.forEach(function (item) {
417
435
  var _newRow2;
418
436
  var name = item.name,
437
+ original_name = item.original_name,
419
438
  total = item.total;
420
- var groupName = name === null ? t(EMPTY_NAME) : getTableValueDisplayName(name, groupbyColumn);
439
+ var groupName = isEmptyName(original_name) ? intl.get(EMPTY_NAME) : name;
421
440
  var cellValue = total.total;
422
441
  if (_isDateSummaryColumn && cellValue) {
423
442
  cellValue = isIncludeHour ? dayjs(cellValue).format('YYYY-MM-DD HH:mm') : dayjs(cellValue).format('YYYY-MM-DD');
424
443
  }
425
- var newRow = (_newRow2 = {}, _defineProperty(_newRow2, groupbyColumn.name, groupName), _defineProperty(_newRow2, t('Total'), cellValue), _newRow2);
444
+ var newRow = (_newRow2 = {}, _defineProperty(_newRow2, groupbyColumn.name, groupName), _defineProperty(_newRow2, intl.get('Total'), cellValue), _newRow2);
426
445
  rows.push(newRow);
427
446
  });
428
447
  return {
@@ -481,8 +500,9 @@ export var getOneDimensionStatisticTableResultToTable = function getOneDimension
481
500
  // generator rows
482
501
  pivot_rows.forEach(function (item) {
483
502
  var name = item.name,
503
+ original_name = item.original_name,
484
504
  total = item.total;
485
- var groupName = name === null ? t(EMPTY_NAME) : getTableValueDisplayName(name, groupbyColumn);
505
+ var groupName = isEmptyName(original_name) ? intl.get(EMPTY_NAME) : name;
486
506
  var newRow = _defineProperty({}, groupbyColumn.name, groupName);
487
507
  Array.isArray(pivot_columns) && pivot_columns.forEach(function (item) {
488
508
  var key = item.key;
@@ -505,11 +525,9 @@ export var getOneDimensionStatisticTableResultToTable = function getOneDimension
505
525
  };
506
526
  };
507
527
  export var getTwoDimensionStatisticTableResultToTable = function getTwoDimensionStatisticTableResultToTable(_ref11) {
508
- var statisticalResult = _ref11.statisticalResult,
509
- t = _ref11.t;
528
+ var statisticalResult = _ref11.statisticalResult;
510
529
  var pivotResult = statisticalResult.pivotResult,
511
530
  groupbyColumn = statisticalResult.groupbyColumn,
512
- columnGroupbyColumn = statisticalResult.columnGroupbyColumn,
513
531
  summaryColumn = statisticalResult.summaryColumn;
514
532
  var pivot_rows = pivotResult.pivot_rows,
515
533
  pivot_columns = pivotResult.pivot_columns;
@@ -560,8 +578,9 @@ export var getTwoDimensionStatisticTableResultToTable = function getTwoDimension
560
578
  }
561
579
  }
562
580
  Array.isArray(pivot_columns) && pivot_columns.forEach(function (item) {
563
- var key = item.key;
564
- var columnName = key === null ? t(EMPTY_NAME) : getTableValueDisplayName(key, columnGroupbyColumn);
581
+ var key = item.key,
582
+ original_key = item.original_key;
583
+ var columnName = isEmptyName(original_key) ? intl.get(EMPTY_NAME) : key;
565
584
  var newColumn = {
566
585
  type: _isDateSummaryColumn ? CellType.DATE : CellType.NUMBER,
567
586
  name: columnName,
@@ -574,7 +593,7 @@ export var getTwoDimensionStatisticTableResultToTable = function getTwoDimension
574
593
  // total column
575
594
  var totalColumn = {
576
595
  type: _isDateSummaryColumn ? CellType.DATE : CellType.NUMBER,
577
- name: t('Total'),
596
+ name: intl.get('Total'),
578
597
  data: columnData
579
598
  };
580
599
  columns.push(totalColumn);
@@ -583,15 +602,18 @@ export var getTwoDimensionStatisticTableResultToTable = function getTwoDimension
583
602
  var dateFormat = isIncludeHour ? 'YYYY-MM-DD HH:mm' : 'YYYY-MM-DD';
584
603
  pivot_rows.forEach(function (item) {
585
604
  var name = item.name,
605
+ original_name = item.original_name,
586
606
  cells = item.cells,
587
607
  total = item.total;
588
- name = name === null ? t(EMPTY_NAME) : getTableValueDisplayName(name, groupbyColumn);
608
+ if (isEmptyName(original_name)) {
609
+ name = intl.get(EMPTY_NAME);
610
+ }
589
611
  var newRow = _defineProperty({}, groupbyColumn.name, name);
590
612
  var cellValue = total;
591
613
  if (_isDateSummaryColumn && cellValue) {
592
614
  cellValue = dayjs(cellValue).format(dateFormat);
593
615
  }
594
- newRow[t('Total')] = cellValue;
616
+ newRow[intl.get('Total')] = cellValue;
595
617
  Object.keys(cells).forEach(function (key) {
596
618
  var cellValue = cells[key].total;
597
619
  if (_isDateSummaryColumn) {
@@ -608,8 +630,7 @@ export var getTwoDimensionStatisticTableResultToTable = function getTwoDimension
608
630
  };
609
631
  export var updateStatisticToTable = function updateStatisticToTable(_ref14) {
610
632
  var updateTable = _ref14.updateTable,
611
- statisticalResult = _ref14.statisticalResult,
612
- t = _ref14.t;
633
+ statisticalResult = _ref14.statisticalResult;
613
634
  var groupbyColumn = statisticalResult.groupbyColumn,
614
635
  columnGroupbyColumn = statisticalResult.columnGroupbyColumn;
615
636
  if (!groupbyColumn) return {};
@@ -618,15 +639,13 @@ export var updateStatisticToTable = function updateStatisticToTable(_ref14) {
618
639
  if (columnGroupbyColumn) {
619
640
  return getUpdatedTwoDimensionStatisticTableResultToTable({
620
641
  updateTable: updateTable,
621
- statisticalResult: statisticalResult,
622
- t: t
642
+ statisticalResult: statisticalResult
623
643
  });
624
644
  }
625
645
 
626
646
  // one dimension table
627
647
  return getUpdatedOneDimensionStatisticTableResultToTable({
628
648
  updateTable: updateTable,
629
- statisticalResult: statisticalResult,
630
- t: t
649
+ statisticalResult: statisticalResult
631
650
  });
632
651
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dtable-statistic",
3
- "version": "4.0.10",
3
+ "version": "4.0.12",
4
4
  "description": "statistics",
5
5
  "main": "dist/dtable-statistic.js",
6
6
  "author": "seafile",
@@ -13,7 +13,7 @@
13
13
  "comlink": "^4.3.1",
14
14
  "dayjs": "1.10.7",
15
15
  "dtable-store": "4.0.6",
16
- "dtable-web-api": "4.0.1",
16
+ "dtable-web-api": "4.0.4",
17
17
  "glamor": "^2.20.40",
18
18
  "html2canvas": "^1.4.1",
19
19
  "rc-slider": "^9.7.4",