From 214b99cd100cfa74fe3867e8c968cabde8184aba Mon Sep 17 00:00:00 2001 From: Sherfin Shamsudeen Date: Tue, 31 Aug 2021 16:07:38 +0530 Subject: [PATCH] Feature: display action button on left (#647) * Add option to set poisition of table action button * Display table actions on the left if their position is set to left * Replace 'buttonPosition' with 'position' for table actions * Use SelectSearch instead of html select * Display actions column only if actions are present --- .../src/Editor/Components/Table/Table.jsx | 39 ++++++++++++++++--- .../src/Editor/Inspector/Components/Table.jsx | 17 ++++++++ 2 files changed, 51 insertions(+), 5 deletions(-) diff --git a/frontend/src/Editor/Components/Table/Table.jsx b/frontend/src/Editor/Components/Table/Table.jsx index b913bfd5da..3cc00c5bf1 100644 --- a/frontend/src/Editor/Components/Table/Table.jsx +++ b/frontend/src/Editor/Components/Table/Table.jsx @@ -429,15 +429,44 @@ export function Table({ tableData = tableData || []; - const actionsCellData = actions.value.length > 0 + const leftActions = () => actions.value.filter(action => action.position === 'left') + const rightActions = () => actions.value.filter(action => [undefined, 'right'].includes(action.position)) + + const leftActionsCellData = leftActions().length > 0 ? [ { - id: 'actions', + id: 'leftActions', Header: 'Actions', accessor: 'edit', width: columnSizes.actions || defaultColumn.width, Cell: (cell) => { - return actions.value.map((action) => ( + return leftActions().map((action) => ( + + )); + } + } + ] + : []; + + const rightActionsCellData = rightActions().length > 0 + ? [ + { + id: 'rightActions', + Header: 'Actions', + accessor: 'edit', + width: columnSizes.actions || defaultColumn.width, + Cell: (cell) => { + return rightActions().map((action) => (