@bento-core/table 1.0.1-ccdihub.76 → 1.0.1-ccdihub.78

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.
@@ -27,7 +27,6 @@ const ExtendedView = _ref => {
27
27
  onColumnViewChange,
28
28
  onRowsPerPageChange,
29
29
  onPageChange,
30
- numSelected = 0,
31
30
  customTheme,
32
31
  queryVariables
33
32
  } = _ref;
@@ -38,7 +37,6 @@ const ExtendedView = _ref => {
38
37
  return null;
39
38
  }
40
39
  const {
41
- download = false,
42
40
  manageViewColumns = false,
43
41
  pagination = false
44
42
  } = extendedViewConfig;
@@ -47,13 +45,7 @@ const ExtendedView = _ref => {
47
45
  });
48
46
  return /*#__PURE__*/_react.default.createElement(_core.ThemeProvider, {
49
47
  theme: themeConfig
50
- }, numSelected === 0 && (download || manageViewColumns) && /*#__PURE__*/_react.default.createElement(_core.Toolbar, {
51
- className: "downloadColumnView"
52
- }, /*#__PURE__*/_react.default.createElement(_ManageColumnView.default, {
53
- table: table,
54
- manageViewColumns: manageViewColumns,
55
- onColumnViewChange: onColumnViewChange
56
- })), pagination && /*#__PURE__*/_react.default.createElement("div", {
48
+ }, pagination && /*#__PURE__*/_react.default.createElement("div", {
57
49
  className: "downloadArea",
58
50
  style: downloadAreaStyle
59
51
  }, /*#__PURE__*/_react.default.createElement(_CustomPagination.default, {
@@ -71,6 +63,10 @@ const ExtendedView = _ref => {
71
63
  count: table.totalRowCount || 0,
72
64
  queryVariables: queryVariables,
73
65
  table: table
66
+ }), /*#__PURE__*/_react.default.createElement(_ManageColumnView.default, {
67
+ table: table,
68
+ manageViewColumns: manageViewColumns,
69
+ onColumnViewChange: onColumnViewChange
74
70
  })));
75
71
  };
76
72
  var _default = ExtendedView;
package/dist/TableView.js CHANGED
@@ -13,6 +13,7 @@ var _CustomToolbar = _interopRequireDefault(require("./toolbar/CustomToolbar"));
13
13
  var _DisplayErrMsg = _interopRequireDefault(require("./errMsg/DisplayErrMsg"));
14
14
  var _ExtendedView = _interopRequireDefault(require("./ExtendedView"));
15
15
  var _DownloadButtonView = _interopRequireDefault(require("./toolbar/DownloadButtonView"));
16
+ var _ManageColumnView = _interopRequireDefault(require("./toolbar/ManageColumnView"));
16
17
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
18
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
18
19
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -89,6 +90,12 @@ const TableView = _ref => {
89
90
  addScrollContainer.style.height = '0px';
90
91
  }
91
92
  });
93
+ const {
94
+ extendedViewConfig
95
+ } = table;
96
+ const {
97
+ manageViewColumns = false
98
+ } = extendedViewConfig;
92
99
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_ExtendedView.default, {
93
100
  table: table,
94
101
  onColumnViewChange: onColumnViewChange,
@@ -140,6 +147,10 @@ const TableView = _ref => {
140
147
  count: table.totalRowCount || 0,
141
148
  queryVariables: queryVariables,
142
149
  table: table
150
+ }), /*#__PURE__*/_react.default.createElement(_ManageColumnView.default, {
151
+ table: table,
152
+ manageViewColumns: manageViewColumns,
153
+ onColumnViewChange: onColumnViewChange
143
154
  })));
144
155
  };
145
156
  var _default = TableView;
