sea-chart 0.0.76-alpha.5 → 0.0.77

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.
@@ -83,7 +83,7 @@ const de = {
83
83
  "Calculate_the_number_of_records_in_two_time_periods": "Anzahl der Einträge in zwei Zeitperioden vergleichen",
84
84
  "Use_a_field_to_calculate_the_sum_maximum_or_minimum_value_of_records_in_two_time_periods": "Ein Feld verwenden, um die Summe, das Maximum, das Minimum oder den Durchschnitt von Datensätzen in zwei Zeiträumen zu berechnen",
85
85
  "No_options": "Keine Optionen",
86
- "Alignment": "Alignment",
86
+ "Alignment": "Ausrichtung",
87
87
  "Text_horizontal_alignment": "Horizontale Ausrichtung des Textes",
88
88
  "Please_input_date": "Datum eingeben",
89
89
  "Filter": "Filtern",
@@ -140,8 +140,10 @@ const de = {
140
140
  "Hour": "Stunde",
141
141
  "Minute": "Minute",
142
142
  "Done": "Erledigt",
143
+ "Error": "Fehler",
143
144
  "Internal_server_error": "Interner Serverfehler",
144
145
  "Network_error": "Netzwerkfehler",
146
+ "Permission_denied": "Zugriff verweigert",
145
147
  "There_are_some_problems_with_the_filters": "Die Filterbedingungen sind abnormal. Bitte setzen sie die Filterbedingungen in den Ansichtseinstellungen zurück.",
146
148
  "Please_complete_the_chart_configuration_first": "Schließen Sie die Konfiguration des Diagramms ab.",
147
149
  "Not_used": "Nicht verwendet",
@@ -179,7 +181,7 @@ const de = {
179
181
  "Statistic_field": "Statisches Feld",
180
182
  "target": "Ziel",
181
183
  "completed": "vollständig",
182
- "Completed_field": "Completed Field",
184
+ "Completed_field": "Abgeschlossenes Feld",
183
185
  "Target_field": "Zielfeld",
184
186
  "Show_percentage": "Prozent anzeigen",
185
187
  "Name_field": "Name",
@@ -239,7 +241,7 @@ const de = {
239
241
  "Previous_30_days": "Vorherige 30 Tage",
240
242
  "The_day_before_yesterday": "Vorgestern",
241
243
  "Can_not_compare_with_{var}": "Ein Vergleich mit {var} ist nicht möglich.",
242
- "Number": "Number",
244
+ "Number": "Zahl",
243
245
  "polylines": "Polygonzug",
244
246
  "curves": "Kurven",
245
247
  "Line_type": "Linientyp",
@@ -140,8 +140,10 @@ const en = {
140
140
  "Hour": "Hour",
141
141
  "Minute": "Minute",
142
142
  "Done": "Done",
143
+ "Error": "Error",
143
144
  "Internal_server_error": "Internal server error",
144
145
  "Network_error": "Network error",
146
+ "Permission_denied": "Permission denied",
145
147
  "There_are_some_problems_with_the_filters": "There are some problems with the filters.",
146
148
  "Please_complete_the_chart_configuration_first": "Please complete the chart configuration first",
147
149
  "Not_used": "Not used",
@@ -140,8 +140,10 @@ const es = {
140
140
  "Hour": "Hour",
141
141
  "Minute": "Minute",
142
142
  "Done": "Done",
143
+ "Error": "Error",
143
144
  "Internal_server_error": "Internal server error",
144
145
  "Network_error": "Network error",
146
+ "Permission_denied": "Permission denied",
145
147
  "There_are_some_problems_with_the_filters": "There are some problems with the filters.",
146
148
  "Please_complete_the_chart_configuration_first": "Please complete the chart configuration first",
147
149
  "Not_used": "Not used",
@@ -83,7 +83,7 @@ const fr = {
83
83
  "Calculate_the_number_of_records_in_two_time_periods": "Calculer le nombre d'enregistrements pour deux périodes de temps",
84
84
  "Use_a_field_to_calculate_the_sum_maximum_or_minimum_value_of_records_in_two_time_periods": "Utiliser une colonne pour calculer la somme, le maximum, le minimum ou la moyenne des enregistrements pour deux périodes de temps",
85
85
  "No_options": "Il n'y a pas d'options.",
86
- "Alignment": "Alignment",
86
+ "Alignment": "Alignement",
87
87
  "Text_horizontal_alignment": "Alignement de texte horizontal",
88
88
  "Please_input_date": "Veuillez entrer la date",
89
89
  "Filter": "Filtrer",
@@ -140,8 +140,10 @@ const fr = {
140
140
  "Hour": "Heure",
141
141
  "Minute": "Minute",
142
142
  "Done": "Fait",
143
+ "Error": "Erreur",
143
144
  "Internal_server_error": "Erreur interne du serveur",
144
145
  "Network_error": "Erreur réseau",
146
+ "Permission_denied": "Permission refusée",
145
147
  "There_are_some_problems_with_the_filters": "Les conditions de filtrage sont anormales. Veuillez réinitialiser les conditions de filtrage dans les paramètres de vue.",
146
148
  "Please_complete_the_chart_configuration_first": "Compléter la configuration du diagramme",
147
149
  "Not_used": "Ne pas utilisé",
@@ -179,7 +181,7 @@ const fr = {
179
181
  "Statistic_field": "Champ statistique",
180
182
  "target": "cible",
181
183
  "completed": "complété",
182
- "Completed_field": "Completed Field",
184
+ "Completed_field": "Champ complété",
183
185
  "Target_field": "Champ cible",
184
186
  "Show_percentage": "Afficher le pourcentage",
185
187
  "Name_field": "Nom",
@@ -199,7 +201,7 @@ const fr = {
199
201
  "Y_axis_column_not_found": "La colonne pour l'axe des y n'a pas été trouvée.",
200
202
  "Numeric_column_not_found": "La colonne numérique n'a pas été trouvée.",
201
203
  "Target_column_not_found": "La colonne cible n'a pas été trouvée",
202
- "Completed_column_not_found": "Completed column not found",
204
+ "Completed_column_not_found": "Colonne complétée introuvable",
203
205
  "Target_summary_method_is_not_valid": "La méthode de résumé cible n'est pas valide.",
204
206
  "Grid_size": "Taille de la grille\n",
205
207
  "Grid_distance": "Ecart entre les grilles",
@@ -239,7 +241,7 @@ const fr = {
239
241
  "Previous_30_days": "30 jours précédents",
240
242
  "The_day_before_yesterday": "Avant-hier",
241
243
  "Can_not_compare_with_{var}": "Il est impossible de comparer avec {var}.",
242
- "Number": "Number",
244
+ "Number": "Nombre",
243
245
  "polylines": "Ligne polygonale",
244
246
  "curves": "Courbes",
245
247
  "Line_type": "Type de ligne",
@@ -140,8 +140,10 @@ const pt = {
140
140
  "Hour": "Hour",
141
141
  "Minute": "Minute",
142
142
  "Done": "Done",
143
+ "Error": "Error",
143
144
  "Internal_server_error": "Internal server error",
144
145
  "Network_error": "Network error",
146
+ "Permission_denied": "Permission denied",
145
147
  "There_are_some_problems_with_the_filters": "There are some problems with the filters.",
146
148
  "Please_complete_the_chart_configuration_first": "Please complete the chart configuration first",
147
149
  "Not_used": "Not used",
@@ -140,8 +140,10 @@ const ru = {
140
140
  "Hour": "Hour",
141
141
  "Minute": "Minute",
142
142
  "Done": "Done",
143
+ "Error": "Error",
143
144
  "Internal_server_error": "Internal server error",
144
145
  "Network_error": "Network error",
146
+ "Permission_denied": "Permission denied",
145
147
  "There_are_some_problems_with_the_filters": "There are some problems with the filters.",
146
148
  "Please_complete_the_chart_configuration_first": "Please complete the chart configuration first",
147
149
  "Not_used": "Not used",
@@ -83,7 +83,7 @@ const zh_CN = {
83
83
  "Calculate_the_number_of_records_in_two_time_periods": "计算两个时间段的记录数",
84
84
  "Use_a_field_to_calculate_the_sum_maximum_or_minimum_value_of_records_in_two_time_periods": "使用字段计算两个时间段内记录的最大值或最小值之和",
85
85
  "No_options": "没有选项",
86
- "Alignment": "Alignment",
86
+ "Alignment": "对齐方式",
87
87
  "Text_horizontal_alignment": "文本水平对齐",
88
88
  "Please_input_date": "请输入日期",
89
89
  "Filter": "过滤",
@@ -140,8 +140,10 @@ const zh_CN = {
140
140
  "Hour": "时",
141
141
  "Minute": "分",
142
142
  "Done": "完成",
143
+ "Error": "错误",
143
144
  "Internal_server_error": "服务端错误",
144
145
  "Network_error": "网络错误",
146
+ "Permission_denied": "权限错误",
145
147
  "There_are_some_problems_with_the_filters": "过滤器有一些问题。",
146
148
  "Please_complete_the_chart_configuration_first": "请先完成图表配置",
147
149
  "Not_used": "不使用",
@@ -239,7 +241,7 @@ const zh_CN = {
239
241
  "Previous_30_days": "之前 30 天",
240
242
  "The_day_before_yesterday": "前天",
241
243
  "Can_not_compare_with_{var}": "无法和 {var} 比较",
242
- "Number": "Number",
244
+ "Number": "数字",
243
245
  "polylines": "折线",
244
246
  "curves": "曲线",
245
247
  "Line_type": "线型",
@@ -5,6 +5,7 @@ import CommonDataSettings from '../widgets/common-data-settings';
5
5
  import Divider from '../widgets/divider';
6
6
  import GroupBy from '../widgets/group-by';
7
7
  import YAxisGroupSettings from '../widgets/y-axis-group-settings';
8
+ import { islinkDateFormula } from '../../utils/column-utils';
8
9
  import { CHART_SUMMARY_TYPE, GEOLOCATION_FORMAT_CITY, GEOLOCATION_FORMAT_MAP } from '../../constants';
9
10
  import intl from '../../intl';
10
11
  const DataSettings = _ref => {
@@ -36,7 +37,7 @@ const DataSettings = _ref => {
36
37
  update['x_axis_date_granularity'] = null;
37
38
  update['x_axis_geolocation_granularity'] = null;
38
39
  } else {
39
- if (DATE_COLUMN_OPTIONS.includes(type)) {
40
+ if (DATE_COLUMN_OPTIONS.includes(type) || islinkDateFormula(column)) {
40
41
  update['x_axis_date_granularity'] = CHART_SUMMARY_TYPE.MONTH;
41
42
  update['x_axis_geolocation_granularity'] = null;
42
43
  } else if (type === CellType.GEOLOCATION) {
@@ -7,6 +7,7 @@ import Divider from '../widgets/divider';
7
7
  import GroupBy from '../widgets/group-by';
8
8
  import BasicSummary from '../widgets/basic-summary';
9
9
  import DataSort from '../widgets/data-sort';
10
+ import { islinkDateFormula } from '../../utils/column-utils';
10
11
  import { CHART_SUMMARY_TYPE, SUPPORT_DATA_SORT_CHART_TYPES, CHART_SUMMARY_TYPES, GEOLOCATION_FORMAT_CITY, GEOLOCATION_FORMAT_MAP, CHART_TYPE } from '../../constants';
11
12
  const DataSettings = _ref => {
12
13
  let {
@@ -37,7 +38,7 @@ const DataSettings = _ref => {
37
38
  update['x_axis_date_granularity'] = null;
38
39
  update['x_axis_geolocation_granularity'] = null;
39
40
  } else {
40
- if (DATE_COLUMN_OPTIONS.includes(type)) {
41
+ if (DATE_COLUMN_OPTIONS.includes(type) || islinkDateFormula(column)) {
41
42
  update['x_axis_date_granularity'] = CHART_SUMMARY_TYPE.MONTH;
42
43
  update['x_axis_geolocation_granularity'] = null;
43
44
  } else if (type === CellType.GEOLOCATION) {
@@ -2,7 +2,7 @@ import React, { useCallback, useMemo, useState, useEffect } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import classnames from 'classnames';
4
4
  import intl from '../intl';
5
- import { settingsContext } from '../utils/contexts';
5
+ import { settingsContext, DepartmentsContext } from '../utils/contexts';
6
6
  import { eventStopPropagation } from '../utils';
7
7
  import { BaseUtils } from '../utils';
8
8
  import { CHART_SETTINGS_TYPE, CHART_SETTINGS } from '../constants';
@@ -18,7 +18,8 @@ const Settings = _ref => {
18
18
  hideTitleStyleSetting,
19
19
  tables,
20
20
  onChange,
21
- children
21
+ children,
22
+ departments
22
23
  } = _ref;
23
24
  const [type, setType] = useState(CHART_SETTINGS_TYPE.DATA);
24
25
  const [labelColorConfigs, setLabelColorConfigs] = useState([]);
@@ -83,12 +84,16 @@ const Settings = _ref => {
83
84
  }, /*#__PURE__*/React.createElement("div", {
84
85
  id: "sea-chart-settings-content",
85
86
  className: "chart-settings-content"
86
- }, type === CHART_SETTINGS_TYPE.DATA && /*#__PURE__*/React.createElement(DataSettings, {
87
+ }, type === CHART_SETTINGS_TYPE.DATA && /*#__PURE__*/React.createElement(DepartmentsContext.Provider, {
88
+ value: {
89
+ departments
90
+ }
91
+ }, /*#__PURE__*/React.createElement(DataSettings, {
87
92
  dataSources: dataSources,
88
93
  chart: chart,
89
94
  tables: tables,
90
95
  onChange: modifyStatistic
91
- }), type === CHART_SETTINGS_TYPE.CHART_STYLE && /*#__PURE__*/React.createElement(StyleSettings, {
96
+ })), type === CHART_SETTINGS_TYPE.CHART_STYLE && /*#__PURE__*/React.createElement(StyleSettings, {
92
97
  chart: chart,
93
98
  labelColorConfigs: labelColorConfigs,
94
99
  onChange: modifyStyle
@@ -1,10 +1,11 @@
1
1
  import _DTableFiltersPopover from "dtable-ui-component/lib/DTableFiltersPopover";
2
- import React, { useCallback, useMemo, useState } from 'react';
2
+ import React, { useCallback, useContext, useMemo, useState } from 'react';
3
3
  import { Label, FormGroup } from 'reactstrap';
4
4
  import { getTableById } from 'dtable-utils';
5
5
  import { eventStopPropagation, generatorKey } from '../../../utils';
6
6
  import intl from '../../../intl';
7
7
  import context from '../../../context';
8
+ import { DepartmentsContext } from '../../../utils/contexts';
8
9
  import './index.css';
9
10
  const DataFilter = _ref => {
10
11
  let {
@@ -13,6 +14,9 @@ const DataFilter = _ref => {
13
14
  onChange
14
15
  } = _ref;
15
16
  const [isFilterSetterShow, setIsFilterSetterShow] = useState(false);
17
+ const {
18
+ departments
19
+ } = useContext(DepartmentsContext);
16
20
  const toggleFilterPopover = useCallback(event => {
17
21
  eventStopPropagation(event);
18
22
  setIsFilterSetterShow(!isFilterSetterShow);
@@ -78,6 +82,7 @@ const DataFilter = _ref => {
78
82
  filterConjunction: filterConjunction,
79
83
  columns: table.columns,
80
84
  collaborators: collaborators,
85
+ departments: departments,
81
86
  hidePopover: toggleFilterPopover,
82
87
  update: updateFilters
83
88
  }))) : /*#__PURE__*/React.createElement("div", {
@@ -4,6 +4,7 @@ import React, { Component } from 'react';
4
4
  import classnames from 'classnames';
5
5
  import { Label, FormGroup } from 'reactstrap';
6
6
  import { CellType, COLUMNS_ICON_CONFIG, DATE_COLUMN_OPTIONS, getTableById, getTableColumnByKey } from 'dtable-utils';
7
+ import { islinkDateFormula } from '../../utils/column-utils';
7
8
  import { CHART_SUPPORT_COLUMNS, DATE_GRANULATES, GEOLOCATION_GRANULATES, CHART_SUMMARY_SHOW, GEOLOCATION_FORMAT_MAP, CHART_TYPE, TIME_COLUMN_LIST, COMPLETENESS_GROUPBY_SUPPORTED_COLUMN_TYPE, NUMBERIC_COLUMN_TYPE, MIRROR_COLUMN_LIST } from '../../constants';
8
9
  import intl from '../../intl';
9
10
  class GroupBy extends Component {
@@ -176,7 +177,7 @@ class GroupBy extends Component {
176
177
  const {
177
178
  type: groupbyColumnType
178
179
  } = groupbyColumn;
179
- return /*#__PURE__*/React.createElement(React.Fragment, null, DATE_COLUMN_OPTIONS.includes(groupbyColumnType) && this.renderGroupbyDateGranulates(), groupbyColumnType === CellType.GEOLOCATION && this.geolocationGranulatesOptions.length > 0 && this.renderGroupbyGeolocationGranulates());
180
+ return /*#__PURE__*/React.createElement(React.Fragment, null, (DATE_COLUMN_OPTIONS.includes(groupbyColumnType) || islinkDateFormula(groupbyColumn)) && this.renderGroupbyDateGranulates(), groupbyColumnType === CellType.GEOLOCATION && this.geolocationGranulatesOptions.length > 0 && this.renderGroupbyGeolocationGranulates());
180
181
  };
181
182
  this.dateGranulatesOptions = this.generatorGranulatesOptions(DATE_GRANULATES);
182
183
  this.initOptions(_props);
@@ -1052,9 +1052,16 @@ BaseUtils.getGroupLabel = (cellValue, formulaRow, column, dateGranularity, geoGr
1052
1052
  if (!formulaRow) return '';
1053
1053
  let formulaCellValue = formulaRow[key];
1054
1054
  let {
1055
- result_type
1055
+ result_type,
1056
+ array_type
1056
1057
  } = data || {};
1057
1058
  if (result_type === FORMULA_RESULT_TYPE.ARRAY) {
1059
+ if (array_type === 'date' && (formulaCellValue === null || formulaCellValue === void 0 ? void 0 : formulaCellValue.length) === 1) {
1060
+ const dateCellValue = formulaCellValue[0];
1061
+ if (!dateGranularity) return getDateDisplayString(dateCellValue);
1062
+ if (dateGranularity.toUpperCase() === 'QUARTER') return DateUtils.getDateByGranularity(dateCellValue, 'QUARTAR');
1063
+ return DateUtils.getDateByGranularity(dateCellValue, dateGranularity);
1064
+ }
1058
1065
  return getFormulaDisplayString(formulaCellValue, data, {
1059
1066
  tables: value.tables
1060
1067
  }) || null;
@@ -1378,4 +1385,22 @@ BaseUtils.mergePivotTableSameCollaborator = pivot_rows => {
1378
1385
  });
1379
1386
  return new_pivot_rows;
1380
1387
  };
1388
+ BaseUtils.getDateGranularityByType = chart => {
1389
+ const {
1390
+ type
1391
+ } = chart;
1392
+ if ([CHART_TYPE.AREA_GROUP, CHART_TYPE.AREA, CHART_TYPE.BAR, CHART_TYPE.BAR_CUSTOM, CHART_TYPE.BAR_GROUP, CHART_TYPE.BAR_STACK, CHART_TYPE.COMPARE_BAR, CHART_TYPE.COMBINATION, CHART_TYPE.LINE_GROUP, CHART_TYPE.LINE].includes(type)) {
1393
+ return chart['x_axis_date_granularity'];
1394
+ }
1395
+ if ([CHART_TYPE.COMPLETENESS_GROUP, CHART_TYPE.SCATTER, CHART_TYPE.TREND].includes(type)) {
1396
+ return chart['date_granularity'];
1397
+ }
1398
+ if ([CHART_TYPE.HORIZONTAL_BAR, CHART_TYPE.HORIZONTAL_GROUP_BAR, CHART_TYPE.STACKED_HORIZONTAL_BAR].includes(type)) {
1399
+ return chart['vertical_axis_date_granularity'];
1400
+ }
1401
+ if ([CHART_TYPE.PIE, CHART_TYPE.RING, CHART_TYPE.TABLE, CHART_TYPE.TREE_MAP].includes(type)) {
1402
+ return chart['groupby_date_granularity'];
1403
+ }
1404
+ return null;
1405
+ };
1381
1406
  export default BaseUtils;
@@ -1,7 +1,7 @@
1
1
  import dayjs from 'dayjs';
2
2
  import { CellType, DATE_COLUMN_OPTIONS, FORMULA_COLUMN_TYPES_MAP, getTableById, getViewById, getTableColumnByKey } from 'dtable-utils';
3
3
  import { CHART_SUMMARY_TYPE, CHART_TYPE, Y_AXIS_TYPE_PREFIX } from '../../../constants';
4
- import { getColorFromSingleSelectColumn } from '../../column-utils';
4
+ import { getColorFromSingleSelectColumn, islinkDateFormula } from '../../column-utils';
5
5
  import { isArrayCellValue } from '../../cell-value-utils';
6
6
  import { getFormattedLabel, isValidRow } from '../../row-utils';
7
7
  import { fixGeoGranularity } from '../../map';
@@ -67,7 +67,7 @@ async function calculateBasicChart(chart, value, _ref) {
67
67
  const {
68
68
  type: groupby_column_type
69
69
  } = groupbyColumn;
70
- if (DATE_COLUMN_OPTIONS.includes(groupby_column_type) && !groupby_date_granularity) {
70
+ if ((DATE_COLUMN_OPTIONS.includes(groupby_column_type) || islinkDateFormula(groupbyColumn)) && !groupby_date_granularity) {
71
71
  groupby_date_granularity = CHART_SUMMARY_TYPE.MONTH;
72
72
  if ([CHART_TYPE.HEAT_MAP].includes(chart.type)) {
73
73
  groupby_date_granularity = CHART_SUMMARY_TYPE.DAY;
@@ -161,7 +161,7 @@ async function calculateGroupingChart(chart, value, _ref2) {
161
161
  const {
162
162
  type: groupby_column_type
163
163
  } = groupbyColumn;
164
- if (DATE_COLUMN_OPTIONS.includes(groupby_column_type) && !groupby_date_granularity) {
164
+ if ((DATE_COLUMN_OPTIONS.includes(groupby_column_type) || islinkDateFormula(groupbyColumn)) && !groupby_date_granularity) {
165
165
  groupby_date_granularity = CHART_SUMMARY_TYPE.MONTH;
166
166
  }
167
167
  if (groupby_column_type === CellType.GEOLOCATION && !groupby_geolocation_granularity) {
@@ -461,7 +461,7 @@ async function calculateCustomBar(statItem, value, _ref4) {
461
461
  } = groupbyColumn;
462
462
  let groupbyDateGranularity = x_axis_date_granularity;
463
463
  let groupbyGeolocationGranularity = x_axis_geolocation_granularity;
464
- if (DATE_COLUMN_OPTIONS.includes(groupbyColumnType) && !groupbyDateGranularity) {
464
+ if ((DATE_COLUMN_OPTIONS.includes(groupbyColumnType) || islinkDateFormula(groupbyColumn)) && !groupbyDateGranularity) {
465
465
  groupbyDateGranularity = CHART_SUMMARY_TYPE.MONTH;
466
466
  }
467
467
  if (groupbyColumnType === CellType.GEOLOCATION && !groupbyGeolocationGranularity) {
@@ -3,6 +3,7 @@ import { getTableById, getViewById } from 'dtable-utils';
3
3
  import { CHART_TYPE, SUPPORT_DATA_SORT_CHART_TYPES } from '../../../constants';
4
4
  import BaseUtils from '../base-utils';
5
5
  import context from '../../../context';
6
+ import { getErrorMessage } from '../..';
6
7
  import PivotTableCalculator from './pivot-table-calculator';
7
8
  import BasicChartCalculator from './basic-chart-calculator';
8
9
  import CompareBarCalculator from './compare-bar-chart-calculator';
@@ -83,7 +84,7 @@ OriginalDataUtils.calculateChart = async (chart, value, callback) => {
83
84
  chartTableColumns
84
85
  });
85
86
  } catch (error) {
86
- const error_message = 'There_are_some_problems';
87
+ const error_message = getErrorMessage(error);
87
88
  return callback && callback(error_message, '', null);
88
89
  }
89
90
  };
@@ -241,13 +241,13 @@ async function calculateTwoDimensionTable(chart, value, _ref2) {
241
241
  const formulaRows = await getTableFormulaResults(table, statRows);
242
242
  const pivot_summary_multiple_columns = [];
243
243
  Array.isArray(summary_columns) && summary_columns.forEach(item => {
244
- const column = getTableColumnByKey(table, item.column_key);
244
+ const column = getTableColumnByKey(table, item.key);
245
245
  if (column && isNumericColumn(column)) {
246
246
  pivot_summary_multiple_columns.push({
247
- key: item.column_key,
247
+ key: item.key,
248
248
  type: column.type,
249
249
  data: column.data,
250
- method: item.summary_method,
250
+ method: item.method,
251
251
  column_name: column.name
252
252
  });
253
253
  }
@@ -14,7 +14,8 @@ import BaseUtils from './base-utils';
14
14
  class SQLStatisticsUtils {}
15
15
  _SQLStatisticsUtils = SQLStatisticsUtils;
16
16
  SQLStatisticsUtils.dataSources = 'sql_statistics';
17
- SQLStatisticsUtils.getGroupLabelFromDB = (cellValue, column, tables, dateGranularity) => {
17
+ SQLStatisticsUtils.getGroupLabelFromDB = (cellValue, column, chart) => {
18
+ const dateGranularity = BaseUtils.getDateGranularityByType(chart);
18
19
  const collaborators = context.getCollaboratorsFromCache();
19
20
  const {
20
21
  type,
@@ -73,9 +74,15 @@ SQLStatisticsUtils.getGroupLabelFromDB = (cellValue, column, tables, dateGranula
73
74
  case CellType.FORMULA:
74
75
  case CellType.LINK_FORMULA:
75
76
  {
76
- const validValue = getFormulaDisplayString(cellValue, data, {
77
- tables
78
- });
77
+ const validValue = getFormulaDisplayString(cellValue, data);
78
+ const {
79
+ array_type
80
+ } = data || {};
81
+ if (array_type === 'date' && (cellValue === null || cellValue === void 0 ? void 0 : cellValue.length) === 1) {
82
+ if (!dateGranularity) return validValue;
83
+ if (dateGranularity.toUpperCase() === 'QUARTER') return DateUtils.getDateByGranularity(validValue, 'QUARTAR');
84
+ return DateUtils.getDateByGranularity(validValue, dateGranularity);
85
+ }
79
86
  if (!validValue && validValue !== 0) return null;
80
87
  return validValue;
81
88
  }
@@ -228,112 +235,6 @@ SQLStatisticsUtils.getGroupData = (result, groupColumn) => {
228
235
  }
229
236
  return groupList;
230
237
  };
231
- SQLStatisticsUtils.oneDimensionTableSQLResult2JavaScript = (chart, sqlRows, chartSQLMap, columnMap, tables) => {
232
- const {
233
- groupbyColumn
234
- } = columnMap;
235
- const {
236
- summary_type
237
- } = chart.config;
238
- const {
239
- sqlGroupbyColumnKey,
240
- sqlSummaryColumnKey
241
- } = chartSQLMap;
242
- let pivot_columns = [];
243
- let pivot_rows = [];
244
- const isCount = summary_type === CHART_SUMMARY_TYPE.COUNT;
245
- let newSqlRows = sqlRows;
246
- if (groupbyColumn.type === CellType.COLLABORATOR) {
247
- newSqlRows = _SQLStatisticsUtils.formatedTableSqlRows(chart, sqlRows, chartSQLMap, columnMap, tables);
248
- }
249
- if (isCount) {
250
- let allTotal = 0;
251
- newSqlRows.forEach(row => {
252
- const total = row[sqlSummaryColumnKey] || 0;
253
- allTotal += total;
254
- pivot_rows.push({
255
- name: _SQLStatisticsUtils.getGroupLabelFromDB(row[sqlGroupbyColumnKey], groupbyColumn, tables),
256
- rows: [],
257
- total: {
258
- total
259
- }
260
- });
261
- });
262
- return {
263
- pivot_columns,
264
- pivot_rows: pivot_rows,
265
- pivot_columns_total: {
266
- total: allTotal
267
- }
268
- };
269
- }
270
- const {
271
- summarySQLColumnName2ColumnKey,
272
- summaryTableColumnKey2Column,
273
- summaryTableColumnKey2Method
274
- } = chartSQLMap;
275
- const summaryColumnKeys = Object.values(summarySQLColumnName2ColumnKey);
276
- const sqlSummaryColumnKeys = Object.keys(summarySQLColumnName2ColumnKey);
277
- let totalTemplate = {};
278
- Object.values(summaryColumnKeys).forEach(key => {
279
- const summaryMethod = summaryTableColumnKey2Method[key];
280
- totalTemplate[key] = BaseUtils.initTotal(summaryMethod);
281
- pivot_columns.push({
282
- key
283
- });
284
- });
285
- let allTotal = {
286
- ...totalTemplate
287
- };
288
- newSqlRows.forEach(row => {
289
- let rowTotal = {
290
- ...totalTemplate
291
- };
292
- sqlSummaryColumnKeys.forEach(key => {
293
- let columnKey = summarySQLColumnName2ColumnKey[key];
294
- let summaryColumn = summaryTableColumnKey2Column[columnKey];
295
- const summaryMethod = summaryTableColumnKey2Method[columnKey];
296
- let value = row[key] || BaseUtils.initTotal(summaryMethod);
297
- allTotal[columnKey] = BaseUtils.getSummaryValue({
298
- summaryColumn,
299
- summaryMethod
300
- }, allTotal[columnKey], value);
301
- if (BaseUtils.isDateSummaryColumn(summaryColumn)) {
302
- rowTotal[columnKey] = value;
303
- } else if (BaseUtils.isNumericSummaryColumn(summaryColumn)) {
304
- rowTotal[columnKey] = rowTotal[columnKey] + value;
305
- }
306
- });
307
- pivot_rows.push({
308
- name: _SQLStatisticsUtils.getGroupLabelFromDB(row[sqlGroupbyColumnKey], groupbyColumn, tables),
309
- rows: [row],
310
- total: rowTotal
311
- });
312
- });
313
- if (pivot_columns.length < 2) {
314
- const pivot_column = pivot_columns[0];
315
- const {
316
- key
317
- } = pivot_column;
318
- pivot_rows.forEach(row => {
319
- row.total = {
320
- ...row.total,
321
- total: row.total[key]
322
- };
323
- });
324
- allTotal = {
325
- ...allTotal,
326
- total: allTotal[key]
327
- };
328
- }
329
- BaseUtils.sortCharts(pivot_rows, groupbyColumn, 'name');
330
- return {
331
- pivot_columns,
332
- pivot_rows,
333
- pivot_columns_total: allTotal,
334
- dimensions: TABLE_DIMENSIONS.ONE
335
- };
336
- };
337
238
  SQLStatisticsUtils.updateTwoDimensionColumns = (pivot_columns, key, _ref) => {
338
239
  let {
339
240
  isIncludeEmpty,
@@ -549,6 +450,112 @@ pivot_table_total, chart) => {
549
450
  });
550
451
  return [pivot_columns_total, pivot_table_total];
551
452
  };
453
+ SQLStatisticsUtils.oneDimensionTableSQLResult2JavaScript = (chart, sqlRows, chartSQLMap, columnMap, tables) => {
454
+ const {
455
+ groupbyColumn
456
+ } = columnMap;
457
+ const {
458
+ summary_type
459
+ } = chart.config;
460
+ const {
461
+ sqlGroupbyColumnKey,
462
+ sqlSummaryColumnKey
463
+ } = chartSQLMap;
464
+ let pivot_columns = [];
465
+ let pivot_rows = [];
466
+ const isCount = summary_type === CHART_SUMMARY_TYPE.COUNT;
467
+ let newSqlRows = sqlRows;
468
+ if (groupbyColumn.type === CellType.COLLABORATOR) {
469
+ newSqlRows = _SQLStatisticsUtils.formatedTableSqlRows(chart, sqlRows, chartSQLMap, columnMap, tables);
470
+ }
471
+ if (isCount) {
472
+ let allTotal = 0;
473
+ newSqlRows.forEach(row => {
474
+ const total = row[sqlSummaryColumnKey] || 0;
475
+ allTotal += total;
476
+ pivot_rows.push({
477
+ name: _SQLStatisticsUtils.getGroupLabelFromDB(row[sqlGroupbyColumnKey], groupbyColumn, chart.config),
478
+ rows: [],
479
+ total: {
480
+ total
481
+ }
482
+ });
483
+ });
484
+ return {
485
+ pivot_columns,
486
+ pivot_rows: pivot_rows,
487
+ pivot_columns_total: {
488
+ total: allTotal
489
+ }
490
+ };
491
+ }
492
+ const {
493
+ summarySQLColumnName2ColumnKey,
494
+ summaryTableColumnKey2Column,
495
+ summaryTableColumnKey2Method
496
+ } = chartSQLMap;
497
+ const summaryColumnKeys = Object.values(summarySQLColumnName2ColumnKey);
498
+ const sqlSummaryColumnKeys = Object.keys(summarySQLColumnName2ColumnKey);
499
+ let totalTemplate = {};
500
+ Object.values(summaryColumnKeys).forEach(key => {
501
+ const summaryMethod = summaryTableColumnKey2Method[key];
502
+ totalTemplate[key] = BaseUtils.initTotal(summaryMethod);
503
+ pivot_columns.push({
504
+ key
505
+ });
506
+ });
507
+ let allTotal = {
508
+ ...totalTemplate
509
+ };
510
+ newSqlRows.forEach(row => {
511
+ let rowTotal = {
512
+ ...totalTemplate
513
+ };
514
+ sqlSummaryColumnKeys.forEach(key => {
515
+ let columnKey = summarySQLColumnName2ColumnKey[key];
516
+ let summaryColumn = summaryTableColumnKey2Column[columnKey];
517
+ const summaryMethod = summaryTableColumnKey2Method[columnKey];
518
+ let value = row[key] || BaseUtils.initTotal(summaryMethod);
519
+ allTotal[columnKey] = BaseUtils.getSummaryValue({
520
+ summaryColumn,
521
+ summaryMethod
522
+ }, allTotal[columnKey], value);
523
+ if (BaseUtils.isDateSummaryColumn(summaryColumn)) {
524
+ rowTotal[columnKey] = value;
525
+ } else if (BaseUtils.isNumericSummaryColumn(summaryColumn)) {
526
+ rowTotal[columnKey] = rowTotal[columnKey] + value;
527
+ }
528
+ });
529
+ pivot_rows.push({
530
+ name: _SQLStatisticsUtils.getGroupLabelFromDB(row[sqlGroupbyColumnKey], groupbyColumn, chart.config),
531
+ rows: [row],
532
+ total: rowTotal
533
+ });
534
+ });
535
+ if (pivot_columns.length < 2) {
536
+ const pivot_column = pivot_columns[0];
537
+ const {
538
+ key
539
+ } = pivot_column;
540
+ pivot_rows.forEach(row => {
541
+ row.total = {
542
+ ...row.total,
543
+ total: row.total[key]
544
+ };
545
+ });
546
+ allTotal = {
547
+ ...allTotal,
548
+ total: allTotal[key]
549
+ };
550
+ }
551
+ BaseUtils.sortCharts(pivot_rows, groupbyColumn, 'name');
552
+ return {
553
+ pivot_columns,
554
+ pivot_rows,
555
+ pivot_columns_total: allTotal,
556
+ dimensions: TABLE_DIMENSIONS.ONE
557
+ };
558
+ };
552
559
  SQLStatisticsUtils.twoDimensionTableSQLResult2JavaScript = (chart, sqlRows, chartSQLMap, columnMap, tables) => {
553
560
  const {
554
561
  groupbyColumn,
@@ -589,14 +596,14 @@ SQLStatisticsUtils.twoDimensionTableSQLResult2JavaScript = (chart, sqlRows, char
589
596
  if (BaseUtils.isCollaborator(groupbyColumn)) {
590
597
  groupbyColumnCellValueKey = groupbyColumnCellValue || [];
591
598
  } else {
592
- groupbyColumnCellValueKey = _SQLStatisticsUtils.getGroupLabelFromDB(groupbyColumnCellValue, groupbyColumn, tables);
599
+ groupbyColumnCellValueKey = _SQLStatisticsUtils.getGroupLabelFromDB(groupbyColumnCellValue, groupbyColumn, chart.config);
593
600
  }
594
601
  const columnGroupbyColumnCellValue = row[sqlColumnGroupbyColumnKey];
595
602
  let columnGroupbyColumnCellValueKey;
596
603
  if (BaseUtils.isCollaborator(columnGroupbyColumn)) {
597
604
  columnGroupbyColumnCellValueKey = columnGroupbyColumnCellValue || [];
598
605
  } else {
599
- columnGroupbyColumnCellValueKey = _SQLStatisticsUtils.getGroupLabelFromDB(columnGroupbyColumnCellValue, columnGroupbyColumn, tables);
606
+ columnGroupbyColumnCellValueKey = _SQLStatisticsUtils.getGroupLabelFromDB(columnGroupbyColumnCellValue, columnGroupbyColumn, chart.config);
600
607
  }
601
608
  if (BaseUtils.isValidCellValue(columnGroupbyColumnCellValue, groupby_include_empty_cells)) {
602
609
  _SQLStatisticsUtils.updateTwoDimensionColumns(pivot_columns, columnGroupbyColumnCellValueKey, {
@@ -660,7 +667,7 @@ SQLStatisticsUtils.twoDimensionTableSQLResult2JavaScript = (chart, sqlRows, char
660
667
  isSingleNumericColumn
661
668
  };
662
669
  };
663
- SQLStatisticsUtils.basicChartSQLResult2JavaScript = (chart, sqlRows, chartSQLMap, columnMap, tables) => {
670
+ SQLStatisticsUtils.basicChartSQLResult2JavaScript = (chart, sqlRows, chartSQLMap, columnMap) => {
664
671
  const {
665
672
  config
666
673
  } = chart;
@@ -688,7 +695,7 @@ SQLStatisticsUtils.basicChartSQLResult2JavaScript = (chart, sqlRows, chartSQLMap
688
695
  formatted_value = getFormattedValue(cellValue, y_axis_summary_column_key, y_axis_summary_method);
689
696
  }
690
697
  if (BaseUtils.isValidCellValue(cellValue)) {
691
- const key = _SQLStatisticsUtils.getGroupLabelFromDB(cellValue, groupbyColumn, tables);
698
+ const key = _SQLStatisticsUtils.getGroupLabelFromDB(cellValue, groupbyColumn, chart.config);
692
699
  if (isGroupbyColumnDataAsAnArray) {
693
700
  if (!Array.isArray(key) || key.length === 0) {
694
701
  let itemIdx = result.findIndex(v => v.name === null);
@@ -802,7 +809,7 @@ SQLStatisticsUtils.customChartSQLResult2JavaScript = (chart, sqlRows, chartSQLMa
802
809
  let result = [];
803
810
  sqlRows.forEach(row => {
804
811
  const cellValue = row[sqlGroupbyColumnKey];
805
- const label = _SQLStatisticsUtils.getGroupLabelFromDB(cellValue, groupbyColumn, tables);
812
+ const label = _SQLStatisticsUtils.getGroupLabelFromDB(cellValue, groupbyColumn, chart.config);
806
813
  const isEmpty = !label;
807
814
  const groupItems = [];
808
815
  summaryMethods.forEach((summaryMethod, index) => {
@@ -843,8 +850,7 @@ SQLStatisticsUtils.compareSQLResult2Javascript = (chart, sqlRows, chartSQLMap, c
843
850
  x_axis_compared_date_range_end,
844
851
  y_axis_summary_type,
845
852
  y_axis_summary_method,
846
- display_increase,
847
- x_axis_date_granularity
853
+ display_increase
848
854
  } = config;
849
855
  const groupName1 = "".concat(x_axis_date_range_start, " - ").concat(x_axis_date_range_end);
850
856
  const groupName2 = "".concat(x_axis_compared_date_range_start, " - ").concat(x_axis_compared_date_range_end);
@@ -853,7 +859,7 @@ SQLStatisticsUtils.compareSQLResult2Javascript = (chart, sqlRows, chartSQLMap, c
853
859
  const isAdvanced = y_axis_summary_type === CHART_SUMMARY_TYPE.ADVANCED;
854
860
  sqlRows.forEach(item => {
855
861
  const name = item[sqlGroupbyColumnKey];
856
- const label = _SQLStatisticsUtils.getGroupLabelFromDB(name, groupbyColumn, tables, x_axis_date_granularity);
862
+ const label = _SQLStatisticsUtils.getGroupLabelFromDB(name, groupbyColumn, chart.config);
857
863
  const value = item[sqlSummaryColumnKey];
858
864
  if (name >= x_axis_date_range_start && name <= x_axis_date_range_end) {
859
865
  const currentValue = dateRangeResult.get(label);
@@ -977,7 +983,7 @@ SQLStatisticsUtils.combinationSQLResult2Javascript = (chart, sqlRows, chartSQLMa
977
983
  sqlRows.forEach(row => {
978
984
  const cellValue = row[sqlGroupbyColumnKey];
979
985
  const summaryValue = row[sqlSummaryColumnKey];
980
- const key = _SQLStatisticsUtils.getGroupLabelFromDB(cellValue, groupbyColumn, tables);
986
+ const key = _SQLStatisticsUtils.getGroupLabelFromDB(cellValue, groupbyColumn, chart.config);
981
987
  let valueLeft = row[sqlLeftSummaryColumnKey] || 0;
982
988
  let valueRight = row[sqlRightSummaryColumnKey] || 0;
983
989
  if (y_axis_left_summary_type === CHART_SUMMARY_TYPE.ADVANCED) {
@@ -1080,7 +1086,7 @@ SQLStatisticsUtils.combinationSQLResult2Javascript = (chart, sqlRows, chartSQLMa
1080
1086
  });
1081
1087
  sqlRows.forEach((item, index) => {
1082
1088
  const cellValue = item[sqlGroupbyColumnKey];
1083
- const key = _SQLStatisticsUtils.getGroupLabelFromDB(cellValue, groupbyColumn, tables);
1089
+ const key = _SQLStatisticsUtils.getGroupLabelFromDB(cellValue, groupbyColumn, chart.config);
1084
1090
  let valueRight = item[sqlRightSummaryColumnKey] || 0;
1085
1091
  if (y_axis_right_summary_type === CHART_SUMMARY_TYPE.ADVANCED) {
1086
1092
  valueRight = BaseUtils.getPrecisionNumber(valueRight, rightSummaryColumn.data);
@@ -1185,10 +1191,10 @@ SQLStatisticsUtils.groupingTwoDimensionChartSQLResult2JavaScript = (chart, sqlRo
1185
1191
  const isColumnGroupbyColumnDataAsAnArray = !!MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP[columnGroupbyColumn.type];
1186
1192
  sqlRows.forEach(row => {
1187
1193
  const groupbyColumnCellValue = row[sqlGroupbyColumnKey];
1188
- const groupbyColumnCellValueKey = _SQLStatisticsUtils.getGroupLabelFromDB(groupbyColumnCellValue, groupbyColumn, tables);
1194
+ const groupbyColumnCellValueKey = _SQLStatisticsUtils.getGroupLabelFromDB(groupbyColumnCellValue, groupbyColumn, chart.config);
1189
1195
  if (BaseUtils.isValidCellValue(groupbyColumnCellValueKey, includeEmpty)) {
1190
1196
  const columnGroupbyColumnCellValue = row[sqlColumnGroupbyColumnKey];
1191
- const columnGroupbyColumnCellValueKey = _SQLStatisticsUtils.getGroupLabelFromDB(columnGroupbyColumnCellValue, columnGroupbyColumn, tables);
1197
+ const columnGroupbyColumnCellValueKey = _SQLStatisticsUtils.getGroupLabelFromDB(columnGroupbyColumnCellValue, columnGroupbyColumn, chart.config);
1192
1198
  const count = row[sqlSummaryColumnKey];
1193
1199
  if (isGroupbyColumnDataAsAnArray) {
1194
1200
  if (!Array.isArray(groupbyColumnCellValueKey) || groupbyColumnCellValueKey.length === 0) {
@@ -1237,7 +1243,7 @@ SQLStatisticsUtils.groupingChartSQLResult2JavaScript = (chart, sqlRows, chartSQL
1237
1243
  const isGroupbyColumnDataAsAnArray = !!MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP[groupbyColumn.type];
1238
1244
  sqlRows.forEach(row => {
1239
1245
  const groupbyColumnCellValue = row[sqlGroupbyColumnKey];
1240
- const groupbyColumnCellValueKey = _SQLStatisticsUtils.getGroupLabelFromDB(groupbyColumnCellValue, groupbyColumn, tables);
1246
+ const groupbyColumnCellValueKey = _SQLStatisticsUtils.getGroupLabelFromDB(groupbyColumnCellValue, groupbyColumn, chart.config);
1241
1247
  if (BaseUtils.isValidCellValue(groupbyColumnCellValueKey, includeEmpty)) {
1242
1248
  Object.keys(summaryColumns).forEach(sqlSummaryColumnName => {
1243
1249
  const {
@@ -1343,7 +1349,7 @@ SQLStatisticsUtils.mirrorMapChartSQLResult2JavaScript = (chart, sqlRows, chartSQ
1343
1349
  const groupData0 = groupData[0] || {};
1344
1350
  const groupData1 = groupData[1] || {};
1345
1351
  sqlRows.forEach(item => {
1346
- const label = _SQLStatisticsUtils.getGroupLabelFromDB(item[column_key], groupbyColumn, tables);
1352
+ const label = _SQLStatisticsUtils.getGroupLabelFromDB(item[column_key], groupbyColumn, chart.config);
1347
1353
  const groupValue = item[group_column_key];
1348
1354
  const equal2GroupData0 = groupData0.id === groupValue;
1349
1355
  const equal2GroupData1 = groupData1.id === groupValue;
@@ -5,21 +5,7 @@ import { MIRROR_COLUMN_LIST, CHART_SUMMARY_TYPE } from '../constants';
5
5
  import { getClientFormulaDisplayString } from './cell-format-utils';
6
6
  import { BaseUtils } from './chart-utils';
7
7
 
8
- // get dtable column options
9
- export function getColumnOptions(columns) {
10
- return columns.map(column => {
11
- return {
12
- value: column,
13
- label: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
14
- className: "sea-chart-column-icon"
15
- }, /*#__PURE__*/React.createElement("i", {
16
- className: COLUMNS_ICON_CONFIG[column.type]
17
- })), /*#__PURE__*/React.createElement("span", {
18
- className: 'select-module select-module-name ml-0'
19
- }, column.name))
20
- };
21
- });
22
- }
8
+ // is
23
9
  export const isMapColumn = column => {
24
10
  if (!column) return false;
25
11
  const {
@@ -90,11 +76,6 @@ export const isWorldMapColumn = column => {
90
76
  }
91
77
  return false;
92
78
  };
93
- export const getDateColumnFormat = column => {
94
- const format = column && column.data && column.data.format ? column.data.format : DEFAULT_DATE_FORMAT;
95
- // Old Europe format is D/M/YYYY new format is DD/MM/YYYY
96
- return format;
97
- };
98
79
  export const isCheckboxColumn = column => {
99
80
  let {
100
81
  type,
@@ -112,116 +93,6 @@ export const isCheckboxColumn = column => {
112
93
  }
113
94
  return type === CellType.CHECKBOX;
114
95
  };
115
- export const getColumnByKey = (columnKey, columns) => {
116
- if (!columnKey || !Array.isArray(columns)) {
117
- return null;
118
- }
119
- return columns.find(column => column.key === columnKey);
120
- };
121
- export const getColumnByName = (columnName, columns) => {
122
- if (!columnName || !Array.isArray(columns)) {
123
- return null;
124
- }
125
- return columns.find(column => column.name === columnName);
126
- };
127
- export const getColumnByType = (columnType, columns) => {
128
- if (!columnType || !Array.isArray(columns)) {
129
- return null;
130
- }
131
- return columns.find(column => column.type === columnType);
132
- };
133
- export const getColumnByIndex = (index, columns) => {
134
- if (Array.isArray(columns)) {
135
- return columns[index];
136
- }
137
- if (typeof Immutable !== 'undefined') {
138
- return columns.get(index);
139
- }
140
- return null;
141
- };
142
- export const isNameColumn = column => {
143
- return column.key === '0000';
144
- };
145
- export const isUrlColumn = column => {
146
- let {
147
- type,
148
- data
149
- } = column;
150
- if (FORMULA_COLUMN_TYPES_MAP[type]) {
151
- const {
152
- result_type,
153
- array_type
154
- } = data || {};
155
- if (result_type === FORMULA_RESULT_TYPE.ARRAY) {
156
- return array_type === CellType.URL;
157
- }
158
- return false;
159
- }
160
- return type === CellType.URL;
161
- };
162
- export const getLinkColumns = columns => {
163
- if (!columns) {
164
- return [];
165
- }
166
- return columns.filter(column => column.type === CellType.LINK && column.data);
167
- };
168
- export const calculateFormulaRows = (rows, columns) => {
169
- const COMPUTED_COLUMN_TYPES = [CellType.FORMULA, CellType.LINK_FORMULA, CellType.LINK];
170
- const formulaColumns = columns.filter(column => COMPUTED_COLUMN_TYPES.includes(column.type));
171
- let formula_rows = {};
172
- if (formulaColumns.length > 0) {
173
- rows.forEach(row => {
174
- let formulaRow = {};
175
- formulaColumns.forEach(column => formulaRow[column.key] = row[column.key]);
176
- formula_rows[row._id] = formulaRow;
177
- });
178
- }
179
- return formula_rows;
180
- };
181
- export const handleCascadeColumn = function (optionValue, columnKey, columns, row) {
182
- let updated = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
183
- let processedColumns = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : new Set();
184
- // This column has already been processed, avoid circular dependency.
185
- if (!Array.isArray(columns) || processedColumns.has(columnKey)) {
186
- return updated;
187
- }
188
- processedColumns.add(columnKey);
189
- const singleSelectColumns = columns.filter(column => column.type === CellType.SINGLE_SELECT);
190
- for (let i = 0; i < singleSelectColumns.length; i++) {
191
- const singleSelectColumn = singleSelectColumns[i];
192
- const {
193
- data: {
194
- cascade_column_key,
195
- cascade_settings
196
- }
197
- } = singleSelectColumn;
198
- if (cascade_column_key === columnKey) {
199
- const {
200
- key: childColumnKey
201
- } = singleSelectColumn;
202
- const childColumnOptions = cascade_settings[optionValue];
203
- const childColumnCellValue = row[childColumnKey];
204
- const cellValueInOptions = childColumnOptions && childColumnOptions.includes(childColumnCellValue);
205
- if (!cellValueInOptions) {
206
- updated[childColumnKey] = '';
207
- handleCascadeColumn('', childColumnKey, columns, row, updated, processedColumns);
208
- }
209
- }
210
- }
211
- return updated;
212
- };
213
- export const isFrozen = column => {
214
- if (!column) return false;
215
- return column.frozen === true;
216
- };
217
- export const findLastFrozenColumnIndex = columns => {
218
- for (let i = 0; i < columns.length; i++) {
219
- if (isFrozen(columns[i])) {
220
- return i;
221
- }
222
- }
223
- return -1;
224
- };
225
96
  export const isStatisticMapColumn = column => {
226
97
  if (!column) return false;
227
98
  const {
@@ -296,6 +167,46 @@ export const isStatisticMirrorColumn = column => {
296
167
  if (!column) return false;
297
168
  return MIRROR_COLUMN_LIST.includes(column.type);
298
169
  };
170
+ export const islinkDateFormula = column => {
171
+ if (column) {
172
+ const {
173
+ type,
174
+ data
175
+ } = column;
176
+ const {
177
+ array_type
178
+ } = data || {};
179
+ if (type === 'link-formula' && array_type === 'date') return true;
180
+ }
181
+ return false;
182
+ };
183
+
184
+ // get
185
+ export function getColumnOptions(columns) {
186
+ return columns.map(column => {
187
+ return {
188
+ value: column,
189
+ label: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
190
+ className: "sea-chart-column-icon"
191
+ }, /*#__PURE__*/React.createElement("i", {
192
+ className: COLUMNS_ICON_CONFIG[column.type]
193
+ })), /*#__PURE__*/React.createElement("span", {
194
+ className: 'select-module select-module-name ml-0'
195
+ }, column.name))
196
+ };
197
+ });
198
+ }
199
+ export const getDateColumnFormat = column => {
200
+ const format = column && column.data && column.data.format ? column.data.format : DEFAULT_DATE_FORMAT;
201
+ // Old Europe format is D/M/YYYY new format is DD/MM/YYYY
202
+ return format;
203
+ };
204
+ export const getColumnByKey = (columnKey, columns) => {
205
+ if (!columnKey || !Array.isArray(columns)) {
206
+ return null;
207
+ }
208
+ return columns.find(column => column.key === columnKey);
209
+ };
299
210
  export const getColorFromSingleSelectColumn = (column, target) => {
300
211
  let {
301
212
  type: columnType,
@@ -444,6 +355,12 @@ export const getSqlGroup = (column, groupBy) => {
444
355
  }
445
356
  return validColumnName;
446
357
  };
358
+ export function getSelectColumnOptions(column) {
359
+ if (!column || !column.data || !Array.isArray(column.data.options)) {
360
+ return [];
361
+ }
362
+ return column.data.options;
363
+ }
447
364
 
448
365
  // for stacked bar, stacked horizontal bar
449
366
  export const sortDataByGroupSum = (data, sortType) => {
@@ -472,10 +389,4 @@ export const formatNumericValue = function (value) {
472
389
  } = data;
473
390
  value = value || 0;
474
391
  return parseFloat(value.toFixed(precision));
475
- };
476
- export function getSelectColumnOptions(column) {
477
- if (!column || !column.data || !Array.isArray(column.data.options)) {
478
- return [];
479
- }
480
- return column.data.options;
481
- }
392
+ };
@@ -1,2 +1,3 @@
1
1
  import React from 'react';
2
- export const settingsContext = React.createContext('');
2
+ export const settingsContext = React.createContext('');
3
+ export const DepartmentsContext = React.createContext([]);
@@ -1,4 +1,5 @@
1
1
  import { GENERIC_KEY_2_SIMILAR_KEYS, GEOLOCATION_GRANULARITY, MAP_LEVEL, MUNICIPALITIES, regions } from '../constants';
2
+ import intl from '../intl';
2
3
  import ObjectUtils from './object-utils';
3
4
  import { BaseUtils, ChartUtils } from './chart-utils';
4
5
  import { ChartDataSQL, chartColumn2SqlColumn, summaryMethodColumn2SqlColumn } from './sql';
@@ -7,10 +8,28 @@ export { getColumnOptions } from 'dtable-utils';
7
8
  export { getClientFormulaDisplayString, getClientLinkDisplayString } from './cell-format-utils';
8
9
  export { generateChartConfig } from './chart';
9
10
  export { getKnownCollaboratorByEmail, getKnownCollaboratorsByEmails, generateDefaultUser } from './collaborator-utils';
10
- export { getDateColumnFormat, isCheckboxColumn, getColumnByKey, getColumnByName, getColumnByType, getColumnByIndex, isNameColumn, isUrlColumn, getLinkColumns, calculateFormulaRows, handleCascadeColumn, isFrozen, findLastFrozenColumnIndex, isStatisticMapColumn, isStatisticWorldMapColumn, isStatisticMirrorColumn, getColorFromSingleSelectColumn } from './column-utils';
11
+ export { getDateColumnFormat, isCheckboxColumn, getColumnByKey, isStatisticMapColumn, isStatisticWorldMapColumn, isStatisticMirrorColumn, getColorFromSingleSelectColumn } from './column-utils';
11
12
  export { generatorKey } from './key-generator';
12
13
  export { translateCalendar } from './date-translate';
13
14
  export { isFunction } from './common-utils';
15
+ export const getErrorMessage = err => {
16
+ if (!err.response) {
17
+ return intl.get('Network_error');
18
+ }
19
+ const {
20
+ status,
21
+ error_msg
22
+ } = err.response;
23
+ if (status === 403) {
24
+ return intl.get('Permission_denied');
25
+ }
26
+ if (status === 500 || status === 502) {
27
+ return intl.get('Internal_server_error');
28
+ }
29
+ // log error to locate problems
30
+ console.error(err);
31
+ return intl.get('Error');
32
+ };
14
33
  export const getGeoGranularityByLevel = mapLevel => {
15
34
  switch (mapLevel) {
16
35
  case MAP_LEVEL.PROVINCE:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sea-chart",
3
- "version": "0.0.76-alpha.5",
3
+ "version": "0.0.77",
4
4
  "main": "./dist/index.js",
5
5
  "dependencies": {
6
6
  "@antv/data-set": "0.11.8",