@bento-core/table 1.0.0-c3dc.33 → 1.0.0-c3dc.35
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.
|
@@ -35,7 +35,7 @@ const ManageColumnView = _ref => {
|
|
|
35
35
|
const [listDisplay, setListDisplay] = (0, _react.useState)('none');
|
|
36
36
|
const [selectAll, setSelectAll] = (0, _react.useState)(false);
|
|
37
37
|
const [needsScroll, setNeedsScroll] = (0, _react.useState)(false);
|
|
38
|
-
const viewColumns = columns.filter(col => col.role === _Types.cellTypes.DISPLAY && col.
|
|
38
|
+
const viewColumns = columns.filter(col => col.role === _Types.cellTypes.DISPLAY && col.downloadOnly !== true);
|
|
39
39
|
const dropdownSelection = (0, _react.useRef)(null);
|
|
40
40
|
const formGroupRef = (0, _react.useRef)(null);
|
|
41
41
|
const handleClose = () => {
|
|
@@ -76,18 +76,28 @@ function downloadData(tableData, table, downloadFileName) {
|
|
|
76
76
|
} = table;
|
|
77
77
|
const filterColumns = columns.filter(_ref => {
|
|
78
78
|
let {
|
|
79
|
-
cellType
|
|
80
|
-
doNotDownload
|
|
79
|
+
cellType
|
|
81
80
|
} = _ref;
|
|
82
|
-
return !_Types.actionCellTypes.includes(cellType)
|
|
83
|
-
})
|
|
81
|
+
return !_Types.actionCellTypes.includes(cellType);
|
|
82
|
+
}).filter(_ref2 => {
|
|
83
|
+
let {
|
|
84
|
+
doNotDownload
|
|
85
|
+
} = _ref2;
|
|
86
|
+
return !doNotDownload;
|
|
87
|
+
}).filter(_ref3 => {
|
|
88
|
+
let {
|
|
89
|
+
display,
|
|
90
|
+
downloadOnly
|
|
91
|
+
} = _ref3;
|
|
92
|
+
return display || downloadOnly;
|
|
93
|
+
}); // want to download hidden columns ('download only columns')
|
|
84
94
|
let formatDataVal = (0, _Dataformat.formatColumnValues)(filterColumns, tableData);
|
|
85
95
|
formatDataVal = formatDataVal.map(item => {
|
|
86
96
|
const updatedItem = {};
|
|
87
|
-
filterColumns.forEach(
|
|
97
|
+
filterColumns.forEach(_ref4 => {
|
|
88
98
|
let {
|
|
89
99
|
dataField
|
|
90
|
-
} =
|
|
100
|
+
} = _ref4;
|
|
91
101
|
updatedItem[dataField] = item[dataField];
|
|
92
102
|
});
|
|
93
103
|
return updatedItem;
|
|
@@ -112,27 +122,27 @@ function downloadData(tableData, table, downloadFileName) {
|
|
|
112
122
|
fileType = 'application/json';
|
|
113
123
|
} else {
|
|
114
124
|
const jsonse = JSON.stringify(formatDataVal);
|
|
115
|
-
const keysToInclude = filterColumns.filter(
|
|
125
|
+
const keysToInclude = filterColumns.filter(_ref5 => {
|
|
116
126
|
let {
|
|
117
127
|
dataField
|
|
118
|
-
} =
|
|
128
|
+
} = _ref5;
|
|
119
129
|
return dataField;
|
|
120
|
-
}).map(
|
|
130
|
+
}).map(_ref6 => {
|
|
121
131
|
let {
|
|
122
132
|
dataField
|
|
123
|
-
} =
|
|
133
|
+
} = _ref6;
|
|
124
134
|
return dataField;
|
|
125
135
|
});
|
|
126
|
-
const headers = filterColumns.filter(
|
|
136
|
+
const headers = filterColumns.filter(_ref7 => {
|
|
127
137
|
let {
|
|
128
138
|
dataField
|
|
129
|
-
} =
|
|
139
|
+
} = _ref7;
|
|
130
140
|
return dataField;
|
|
131
|
-
}).map(
|
|
141
|
+
}).map(_ref8 => {
|
|
132
142
|
let {
|
|
133
143
|
header,
|
|
134
144
|
downloadHeader
|
|
135
|
-
} =
|
|
145
|
+
} = _ref8;
|
|
136
146
|
return downloadHeader || header;
|
|
137
147
|
});
|
|
138
148
|
fileContent = convertToCSV(jsonse, keysToInclude, headers);
|
package/package.json
CHANGED
|
@@ -41,7 +41,7 @@ const ManageColumnView = ({
|
|
|
41
41
|
const [needsScroll, setNeedsScroll] = useState(false);
|
|
42
42
|
|
|
43
43
|
const viewColumns = columns.filter((col) => col.role === cellTypes.DISPLAY
|
|
44
|
-
&& col.
|
|
44
|
+
&& col.downloadOnly !== true);
|
|
45
45
|
|
|
46
46
|
const dropdownSelection = useRef(null);
|
|
47
47
|
const formGroupRef = useRef(null);
|
|
@@ -63,8 +63,10 @@ export function convertToCSV(jsonse, keysToInclude, header) {
|
|
|
63
63
|
|
|
64
64
|
export function downloadData(tableData, table, downloadFileName, format = 'csv') {
|
|
65
65
|
const { columns = [] } = table;
|
|
66
|
-
const filterColumns = columns
|
|
67
|
-
|
|
66
|
+
const filterColumns = columns
|
|
67
|
+
.filter(({ cellType }) => !actionCellTypes.includes(cellType))
|
|
68
|
+
.filter(({ doNotDownload }) => !doNotDownload)
|
|
69
|
+
.filter(({ display, downloadOnly }) => display || downloadOnly); // want to download hidden columns ('download only columns')
|
|
68
70
|
let formatDataVal = formatColumnValues(filterColumns, tableData);
|
|
69
71
|
|
|
70
72
|
formatDataVal = formatDataVal.map((item) => {
|