dtable-statistic 4.3.5 → 4.3.6

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.
@@ -15,36 +15,37 @@ var _constants = require("../../constants");
15
15
  class PivotTableDisplayName extends _react.default.Component {
16
16
  constructor(props) {
17
17
  super(props);
18
- this.updateCreator = email => {
18
+ this.updateUser = email => {
19
19
  if (!window || !window.app) {
20
20
  return;
21
21
  }
22
22
  let {
23
23
  collaborators
24
24
  } = window.app.state;
25
- let creator = (0, _utils.getKnownCreatorByEmail)(collaborators, email);
26
- if (creator) {
25
+ let user = (0, _utils.getKnownCreatorByEmail)(collaborators, email);
26
+ if (user) {
27
27
  this.setState({
28
- creator
28
+ user
29
29
  });
30
30
  return;
31
31
  }
32
32
  let dtableCollaborators = window.app.collaboratorsCache;
33
+ if (!window.app.queryUsers) return;
33
34
  window.app.queryUsers([email], emailUserMap => {
34
- creator = emailUserMap && emailUserMap[email];
35
- if (creator) {
36
- dtableCollaborators[email] = creator;
35
+ user = emailUserMap && emailUserMap[email];
36
+ if (user) {
37
+ dtableCollaborators[email] = user;
37
38
  this.setState({
38
- creator
39
+ user
39
40
  });
40
41
  return;
41
42
  }
42
43
 
43
44
  // error handle
44
- creator = (0, _utils.generateDefaultUser)(email);
45
- dtableCollaborators[email] = creator;
45
+ user = (0, _utils.generateDefaultUser)(email);
46
+ dtableCollaborators[email] = user;
46
47
  this.setState({
47
- creator
48
+ user
48
49
  });
49
50
  });
50
51
  };
@@ -79,22 +80,12 @@ class PivotTableDisplayName extends _react.default.Component {
79
80
  }, optionName);
80
81
  break;
81
82
  }
82
- case _dtableStore.CellType.COLLABORATOR:
83
- {
84
- let collaborator = (0, _dtableStore.getCollaborator)(collaborators, value) || {};
85
- displayName = /*#__PURE__*/_react.default.createElement(Collaborator, {
86
- collaborator: collaborator
87
- });
88
- break;
89
- }
90
83
  case _dtableStore.CellType.CREATOR:
84
+ case _dtableStore.CellType.COLLABORATOR:
91
85
  case _dtableStore.CellType.LAST_MODIFIER:
92
86
  {
93
- let {
94
- creator
95
- } = this.state;
96
87
  displayName = /*#__PURE__*/_react.default.createElement(Collaborator, {
97
- collaborator: creator
88
+ collaborator: this.state.user
98
89
  });
99
90
  break;
100
91
  }
@@ -161,28 +152,31 @@ class PivotTableDisplayName extends _react.default.Component {
161
152
  return displayName;
162
153
  };
163
154
  this.state = {
164
- creator: {}
155
+ user: {}
165
156
  };
166
157
  }
167
158
  componentDidMount() {
168
- let {
159
+ const {
169
160
  column,
170
161
  value
171
162
  } = this.props;
172
- if (column.type !== _dtableStore.CellType.CREATOR && column.type !== _dtableStore.CellType.LAST_MODIFIER) return;
173
- this.updateCreator(value);
163
+ const {
164
+ type
165
+ } = column;
166
+ if (!_dtableStore.COLLABORATOR_COLUMN_TYPES.includes(type)) return;
167
+ this.updateUser(value);
174
168
  }
175
169
  UNSAFE_componentWillReceiveProps(nextProps) {
176
- let {
170
+ const {
177
171
  column,
178
172
  value
179
173
  } = nextProps;
180
- let {
174
+ const {
181
175
  type
182
176
  } = column;
183
- if (type !== _dtableStore.CellType.CREATOR && type !== _dtableStore.CellType.LAST_MODIFIER) return;
177
+ if (!_dtableStore.COLLABORATOR_COLUMN_TYPES.includes(type)) return;
184
178
  if (value !== this.props.value || (0, _commonUtils.shallowEqual)(nextProps.column, this.props.column)) {
185
- this.updateCreator(value);
179
+ this.updateUser(value);
186
180
  }
187
181
  }
188
182
  render() {
@@ -6,14 +6,9 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _dtableStore = require("dtable-store");
8
8
  var _utils = require("../utils");
9
+ var _collaborator = require("./collaborator");
9
10
  var _constants = require("../constants");
10
11
  const SUPPORT_SORT_COLUMNS = [_dtableStore.CellType.TEXT, _dtableStore.CellType.NUMBER, _dtableStore.CellType.DATE, _dtableStore.CellType.SINGLE_SELECT, _dtableStore.CellType.FORMULA, _dtableStore.CellType.LINK_FORMULA, _dtableStore.CellType.CTIME, _dtableStore.CellType.MTIME, _dtableStore.CellType.RATE];
11
- const getValidCollaborators = (collaborators, emails) => {
12
- if (!Array.isArray(emails)) {
13
- return [];
14
- }
15
- return emails.filter(e => collaborators.findIndex(c => c.email === e) > -1);
16
- };
17
12
  class StatUtils {
18
13
  static getGroupLabel(cellValue, formulaRow, column, dateGranularity, geoGranularity, value) {
19
14
  let {
@@ -66,7 +61,8 @@ class StatUtils {
66
61
  }
67
62
  case _dtableStore.CellType.COLLABORATOR:
68
63
  {
69
- return getValidCollaborators(value.collaborators, cellValue);
64
+ if (!Array.isArray(cellValue)) return [];
65
+ return cellValue.filter(email => (0, _collaborator.isValidCollaboratorEmail)(email));
70
66
  }
71
67
  case _dtableStore.CellType.CREATOR:
72
68
  case _dtableStore.CellType.LAST_MODIFIER:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dtable-statistic",
3
- "version": "4.3.5",
3
+ "version": "4.3.6",
4
4
  "description": "statistics",
5
5
  "main": "dist/dtable-statistic.js",
6
6
  "author": "seafile",