mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-23 08:58:26 +00:00
Habdle save changes & discard events for tables
This commit is contained in:
parent
537c9986e6
commit
c10f452f84
1 changed files with 21 additions and 3 deletions
|
|
@ -76,7 +76,20 @@ export function Table({ id, width, height, component, onComponentClick, currentS
|
|||
}
|
||||
|
||||
function handleChangesSaved() {
|
||||
// Handle events after changes are saved
|
||||
Object.keys(changeSet).map(key => {
|
||||
tableData[key] = {
|
||||
...tableData[key],
|
||||
...changeSet[key]
|
||||
}
|
||||
});
|
||||
|
||||
onComponentOptionChanged(component, 'changeSet', {});
|
||||
onComponentOptionChanged(component, 'dataUpdates', []);
|
||||
}
|
||||
|
||||
function handleChangesDiscarded() {
|
||||
onComponentOptionChanged(component, 'changeSet', {});
|
||||
onComponentOptionChanged(component, 'dataUpdates', []);
|
||||
}
|
||||
|
||||
const changeSet = componentState ? componentState.changeSet : {};
|
||||
|
|
@ -348,7 +361,7 @@ export function Table({ id, width, height, component, onComponentClick, currentS
|
|||
</button>{' '}
|
||||
</div>
|
||||
|
||||
{componentState.changeSet &&
|
||||
{Object.keys(componentState.changeSet || {}).length > 0 &&
|
||||
<div className="col">
|
||||
<button
|
||||
className={`btn btn-primary btn-sm ${componentState.isSavingChanges ? 'btn-loading' : ''}`}
|
||||
|
|
@ -358,7 +371,12 @@ export function Table({ id, width, height, component, onComponentClick, currentS
|
|||
>
|
||||
Save Changes
|
||||
</button>
|
||||
<button className="btn btn-light btn-sm mx-2">Cancel</button>
|
||||
<button
|
||||
className="btn btn-light btn-sm mx-2"
|
||||
onClick={(e) => handleChangesDiscarded()}
|
||||
>
|
||||
Cancel
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue