sccoreui 6.1.86 → 6.1.88
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/App.scss +1 -1
- package/dist/components/ag-grid/advancedFeature/column-group.js +1 -1
- package/dist/components/ag-grid/advancedFeature/custom-sort.js +1 -1
- package/dist/components/ag-grid/advancedFeature/new-filter/table-filter.js +1 -1
- package/dist/components/ag-grid/helper.js +358 -12
- package/dist/components/ag-grid/parent-for-grid.js +26 -213
- package/dist/components/ag-grid/utilComponents.js +18 -0
- package/dist/types/components/ag-grid/grid-checkbox.d.ts +1 -1
- package/dist/types/components/ag-grid/helper.d.ts +17 -0
- package/dist/types/components/ag-grid/utilComponents.d.ts +2 -0
- package/package.json +1 -1
package/dist/App.scss
CHANGED
|
@@ -144,6 +144,6 @@ const ColumnGroup = (props) => {
|
|
|
144
144
|
setRenderColumns(columnsFromGrid);
|
|
145
145
|
}
|
|
146
146
|
}, [(_d = (_c = (_b = (_a = gridApi === null || gridApi === void 0 ? void 0 : gridApi.current) === null || _a === void 0 ? void 0 : _a.api) === null || _b === void 0 ? void 0 : _b.columnModel) === null || _c === void 0 ? void 0 : _c.columnDefs) === null || _d === void 0 ? void 0 : _d.length]);
|
|
147
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ className: `${(columnsSelectedForGroup === null || columnsSelectedForGroup === void 0 ? void 0 : columnsSelectedForGroup.length) > 0 ? "bg-primary-50" : "bg-white"} hover:bg-primary-
|
|
147
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ className: `${(columnsSelectedForGroup === null || columnsSelectedForGroup === void 0 ? void 0 : columnsSelectedForGroup.length) > 0 ? "bg-primary-50" : "bg-white"} hover:bg-primary-25 br-8 cursor-pointer pd-9 flex align-items-cente gap-1 zoom_animate`, ref: btnRef, onClick: showColumnOptions }, { children: [(0, jsx_runtime_1.jsx)(svg_component_1.default, { icon: "grid-01", size: 18, color: (columnsSelectedForGroup === null || columnsSelectedForGroup === void 0 ? void 0 : columnsSelectedForGroup.length) > 0 ? "text-primary-400" : "text-gray-500" }), (columnsSelectedForGroup === null || columnsSelectedForGroup === void 0 ? void 0 : columnsSelectedForGroup.length) > 0 && ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "flex align-items-center justify-content-center" }, { children: [(0, jsx_runtime_1.jsx)("span", Object.assign({ className: "text-primary-400 font-semibold ml-1" }, { children: columnsSelectedForGroup === null || columnsSelectedForGroup === void 0 ? void 0 : columnsSelectedForGroup.length })), (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "flex align-items-center gap-2 text-primary-400 font-semibold" }, { children: [(0, jsx_runtime_1.jsx)("p", Object.assign({ className: "ml-2" }, { children: "Selected" })), (0, jsx_runtime_1.jsx)(button_1.Button, { onClick: (e) => clearListItems(e), className: "h-auto p-0", text: true, icon: (0, jsx_runtime_1.jsx)(svg_component_1.default, { icon: "x-close", color: "text-primary-400", size: 18 }) })] }))] })))] })), (0, jsx_runtime_1.jsxs)(overlaypanel_1.OverlayPanel, Object.assign({ ref: columnGroupRef, className: "column-group p-1", onHide: handleHide }, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "column-header" }, { children: [(0, jsx_runtime_1.jsx)("h3", Object.assign({ className: "my-0" }, { children: "Grouping" })), (0, jsx_runtime_1.jsx)("p", Object.assign({ className: "my-0 mb-4" }, { children: "Select one or two columns for sorting" }))] })), (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "column-body" }, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "p-input-icon-right w-full p-2 bg-gray-50" }, { children: [(0, jsx_runtime_1.jsx)("span", Object.assign({ className: "p-input-suffix top-0", style: { right: "20px" } }, { children: (0, jsx_runtime_1.jsx)(svg_component_1.default, { icon: "search-md" }) })), (0, jsx_runtime_1.jsx)(inputtext_1.InputText, { onChange: (e) => searchResults(e), value: inpVlaue, disabled: false, placeholder: "Enter any column name", className: "text-lg font-normal text-gray-500 hover:text-gray-900 w-full" })] })), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "flex flex-column gap-1 mt-1 mr-1 max-h-15rem max-w-30rem overflow-y-auto" }, { children: renderColumns.map((column, index) => ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "flex align-items-center gap-2 pl-2" }, { children: [column.rowGroup && ((0, jsx_runtime_1.jsx)("img", { onDragStart: (e) => onDragStart(e, index), onDragOver: onDragOver, onDrop: (e) => onDrop(e, index), src: drag_and_drop_icon_png_1.default, width: 20, height: 20 })), (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: `flex gap-2 ${column.rowGroup && "bg-primary-25"} hover:bg-primary-25 border-round-sm p-3 w-full` }, { children: [(0, jsx_runtime_1.jsx)(checkbox_1.Checkbox, { checked: column.rowGroup, onChange: (e) => onSelectedCheckbox(column, e), disabled: selectedCheckBoxesLength === 2 && !column.rowGroup }), (0, jsx_runtime_1.jsx)("label", Object.assign({ className: "max-w-28rem line-clamp line-clamp-1 inline-block", title: column.headerName }, { children: column.headerName }))] }))] }), column.id))) }))] })), (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "column-footer gap-2 border-top-1 border-gray-200 flex align-items-center justify-content-between" }, { children: [(0, jsx_runtime_1.jsx)(button_1.Button, { className: "cursor-pointer", text: true, label: "Remove Grouping", onClick: (e) => clearListItems(e) }), (0, jsx_runtime_1.jsx)(button_1.Button, { className: "cursor-pointer", label: "Save Grouping", onClick: (e) => saveGrouping(e) })] }))] }))] }));
|
|
148
148
|
};
|
|
149
149
|
exports.default = ColumnGroup;
|
|
@@ -86,7 +86,7 @@ function Sort() {
|
|
|
86
86
|
setIsApplyDisable(true);
|
|
87
87
|
}
|
|
88
88
|
}, [sortValue, sortBy]);
|
|
89
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ className: `cursor-pointer sc_icon_hover flex align-items-center ${isOverlayOpened || featureDetails.sort.isSortable
|
|
89
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ className: `cursor-pointer sc_icon_hover flex align-items-center border-round hover:bg-primary-25 ${isOverlayOpened || featureDetails.sort.isSortable
|
|
90
90
|
? "bg-primary-50" : "bg-white"}` }, { children: [featureDetails.sort.isSortable && ((0, jsx_runtime_1.jsx)("span", Object.assign({ className: "flex align-items-center text-primary-400 ml-3" }, { children: (sortModelText === null || sortModelText === void 0 ? void 0 : sortModelText.onSelectedSort) ? sortModelText.onSelectedSort : `Selected` }))), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: `rounded_btn sc_icon_hover border-round-md`, onClick: (event) => onClickSort(event) }, { children: (0, jsx_runtime_1.jsx)(svg_component_1.default, { icon: "switch-vertical-02", size: 16, color: isOverlayOpened || featureDetails.sort.isSortable
|
|
91
91
|
? "text-primary-400"
|
|
92
92
|
: "text-gray-700" }) }))] })), (0, jsx_runtime_1.jsxs)(overlaypanel_1.OverlayPanel, Object.assign({ ref: showShort, onShow: () => setIsOverlayOpened(true), onHide: () => setIsOverlayOpened(false), className: "w-18rem mt-2 overlay_list_options" }, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ className: "p-4 text-lg font-semibold line-height-3 text-gray-900 border-bottom-1 border-gray-200" }, { children: (sortModelText === null || sortModelText === void 0 ? void 0 : sortModelText.header) ? sortModelText.header : "Column Sorting" })), (0, jsx_runtime_1.jsx)("ul", Object.assign({ className: "pl-0 m-1 max-h-10rem overflow-auto" }, { children: columnData === null || columnData === void 0 ? void 0 : columnData.map((eachColumn, index) => {
|
|
@@ -137,7 +137,7 @@ const TableFilter = () => {
|
|
|
137
137
|
});
|
|
138
138
|
setAllFieldsFilled(isAllFieldsFilled && enbleApply);
|
|
139
139
|
}, [conditionsArray, enbleApply]);
|
|
140
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ className: `cursor-pointer filter-btn-grid font-semibold hover:bg-primary-
|
|
140
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ className: `cursor-pointer filter-btn-grid font-semibold hover:bg-primary-25 sc_icon_hover flex align-items-center gap-2 border-round-lg ${isOverlayOpened ||
|
|
141
141
|
(globalFilters === null || globalFilters === void 0 ? void 0 : globalFilters.filter((each) => each.isActive).length) >= 1
|
|
142
142
|
? "bg-primary-50"
|
|
143
143
|
: "bg-white"}` }, { children: (0, jsx_runtime_1.jsxs)("span", Object.assign({ onClick: (e) => onClickFilter(e), className: "flex zoom_animate" }, { children: [(0, jsx_runtime_1.jsx)(svg_component_1.default, { icon: "filter-lines", size: 18, color: isOverlayOpened ||
|
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.autoGroupColumnDef = exports.fillOperation = exports.updateCells = exports.getCheckedStatus = exports.sortColumns = exports.parseIfNeeded = exports.applyDefaultFilters = void 0;
|
|
3
|
+
exports.handleCheckboxClick = exports.getGroupIds = exports.handleUncheckedState = exports.handleCheckedState = exports.updateGroupState = exports.determineConditions = exports.updateRecords = exports.autoGroupColumnDef = exports.fillOperation = exports.updateCells = exports.getCheckedStatus = exports.sortColumns = exports.parseIfNeeded = exports.applyDefaultFilters = exports.initialCheckBoxData = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
const constants_1 = require("./constants");
|
|
6
|
+
// initial checkbox data
|
|
7
|
+
exports.initialCheckBoxData = {
|
|
8
|
+
allBoxChecked: false,
|
|
9
|
+
isIndeterminate: false,
|
|
10
|
+
includedRecords: [],
|
|
11
|
+
excludedRecords: [],
|
|
12
|
+
headerCheckBoxStatus: constants_1.GRID_CHECKBOX_STATUS.NEUTRAL,
|
|
13
|
+
};
|
|
5
14
|
const applyDefaultFilters = (defaultFilters) => {
|
|
6
15
|
const filters = defaultFilters === null || defaultFilters === void 0 ? void 0 : defaultFilters.map((item) => {
|
|
7
16
|
const obj = {
|
|
8
17
|
logicalOperator: item === null || item === void 0 ? void 0 : item.logicalOperator,
|
|
9
18
|
selectedColumn: item === null || item === void 0 ? void 0 : item.columnName,
|
|
10
19
|
selectedOperation: item === null || item === void 0 ? void 0 : item.condition,
|
|
11
|
-
value: item === null || item === void 0 ? void 0 : item.value
|
|
20
|
+
value: item === null || item === void 0 ? void 0 : item.value,
|
|
12
21
|
};
|
|
13
22
|
return obj;
|
|
14
23
|
});
|
|
@@ -35,8 +44,8 @@ const parseIfNeeded = (value) => {
|
|
|
35
44
|
exports.parseIfNeeded = parseIfNeeded;
|
|
36
45
|
const sortColumns = (columns) => {
|
|
37
46
|
const sortedColumns = columns === null || columns === void 0 ? void 0 : columns.sort((a, b) => {
|
|
38
|
-
a.body = a.cellRenderer, // Update the rederer key to avoid recursion
|
|
39
|
-
b.body = b.cellRenderer; // Update the rederer key to avoid recursion
|
|
47
|
+
(a.body = a.cellRenderer), // Update the rederer key to avoid recursion
|
|
48
|
+
(b.body = b.cellRenderer); // Update the rederer key to avoid recursion
|
|
40
49
|
if (!a.seq)
|
|
41
50
|
return 1;
|
|
42
51
|
if (!b.seq)
|
|
@@ -80,12 +89,12 @@ const updateCells = (updatedRowData, setUpdateRowData, api) => {
|
|
|
80
89
|
}
|
|
81
90
|
};
|
|
82
91
|
exports.updateCells = updateCells;
|
|
83
|
-
// Fill data in grid through drag
|
|
92
|
+
// Fill data in grid through drag
|
|
84
93
|
const fillOperation = (params, api, editedRecords, setEditedRecords) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
85
94
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
86
95
|
const { finalRange } = params;
|
|
87
96
|
const { startRow, endRow, columns,
|
|
88
|
-
// startColumn
|
|
97
|
+
// startColumn
|
|
89
98
|
} = finalRange;
|
|
90
99
|
const columnDetails = columns[0].colDef;
|
|
91
100
|
const parentRowData = (_c = api.getDisplayedRowAtIndex((_b = (_a = params === null || params === void 0 ? void 0 : params.initialRange) === null || _a === void 0 ? void 0 : _a.startRow) === null || _b === void 0 ? void 0 : _b.rowIndex)) === null || _c === void 0 ? void 0 : _c.data;
|
|
@@ -99,11 +108,12 @@ const fillOperation = (params, api, editedRecords, setEditedRecords) => tslib_1.
|
|
|
99
108
|
continue; // Skip if rowNode is undefined
|
|
100
109
|
const rowData = rowNode === null || rowNode === void 0 ? void 0 : rowNode.data;
|
|
101
110
|
// Check if rowData exists and update the field
|
|
102
|
-
if (rowData &&
|
|
111
|
+
if (rowData && rowNode.id != (parentRowData === null || parentRowData === void 0 ? void 0 : parentRowData.id)) {
|
|
103
112
|
// Skip edit for same values
|
|
104
|
-
if ((rowData === null || rowData === void 0 ? void 0 : rowData[columnDetails === null || columnDetails === void 0 ? void 0 : columnDetails.field]) ===
|
|
113
|
+
if ((rowData === null || rowData === void 0 ? void 0 : rowData[columnDetails === null || columnDetails === void 0 ? void 0 : columnDetails.field]) ===
|
|
114
|
+
(parentRowData === null || parentRowData === void 0 ? void 0 : parentRowData[columnDetails === null || columnDetails === void 0 ? void 0 : columnDetails.field]))
|
|
105
115
|
continue;
|
|
106
|
-
// If Dragged cell is grouped only group headers should edit vice versa to child cells
|
|
116
|
+
// If Dragged cell is grouped only group headers should edit vice versa to child cells
|
|
107
117
|
if (((_d = rowData === null || rowData === void 0 ? void 0 : rowData.orgHierarchy) === null || _d === void 0 ? void 0 : _d.length) !== ((_e = parentRowData === null || parentRowData === void 0 ? void 0 : parentRowData.orgHierarchy) === null || _e === void 0 ? void 0 : _e.length))
|
|
108
118
|
continue;
|
|
109
119
|
// if( rowData?.[columnDetails?.field] == EMPTY_RECORD || rowData?.type !== parentRowData?.type || !rowData?.[columnDetails?.field] ){
|
|
@@ -120,7 +130,7 @@ const fillOperation = (params, api, editedRecords, setEditedRecords) => tslib_1.
|
|
|
120
130
|
const schemaForEdit = {
|
|
121
131
|
row: rowData,
|
|
122
132
|
field: [],
|
|
123
|
-
isCustomAttribute: columnDetails === null || columnDetails === void 0 ? void 0 : columnDetails.isCustomAttribute
|
|
133
|
+
isCustomAttribute: columnDetails === null || columnDetails === void 0 ? void 0 : columnDetails.isCustomAttribute,
|
|
124
134
|
};
|
|
125
135
|
if (!((_f = schemaForEdit === null || schemaForEdit === void 0 ? void 0 : schemaForEdit.field) === null || _f === void 0 ? void 0 : _f.includes(columnDetails === null || columnDetails === void 0 ? void 0 : columnDetails.field))) {
|
|
126
136
|
(_g = schemaForEdit === null || schemaForEdit === void 0 ? void 0 : schemaForEdit.field) === null || _g === void 0 ? void 0 : _g.push(columnDetails === null || columnDetails === void 0 ? void 0 : columnDetails.field);
|
|
@@ -193,13 +203,349 @@ const autoGroupColumnDef = (isTreeEnable, headerName, groupField, GroupHeaderCom
|
|
|
193
203
|
return {
|
|
194
204
|
suppressCount: false,
|
|
195
205
|
checkbox: false,
|
|
196
|
-
innerRenderer: HeaderRendererForGroup
|
|
206
|
+
innerRenderer: HeaderRendererForGroup,
|
|
197
207
|
};
|
|
198
208
|
}
|
|
199
209
|
// Return specific params for group rows to use default rendering
|
|
200
|
-
return {
|
|
210
|
+
return {
|
|
211
|
+
suppressCount: typeof displayGroupCount === "boolean" ? !displayGroupCount : true,
|
|
212
|
+
};
|
|
201
213
|
},
|
|
202
214
|
};
|
|
203
215
|
}
|
|
204
216
|
};
|
|
205
217
|
exports.autoGroupColumnDef = autoGroupColumnDef;
|
|
218
|
+
// function to update the records based on checkbox state
|
|
219
|
+
// This function determines how to update `includedRecords` and `excludedRecords`
|
|
220
|
+
// depending on whether all checkboxes are checked or not (`allBoxChecked` state)
|
|
221
|
+
const updateRecords = (rowData, featureDetails, gridData) => {
|
|
222
|
+
var _a, _b, _c, _d;
|
|
223
|
+
const { excludedRecords, includedRecords, allBoxChecked } = featureDetails.checkBoxSelection;
|
|
224
|
+
let newExcludedRecords = [...excludedRecords];
|
|
225
|
+
let newIncludedRecords = [...includedRecords];
|
|
226
|
+
// When all checkboxes are checked
|
|
227
|
+
if (allBoxChecked) {
|
|
228
|
+
// Update excluded records: add or remove the current rowData
|
|
229
|
+
newExcludedRecords = (excludedRecords === null || excludedRecords === void 0 ? void 0 : excludedRecords.includes(rowData))
|
|
230
|
+
? excludedRecords === null || excludedRecords === void 0 ? void 0 : excludedRecords.filter((item) => item !== rowData)
|
|
231
|
+
: [...excludedRecords, rowData];
|
|
232
|
+
// Check if all records are included; reset if so
|
|
233
|
+
if ((newIncludedRecords === null || newIncludedRecords === void 0 ? void 0 : newIncludedRecords.length) === ((_a = gridData === null || gridData === void 0 ? void 0 : gridData.rowData) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
234
|
+
return {
|
|
235
|
+
excludedRecords: [],
|
|
236
|
+
includedRecords: [],
|
|
237
|
+
isIndeterminate: false,
|
|
238
|
+
allBoxChecked: true,
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
// Check if all records are excluded; reset if so
|
|
242
|
+
else if ((newExcludedRecords === null || newExcludedRecords === void 0 ? void 0 : newExcludedRecords.length) === ((_b = gridData === null || gridData === void 0 ? void 0 : gridData.rowData) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
243
|
+
return exports.initialCheckBoxData;
|
|
244
|
+
}
|
|
245
|
+
// Otherwise, update the excluded records and indeterminate state
|
|
246
|
+
else {
|
|
247
|
+
return Object.assign(Object.assign({}, featureDetails === null || featureDetails === void 0 ? void 0 : featureDetails.checkBoxSelection), { excludedRecords: newExcludedRecords, isIndeterminate: !(excludedRecords === null || excludedRecords === void 0 ? void 0 : excludedRecords.includes(rowData)) });
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
// When not all checkboxes are checked
|
|
251
|
+
else {
|
|
252
|
+
// Update included records: add or remove the current rowData
|
|
253
|
+
newIncludedRecords = (includedRecords === null || includedRecords === void 0 ? void 0 : includedRecords.includes(rowData))
|
|
254
|
+
? includedRecords === null || includedRecords === void 0 ? void 0 : includedRecords.filter((item) => (item === null || item === void 0 ? void 0 : item.id) !== (rowData === null || rowData === void 0 ? void 0 : rowData.id))
|
|
255
|
+
: [...includedRecords, rowData];
|
|
256
|
+
// Check if all records are included; reset if so
|
|
257
|
+
if ((newIncludedRecords === null || newIncludedRecords === void 0 ? void 0 : newIncludedRecords.length) === ((_c = gridData === null || gridData === void 0 ? void 0 : gridData.rowData) === null || _c === void 0 ? void 0 : _c.length)) {
|
|
258
|
+
return {
|
|
259
|
+
excludedRecords: [],
|
|
260
|
+
includedRecords: [],
|
|
261
|
+
isIndeterminate: false,
|
|
262
|
+
allBoxChecked: true,
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
// Check if all records are excluded; reset if so
|
|
266
|
+
else if ((newExcludedRecords === null || newExcludedRecords === void 0 ? void 0 : newExcludedRecords.length) === ((_d = gridData === null || gridData === void 0 ? void 0 : gridData.rowData) === null || _d === void 0 ? void 0 : _d.length)) {
|
|
267
|
+
return exports.initialCheckBoxData;
|
|
268
|
+
}
|
|
269
|
+
// Otherwise, update the included records
|
|
270
|
+
else {
|
|
271
|
+
return Object.assign(Object.assign({}, featureDetails === null || featureDetails === void 0 ? void 0 : featureDetails.checkBoxSelection), { includedRecords: newIncludedRecords });
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
exports.updateRecords = updateRecords;
|
|
276
|
+
// Utility function to determine conditions for updating group states
|
|
277
|
+
// Based on various flags and states, determines whether to add or remove group IDs
|
|
278
|
+
const determineConditions = (isChecked, allBoxChecked, isEveryParentGroupInclude, isEveryParentGroupExcluded, isEverySuperParentGroupExcluded) => ({
|
|
279
|
+
addParent: (!allBoxChecked && isChecked && isEveryParentGroupInclude) ||
|
|
280
|
+
(allBoxChecked && isChecked && !isEveryParentGroupExcluded),
|
|
281
|
+
addSuperParent: (!allBoxChecked && isChecked && isEveryParentGroupInclude) ||
|
|
282
|
+
(allBoxChecked && isChecked && !isEverySuperParentGroupExcluded),
|
|
283
|
+
removeParent: (!allBoxChecked && !isChecked && !isEveryParentGroupInclude) ||
|
|
284
|
+
(allBoxChecked && !isChecked && isEveryParentGroupExcluded),
|
|
285
|
+
removeSuperParent: (!allBoxChecked && !isChecked && !isEveryParentGroupInclude) ||
|
|
286
|
+
(allBoxChecked && !isChecked && isEverySuperParentGroupExcluded),
|
|
287
|
+
});
|
|
288
|
+
exports.determineConditions = determineConditions;
|
|
289
|
+
// Function to update the selected groups in the state
|
|
290
|
+
// Takes the group ID and a boolean flag `add` to decide whether to add or remove the group ID
|
|
291
|
+
const updateSelectedGroup = (id, add, setSelectedGroup) => {
|
|
292
|
+
setSelectedGroup((prev) => {
|
|
293
|
+
if (add) {
|
|
294
|
+
// If `add` is true, add the group ID if it does not already exist in the state
|
|
295
|
+
if (!prev.includes(id)) {
|
|
296
|
+
return [...prev, id];
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
// If `add` is false, remove the group ID from the state
|
|
301
|
+
return prev.filter((groupId) => groupId !== id);
|
|
302
|
+
}
|
|
303
|
+
return prev;
|
|
304
|
+
});
|
|
305
|
+
};
|
|
306
|
+
// function to update the selected groups in the state
|
|
307
|
+
// Manages adding or removing group IDs based on the grouping column count and conditions
|
|
308
|
+
const updateGroupState = (groupingColumns, parentId, superParentId, conditions, setSelectedGroup) => {
|
|
309
|
+
const { addParent, addSuperParent, removeParent, removeSuperParent } = conditions;
|
|
310
|
+
// Handle logic when there are 2 grouping columns
|
|
311
|
+
if (groupingColumns === 2) {
|
|
312
|
+
if (addSuperParent)
|
|
313
|
+
updateSelectedGroup(superParentId, true, setSelectedGroup); // Add super parent group ID
|
|
314
|
+
if (addParent)
|
|
315
|
+
updateSelectedGroup(parentId, true, setSelectedGroup); // Add parent group ID
|
|
316
|
+
if (removeSuperParent)
|
|
317
|
+
updateSelectedGroup(superParentId, false, setSelectedGroup); // Remove super parent group ID
|
|
318
|
+
if (removeParent)
|
|
319
|
+
updateSelectedGroup(parentId, false, setSelectedGroup); // Remove parent group ID
|
|
320
|
+
}
|
|
321
|
+
// Handle logic when there is 1 grouping column
|
|
322
|
+
else if (groupingColumns === 1) {
|
|
323
|
+
if (addParent)
|
|
324
|
+
updateSelectedGroup(parentId, true, setSelectedGroup); // Add parent group ID
|
|
325
|
+
if (removeParent)
|
|
326
|
+
updateSelectedGroup(parentId, false, setSelectedGroup); // Remove parent group ID
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
exports.updateGroupState = updateGroupState;
|
|
330
|
+
// ------------------------------------- group header checkbox -------------------------------------------
|
|
331
|
+
// Utility function to gather all child and parent data for a group
|
|
332
|
+
const gatherGroupData = (params) => {
|
|
333
|
+
var _a, _b, _c, _d;
|
|
334
|
+
const groupData = (_b = (_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.allLeafChildren) === null || _b === void 0 ? void 0 : _b.map((childNode) => childNode === null || childNode === void 0 ? void 0 : childNode.data);
|
|
335
|
+
const parentGroupData = (_d = (_c = params === null || params === void 0 ? void 0 : params.node.parent) === null || _c === void 0 ? void 0 : _c.allLeafChildren) === null || _d === void 0 ? void 0 : _d.map((childNode) => childNode === null || childNode === void 0 ? void 0 : childNode.data);
|
|
336
|
+
return { groupData, parentGroupData };
|
|
337
|
+
};
|
|
338
|
+
// Utility function to handle checked state updates
|
|
339
|
+
const handleCheckedState = (params, featureDetails, gridData, setFeatureDetails, setSelectedGroup, groupingColumns) => {
|
|
340
|
+
const { excludedRecords, includedRecords, allBoxChecked } = featureDetails === null || featureDetails === void 0 ? void 0 : featureDetails.checkBoxSelection;
|
|
341
|
+
const { groupData, parentGroupData } = gatherGroupData(params);
|
|
342
|
+
let newExcludedRecords = [...excludedRecords];
|
|
343
|
+
let newIncludedRecords = [...includedRecords];
|
|
344
|
+
// Update records based on the checkbox state
|
|
345
|
+
groupData.forEach((group) => {
|
|
346
|
+
var _a, _b;
|
|
347
|
+
if (allBoxChecked) {
|
|
348
|
+
newExcludedRecords = (newExcludedRecords === null || newExcludedRecords === void 0 ? void 0 : newExcludedRecords.includes(group))
|
|
349
|
+
? newExcludedRecords.filter((item) => item !== group)
|
|
350
|
+
: [...newExcludedRecords, group];
|
|
351
|
+
}
|
|
352
|
+
else if (!((_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.leafGroup) && ((_b = params === null || params === void 0 ? void 0 : params.node) === null || _b === void 0 ? void 0 : _b.level) === 0) {
|
|
353
|
+
newIncludedRecords = newIncludedRecords.includes(group)
|
|
354
|
+
? newIncludedRecords
|
|
355
|
+
: [...newIncludedRecords, group];
|
|
356
|
+
}
|
|
357
|
+
else {
|
|
358
|
+
newIncludedRecords = newIncludedRecords.includes(group)
|
|
359
|
+
? newIncludedRecords.filter((item) => {
|
|
360
|
+
if (item.id !== group.id)
|
|
361
|
+
group.isSelected = false;
|
|
362
|
+
return item.id !== group.id;
|
|
363
|
+
})
|
|
364
|
+
: [...newIncludedRecords, group];
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
updateCheckboxData(newIncludedRecords, newExcludedRecords, gridData, featureDetails, setFeatureDetails);
|
|
368
|
+
const isParent = determineParentGroupState(parentGroupData, newIncludedRecords, newExcludedRecords, allBoxChecked);
|
|
369
|
+
handleGroupSelection(params, setSelectedGroup, groupingColumns, isParent);
|
|
370
|
+
};
|
|
371
|
+
exports.handleCheckedState = handleCheckedState;
|
|
372
|
+
// Utility function to handle unchecked state updates
|
|
373
|
+
const handleUncheckedState = (params, featureDetails, gridData, setFeatureDetails, setSelectedGroup, groupingColumns) => {
|
|
374
|
+
const { excludedRecords, includedRecords, allBoxChecked } = featureDetails.checkBoxSelection;
|
|
375
|
+
const { groupData, parentGroupData } = gatherGroupData(params);
|
|
376
|
+
let newExcludedRecords = [...excludedRecords];
|
|
377
|
+
let newIncludedRecords = [...includedRecords];
|
|
378
|
+
// Update records based on the checkbox state
|
|
379
|
+
groupData.forEach((group) => {
|
|
380
|
+
if (allBoxChecked) {
|
|
381
|
+
newExcludedRecords = newExcludedRecords.includes(group)
|
|
382
|
+
? newExcludedRecords
|
|
383
|
+
: [...newExcludedRecords, group];
|
|
384
|
+
}
|
|
385
|
+
else {
|
|
386
|
+
newIncludedRecords = newIncludedRecords.includes(group)
|
|
387
|
+
? newIncludedRecords.filter((item) => {
|
|
388
|
+
if (item.id !== group.id)
|
|
389
|
+
group.isSelected = false;
|
|
390
|
+
return item.id !== group.id;
|
|
391
|
+
})
|
|
392
|
+
: [...newIncludedRecords, group];
|
|
393
|
+
}
|
|
394
|
+
});
|
|
395
|
+
updateCheckboxData(newIncludedRecords, newExcludedRecords, gridData, featureDetails, setFeatureDetails);
|
|
396
|
+
const isEveryParentGroupInclude = parentGroupData === null || parentGroupData === void 0 ? void 0 : parentGroupData.every((parent) => newIncludedRecords.some((included) => (included === null || included === void 0 ? void 0 : included.id) === (parent === null || parent === void 0 ? void 0 : parent.id)));
|
|
397
|
+
const isParent = determineParentGroupState(parentGroupData, newIncludedRecords, newExcludedRecords, allBoxChecked);
|
|
398
|
+
handleGroupDeselection(params, setSelectedGroup, groupingColumns, isParent, isEveryParentGroupInclude);
|
|
399
|
+
};
|
|
400
|
+
exports.handleUncheckedState = handleUncheckedState;
|
|
401
|
+
// Utility function to update checkbox data in the state
|
|
402
|
+
const updateCheckboxData = (newIncludedRecords, newExcludedRecords, gridData, featureDetails, setFeatureDetails) => {
|
|
403
|
+
var _a, _b;
|
|
404
|
+
if ((newIncludedRecords === null || newIncludedRecords === void 0 ? void 0 : newIncludedRecords.length) === ((_a = gridData === null || gridData === void 0 ? void 0 : gridData.rowData) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
405
|
+
setFeatureDetails(Object.assign(Object.assign({}, featureDetails), { checkBoxSelection: Object.assign(Object.assign({}, featureDetails.checkBoxSelection), { excludedRecords: [], includedRecords: [], isIndeterminate: false, allBoxChecked: true }) }));
|
|
406
|
+
}
|
|
407
|
+
else if ((newExcludedRecords === null || newExcludedRecords === void 0 ? void 0 : newExcludedRecords.length) === ((_b = gridData === null || gridData === void 0 ? void 0 : gridData.rowData) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
408
|
+
setFeatureDetails(Object.assign(Object.assign({}, featureDetails), { checkBoxSelection: exports.initialCheckBoxData }));
|
|
409
|
+
}
|
|
410
|
+
else {
|
|
411
|
+
setFeatureDetails(Object.assign(Object.assign({}, featureDetails), { checkBoxSelection: Object.assign(Object.assign({}, featureDetails.checkBoxSelection), { excludedRecords: newExcludedRecords, includedRecords: newIncludedRecords, isIndeterminate: featureDetails.checkBoxSelection.allBoxChecked ? true : featureDetails.checkBoxSelection.isIndeterminate }) }));
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
// Utility function to determine parent group inclusion or exclusion states
|
|
415
|
+
const determineParentGroupState = (parentGroupData, newIncludedRecords, newExcludedRecords, allBoxChecked) => {
|
|
416
|
+
const isAnyParentGroupInclude = parentGroupData === null || parentGroupData === void 0 ? void 0 : parentGroupData.every((parent) => newIncludedRecords.some((included) => included.id === parent.id));
|
|
417
|
+
const isAnyParentGroupExcluded = parentGroupData === null || parentGroupData === void 0 ? void 0 : parentGroupData.some((parent) => newExcludedRecords.some((excluded) => excluded.id === parent.id));
|
|
418
|
+
return allBoxChecked ? isAnyParentGroupExcluded : isAnyParentGroupInclude;
|
|
419
|
+
};
|
|
420
|
+
// Utility function to handle group selection logic for checked state
|
|
421
|
+
const handleGroupSelection = (params, setSelectedGroup, groupingColumns, isParent) => {
|
|
422
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
423
|
+
if (groupingColumns === 2 && !((_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.leafGroup) && ((_b = params === null || params === void 0 ? void 0 : params.node) === null || _b === void 0 ? void 0 : _b.level) === 0) {
|
|
424
|
+
(_d = (_c = params === null || params === void 0 ? void 0 : params.node) === null || _c === void 0 ? void 0 : _c.childrenAfterGroup) === null || _d === void 0 ? void 0 : _d.forEach((childNode) => {
|
|
425
|
+
setSelectedGroup((prev) => prev.includes(childNode.id) ? prev : [...prev, childNode.id]);
|
|
426
|
+
});
|
|
427
|
+
setSelectedGroup((prev) => prev.includes(params.node.id) ? prev : [...prev, params.node.id]);
|
|
428
|
+
}
|
|
429
|
+
else if (((_e = params === null || params === void 0 ? void 0 : params.node) === null || _e === void 0 ? void 0 : _e.leafGroup) && ((_f = params === null || params === void 0 ? void 0 : params.node) === null || _f === void 0 ? void 0 : _f.level) === 1 && isParent) {
|
|
430
|
+
setSelectedGroup((prev) => prev.includes(params.node.id) ? prev : [...prev, params.node.id]);
|
|
431
|
+
setSelectedGroup((prev) => {
|
|
432
|
+
var _a, _b, _c, _d;
|
|
433
|
+
return prev.includes((_b = (_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.id)
|
|
434
|
+
? prev
|
|
435
|
+
: [...prev, (_d = (_c = params === null || params === void 0 ? void 0 : params.node) === null || _c === void 0 ? void 0 : _c.parent) === null || _d === void 0 ? void 0 : _d.id];
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
else if (((_g = params === null || params === void 0 ? void 0 : params.node) === null || _g === void 0 ? void 0 : _g.leafGroup) && ((_h = params === null || params === void 0 ? void 0 : params.node) === null || _h === void 0 ? void 0 : _h.level) === 1 && !isParent) {
|
|
439
|
+
setSelectedGroup((prev) => {
|
|
440
|
+
var _a, _b, _c, _d;
|
|
441
|
+
return prev.includes((_b = (_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.id)
|
|
442
|
+
? prev
|
|
443
|
+
: [...prev, (_d = (_c = params === null || params === void 0 ? void 0 : params.node) === null || _c === void 0 ? void 0 : _c.parent) === null || _d === void 0 ? void 0 : _d.id];
|
|
444
|
+
});
|
|
445
|
+
setSelectedGroup((prev) => {
|
|
446
|
+
var _a, _b;
|
|
447
|
+
return prev.includes((_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.id)
|
|
448
|
+
? prev
|
|
449
|
+
: [...prev, (_b = params === null || params === void 0 ? void 0 : params.node) === null || _b === void 0 ? void 0 : _b.id];
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
else {
|
|
453
|
+
setSelectedGroup((prev) => { var _a; return prev.includes(params.node.id) ? prev : [...prev, (_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.id]; });
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
// Utility function to handle group deselection logic for unchecked state
|
|
457
|
+
const handleGroupDeselection = (params, setSelectedGroup, groupingColumns, isParent, isEveryParentGroupInclude) => {
|
|
458
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
459
|
+
if (groupingColumns === 2 && !((_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.leafGroup) && ((_b = params === null || params === void 0 ? void 0 : params.node) === null || _b === void 0 ? void 0 : _b.level) === 0) {
|
|
460
|
+
(_d = (_c = params === null || params === void 0 ? void 0 : params.node) === null || _c === void 0 ? void 0 : _c.childrenAfterGroup) === null || _d === void 0 ? void 0 : _d.forEach((childNode) => {
|
|
461
|
+
setSelectedGroup((prev) => prev === null || prev === void 0 ? void 0 : prev.filter((id) => id !== (childNode === null || childNode === void 0 ? void 0 : childNode.id)));
|
|
462
|
+
});
|
|
463
|
+
setSelectedGroup((prev) => prev === null || prev === void 0 ? void 0 : prev.filter((id) => { var _a; return id !== ((_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.id); }));
|
|
464
|
+
}
|
|
465
|
+
else if (((_e = params === null || params === void 0 ? void 0 : params.node) === null || _e === void 0 ? void 0 : _e.leafGroup) &&
|
|
466
|
+
((_f = params === null || params === void 0 ? void 0 : params.node) === null || _f === void 0 ? void 0 : _f.level) === 1 &&
|
|
467
|
+
!isEveryParentGroupInclude) {
|
|
468
|
+
// Handle cases where current node is a leaf group at level 1
|
|
469
|
+
setSelectedGroup((prev) => {
|
|
470
|
+
if (prev === null || prev === void 0 ? void 0 : prev.includes(params.node.id)) {
|
|
471
|
+
return prev === null || prev === void 0 ? void 0 : prev.filter((id) => { var _a; return id !== ((_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.id); });
|
|
472
|
+
}
|
|
473
|
+
return prev;
|
|
474
|
+
});
|
|
475
|
+
setSelectedGroup((prev) => {
|
|
476
|
+
var _a, _b;
|
|
477
|
+
if (prev === null || prev === void 0 ? void 0 : prev.includes((_b = (_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.id)) {
|
|
478
|
+
return prev === null || prev === void 0 ? void 0 : prev.filter((id) => { var _a, _b; return id !== ((_b = (_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.id); });
|
|
479
|
+
}
|
|
480
|
+
return prev;
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
else if (((_g = params === null || params === void 0 ? void 0 : params.node) === null || _g === void 0 ? void 0 : _g.leafGroup) && ((_h = params === null || params === void 0 ? void 0 : params.node) === null || _h === void 0 ? void 0 : _h.level) === 1 && !isParent) {
|
|
484
|
+
setSelectedGroup((prev) => {
|
|
485
|
+
if (prev === null || prev === void 0 ? void 0 : prev.includes(params.node.id)) {
|
|
486
|
+
return prev === null || prev === void 0 ? void 0 : prev.filter((id) => { var _a; return id !== ((_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.id); });
|
|
487
|
+
}
|
|
488
|
+
return prev;
|
|
489
|
+
});
|
|
490
|
+
setSelectedGroup((prev) => {
|
|
491
|
+
var _a, _b;
|
|
492
|
+
if (prev === null || prev === void 0 ? void 0 : prev.includes((_b = (_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.id)) {
|
|
493
|
+
return prev === null || prev === void 0 ? void 0 : prev.filter((id) => { var _a, _b; return id !== ((_b = (_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.id); });
|
|
494
|
+
}
|
|
495
|
+
return prev;
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
else if (((_j = params === null || params === void 0 ? void 0 : params.node) === null || _j === void 0 ? void 0 : _j.leafGroup) && ((_k = params === null || params === void 0 ? void 0 : params.node) === null || _k === void 0 ? void 0 : _k.level) === 1 && isParent) {
|
|
499
|
+
setSelectedGroup((prev) => {
|
|
500
|
+
var _a, _b;
|
|
501
|
+
if (prev.includes((_b = (_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.id)) {
|
|
502
|
+
return prev.filter((id) => { var _a, _b; return id !== ((_b = (_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.id); });
|
|
503
|
+
}
|
|
504
|
+
return prev;
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
else {
|
|
508
|
+
setSelectedGroup((prev) => prev.filter((id) => id !== params.node.id));
|
|
509
|
+
}
|
|
510
|
+
};
|
|
511
|
+
// ------------------------------------- group header checkbox -------------------------------------------
|
|
512
|
+
// iterating over eachnode and return first and second group ids
|
|
513
|
+
const getGroupIds = (gridRef) => {
|
|
514
|
+
var _a, _b;
|
|
515
|
+
const firstGroupIds = [];
|
|
516
|
+
const secondGroupIds = [];
|
|
517
|
+
(_b = (_a = gridRef === null || gridRef === void 0 ? void 0 : gridRef.current) === null || _a === void 0 ? void 0 : _a.api) === null || _b === void 0 ? void 0 : _b.forEachNode((node) => {
|
|
518
|
+
if (node === null || node === void 0 ? void 0 : node.group) {
|
|
519
|
+
if ((node === null || node === void 0 ? void 0 : node.level) === 0) {
|
|
520
|
+
// Store the ID of the first level group
|
|
521
|
+
firstGroupIds === null || firstGroupIds === void 0 ? void 0 : firstGroupIds.push(node === null || node === void 0 ? void 0 : node.id);
|
|
522
|
+
}
|
|
523
|
+
else if ((node === null || node === void 0 ? void 0 : node.level) === 1) {
|
|
524
|
+
// Store the ID of the second level group
|
|
525
|
+
secondGroupIds === null || secondGroupIds === void 0 ? void 0 : secondGroupIds.push(node === null || node === void 0 ? void 0 : node.id);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
});
|
|
529
|
+
return { firstGroupIds, secondGroupIds };
|
|
530
|
+
};
|
|
531
|
+
exports.getGroupIds = getGroupIds;
|
|
532
|
+
const handleCheckboxClick = (e, params, featureDetails, gridData, setFeatureDetails, groupingColumns, setSelectedGroup) => {
|
|
533
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
534
|
+
const isChecked = e.checked;
|
|
535
|
+
const { data: rowData } = params;
|
|
536
|
+
// Update checkbox data and set the updated state
|
|
537
|
+
const updatedCheckBoxData = (0, exports.updateRecords)(rowData, featureDetails, gridData);
|
|
538
|
+
setFeatureDetails(Object.assign(Object.assign({}, featureDetails), { checkBoxSelection: updatedCheckBoxData }));
|
|
539
|
+
// Gather parent and super parent group data for condition checks
|
|
540
|
+
const parentGroupData = (_c = (_b = (_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.childrenAfterGroup) === null || _c === void 0 ? void 0 : _c.map((childNode) => childNode === null || childNode === void 0 ? void 0 : childNode.data);
|
|
541
|
+
const superParentData = (_g = (_f = (_e = (_d = params === null || params === void 0 ? void 0 : params.node) === null || _d === void 0 ? void 0 : _d.parent) === null || _e === void 0 ? void 0 : _e.parent) === null || _f === void 0 ? void 0 : _f.allLeafChildren) === null || _g === void 0 ? void 0 : _g.map((children) => children === null || children === void 0 ? void 0 : children.data);
|
|
542
|
+
// Determine if all or any parent groups are included/excluded
|
|
543
|
+
const isEveryParentGroupInclude = parentGroupData === null || parentGroupData === void 0 ? void 0 : parentGroupData.every((parent) => { var _a; return (_a = updatedCheckBoxData === null || updatedCheckBoxData === void 0 ? void 0 : updatedCheckBoxData.includedRecords) === null || _a === void 0 ? void 0 : _a.some((included) => (included === null || included === void 0 ? void 0 : included.id) === (parent === null || parent === void 0 ? void 0 : parent.id)); });
|
|
544
|
+
const isEveryParentGroupExcluded = parentGroupData === null || parentGroupData === void 0 ? void 0 : parentGroupData.every((parent) => { var _a; return (_a = updatedCheckBoxData === null || updatedCheckBoxData === void 0 ? void 0 : updatedCheckBoxData.excludedRecords) === null || _a === void 0 ? void 0 : _a.some((excluded) => (excluded === null || excluded === void 0 ? void 0 : excluded.id) === (parent === null || parent === void 0 ? void 0 : parent.id)); });
|
|
545
|
+
const isEverySuperParentGroupExcluded = superParentData === null || superParentData === void 0 ? void 0 : superParentData.every((parent) => { var _a; return (_a = updatedCheckBoxData === null || updatedCheckBoxData === void 0 ? void 0 : updatedCheckBoxData.excludedRecords) === null || _a === void 0 ? void 0 : _a.some((excluded) => (excluded === null || excluded === void 0 ? void 0 : excluded.id) === (parent === null || parent === void 0 ? void 0 : parent.id)); });
|
|
546
|
+
// Determine the conditions to update group state
|
|
547
|
+
const conditions = (0, exports.determineConditions)(isChecked, updatedCheckBoxData.allBoxChecked, isEveryParentGroupInclude, isEveryParentGroupExcluded, isEverySuperParentGroupExcluded);
|
|
548
|
+
// Update group state based on determined conditions
|
|
549
|
+
(0, exports.updateGroupState)(groupingColumns, (_j = (_h = params === null || params === void 0 ? void 0 : params.node) === null || _h === void 0 ? void 0 : _h.parent) === null || _j === void 0 ? void 0 : _j.id, (_m = (_l = (_k = params === null || params === void 0 ? void 0 : params.node) === null || _k === void 0 ? void 0 : _k.parent) === null || _l === void 0 ? void 0 : _l.parent) === null || _m === void 0 ? void 0 : _m.id, conditions, setSelectedGroup);
|
|
550
|
+
};
|
|
551
|
+
exports.handleCheckboxClick = handleCheckboxClick;
|
|
@@ -12,11 +12,12 @@ const error_ui_1 = tslib_1.__importDefault(require("./error-ui"));
|
|
|
12
12
|
const loading_component_1 = tslib_1.__importDefault(require("./loading-component"));
|
|
13
13
|
const context_provider_1 = tslib_1.__importDefault(require("./context-provider"));
|
|
14
14
|
const group_checkbox_1 = tslib_1.__importDefault(require("./group-checkbox"));
|
|
15
|
+
const utilComponents_1 = require("./utilComponents");
|
|
15
16
|
function ParentForGrid(props) {
|
|
16
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
17
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
17
18
|
const [gridData, setGridData] = (0, react_1.useState)({
|
|
18
19
|
rowData: [],
|
|
19
|
-
columnData: (0, helper_1.sortColumns)(props === null || props === void 0 ? void 0 : props.columnData)
|
|
20
|
+
columnData: (0, helper_1.sortColumns)(props === null || props === void 0 ? void 0 : props.columnData),
|
|
20
21
|
});
|
|
21
22
|
let maxLength = 0;
|
|
22
23
|
const [style] = (0, react_1.useState)(props.style);
|
|
@@ -62,6 +63,7 @@ function ParentForGrid(props) {
|
|
|
62
63
|
});
|
|
63
64
|
// const [columnToRender,setColumnToRender] = useState<ColumnDef[]>([])
|
|
64
65
|
const gridRef = (0, react_1.useRef)(null);
|
|
66
|
+
const groupingColumns = (_b = (_a = gridData === null || gridData === void 0 ? void 0 : gridData.columnData) === null || _a === void 0 ? void 0 : _a.filter((colDef) => colDef === null || colDef === void 0 ? void 0 : colDef.rowGroup)) === null || _b === void 0 ? void 0 : _b.length;
|
|
65
67
|
// Default column specification
|
|
66
68
|
const defaultColDef = (0, react_1.useMemo)(() => {
|
|
67
69
|
return {
|
|
@@ -72,88 +74,11 @@ function ParentForGrid(props) {
|
|
|
72
74
|
sortable: false,
|
|
73
75
|
};
|
|
74
76
|
}, []);
|
|
75
|
-
const handleCheckboxClick = (rowData) => {
|
|
76
|
-
var _a;
|
|
77
|
-
console.log("rowData handle click", rowData);
|
|
78
|
-
const { excludedRecords, includedRecords, allBoxChecked } = featureDetails.checkBoxSelection;
|
|
79
|
-
let isIndeterminate;
|
|
80
|
-
let updatedIncludedRecords = includedRecords;
|
|
81
|
-
// Helper function to update the checkbox selection state for a single record
|
|
82
|
-
const updateCheckboxSelection = (data, excludedRecords) => {
|
|
83
|
-
let updatedExcludedRecords = excludedRecords;
|
|
84
|
-
// Handle the case where 'allBoxChecked' is true
|
|
85
|
-
if (allBoxChecked) {
|
|
86
|
-
if (excludedRecords.includes(data)) {
|
|
87
|
-
// Remove from excludedRecords if already present
|
|
88
|
-
updatedExcludedRecords = excludedRecords.filter((item) => item !== data);
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
// Add to excludedRecords if not present
|
|
92
|
-
updatedExcludedRecords = [...excludedRecords, data];
|
|
93
|
-
}
|
|
94
|
-
// Set isIndeterminate to true if there are any excluded records
|
|
95
|
-
isIndeterminate = updatedExcludedRecords.length > 0;
|
|
96
|
-
return updatedExcludedRecords;
|
|
97
|
-
}
|
|
98
|
-
// Handle the case where 'allBoxChecked' is false
|
|
99
|
-
if (includedRecords.includes(data)) {
|
|
100
|
-
// Remove from includedRecords if already present
|
|
101
|
-
updatedIncludedRecords = updatedIncludedRecords.filter((item) => item.id !== data.id);
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
// Add to includedRecords if not present
|
|
105
|
-
updatedIncludedRecords = [...updatedIncludedRecords, data];
|
|
106
|
-
}
|
|
107
|
-
// Set isIndeterminate to true if not all records are included
|
|
108
|
-
isIndeterminate =
|
|
109
|
-
updatedIncludedRecords.length > 0 &&
|
|
110
|
-
updatedIncludedRecords.length < totalRecordsCount;
|
|
111
|
-
return updatedExcludedRecords;
|
|
112
|
-
};
|
|
113
|
-
// Assuming you have access to the total number of records
|
|
114
|
-
const totalRecordsCount = (_a = gridData === null || gridData === void 0 ? void 0 : gridData.rowData) === null || _a === void 0 ? void 0 : _a.length;
|
|
115
|
-
// Check if rowData is an array or a single object
|
|
116
|
-
let updatedExcludedRecords = excludedRecords;
|
|
117
|
-
console.log("updated excluded records", updatedExcludedRecords, updatedIncludedRecords);
|
|
118
|
-
if (Array.isArray(rowData)) {
|
|
119
|
-
rowData.forEach((data) => {
|
|
120
|
-
updatedExcludedRecords = updateCheckboxSelection(data, updatedExcludedRecords);
|
|
121
|
-
});
|
|
122
|
-
isIndeterminate = true;
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
updatedExcludedRecords = updateCheckboxSelection(rowData, updatedExcludedRecords);
|
|
126
|
-
}
|
|
127
|
-
// Update the state with the new excluded records
|
|
128
|
-
const checkboxData = Object.assign(Object.assign({}, featureDetails.checkBoxSelection), { excludedRecords: updatedExcludedRecords, includedRecords: updatedIncludedRecords, isIndeterminate: isIndeterminate });
|
|
129
|
-
setFeatureDetails(Object.assign(Object.assign({}, featureDetails), { checkBoxSelection: checkboxData }));
|
|
130
|
-
};
|
|
131
|
-
// iterating over eachnode and return first and second group ids
|
|
132
|
-
const getGroupIds = () => {
|
|
133
|
-
const firstGroupIds = [];
|
|
134
|
-
const secondGroupIds = [];
|
|
135
|
-
gridRef.current.api.forEachNode((node) => {
|
|
136
|
-
if (node.group) {
|
|
137
|
-
if (node.level === 0) {
|
|
138
|
-
// Store the ID of the first level group
|
|
139
|
-
firstGroupIds.push(node.id);
|
|
140
|
-
}
|
|
141
|
-
else if (node.level === 1) {
|
|
142
|
-
// Store the ID of the second level group
|
|
143
|
-
secondGroupIds.push(node.id);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
return { firstGroupIds, secondGroupIds };
|
|
148
|
-
};
|
|
149
77
|
// Function to handle header checkbox click event
|
|
150
78
|
const handleHeaderCheckbox = (props) => {
|
|
151
79
|
// get the group and subgroupids
|
|
152
|
-
const { firstGroupIds, secondGroupIds } = getGroupIds();
|
|
153
|
-
console.log("First Group IDs:", firstGroupIds, secondGroupIds);
|
|
154
|
-
console.log("Second Group IDs:", secondGroupIds);
|
|
80
|
+
const { firstGroupIds, secondGroupIds } = (0, helper_1.getGroupIds)(gridRef);
|
|
155
81
|
console.log("header props checkbox", props.node);
|
|
156
|
-
console.log("record values in handle", gridRef.current.api);
|
|
157
82
|
const { allBoxChecked } = featureDetails.checkBoxSelection;
|
|
158
83
|
const currentStatus = !allBoxChecked;
|
|
159
84
|
const checkboxData = Object.assign(Object.assign({}, featureDetails.checkBoxSelection), { allBoxChecked: currentStatus, isIndeterminate: false, includedRecords: [], excludedRecords: [], headerCheckBoxStatus: currentStatus
|
|
@@ -185,13 +110,7 @@ function ParentForGrid(props) {
|
|
|
185
110
|
const { data } = params;
|
|
186
111
|
// const { allBoxChecked, excludedRecords, includedRecords } = featureDetails.checkBoxSelection;
|
|
187
112
|
const isChecked = (0, helper_1.getCheckedStatus)(data, featureDetails, constants_1.GRID_CHECKBOX_STATUS, setFeatureDetails);
|
|
188
|
-
return ((0, jsx_runtime_1.jsx)(grid_checkbox_1.default, { checked: isChecked, onChange: () => handleCheckboxClick(
|
|
189
|
-
};
|
|
190
|
-
// Render checkbox as well as initial component/data from props
|
|
191
|
-
const dataCellRenderer = (cellRendererParams, column) => {
|
|
192
|
-
var _a, _b, _c;
|
|
193
|
-
const { initialRenderer, cellCheckBoxRenderer } = cellRendererParams;
|
|
194
|
-
return ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: "flex w-full" }, { children: ((_a = props === null || props === void 0 ? void 0 : props.conditionsToDisplay) === null || _a === void 0 ? void 0 : _a.displayCheckboxOnRight) ? ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "custom_class_name flex w-full justify-content-between" }, { children: [typeof initialRenderer === "function" ? (initialRenderer(cellRendererParams)) : ((0, jsx_runtime_1.jsx)("div", { children: (_b = cellRendererParams === null || cellRendererParams === void 0 ? void 0 : cellRendererParams.data) === null || _b === void 0 ? void 0 : _b[column === null || column === void 0 ? void 0 : column.field] })), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "flex align-items-center" }, { children: cellCheckBoxRenderer(cellRendererParams) }))] }))) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ className: "flex align-items-center " }, { children: cellCheckBoxRenderer(cellRendererParams) })), typeof initialRenderer === "function" ? (initialRenderer(cellRendererParams)) : ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: "px-3" }, { children: (_c = cellRendererParams === null || cellRendererParams === void 0 ? void 0 : cellRendererParams.data) === null || _c === void 0 ? void 0 : _c[column === null || column === void 0 ? void 0 : column.field] })))] })) })));
|
|
113
|
+
return ((0, jsx_runtime_1.jsx)(grid_checkbox_1.default, { checked: isChecked, onChange: (e) => (0, helper_1.handleCheckboxClick)(e, params, featureDetails, gridData, setFeatureDetails, groupingColumns, setSelectedGroup), isIndeterminate: false, shouldRenderOnRight: (_a = props === null || props === void 0 ? void 0 : props.conditionsToDisplay) === null || _a === void 0 ? void 0 : _a.displayCheckboxOnRight }));
|
|
195
114
|
};
|
|
196
115
|
// Callback to products for getting data
|
|
197
116
|
const getData = (startRow, endRow, currentFeatures, params) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
@@ -242,7 +161,7 @@ function ParentForGrid(props) {
|
|
|
242
161
|
else if (props.rowModelType === constants_1.ROWMODELTYPE.SERVER_SIDE) {
|
|
243
162
|
const dataSource = {
|
|
244
163
|
getRows: (params) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
245
|
-
var
|
|
164
|
+
var _m, _o;
|
|
246
165
|
const startRow = params.request.startRow;
|
|
247
166
|
const endRow = params.request.endRow;
|
|
248
167
|
// Scroll should not exit MAX_RECORDS_TO_LOAD
|
|
@@ -258,7 +177,7 @@ function ParentForGrid(props) {
|
|
|
258
177
|
// get data for request from our fake server
|
|
259
178
|
const response = yield getData(startRow, endRow, currentFeatures, params);
|
|
260
179
|
// simulating real server call with a 500ms delay
|
|
261
|
-
if (((
|
|
180
|
+
if (((_m = response.rowData) === null || _m === void 0 ? void 0 : _m.length) > 0) {
|
|
262
181
|
setGridData(Object.assign(Object.assign({}, gridData), { rowData: response.rowData }));
|
|
263
182
|
gridRef.current.api.hideOverlay();
|
|
264
183
|
// supply rows for requested block to grid
|
|
@@ -268,7 +187,7 @@ function ParentForGrid(props) {
|
|
|
268
187
|
else {
|
|
269
188
|
// params.fail();
|
|
270
189
|
const gridRows = startRow >= constants_1.BLOCK_SIZE ? gridData.rowData : [];
|
|
271
|
-
if (!((
|
|
190
|
+
if (!((_o = params === null || params === void 0 ? void 0 : params.parentNode) === null || _o === void 0 ? void 0 : _o.id))
|
|
272
191
|
gridRef.current.api.showNoRowsOverlay();
|
|
273
192
|
params.success({ rowData: gridRows });
|
|
274
193
|
return;
|
|
@@ -293,19 +212,6 @@ function ParentForGrid(props) {
|
|
|
293
212
|
const getDataPath = (0, react_1.useCallback)((data) => {
|
|
294
213
|
return data.orgHierarchy;
|
|
295
214
|
}, []);
|
|
296
|
-
//Get this compnent from products
|
|
297
|
-
const GroupHeader = (params) => {
|
|
298
|
-
console.log(params, "params in custom component of group products");
|
|
299
|
-
return (0, jsx_runtime_1.jsx)("p", { children: "My Custom Group" });
|
|
300
|
-
};
|
|
301
|
-
// useEffect(() => {
|
|
302
|
-
// // Check if all columns in columnData have rowGroup set to false
|
|
303
|
-
// const allFalse = gridData?.columnData?.every(column => !column?.rowGroup);
|
|
304
|
-
// // If all are false, set selectedGroup to an empty array
|
|
305
|
-
// if (allFalse) {
|
|
306
|
-
// setSelectedGroup([]);
|
|
307
|
-
// }
|
|
308
|
-
// }, [gridData?.columnData]);
|
|
309
215
|
// Render group child conditionally with/without checkbox
|
|
310
216
|
const manageColumnGrouping = () => {
|
|
311
217
|
var _a;
|
|
@@ -313,117 +219,24 @@ function ParentForGrid(props) {
|
|
|
313
219
|
const GroupHeaderRenderer = (params) => {
|
|
314
220
|
var _a, _b, _c, _d, _e;
|
|
315
221
|
const Wrapper = () => {
|
|
316
|
-
return (0, jsx_runtime_1.jsx)(GroupHeader, { params: params });
|
|
317
|
-
};
|
|
318
|
-
// Logic to add and remove the row index from state
|
|
319
|
-
const addIndexToSelectedGroup = (params) => {
|
|
320
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
321
|
-
const { allBoxChecked } = featureDetails.checkBoxSelection;
|
|
322
|
-
console.log("all box checked", allBoxChecked);
|
|
323
|
-
let currentIds = selectedGroup || [];
|
|
324
|
-
const groupData = (_b = (_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.allLeafChildren) === null || _b === void 0 ? void 0 : _b.map((childNode) => childNode === null || childNode === void 0 ? void 0 : childNode.data);
|
|
325
|
-
console.log("data to bind for selected group", params, groupData);
|
|
326
|
-
console.log("group data render child", groupData);
|
|
327
|
-
let updatedIncludedRecords = [
|
|
328
|
-
...(_c = featureDetails === null || featureDetails === void 0 ? void 0 : featureDetails.checkBoxSelection) === null || _c === void 0 ? void 0 : _c.includedRecords,
|
|
329
|
-
];
|
|
330
|
-
// Check if the current group is already selected
|
|
331
|
-
if (currentIds.includes((_d = params === null || params === void 0 ? void 0 : params.node) === null || _d === void 0 ? void 0 : _d.id)) {
|
|
332
|
-
// Remove the group ID and its data from includedRecords
|
|
333
|
-
currentIds = currentIds.filter((item) => { var _a; return item !== ((_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.id); });
|
|
334
|
-
updatedIncludedRecords = updatedIncludedRecords.filter((record) => !groupData.includes(record));
|
|
335
|
-
}
|
|
336
|
-
else {
|
|
337
|
-
// Add the group ID and its data to includedRecords
|
|
338
|
-
currentIds.push((_e = params === null || params === void 0 ? void 0 : params.node) === null || _e === void 0 ? void 0 : _e.id);
|
|
339
|
-
updatedIncludedRecords.push(...groupData);
|
|
340
|
-
}
|
|
341
|
-
// Iterate over all child groups (if any) to update their selection state
|
|
342
|
-
(_g = (_f = params === null || params === void 0 ? void 0 : params.node) === null || _f === void 0 ? void 0 : _f.childrenAfterGroup) === null || _g === void 0 ? void 0 : _g.forEach((childGroup) => {
|
|
343
|
-
var _a, _b, _c, _d;
|
|
344
|
-
const childGroupData = (_b = (_a = childGroup === null || childGroup === void 0 ? void 0 : childGroup.parent) === null || _a === void 0 ? void 0 : _a.allLeafChildren) === null || _b === void 0 ? void 0 : _b.map((child) => child === null || child === void 0 ? void 0 : child.data);
|
|
345
|
-
if (currentIds.includes(childGroup === null || childGroup === void 0 ? void 0 : childGroup.id)) {
|
|
346
|
-
// Remove the childGroup ID if it exists and update includedRecords
|
|
347
|
-
currentIds = currentIds.filter((child) => child !== (childGroup === null || childGroup === void 0 ? void 0 : childGroup.id));
|
|
348
|
-
updatedIncludedRecords = updatedIncludedRecords.filter((record) => !childGroupData.includes(record));
|
|
349
|
-
}
|
|
350
|
-
else {
|
|
351
|
-
// Add the childGroup ID if it doesn't exist
|
|
352
|
-
if (!currentIds.includes(childGroup === null || childGroup === void 0 ? void 0 : childGroup.id)) {
|
|
353
|
-
currentIds.push(childGroup === null || childGroup === void 0 ? void 0 : childGroup.id);
|
|
354
|
-
}
|
|
355
|
-
// Check if each child's data is already included before adding it
|
|
356
|
-
const newChildren = (_d = (_c = childGroup === null || childGroup === void 0 ? void 0 : childGroup.parent) === null || _c === void 0 ? void 0 : _c.allLeafChildren) === null || _d === void 0 ? void 0 : _d.filter((child) => !updatedIncludedRecords.some((record) => record.id === (child === null || child === void 0 ? void 0 : child.data.id)));
|
|
357
|
-
updatedIncludedRecords.push(...newChildren.map((child) => child === null || child === void 0 ? void 0 : child.data));
|
|
358
|
-
}
|
|
359
|
-
});
|
|
360
|
-
// After processing, ensure the parent group is selected if any of its subgroups are selected
|
|
361
|
-
const isAnySubgroupSelected = (_j = (_h = params === null || params === void 0 ? void 0 : params.node) === null || _h === void 0 ? void 0 : _h.childrenAfterGroup) === null || _j === void 0 ? void 0 : _j.some((childGroup) => currentIds.includes(childGroup === null || childGroup === void 0 ? void 0 : childGroup.id));
|
|
362
|
-
if (isAnySubgroupSelected && !currentIds.includes((_k = params === null || params === void 0 ? void 0 : params.node) === null || _k === void 0 ? void 0 : _k.id)) {
|
|
363
|
-
currentIds.push((_l = params === null || params === void 0 ? void 0 : params.node) === null || _l === void 0 ? void 0 : _l.id);
|
|
364
|
-
updatedIncludedRecords.push(...groupData);
|
|
365
|
-
}
|
|
366
|
-
console.log(currentIds, "current id on selecting group");
|
|
367
|
-
console.log("params in addIndex", params);
|
|
368
|
-
// Update the state with the modified array
|
|
369
|
-
setSelectedGroup(currentIds);
|
|
370
|
-
// Update the includedRecords in featureDetails
|
|
371
|
-
setFeatureDetails(Object.assign(Object.assign({}, featureDetails), { checkBoxSelection: Object.assign(Object.assign({}, featureDetails.checkBoxSelection), { includedRecords: updatedIncludedRecords }) }));
|
|
372
|
-
};
|
|
373
|
-
// Update parent checkbox state based on child selection
|
|
374
|
-
const updateParentCheckboxState = (params) => {
|
|
375
|
-
var _a, _b, _c, _d, _e, _f;
|
|
376
|
-
const groupData = (_b = (_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.allLeafChildren) === null || _b === void 0 ? void 0 : _b.map((childNode) => childNode === null || childNode === void 0 ? void 0 : childNode.data);
|
|
377
|
-
const allChildrenSelected = (_d = (_c = params === null || params === void 0 ? void 0 : params.node) === null || _c === void 0 ? void 0 : _c.allLeafChildren) === null || _d === void 0 ? void 0 : _d.every((childNode) => {
|
|
378
|
-
return selectedGroup === null || selectedGroup === void 0 ? void 0 : selectedGroup.includes(childNode.id);
|
|
379
|
-
});
|
|
380
|
-
const parentNodeId = (_f = (_e = params === null || params === void 0 ? void 0 : params.node) === null || _e === void 0 ? void 0 : _e.parent) === null || _f === void 0 ? void 0 : _f.id;
|
|
381
|
-
if (allChildrenSelected) {
|
|
382
|
-
setSelectedGroup((prev) => [...prev, parentNodeId]);
|
|
383
|
-
}
|
|
384
|
-
else {
|
|
385
|
-
handleCheckboxClick(groupData);
|
|
386
|
-
setSelectedGroup((prev) => prev === null || prev === void 0 ? void 0 : prev.filter((id) => id !== parentNodeId));
|
|
387
|
-
}
|
|
222
|
+
return (0, jsx_runtime_1.jsx)(utilComponents_1.GroupHeader, { params: params });
|
|
388
223
|
};
|
|
224
|
+
// Main onChange handler function for group checkbox
|
|
389
225
|
const onChange = (e, params) => {
|
|
390
|
-
var _a, _b, _c, _d;
|
|
391
|
-
console.log(params, "params of group check");
|
|
392
226
|
const isChecked = e.checked;
|
|
393
|
-
console.log("selected group row iddddd", selectedGroup, params.node.id);
|
|
394
|
-
const groupData = (_b = (_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.allLeafChildren) === null || _b === void 0 ? void 0 : _b.map((childNode) => childNode === null || childNode === void 0 ? void 0 : childNode.data);
|
|
395
|
-
console.log("group data render child", groupData);
|
|
396
227
|
if (isChecked) {
|
|
397
|
-
|
|
228
|
+
(0, helper_1.handleCheckedState)(params, featureDetails, gridData, setFeatureDetails, setSelectedGroup, groupingColumns);
|
|
398
229
|
}
|
|
399
230
|
else {
|
|
400
|
-
|
|
401
|
-
handleCheckboxClick(groupData);
|
|
402
|
-
setSelectedGroup((prev) => prev === null || prev === void 0 ? void 0 : prev.filter((id) => { var _a; return id !== ((_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.id); }));
|
|
403
|
-
(_d = (_c = params === null || params === void 0 ? void 0 : params.node) === null || _c === void 0 ? void 0 : _c.childrenAfterGroup) === null || _d === void 0 ? void 0 : _d.forEach((childNode) => {
|
|
404
|
-
setSelectedGroup((prev) => prev === null || prev === void 0 ? void 0 : prev.filter((id) => id !== (childNode === null || childNode === void 0 ? void 0 : childNode.id)));
|
|
405
|
-
});
|
|
406
|
-
// setFeatureDetails((prevDetails) => ({
|
|
407
|
-
// ...prevDetails,
|
|
408
|
-
// checkBoxSelection: {
|
|
409
|
-
// ...prevDetails.checkBoxSelection,
|
|
410
|
-
// includedRecords:
|
|
411
|
-
// prevDetails.checkBoxSelection.includedRecords.filter(
|
|
412
|
-
// (record) => !groupData.includes(record)
|
|
413
|
-
// ),
|
|
414
|
-
// },
|
|
415
|
-
// }));
|
|
231
|
+
(0, helper_1.handleUncheckedState)(params, featureDetails, gridData, setFeatureDetails, setSelectedGroup, groupingColumns);
|
|
416
232
|
}
|
|
417
|
-
// Update parent state after any change
|
|
418
|
-
updateParentCheckboxState(params);
|
|
419
233
|
};
|
|
420
|
-
console.log("dataaa", params.node);
|
|
421
234
|
// To display checkbox
|
|
422
235
|
if ((_a = props === null || props === void 0 ? void 0 : props.conditionsToDisplay) === null || _a === void 0 ? void 0 : _a.displayCheckboxForGroups) {
|
|
423
236
|
// To display checkbox on right
|
|
424
237
|
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "flex align-items-center justify-content-between" }, { children: [(0, jsx_runtime_1.jsx)(group_checkbox_1.default, { checked: (selectedGroup === null || selectedGroup === void 0 ? void 0 : selectedGroup.includes((_b = params === null || params === void 0 ? void 0 : params.node) === null || _b === void 0 ? void 0 : _b.id)) ||
|
|
425
238
|
(((_c = featureDetails === null || featureDetails === void 0 ? void 0 : featureDetails.checkBoxSelection) === null || _c === void 0 ? void 0 : _c.allBoxChecked) &&
|
|
426
|
-
!((_d = featureDetails === null || featureDetails === void 0 ? void 0 : featureDetails.checkBoxSelection) === null || _d === void 0 ? void 0 : _d.isIndeterminate)), onChange: (e) => onChange(e, params), isIndeterminate: false, shouldRenderOnRight: false }), (0, jsx_runtime_1.jsx)("span", { children: (_e = params === null || params === void 0 ? void 0 : params.node) === null || _e === void 0 ? void 0 : _e.
|
|
239
|
+
!((_d = featureDetails === null || featureDetails === void 0 ? void 0 : featureDetails.checkBoxSelection) === null || _d === void 0 ? void 0 : _d.isIndeterminate)), onChange: (e) => onChange(e, params), isIndeterminate: false, shouldRenderOnRight: false }), (0, jsx_runtime_1.jsx)("span", { children: (_e = params === null || params === void 0 ? void 0 : params.node) === null || _e === void 0 ? void 0 : _e.id })] })));
|
|
427
240
|
}
|
|
428
241
|
return (0, jsx_runtime_1.jsx)(Wrapper, {});
|
|
429
242
|
};
|
|
@@ -463,10 +276,10 @@ function ParentForGrid(props) {
|
|
|
463
276
|
};
|
|
464
277
|
// Options that grid should have
|
|
465
278
|
const gridOptions = {
|
|
466
|
-
columnDefs: (
|
|
279
|
+
columnDefs: (_c = gridData === null || gridData === void 0 ? void 0 : gridData.columnData) === null || _c === void 0 ? void 0 : _c.map((column) => {
|
|
467
280
|
var _a, _b;
|
|
468
|
-
if (column.enableChildCheckbox && column.enableHeaderCheckbox) {
|
|
469
|
-
return Object.assign(Object.assign({}, column), { headerComponent: (params) => headerCheckBoxRenderer(params === null || params === void 0 ? void 0 : params.displayName, column === null || column === void 0 ? void 0 : column.headerComponent), cellRenderer: (params) => dataCellRenderer(params, column), cellRendererParams: {
|
|
281
|
+
if ((column === null || column === void 0 ? void 0 : column.enableChildCheckbox) && (column === null || column === void 0 ? void 0 : column.enableHeaderCheckbox)) {
|
|
282
|
+
return Object.assign(Object.assign({}, column), { headerComponent: (params) => headerCheckBoxRenderer(params === null || params === void 0 ? void 0 : params.displayName, (column === null || column === void 0 ? void 0 : column.headerComponent) && ""), cellRenderer: (params) => (0, utilComponents_1.dataCellRenderer)(params, column, props), cellRendererParams: {
|
|
470
283
|
initialRenderer: column === null || column === void 0 ? void 0 : column.body,
|
|
471
284
|
cellCheckBoxRenderer: cellCheckBoxRenderer,
|
|
472
285
|
}, headerName: (_a = column === null || column === void 0 ? void 0 : column.headerName) === null || _a === void 0 ? void 0 : _a.toUpperCase() });
|
|
@@ -494,8 +307,8 @@ function ParentForGrid(props) {
|
|
|
494
307
|
suppressCellFocus: true,
|
|
495
308
|
suppressPropertyNamesCheck: true,
|
|
496
309
|
suppressServerSideFullWidthLoadingRow: true,
|
|
497
|
-
enableRangeSelection: (
|
|
498
|
-
enableFillHandle: (
|
|
310
|
+
enableRangeSelection: (_d = props === null || props === void 0 ? void 0 : props.conditionsToDisplay) === null || _d === void 0 ? void 0 : _d.enableFillHandle,
|
|
311
|
+
enableFillHandle: (_e = props === null || props === void 0 ? void 0 : props.conditionsToDisplay) === null || _e === void 0 ? void 0 : _e.enableFillHandle,
|
|
499
312
|
onFillEnd: wrapperToFillOpertation,
|
|
500
313
|
fillOperation: myOpertaion,
|
|
501
314
|
getRowId: getRowId,
|
|
@@ -567,11 +380,11 @@ function ParentForGrid(props) {
|
|
|
567
380
|
initialFeature,
|
|
568
381
|
defaultFilters,
|
|
569
382
|
createView: props === null || props === void 0 ? void 0 : props.createView,
|
|
570
|
-
enableViewCreate: (
|
|
571
|
-
filterModelText: (
|
|
572
|
-
sortModelText: (
|
|
573
|
-
recordDetailModelText: (
|
|
574
|
-
sidePanelText: (
|
|
383
|
+
enableViewCreate: (_f = props === null || props === void 0 ? void 0 : props.conditionsToDisplay) === null || _f === void 0 ? void 0 : _f.enableViewCreate,
|
|
384
|
+
filterModelText: (_g = props === null || props === void 0 ? void 0 : props.dynamicText) === null || _g === void 0 ? void 0 : _g.filterModelText,
|
|
385
|
+
sortModelText: (_h = props === null || props === void 0 ? void 0 : props.dynamicText) === null || _h === void 0 ? void 0 : _h.sortModelText,
|
|
386
|
+
recordDetailModelText: (_j = props === null || props === void 0 ? void 0 : props.dynamicText) === null || _j === void 0 ? void 0 : _j.recordDetailModelText,
|
|
387
|
+
sidePanelText: (_k = props === null || props === void 0 ? void 0 : props.dynamicText) === null || _k === void 0 ? void 0 : _k.sidePanelText,
|
|
575
388
|
sortOptions: (props === null || props === void 0 ? void 0 : props.sortOptions)
|
|
576
389
|
? props.sortOptions
|
|
577
390
|
: constants_1.COLUMN_SORT_OPTIONS,
|
|
@@ -584,7 +397,7 @@ function ParentForGrid(props) {
|
|
|
584
397
|
columnToRender: gridData.columnData,
|
|
585
398
|
selectedGroup: selectedGroup,
|
|
586
399
|
setSelectedGroup: setSelectedGroup,
|
|
587
|
-
initialCheckBoxData: initialCheckBoxData
|
|
588
|
-
} }, { children: ((
|
|
400
|
+
initialCheckBoxData: initialCheckBoxData,
|
|
401
|
+
} }, { children: ((_l = props === null || props === void 0 ? void 0 : props.conditionsToDisplay) === null || _l === void 0 ? void 0 : _l.displayFeaturesHeader) && ((0, jsx_runtime_1.jsx)(advanced_feature_1.default, { props: props })) })), (0, jsx_runtime_1.jsx)(AgGrid_1.default, { style: style, gridOptions: gridOptions, onGridReady: onGridReady, gridRef: gridRef })] }) })) }) }));
|
|
589
402
|
}
|
|
590
403
|
exports.default = ParentForGrid;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GroupHeader = exports.dataCellRenderer = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
// import Checkbox from "./grid-checkbox";
|
|
6
|
+
// Render checkbox as well as initial component/data from props
|
|
7
|
+
const dataCellRenderer = (cellRendererParams, column, props) => {
|
|
8
|
+
var _a, _b, _c;
|
|
9
|
+
const { initialRenderer, cellCheckBoxRenderer } = cellRendererParams;
|
|
10
|
+
return ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: "flex w-full" }, { children: ((_a = props === null || props === void 0 ? void 0 : props.conditionsToDisplay) === null || _a === void 0 ? void 0 : _a.displayCheckboxOnRight) ? ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "custom_class_name flex w-full justify-content-between" }, { children: [typeof initialRenderer === "function" ? (initialRenderer(cellRendererParams)) : ((0, jsx_runtime_1.jsx)("div", { children: (_b = cellRendererParams === null || cellRendererParams === void 0 ? void 0 : cellRendererParams.data) === null || _b === void 0 ? void 0 : _b[column === null || column === void 0 ? void 0 : column.field] })), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "flex align-items-center" }, { children: cellCheckBoxRenderer(cellRendererParams) }))] }))) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ className: "flex align-items-center " }, { children: cellCheckBoxRenderer(cellRendererParams) })), typeof initialRenderer === "function" ? (initialRenderer(cellRendererParams)) : ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: "px-3" }, { children: (_c = cellRendererParams === null || cellRendererParams === void 0 ? void 0 : cellRendererParams.data) === null || _c === void 0 ? void 0 : _c[column === null || column === void 0 ? void 0 : column.field] })))] })) })));
|
|
11
|
+
};
|
|
12
|
+
exports.dataCellRenderer = dataCellRenderer;
|
|
13
|
+
//Get this compnent from products
|
|
14
|
+
const GroupHeader = (params) => {
|
|
15
|
+
console.log(params, "params in custom component of group products");
|
|
16
|
+
return (0, jsx_runtime_1.jsx)("p", { children: "My Custom Group" });
|
|
17
|
+
};
|
|
18
|
+
exports.GroupHeader = GroupHeader;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { CheckBoxSelection } from "./Types";
|
|
3
|
+
export declare const initialCheckBoxData: CheckBoxSelection;
|
|
2
4
|
export declare const applyDefaultFilters: (defaultFilters: any) => any;
|
|
3
5
|
export declare const parseIfNeeded: (value: any) => any;
|
|
4
6
|
export declare const sortColumns: (columns: any) => any;
|
|
@@ -34,3 +36,18 @@ export declare const autoGroupColumnDef: (isTreeEnable: boolean, headerName: str
|
|
|
34
36
|
headerName?: undefined;
|
|
35
37
|
minWidth?: undefined;
|
|
36
38
|
};
|
|
39
|
+
export declare const updateRecords: (rowData: any, featureDetails: any, gridData: any) => any;
|
|
40
|
+
export declare const determineConditions: (isChecked: any, allBoxChecked: any, isEveryParentGroupInclude: any, isEveryParentGroupExcluded: any, isEverySuperParentGroupExcluded: any) => {
|
|
41
|
+
addParent: any;
|
|
42
|
+
addSuperParent: any;
|
|
43
|
+
removeParent: any;
|
|
44
|
+
removeSuperParent: any;
|
|
45
|
+
};
|
|
46
|
+
export declare const updateGroupState: (groupingColumns: any, parentId: any, superParentId: any, conditions: any, setSelectedGroup: any) => void;
|
|
47
|
+
export declare const handleCheckedState: (params: any, featureDetails: any, gridData: any, setFeatureDetails: any, setSelectedGroup: any, groupingColumns: any) => void;
|
|
48
|
+
export declare const handleUncheckedState: (params: any, featureDetails: any, gridData: any, setFeatureDetails: any, setSelectedGroup: any, groupingColumns: any) => void;
|
|
49
|
+
export declare const getGroupIds: (gridRef: any) => {
|
|
50
|
+
firstGroupIds: string[];
|
|
51
|
+
secondGroupIds: string[];
|
|
52
|
+
};
|
|
53
|
+
export declare const handleCheckboxClick: (e: any, params: any, featureDetails: any, gridData: any, setFeatureDetails: any, groupingColumns: any, setSelectedGroup: any) => void;
|