sea-chart 2.0.58 → 2.0.60

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.
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.default = void 0;
9
+ var _DTableSwitch2 = _interopRequireDefault(require("dtable-ui-component/lib/DTableSwitch"));
9
10
  var _DTableEmptyTip2 = _interopRequireDefault(require("dtable-ui-component/lib/DTableEmptyTip"));
10
11
  var _toaster2 = _interopRequireDefault(require("dtable-ui-component/lib/toaster"));
11
12
  var _react = _interopRequireWildcard(require("react"));
@@ -19,6 +20,8 @@ var _loading = _interopRequireDefault(require("../loading"));
19
20
  var _search = require("../../utils/search");
20
21
  var _chartDataSql = _interopRequireDefault(require("../../utils/sql/chart-data-sql"));
21
22
  var _rowRecordUtils = require("../../utils/row-record-utils");
23
+ var _icon = _interopRequireDefault(require("../icon"));
24
+ var _hideColumnPopover = _interopRequireDefault(require("../popover/hide-column-popover/hide-column-popover"));
22
25
  var _rowCard = _interopRequireDefault(require("../row-card/row-card"));
23
26
  var _commonConstants = require("../../constants/common-constants");
24
27
  var _utils = require("../../utils");
@@ -26,7 +29,83 @@ var _constants = require("../../constants");
26
29
  require("./index.css");