@@ -28,12 +28,17 @@ const ManageColumnView = _ref => {
28
28
  const {
29
29
  columns
30
30
  } = table;
31
- const viewColumns = columns.filter(col => col.role === _Types.cellTypes.DISPLAY);
31
+ const viewColumns = columns.filter(col => col.role === _Types.cellTypes.DISPLAY && col.hideable);
32
32
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_core.Tooltip, {
33
33
  title: manageViewColumns.title
34
34
  }, /*#__PURE__*/_react.default.createElement(_core.IconButton, {
35
35
  variant: "contained",
36
- onClick: handleClick
36
+ onClick: handleClick,
37
+ style: {
38
+ marginLeft: '10px',
39
+ marginTop: '9px',
40
+ height: '24px'
41
+ }
37
42
  }, /*#__PURE__*/_react.default.createElement(_icons.ViewColumn, null))), /*#__PURE__*/_react.default.createElement(_core.Popover, {
38
43
  open: open,
39
44
  anchorEl: anchorEl,
@@ -47,7 +52,10 @@ const ManageColumnView = _ref => {
47
52
  className: "viewColumnText"
48
53
  }, manageViewColumns.title), /*#__PURE__*/_react.default.createElement(_core.IconButton, {
49
54
  onClick: handleClose,
50
- className: "closeIcon"
55
+ className: "closeIcon",
56
+ style: {
57
+ float: 'right'
58
+ }
51
59
  }, /*#__PURE__*/_react.default.createElement(_icons.Close, null)), /*#__PURE__*/_react.default.createElement(_core.List, {
52
60
  className: "viewColumnList"
53
61
  }, viewColumns.map(column => /*#__PURE__*/_react.default.createElement(_core.ListItem, {
@@ -97,30 +97,35 @@ function downloadCSV(tableData, table, downloadFileName) {
97
97
  cellStyle
98
98
  } = _ref2;
99
99
  return !_Types.notIncludedCellStyle.includes(cellStyle);
100
+ }).filter(_ref3 => {
101
+ let {
102
+ display
103
+ } = _ref3;
104
+ return display;
100
105
  });
101
106
  const formatDataVal = (0, _Dataformat.formatColumnValues)(filterColumns, tableData);
102
107
  const jsonse = JSON.stringify(formatDataVal);
103
- const keysToInclude = filterColumns.filter(_ref3 => {
108
+ const keysToInclude = filterColumns.filter(_ref4 => {
104
109
  let {
105
110
  dataField
106
- } = _ref3;
111
+ } = _ref4;
107
112
  return dataField;
108
- }).map(_ref4 => {
113
+ }).map(_ref5 => {
109
114
  let {
110
115
  dataField
111
- } = _ref4;
116
+ } = _ref5;
112
117
  return dataField;
113
118
  });
114
- const headers = filterColumns.filter(_ref5 => {
119
+ const headers = filterColumns.filter(_ref6 => {
115
120
  let {
116
121
  dataField
117
- } = _ref5;
122
+ } = _ref6;
118
123
  return dataField;
119
- }).map(_ref6 => {
124
+ }).map(_ref7 => {
120
125
  let {
121
126
  header,
122
127
  downloadHeader
123
- } = _ref6;
128
+ } = _ref7;
124
129
  return downloadHeader || header;
125
130
  });
126
131
  const csv = convertToCSV(jsonse, keysToInclude, headers);
@@ -140,11 +145,17 @@ function downloadJson(tableData, table, downloadFileName) {
140
145
  const {
141
146
  columns = []
142
147
  } = table;
143
- const filterColumns = columns.filter(_ref7 => {
148
+ const toDelete = columns.filter(e => !e.display);
149
+ const filterColumns = columns.filter(_ref8 => {
144
150
  let {
145
151
  cellType
146
- } = _ref7;
152
+ } = _ref8;
147
153
  return !_Types.actionCellTypes.includes(cellType);
154
+ }).filter(_ref9 => {
155
+ let {
156
+ display
157
+ } = _ref9;
158
+ return display;
148
159
  });
149
160
  let formatDataVal = (0, _Dataformat.formatColumnValues)(filterColumns, tableData);
150
161
  formatDataVal = formatDataVal.map(entry => {
@@ -164,6 +175,7 @@ function downloadJson(tableData, table, downloadFileName) {
164
175
  dataCategory = dataCategory.toString().substring(1, dataCategory.length - 1);
165
176
  toReturn['Data Category'] = dataCategory;
166
177
  }
178
+ toDelete.forEach(column => delete toReturn[column.dataField]);
167
179
  return toReturn;
168
180
  });
169
181
  filterColumns.forEach(column => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bento-core/table",
3
- "version": "1.0.1-ccdihub.76",
3
+ "version": "1.0.1-ccdihub.78",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "build": "npm run lint && cross-env-shell rm -rf dist && NODE_ENV=production BABEL_ENV=es babel src --out-dir dist --copy-files",
@@ -1,7 +1,6 @@
1
1
  import React from 'react';
2
2
  import {
3
3
  ThemeProvider,
4
- Toolbar,
5
4
  createTheme,
6
5
  } from '@material-ui/core';
7
6
  import CustomPagination from './pagination/CustomPagination';
@@ -20,7 +19,6 @@ const ExtendedView = ({
20
19
  onColumnViewChange,
21
20
  onRowsPerPageChange,
22
21
  onPageChange,
23
- numSelected = 0,
24
22
  customTheme,
25
23
  queryVariables,
26
24
  }) => {
@@ -29,7 +27,6 @@ const ExtendedView = ({
29
27
  return null;
30
28
  }
31
29
  const {
32
- download = false,
33
30
  manageViewColumns = false,
34
31
  pagination = false,
35
32
  } = extendedViewConfig;
@@ -37,18 +34,13 @@ const ExtendedView = ({
37
34
  const themeConfig = createTheme({ overrides: { ...defaultTheme(), ...customTheme } });
38
35
  return (
39
36
  <ThemeProvider theme={themeConfig}>
40
- {(numSelected === 0 && (download || manageViewColumns)) && (
37
+ {/* {(numSelected === 0 && (download || manageViewColumns)) && (
41
38
  <Toolbar className="downloadColumnView">
42
- {/* <DownloadButton
39
+ <DownloadButton
43
40
  download={download}
44
- /> */}
45
- <ManageColumnView
46
- table={table}
47
- manageViewColumns={manageViewColumns}
48
- onColumnViewChange={onColumnViewChange}
49
41
  />
50
42
  </Toolbar>
51
- )}
43
+ )} */}
52
44
  {
53
45
  (pagination) && (
54
46
  <div className="downloadArea" style={downloadAreaStyle}>
@@ -69,6 +61,11 @@ const ExtendedView = ({
69
61
  queryVariables={queryVariables}
70
62
  table={table}
71
63
  />
64
+ <ManageColumnView
65
+ table={table}
66
+ manageViewColumns={manageViewColumns}
67
+ onColumnViewChange={onColumnViewChange}
68
+ />
72
69
  </div>
73
70
  )
74
71
  }
package/src/TableView.js CHANGED
@@ -13,6 +13,7 @@ import CustomToolbar from './toolbar/CustomToolbar';
13
13
  import DisplayErrMsg from './errMsg/DisplayErrMsg';
14
14
  import ExtendedView from './ExtendedView';
15
15
  import DownloadButton from './toolbar/DownloadButtonView';
16
+ import ManageColumnView from './toolbar/ManageColumnView';
16
17
 
17
18
  const CustomTableContainer = (props) => {
18
19
  const { children, customTheme } = props;
@@ -81,7 +82,10 @@ const TableView = ({
81
82
  addScrollContainer.style.height = '0px';
82
83
  }
83
84
  });
84
-
85
+ const { extendedViewConfig } = table;
86
+ const {
87
+ manageViewColumns = false,
88
+ } = extendedViewConfig;
85
89
  return (
86
90
  <>
87
91
  <ExtendedView
@@ -144,6 +148,11 @@ const TableView = ({
144
148
  queryVariables={queryVariables}
145
149
  table={table}
146
150
  />
151
+ <ManageColumnView
152
+ table={table}
153
+ manageViewColumns={manageViewColumns}
154
+ onColumnViewChange={onColumnViewChange}
155
+ />
147
156
  </div>
148
157
  </>
149
158
  );
@@ -34,12 +34,11 @@ const ManageColumnView = ({
34
34
 
35
35
  const open = Boolean(anchorEl);
36
36
  const { columns } = table;
37
- const viewColumns = columns.filter((col) => col.role === cellTypes.DISPLAY);
38
-
37
+ const viewColumns = columns.filter((col) => col.role === cellTypes.DISPLAY && col.hideable);
39
38
  return (
40
39
  <>
41
40
  <Tooltip title={manageViewColumns.title}>
42
- <IconButton variant="contained" onClick={handleClick}>
41
+ <IconButton variant="contained" onClick={handleClick} style={{ marginLeft: '10px', marginTop: '9px', height: '24px' }}>
43
42
  <ViewColumn />
44
43
  </IconButton>
45
44
  </Tooltip>
@@ -58,6 +57,7 @@ const ManageColumnView = ({
58
57
  <IconButton
59
58
  onClick={handleClose}
60
59
  className="closeIcon"
60
+ style={{ float: 'right' }}
61
61
  >
62
62
  <Close />
63
63
  </IconButton>
@@ -73,7 +73,8 @@ export function convertToCSV(jsonse, keysToInclude, header) {
73
73
  export function downloadCSV(tableData, table, downloadFileName) {
74
74
  const { columns = [] } = table;
75
75
  const filterColumns = columns.filter(({ cellType }) => !actionCellTypes.includes(cellType))
76
- .filter(({ cellStyle }) => !notIncludedCellStyle.includes(cellStyle));
76
+ .filter(({ cellStyle }) => !notIncludedCellStyle.includes(cellStyle))
77
+ .filter(({ display }) => display);
77
78
  const formatDataVal = formatColumnValues(filterColumns, tableData);
78
79
  const jsonse = JSON.stringify(formatDataVal);
79
80
  const keysToInclude = filterColumns.filter(({ dataField }) => dataField)
@@ -94,7 +95,9 @@ export function downloadCSV(tableData, table, downloadFileName) {
94
95
 
95
96
  export function downloadJson(tableData, table, downloadFileName) {
96
97
  const { columns = [] } = table;
97
- const filterColumns = columns.filter(({ cellType }) => !actionCellTypes.includes(cellType));
98
+ const toDelete = columns.filter((e) => !e.display);
99
+ const filterColumns = columns.filter(({ cellType }) => !actionCellTypes.includes(cellType))
100
+ .filter(({ display }) => display);
98
101
  let formatDataVal = formatColumnValues(filterColumns, tableData);
99
102
  formatDataVal = formatDataVal.map((entry) => {
100
103
  let survivalStatus = entry.last_known_survival_status;
@@ -114,6 +117,7 @@ export function downloadJson(tableData, table, downloadFileName) {
114
117
  dataCategory = dataCategory.toString().substring(1, dataCategory.length - 1);
115
118
  toReturn['Data Category'] = dataCategory;
116
119
  }
120
+ toDelete.forEach((column) => delete toReturn[column.dataField]);
117
121
  return toReturn;
118
122
  });
119
123
  filterColumns.forEach((column) => {