ToolJet/frontend/src/Editor/Components/Table/reducer.js
Manish Kushare 55c1d5a31b
Added feature to add new rows in the table (#5954)
* initial commit

* design the UI to add new row

* added logic to add and discard single row

* added csa to discard newly added row

* added feature to add and discard multiple rows

* added a dot to the icon of add new row to determine if the new rows is still not saved or discarded

* discard rows added csa bug fixed

* fixing the horizontal spacing issue inside the cell

* changing the default height of the table widget to make sure filter and add new rows pop-up windows footer is visible upfront

* made suggested text and spacing changes

* fixed spacing for add another row button

* fixed es lint issue

* bug fixed added missing return statement

* changed the exposedVariable name to newRows for adding new rows

some text and style changes for button

* fixed tooltip issue for adding new rows button

* avoided deleting new row added immediately after clicking on save button

* handled edge case if data url is chnaged in between add new row operation

* simplified the code in AddNewRowComponent.jsx

* docs: updated table doc with ui options

* Fixed bug on adding different column types

* Update docs/docs/widgets/table.md

---------

Co-authored-by: Shubhendra <[email protected]>
Co-authored-by: Kavin Venkatachalam <[email protected]>
2023-04-21 15:42:48 +05:30

63 lines
1.2 KiB
JavaScript

export const initialState = () => ({
loadingState: false,
columnProperties: [],
filterDetails: {
filters: [],
filtersVisible: false,
},
addNewRowsDetails: {
addingNewRows: false,
newRowsDataUpdates: {},
newRowsChangeSet: {},
},
});
const mergeToTableDetails = (payload) => ({
type: 'MERGE_TO_TABLE_DETAILS',
payload,
});
const mergeToFilterDetails = (payload) => ({
type: 'MERGE_TO_FILTER_DETAILS',
payload,
});
const mergeToAddNewRowsDetails = (payload) => ({
type: 'MERGE_TO_ADD_NEW_ROWS',
payload,
});
export const reducerActions = {
mergeToFilterDetails,
mergeToTableDetails,
mergeToAddNewRowsDetails,
};
export const reducer = (state, action) => {
switch (action.type) {
case 'MERGE_TO_TABLE_DETAILS':
return {
...state,
...action.payload,
};
case 'MERGE_TO_FILTER_DETAILS':
return {
...state,
filterDetails: {
...state.filterDetails,
...action.payload,
},
};
case 'MERGE_TO_ADD_NEW_ROWS':
return {
...state,
addNewRowsDetails: {
...state.addNewRowsDetails,
...action.payload,
},
};
default:
return initialState();
}
};