@bento-core/table 1.0.1-ccdihub.67 → 1.0.1-ccdihub.69
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.
- package/dist/util/Types.js +10 -2
- package/dist/util/downloadTable.js +15 -10
- package/package.json +1 -1
- package/src/util/Types.js +6 -0
- package/src/util/downloadTable.js +5 -4
package/dist/util/Types.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.headerTypes = exports.dataFormatTypes = exports.cellTypes = exports.cellStyles = exports.actionCellTypes = exports.TRANSFORM = exports.LINK = exports.FORMAT_DATA_CELLS = exports.FORMAT_DATA = exports.FORMAT_BYTES = exports.EXPAND = exports.DISPLAY = exports.DELETE = exports.DEFAULT = exports.ComponentTypes = exports.CUSTOM_ELEM = exports.CHECKBOX = void 0;
|
|
6
|
+
exports.notIncludedCellStyle = exports.headerTypes = exports.dataFormatTypes = exports.cellTypes = exports.cellStyles = exports.actionCellTypes = exports.TRANSFORM = exports.STUDY_DOWNLOAD = exports.LINK = exports.FORMAT_DATA_CELLS = exports.FORMAT_DATA = exports.FORMAT_BYTES = exports.EXPAND = exports.DISPLAY = exports.DELETE = exports.DEFAULT = exports.DBGAP = exports.ComponentTypes = exports.CUSTOM_ELEM = exports.CHECKBOX = void 0;
|
|
7
7
|
const CHECKBOX = 'CHECKBOX';
|
|
8
8
|
exports.CHECKBOX = CHECKBOX;
|
|
9
9
|
const DELETE = 'DELETE';
|
|
@@ -22,8 +22,12 @@ const FORMAT_BYTES = 'FORMAT_BYTES';
|
|
|
22
22
|
exports.FORMAT_BYTES = FORMAT_BYTES;
|
|
23
23
|
const TRANSFORM = 'TRANSFORM';
|
|
24
24
|
exports.TRANSFORM = TRANSFORM;
|
|
25
|
+
const STUDY_DOWNLOAD = 'STUDY_DOWNLOAD';
|
|
26
|
+
exports.STUDY_DOWNLOAD = STUDY_DOWNLOAD;
|
|
25
27
|
const EXPAND = 'EXPAND';
|
|
26
28
|
exports.EXPAND = EXPAND;
|
|
29
|
+
const DBGAP = 'DBGAP';
|
|
30
|
+
exports.DBGAP = DBGAP;
|
|
27
31
|
const cellTypes = {
|
|
28
32
|
CUSTOM_ELEM,
|
|
29
33
|
LINK,
|
|
@@ -36,11 +40,15 @@ const cellTypes = {
|
|
|
36
40
|
exports.cellTypes = cellTypes;
|
|
37
41
|
const cellStyles = {
|
|
38
42
|
TRANSFORM,
|
|
39
|
-
EXPAND
|
|
43
|
+
EXPAND,
|
|
44
|
+
DBGAP,
|
|
45
|
+
STUDY_DOWNLOAD
|
|
40
46
|
};
|
|
41
47
|
exports.cellStyles = cellStyles;
|
|
42
48
|
const actionCellTypes = [CHECKBOX, DELETE];
|
|
43
49
|
exports.actionCellTypes = actionCellTypes;
|
|
50
|
+
const notIncludedCellStyle = [STUDY_DOWNLOAD];
|
|
51
|
+
exports.notIncludedCellStyle = notIncludedCellStyle;
|
|
44
52
|
const FORMAT_DATA_CELLS = [FORMAT_BYTES];
|
|
45
53
|
exports.FORMAT_DATA_CELLS = FORMAT_DATA_CELLS;
|
|
46
54
|
const dataFormatTypes = {
|
|
@@ -79,30 +79,35 @@ function downloadCSV(tableData, table, downloadFileName) {
|
|
|
79
79
|
cellType
|
|
80
80
|
} = _ref;
|
|
81
81
|
return !_Types.actionCellTypes.includes(cellType);
|
|
82
|
+
}).filter(_ref2 => {
|
|
83
|
+
let {
|
|
84
|
+
cellStyle
|
|
85
|
+
} = _ref2;
|
|
86
|
+
return !_Types.notIncludedCellStyle.includes(cellStyle);
|
|
82
87
|
});
|
|
83
88
|
const formatDataVal = (0, _Dataformat.formatColumnValues)(filterColumns, tableData);
|
|
84
89
|
const jsonse = JSON.stringify(formatDataVal);
|
|
85
|
-
const keysToInclude =
|
|
90
|
+
const keysToInclude = filterColumns.filter(_ref3 => {
|
|
86
91
|
let {
|
|
87
92
|
dataField
|
|
88
|
-
} =
|
|
93
|
+
} = _ref3;
|
|
89
94
|
return dataField;
|
|
90
|
-
}).map(
|
|
95
|
+
}).map(_ref4 => {
|
|
91
96
|
let {
|
|
92
97
|
dataField
|
|
93
|
-
} =
|
|
98
|
+
} = _ref4;
|
|
94
99
|
return dataField;
|
|
95
100
|
});
|
|
96
|
-
const headers =
|
|
101
|
+
const headers = filterColumns.filter(_ref5 => {
|
|
97
102
|
let {
|
|
98
103
|
dataField
|
|
99
|
-
} =
|
|
104
|
+
} = _ref5;
|
|
100
105
|
return dataField;
|
|
101
|
-
}).map(
|
|
106
|
+
}).map(_ref6 => {
|
|
102
107
|
let {
|
|
103
108
|
header,
|
|
104
109
|
downloadHeader
|
|
105
|
-
} =
|
|
110
|
+
} = _ref6;
|
|
106
111
|
return downloadHeader || header;
|
|
107
112
|
});
|
|
108
113
|
const csv = convertToCSV(jsonse, keysToInclude, headers);
|
|
@@ -122,10 +127,10 @@ function downloadJson(tableData, table, downloadFileName) {
|
|
|
122
127
|
const {
|
|
123
128
|
columns = []
|
|
124
129
|
} = table;
|
|
125
|
-
const filterColumns = columns.filter(
|
|
130
|
+
const filterColumns = columns.filter(_ref7 => {
|
|
126
131
|
let {
|
|
127
132
|
cellType
|
|
128
|
-
} =
|
|
133
|
+
} = _ref7;
|
|
129
134
|
return !_Types.actionCellTypes.includes(cellType);
|
|
130
135
|
});
|
|
131
136
|
let formatDataVal = (0, _Dataformat.formatColumnValues)(filterColumns, tableData);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bento-core/table",
|
|
3
|
-
"version": "1.0.1-ccdihub.
|
|
3
|
+
"version": "1.0.1-ccdihub.69",
|
|
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",
|
package/src/util/Types.js
CHANGED
|
@@ -7,7 +7,9 @@ export const DEFAULT = 'DEFAULT';
|
|
|
7
7
|
export const FORMAT_DATA = 'FORMAT_DATA';
|
|
8
8
|
export const FORMAT_BYTES = 'FORMAT_BYTES';
|
|
9
9
|
export const TRANSFORM = 'TRANSFORM';
|
|
10
|
+
export const STUDY_DOWNLOAD = 'STUDY_DOWNLOAD';
|
|
10
11
|
export const EXPAND = 'EXPAND';
|
|
12
|
+
export const DBGAP = 'DBGAP';
|
|
11
13
|
|
|
12
14
|
export const cellTypes = {
|
|
13
15
|
CUSTOM_ELEM,
|
|
@@ -22,10 +24,14 @@ export const cellTypes = {
|
|
|
22
24
|
export const cellStyles = {
|
|
23
25
|
TRANSFORM,
|
|
24
26
|
EXPAND,
|
|
27
|
+
DBGAP,
|
|
28
|
+
STUDY_DOWNLOAD,
|
|
25
29
|
};
|
|
26
30
|
|
|
27
31
|
export const actionCellTypes = [CHECKBOX, DELETE];
|
|
28
32
|
|
|
33
|
+
export const notIncludedCellStyle = [STUDY_DOWNLOAD];
|
|
34
|
+
|
|
29
35
|
export const FORMAT_DATA_CELLS = [FORMAT_BYTES];
|
|
30
36
|
|
|
31
37
|
export const dataFormatTypes = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { formatBytes, formatColumnValues } from './Dataformat';
|
|
2
|
-
import { actionCellTypes } from './Types';
|
|
2
|
+
import { actionCellTypes, notIncludedCellStyle } from './Types';
|
|
3
3
|
|
|
4
4
|
export function createFileName(fileName, type) {
|
|
5
5
|
const date = new Date();
|
|
@@ -64,12 +64,13 @@ export function convertToCSV(jsonse, keysToInclude, header) {
|
|
|
64
64
|
|
|
65
65
|
export function downloadCSV(tableData, table, downloadFileName) {
|
|
66
66
|
const { columns = [] } = table;
|
|
67
|
-
const filterColumns = columns.filter(({ cellType }) => !actionCellTypes.includes(cellType))
|
|
67
|
+
const filterColumns = columns.filter(({ cellType }) => !actionCellTypes.includes(cellType))
|
|
68
|
+
.filter(({ cellStyle }) => !notIncludedCellStyle.includes(cellStyle));
|
|
68
69
|
const formatDataVal = formatColumnValues(filterColumns, tableData);
|
|
69
70
|
const jsonse = JSON.stringify(formatDataVal);
|
|
70
|
-
const keysToInclude =
|
|
71
|
+
const keysToInclude = filterColumns.filter(({ dataField }) => dataField)
|
|
71
72
|
.map(({ dataField }) => dataField);
|
|
72
|
-
const headers =
|
|
73
|
+
const headers = filterColumns.filter(({ dataField }) => dataField)
|
|
73
74
|
.map(({ header, downloadHeader }) => (downloadHeader || header));
|
|
74
75
|
const csv = convertToCSV(jsonse, keysToInclude, headers);
|
|
75
76
|
const exportData = new Blob([csv], { type: 'text/csv' });
|