27
30
  class StatisticRecordDialog extends _react.default.Component {
28
31
  constructor(_props) {
32
+ var _this;
29
33
  super(_props);
34
+ _this = this;
35
+ this.initSearchSettings = (chart, table) => {
36
+ const allColumnKeys = ((table === null || table === void 0 ? void 0 : table.columns) || []).map(column => column.key);
37
+ const searchSettingKey = `${chart === null || chart === void 0 ? void 0 : chart.id}-${table === null || table === void 0 ? void 0 : table._id}`;
38
+ const searchConfig = JSON.parse(window.localStorage.getItem('sea-chart-search-config') || '{}');
39
+ const searchSetting = searchConfig[searchSettingKey] || {};
40
+ const nameColumnKey = allColumnKeys[0];
41
+ const savedColumns = searchSetting.search_participate_columns || allColumnKeys;
42
+ const searchParticipateColumns = savedColumns.includes(nameColumnKey) ? savedColumns : [nameColumnKey, ...savedColumns];
43
+ return {
44
+ isExactSearch: !!searchSetting.is_exact,
45
+ searchParticipateColumns
46
+ };
47
+ };
48
+ this.onSaveSearchConfig = function () {
49
+ let updatedConfig = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
50
+ const {
51
+ chart
52
+ } = _this.props.chartRecordsParams || {};
53
+ if (!chart || !_this.table) return;
54
+ const searchSettingKey = `${chart.id}-${_this.table._id}`;
55
+ const searchConfig = JSON.parse(window.localStorage.getItem('sea-chart-search-config') || '{}');
56
+ window.localStorage.setItem('sea-chart-search-config', JSON.stringify({
57
+ ...searchConfig,
58
+ [searchSettingKey]: updatedConfig
59
+ }));
60
+ };
61
+ this.onChangeExactSearch = () => {
62
+ const isExactSearch = !this.state.isExactSearch;
63
+ const {
64
+ rows,
65
+ searchVal
66
+ } = this.state;
67
+ const searchedRowsIds = this.getSearchedRows(rows, searchVal, {
68
+ isExactSearch
69
+ });
70
+ this.setState({
71
+ isExactSearch,
72
+ searchedRowsIds
73
+ });
74
+ this.onSaveSearchConfig({
75
+ is_exact: isExactSearch,
76
+ search_participate_columns: this.state.searchParticipateColumns
77
+ });
78
+ };
79
+ this.modifySearchParticipateColumns = shownColumnKeys => {
80
+ var _this$table$columns$;
81
+ const nameColumnKey = (_this$table$columns$ = this.table.columns[0]) === null || _this$table$columns$ === void 0 ? void 0 : _this$table$columns$.key;
82
+ const searchParticipateColumns = shownColumnKeys.includes(nameColumnKey) ? shownColumnKeys : [nameColumnKey, ...shownColumnKeys];
83
+ const {
84
+ rows,
85
+ searchVal
86
+ } = this.state;
87
+ const searchedRowsIds = this.getSearchedRows(rows, searchVal, {
88
+ searchParticipateColumns
89
+ });
90
+ this.setState({
91
+ searchParticipateColumns,
92
+ searchedRowsIds
93
+ });
94
+ this.onSaveSearchConfig({
95
+ is_exact: this.state.isExactSearch,
96
+ search_participate_columns: searchParticipateColumns
97
+ });
98
+ };
99
+ this.toggleSearchHidePopover = () => {
100
+ this.setState({
101
+ isShowSearchHidePopover: !this.state.isShowSearchHidePopover
102
+ });
103
+ };
104
+ this.onToggleShowExactMatch = () => {
105
+ this.setState({
106
+ isShowExactMatch: !this.state.isShowExactMatch
107
+ });
108
+ };
30
109
  this.init = () => {
31
110
  const {
32
111
  chartRecordsParams,
@@ -186,10 +265,22 @@ class StatisticRecordDialog extends _react.default.Component {
186
265
  searchVal: ''
187
266
  });
188
267
  };
189
- this.getSearchedRows = (rows, searchVal) => {
268
+ this.getSearchedRows = function (rows, searchVal) {
269
+ let settings = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
190
270
  if (!Array.isArray(rows) || rows.length === 0) return [];
191
271
  if (searchVal) {
192
- return (0, _search.searchRows)(rows, (0, _dtableUtils.getViewShownColumns)(this.view, this.table.columns), searchVal, row => {
272
+ var _settings$isExactSear, _settings$searchParti, _this$table$columns$2;
273
+ const isExactSearch = (_settings$isExactSear = settings.isExactSearch) !== null && _settings$isExactSear !== void 0 ? _settings$isExactSear : _this.state.isExactSearch;
274
+ const participateKeys = (_settings$searchParti = settings.searchParticipateColumns) !== null && _settings$searchParti !== void 0 ? _settings$searchParti : _this.state.searchParticipateColumns;
275
+ const nameColumnKey = (_this$table$columns$2 = _this.table.columns[0]) === null || _this$table$columns$2 === void 0 ? void 0 : _this$table$columns$2.key;
276
+ const searchParticipateColumns = participateKeys.includes(nameColumnKey) ? participateKeys : [nameColumnKey, ...participateKeys];
277
+ const searchColumns = (0, _dtableUtils.getViewShownColumns)(_this.view, _this.table.columns).filter(col => searchParticipateColumns.includes(col.key));
278
+ if (isExactSearch) {
279
+ return (0, _search.searchRowsByExactVal)(searchVal.trim().toLowerCase(), rows, searchColumns, {
280
+ formulaRows: _this.formulaRows
281
+ }).map(row => row._id);
282
+ }
283
+ return (0, _search.searchRows)(rows, searchColumns, searchVal, row => {
193
284
  return row;
194
285
  }).map(row => row._id);
195
286
  }
@@ -294,14 +385,25 @@ class StatisticRecordDialog extends _react.default.Component {
294
385
  formulaRows: view.formula_rows
295
386
  };
296
387
  };
388
+ this.getCachedSearchedRows = (searchedRowsIds, rows) => {
389
+ if (this.searchedRowsCache.searchedRowsIds !== searchedRowsIds || this.searchedRowsCache.rows !== rows) {
390
+ this.searchedRowsCache = {
391
+ searchedRowsIds,
392
+ rows,
393
+ result: this.getRowsByIds(searchedRowsIds)
394
+ };
395
+ }
396
+ return this.searchedRowsCache.result;
397
+ };
297
398
  this.renderRowsCards = () => {
298
399
  const {
299
400
  isCalculateByView
300
401
  } = this.props;
301
402
  const {
302
- searchedRowsIds
403
+ searchedRowsIds,
404
+ rows
303
405
  } = this.state;
304
- const searchedRows = this.getRowsByIds(searchedRowsIds);
406
+ const searchedRows = this.getCachedSearchedRows(searchedRowsIds, rows);
305
407
  if (searchedRows.length === 0) return /*#__PURE__*/_react.default.createElement("div", {
306
408
  className: "w-100 h-100"
307
409
  }, /*#__PURE__*/_react.default.createElement(_DTableEmptyTip2.default, {
@@ -317,22 +419,45 @@ class StatisticRecordDialog extends _react.default.Component {
317
419
  columns: this.renderedColumns,
318
420
  rows: searchedRows,
319
421
  isExpandRowDetail: isCalculateByView,
422
+ isVirtualized: true,
423
+ showScrollBtn: !window.isMobile,
320
424
  rowCardType: 'statistic'
321
425
  };
322
426
  return /*#__PURE__*/_react.default.createElement(_rowCard.default, props);
323
427
  };
428
+ const {
429
+ chartRecordsParams: _chartRecordsParams,
430
+ tables: _tables
431
+ } = _props;
432
+ const {
433
+ chart: _chart
434
+ } = _chartRecordsParams || {};
435
+ const _table = _chart ? (0, _dtableUtils.getTableById)(_tables, _chart.config.table_id) : null;
436
+ const {
437
+ isExactSearch: _isExactSearch,
438
+ searchParticipateColumns: _searchParticipateColumns
439
+ } = this.initSearchSettings(_chart, _table);
324
440
  this.state = {
325
441
  loading: true,
326
442
  title: '',
327
443
  rows: [],
328
444
  idRowMap: {},
329
445
  searchVal: '',
330
- searchedRowsIds: []
446
+ searchedRowsIds: [],
447
+ isExactSearch: _isExactSearch,
448
+ searchParticipateColumns: _searchParticipateColumns,
449
+ isShowExactMatch: _isExactSearch,
450
+ isShowSearchHidePopover: false
331
451
  };
332
452
  this.table = null;
333
453
  this.valueChanged = false;
334
454
  this.renderedColumns = [];
335
455
  this.formulaRows = null;
456
+ this.searchedRowsCache = {
457
+ searchedRowsIds: null,
458
+ rows: null,
459
+ result: []
460
+ };
336
461
  }
337
462
  componentDidMount() {
338
463
  const {
@@ -348,10 +473,17 @@ class StatisticRecordDialog extends _react.default.Component {
348
473
  this.unsubscribeExpandRowDeleted && this.unsubscribeExpandRowDeleted();
349
474
  }
350
475
  render() {
476
+ var _this$table, _this$table2, _this$table2$columns, _this$table2$columns$;
351
477
  const {
352
478
  loading,
353
- title
479
+ title,
480
+ isExactSearch,
481
+ searchParticipateColumns,
482
+ isShowExactMatch,
483
+ isShowSearchHidePopover
354
484
  } = this.state;
485
+ const searchableColumns = (((_this$table = this.table) === null || _this$table === void 0 ? void 0 : _this$table.columns) || []).filter(col => _search.SUPPORT_SEARCH_COLUMN_TYPES.includes(col.type));
486
+ const nameColumnKey = (_this$table2 = this.table) === null || _this$table2 === void 0 ? void 0 : (_this$table2$columns = _this$table2.columns) === null || _this$table2$columns === void 0 ? void 0 : (_this$table2$columns$ = _this$table2$columns[0]) === null || _this$table2$columns$ === void 0 ? void 0 : _this$table2$columns$.key;
355
487
  return /*#__PURE__*/_react.default.createElement(_reactstrap.Modal, {
356
488
  isOpen: true,
357
489
  autoFocus: false,
@@ -384,9 +516,40 @@ class StatisticRecordDialog extends _react.default.Component {
384
516
  }, /*#__PURE__*/_react.default.createElement("i", {
385
517
  className: "dtable-font dtable-icon-x-"
386
518
  }));
519
+ },
520
+ ExactMatchIndicator: () => {
521
+ return /*#__PURE__*/_react.default.createElement("span", {
522
+ className: "clear-search-text exact-match-search-text"
523
+ }, /*#__PURE__*/_react.default.createElement("div", {
524
+ className: "right-exact-button",
525
+ onClick: this.onToggleShowExactMatch
526
+ }, /*#__PURE__*/_react.default.createElement(_icon.default, {
527
+ symbol: "exact-match"
528
+ })));
387
529
  }
388
530
  }
389
- })), /*#__PURE__*/_react.default.createElement(_reactstrap.ModalBody, {
531
+ })), isShowExactMatch && /*#__PURE__*/_react.default.createElement("div", {
532
+ className: "search-settings-container d-flex align-items-center"
533
+ }, /*#__PURE__*/_react.default.createElement(_DTableSwitch2.default, {
534
+ size: "sm",
535
+ switchPosition: "left",
536
+ checked: isExactSearch,
537
+ placeholder: _intl.default.get('Exact_match'),
538
+ onChange: this.onChangeExactSearch
539
+ }), /*#__PURE__*/_react.default.createElement("span", {
540
+ className: "toolbar-btn exact-search-columns",
541
+ id: "statistic-search-hide-column",
542
+ onClick: this.toggleSearchHidePopover
543
+ }, /*#__PURE__*/_react.default.createElement(_icon.default, {
544
+ symbol: "field-set"
545
+ }), /*#__PURE__*/_react.default.createElement("span", null, _intl.default.get('Searchable_columns')))), isShowSearchHidePopover && /*#__PURE__*/_react.default.createElement(_hideColumnPopover.default, {
546
+ columns: searchableColumns,
547
+ ignoreColumnsKeys: nameColumnKey ? [nameColumnKey] : [],
548
+ target: "statistic-search-hide-column",
549
+ shownColumnKeys: searchParticipateColumns,
550
+ modifyHiddenColumns: this.modifySearchParticipateColumns,
551
+ onPopoverToggle: this.toggleSearchHidePopover
552
+ }), /*#__PURE__*/_react.default.createElement(_reactstrap.ModalBody, {
390
553
  className: "sea-chart-statistic-records-container"
391
554
  }, loading ? /*#__PURE__*/_react.default.createElement("div", {
392
555
  className: "d-flex py-8"
@@ -259,6 +259,10 @@ const de = {
259
259
  "Use_default_color": "Standardfarbe verwenden",
260
260
  "Use_colors_in_single_select_solumn": "Verwenden Sie Farben in einer einzelnen Auswahlspalte",
261
261
  "Search_records": "Einträge suchen",
262
+ "Exact_match": "Exakte Übereinstimmung",
263
+ "Searchable_columns": "Durchsuchbare Spalten",
264
+ "Clear_search_text": "Suchtext leeren",
265
+ "No_columns_available_to_be_hidden": "Es können keine Spalten ausgeblendet werden.",
262
266
  "Please_select_a_grouping_column": "Bitte Gruppierungsspalte auswählen",
263
267
  "View": "Sicht",
264
268
  "Funnel": "Trichterdiagramm",
@@ -259,6 +259,10 @@ const en = {
259
259
  "Use_default_color": "Use default color",
260
260
  "Use_colors_in_single_select_solumn": "Use colors in single select column",
261
261
  "Search_records": "Search records",
262
+ "Exact_match": "Exact match",
263
+ "Searchable_columns": "Searchable columns",
264
+ "Clear_search_text": "Clear search text",
265
+ "No_columns_available_to_be_hidden": "No columns available to be hidden.",
262
266
  "Please_select_a_grouping_column": "Please select grouping column",
263
267
  "View": "View",
264
268
  "Funnel": "Funnel",
@@ -259,6 +259,10 @@ const es = {
259
259
  "Use_default_color": "Use default color",
260
260
  "Use_colors_in_single_select_solumn": "Use colors in single select column",
261
261
  "Search_records": "Search records",
262
+ "Exact_match": "Coincidencia exacta",
263
+ "Searchable_columns": "Columnas de búsqueda",
264
+ "Clear_search_text": "Limpiar texto de búsqueda",
265
+ "No_columns_available_to_be_hidden": "No hay columnas disponibles para ocultar.",
262
266
  "Please_select_a_grouping_column": "Please select grouping column",
263
267
  "View": "View",
264
268
  "Funnel": "Funnel",
@@ -259,6 +259,10 @@ const fr = {
259
259
  "Use_default_color": "Utiliser la couleur par défaut",
260
260
  "Use_colors_in_single_select_solumn": "Utiliser les couleurs dans une colonne de sélection unique",
261
261
  "Search_records": "Rechercher des enregistrements",
262
+ "Exact_match": "Correspondence exacte",
263
+ "Searchable_columns": "Colonnes de recherche",
264
+ "Clear_search_text": "Effacer le texte de recherche",
265
+ "No_columns_available_to_be_hidden": "Aucune colonne ne peut être masquée.",
262
266
  "Please_select_a_grouping_column": "Veuillez sélectionner la colonne de regroupement",
263
267
  "View": "Voir",
264
268
  "Funnel": "Entonnoir",
@@ -259,6 +259,10 @@ const pt = {
259
259
  "Use_default_color": "Use default color",
260
260
  "Use_colors_in_single_select_solumn": "Use colors in single select column",
261
261
  "Search_records": "Search records",
262
+ "Exact_match": "Correspondência exacta",
263
+ "Searchable_columns": "Colunas pesquisáveis",
264
+ "Clear_search_text": "Limpar texto de pesquisa",
265
+ "No_columns_available_to_be_hidden": "Nenhuma coluna disponível para ser ocultada.",
262
266
  "Please_select_a_grouping_column": "Please select grouping column",
263
267
  "View": "View",
264
268
  "Funnel": "Funnel",
@@ -259,6 +259,10 @@ const ru = {
259
259
  "Use_default_color": "Use default color",
260
260
  "Use_colors_in_single_select_solumn": "Use colors in single select column",
261
261
  "Search_records": "Search records",
262
+ "Exact_match": "Точное соответствие",
263
+ "Searchable_columns": "Поиск столбцов",
264
+ "Clear_search_text": "Очистить текст поиска",
265
+ "No_columns_available_to_be_hidden": "Нет доступных столбцов для скрытия",
262
266
  "Please_select_a_grouping_column": "Please select grouping column",
263
267
  "View": "View",
264
268
  "Funnel": "Funnel",
@@ -259,6 +259,10 @@ const zh_CN = {
259
259
  "Use_default_color": "使用默认颜色",
260
260
  "Use_colors_in_single_select_solumn": "使用列中的选项颜色",
261
261
  "Search_records": "搜索记录",
262
+ "Exact_match": "精确匹配",
263
+ "Searchable_columns": "可搜索的列",
264
+ "Clear_search_text": "清除搜索文本",
265
+ "No_columns_available_to_be_hidden": "没有列可以被隐藏。",
262
266
  "Please_select_a_grouping_column": "请选择一个分组列",
263
267
  "View": "视图",
264
268
  "Funnel": "漏斗图",
@@ -4,12 +4,13 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.searchRows = void 0;
7
+ exports.searchRowsByExactVal = exports.searchRows = exports.SUPPORT_SEARCH_COLUMN_TYPES = void 0;
8
8
  var _dayjs = _interopRequireDefault(require("dayjs"));
9
- var _context = _interopRequireDefault(require("../context"));
10
9
  var _dtableUtils = require("dtable-utils");
10
+ var _context = _interopRequireDefault(require("../context"));
11
11
  var _columnUtils = require("./column-utils");
12
- const SUPPORT_SEARCH_COLUMN_TYPES = [_dtableUtils.CellType.DATE, _dtableUtils.CellType.TEXT, _dtableUtils.CellType.LONG_TEXT, _dtableUtils.CellType.NUMBER, _dtableUtils.CellType.URL, _dtableUtils.CellType.EMAIL, _dtableUtils.CellType.SINGLE_SELECT, _dtableUtils.CellType.CTIME, _dtableUtils.CellType.MTIME, _dtableUtils.CellType.MULTIPLE_SELECT, _dtableUtils.CellType.LAST_MODIFIER, _dtableUtils.CellType.CREATOR, _dtableUtils.CellType.COLLABORATOR, _dtableUtils.CellType.LINK, _dtableUtils.CellType.FORMULA, _dtableUtils.CellType.LINK_FORMULA, _dtableUtils.CellType.AUTO_NUMBER, _dtableUtils.CellType.GEOLOCATION, _dtableUtils.CellType.DURATION];
12
+ var _cellFormatUtils = require("./cell-format-utils");
13
+ const SUPPORT_SEARCH_COLUMN_TYPES = exports.SUPPORT_SEARCH_COLUMN_TYPES = [_dtableUtils.CellType.DATE, _dtableUtils.CellType.TEXT, _dtableUtils.CellType.LONG_TEXT, _dtableUtils.CellType.NUMBER, _dtableUtils.CellType.URL, _dtableUtils.CellType.EMAIL, _dtableUtils.CellType.SINGLE_SELECT, _dtableUtils.CellType.CTIME, _dtableUtils.CellType.MTIME, _dtableUtils.CellType.MULTIPLE_SELECT, _dtableUtils.CellType.LAST_MODIFIER, _dtableUtils.CellType.CREATOR, _dtableUtils.CellType.COLLABORATOR, _dtableUtils.CellType.LINK, _dtableUtils.CellType.FORMULA, _dtableUtils.CellType.LINK_FORMULA, _dtableUtils.CellType.AUTO_NUMBER, _dtableUtils.CellType.GEOLOCATION, _dtableUtils.CellType.DURATION];
13
14
  const searchRows = (rows, columns, val, processRow) => {
14
15
  let dtableCollaborators = _context.default.getCollaboratorFromCache() || [];
15
16
  let collaborators = _context.default.collaborators || [];
@@ -71,4 +72,35 @@ const searchRows = (rows, columns, val, processRow) => {
71
72
  });
72
73
  return searchResult;
73
74
  };
74
- exports.searchRows = searchRows;
75
+ exports.searchRows = searchRows;
76
+ const searchRowsByExactVal = function (searchValue) {
77
+ let rows = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
78
+ let columns = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
79
+ let {
80
+ formulaRows = {}
81
+ } = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
82
+ // search matched rows from support columns
83
+ const validColumns = columns.filter(column => SUPPORT_SEARCH_COLUMN_TYPES.includes(column.type));
84
+ if (!Array.isArray(rows) || rows.length === 0) return [];
85
+ if (!searchValue) return rows;
86
+ const collaborators = [...(_context.default.getCollaboratorsFromCache() || []), ...(_context.default.collaborators || [])];
87
+ return rows.filter(row => {
88
+ for (const column of validColumns) {
89
+ const {
90
+ key,
91
+ type,
92
+ data
93
+ } = column;
94
+ const formattedCellValue = (0, _cellFormatUtils.getClientCellValueDisplayString)(row, type, key, {
95
+ formulaRows,
96
+ data,
97
+ collaborators
98
+ });
99
+ if (formattedCellValue && formattedCellValue.trim() && formattedCellValue.toLowerCase() === searchValue) {
100
+ return true;
101
+ }
102
+ }
103
+ return false;
104
+ });
105
+ };
106
+ exports.searchRowsByExactVal = searchRowsByExactVal;
@@ -146,7 +146,10 @@ class View extends _react.default.PureComponent {
146
146
  isCalculateByView,
147
147
  autoRefresh,
148
148
  refreshInterval,
149
- pageId
149
+ pageId,
150
+ hasUnSaved,
151
+ chart,
152
+ tables
150
153
  } = this.props;
151
154
  this.unsubscribeReFreshChart = _eventBus.default.subscribe(_commonConstants.CommonEventTypes.REFRESH_CHARTS, this.refreshChart);
152
155
 
@@ -167,10 +170,7 @@ class View extends _react.default.PureComponent {
167
170
  this.calculateStatistic();
168
171
  }, refreshInterval * 60000);
169
172
  }
170
- const {
171
- hasUnSaved
172
- } = this.props;
173
- if (!hasUnSaved) {
173
+ if (!hasUnSaved || !_chartUtils.BaseUtils.isValidExistChart(tables, chart)) {
174
174
  this.calculateStatistic();
175
175
  }
176
176
  }
@@ -178,20 +178,20 @@ class View extends _react.default.PureComponent {
178
178
  this.unsubscribeReFreshChart();
179
179
  this.refreshTimer && clearInterval(this.refreshTimer);
180
180
  }
181
- componentDidUpdate(nextProps) {
182
- const {
183
- chart: oldChart,
184
- hasUnSaved,
185
- version
186
- } = this.props;
181
+ componentDidUpdate(prevProps) {
187
182
  const {
188
183
  chart,
189
- hasUnSaved: nextUnSaved,
190
- version: nextVersion,
184
+ hasUnSaved,
185
+ version,
191
186
  autoRefresh,
192
187
  refreshInterval,
193
188
  pageId
194
- } = nextProps;
189
+ } = this.props;
190
+ const {
191
+ chart: oldChart,
192
+ hasUnSaved: prevHasUnSaved,
193
+ version: prevVersion
194
+ } = prevProps;
195
195
  const {
196
196
  data
197
197
  } = this.state;
@@ -216,32 +216,32 @@ class View extends _react.default.PureComponent {
216
216
 
217
217
  // universal-apps will not trigger calculation of the chart before the chart config saved
218
218
  // after saving, hasUnSaved was set to false, then start calculation
219
- const needCalc = hasUnSaved === true && nextUnSaved === false;
219
+ const needCalc = prevHasUnSaved === true && hasUnSaved === false;
220
220
  if (needCalc && !data) {
221
221
  this.calculateStatistic();
222
222
  return;
223
223
  }
224
224
 
225
225
  // version was used to dectect table change in big screen plugin
226
- if ((0, _shallowequal.default)(chart, oldChart) && version === nextVersion) return;
226
+ if ((0, _shallowequal.default)(chart, oldChart) && version === prevVersion) return;
227
227
  this.setState({
228
228
  isCalculated: false
229
229
  }, () => {
230
- if (_chartUtils.BaseUtils.isChartTypeChange(chart, oldChart)) {
230
+ if (_chartUtils.BaseUtils.isChartTypeChange(oldChart, chart)) {
231
231
  this.calculateStatistic();
232
232
  return;
233
233
  }
234
- if (_chartUtils.BaseUtils.isChartViewChange(chart, oldChart)) {
234
+ if (_chartUtils.BaseUtils.isChartViewChange(oldChart, chart)) {
235
235
  this.calculateStatistic();
236
236
  return;
237
237
  }
238
- if (_chartUtils.BaseUtils.isChartStyleChange(chart, oldChart)) {
238
+ if (_chartUtils.BaseUtils.isChartStyleChange(oldChart, chart)) {
239
239
  this.setState({
240
240
  isCalculated: true
241
241
  });
242
242
  return;
243
243
  }
244
- if (_chartUtils.BaseUtils.isChartSortChange(chart, oldChart)) {
244
+ if (_chartUtils.BaseUtils.isChartSortChange(oldChart, chart)) {
245
245
  this.calculateStatistic(false);
246
246
  return;
247
247
  }
@@ -365,6 +365,11 @@ const propTypes = exports.propTypes = {
365
365
  departments: _propTypes.default.array,
366
366
  dtableStoreValue: _propTypes.default.object,
367
367
  isCalculateByView: _propTypes.default.bool,
368
+ hasUnSaved: _propTypes.default.bool,
369
+ pageId: _propTypes.default.string,
370
+ version: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
371
+ autoRefresh: _propTypes.default.bool,
372
+ refreshInterval: _propTypes.default.number,
368
373
  // event
369
374
  integratedEventTypes: _propTypes.default.object,
370
375
  integratedEventBus: _propTypes.default.object,