mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-05 22:38:48 +00:00
[ 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:
parent
633edc7271
commit
b88c50eca6
2 changed files with 35 additions and 0 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -378,6 +378,14 @@ export const widgets = [
|
|||
{ handle: 'value', displayName: 'Value' },
|
||||
],
|
||||
},
|
||||
{
|
||||
handle: 'deselectRow',
|
||||
displayName: 'Deselect row',
|
||||
},
|
||||
{
|
||||
handle: 'discardChanges',
|
||||
displayName: 'Discard Changes',
|
||||
},
|
||||
],
|
||||
definition: {
|
||||
others: {
|
||||
|
|
|
|||
Loading…
Reference in a new issue