[ Feature added ] : [Table widget ] adding CSA to deselect the row (#5320)

* feature add: un select the selected row using csa

* adding age case if wrong key and value is provided while un selecting selecetd row, then show alert message and do nothing

* made the suggested changes

* added csa action to discard the changes

* update the changes rquested
This commit is contained in:
Manish Kushare 2023-01-24 20:43:16 +05:30 committed by GitHub
parent 633edc7271
commit b88c50eca6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 0 deletions

View file

@ -40,6 +40,7 @@ import * as XLSX from 'xlsx/xlsx.mjs';
import OverlayTrigger from 'react-bootstrap/OverlayTrigger';
import Popover from 'react-bootstrap/Popover';
import { useMounted } from '@/_hooks/use-mount';
import { toast } from 'react-hot-toast';
export function Table({
id,
@ -486,6 +487,32 @@ export function Table({
},
[JSON.stringify(tableData), JSON.stringify(tableDetails.selectedRow)]
);
registerAction(
'deselectRow',
async function () {
if (!_.isEmpty(tableDetails.selectedRow)) {
const selectedRowDetails = { selectedRow: {}, selectedRowId: {} };
mergeToTableDetails(selectedRowDetails);
setExposedVariables(selectedRowDetails);
}
return;
},
[JSON.stringify(tableData), JSON.stringify(tableDetails.selectedRow)]
);
registerAction(
'discardChanges',
async function () {
if (Object.keys(tableDetails.changeSet || {}).length > 0) {
setExposedVariables({
changeSet: {},
dataUpdates: [],
}).then(() => {
mergeToTableDetails({ dataUpdates: {}, changeSet: {} });
});
}
},
[JSON.stringify(tableData), JSON.stringify(tableDetails.changeSet)]
);
useEffect(() => {
const selectedRowsOriginalData = selectedFlatRows.map((row) => row.original);

View file

@ -378,6 +378,14 @@ export const widgets = [
{ handle: 'value', displayName: 'Value' },
],
},
{
handle: 'deselectRow',
displayName: 'Deselect row',
},
{
handle: 'discardChanges',
displayName: 'Discard Changes',
},
],
definition: {
others: {