FEATURE-2111 : Show/Hide Table Controls
-- Add the header options section for the visibility setting -- Render conditionally the header part based on the setting
This commit is contained in:
parent
de4c66bf4e
commit
c76ef9e3d7
|
|
@ -60,6 +60,11 @@ interface TableProps {
|
||||||
applyFilter: (filters: ReactTableFilter[]) => void;
|
applyFilter: (filters: ReactTableFilter[]) => void;
|
||||||
compactMode?: CompactMode;
|
compactMode?: CompactMode;
|
||||||
updateCompactMode: (compactMode: CompactMode) => void;
|
updateCompactMode: (compactMode: CompactMode) => void;
|
||||||
|
isVisibleCompactMode?: boolean;
|
||||||
|
isVisibleDownload?: boolean;
|
||||||
|
isVisibleFilters?: boolean;
|
||||||
|
isVisiblePagination?: boolean;
|
||||||
|
isVisibleSearch?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultColumn = {
|
const defaultColumn = {
|
||||||
|
|
@ -170,6 +175,11 @@ export function Table(props: TableProps) {
|
||||||
triggerRowSelection={props.triggerRowSelection}
|
triggerRowSelection={props.triggerRowSelection}
|
||||||
width={props.width}
|
width={props.width}
|
||||||
>
|
>
|
||||||
|
{(props.isVisibleSearch ||
|
||||||
|
props.isVisibleFilters ||
|
||||||
|
props.isVisibleDownload ||
|
||||||
|
props.isVisibleCompactMode ||
|
||||||
|
props.isVisiblePagination) && (
|
||||||
<TableHeaderWrapper
|
<TableHeaderWrapper
|
||||||
backgroundColor={Colors.WHITE}
|
backgroundColor={Colors.WHITE}
|
||||||
ref={tableHeaderWrapperRef}
|
ref={tableHeaderWrapperRef}
|
||||||
|
|
@ -195,6 +205,11 @@ export function Table(props: TableProps) {
|
||||||
currentPageIndex={currentPageIndex}
|
currentPageIndex={currentPageIndex}
|
||||||
editMode={props.editMode}
|
editMode={props.editMode}
|
||||||
filters={props.filters}
|
filters={props.filters}
|
||||||
|
isVisibleCompactMode={props.isVisibleCompactMode}
|
||||||
|
isVisibleDownload={props.isVisibleDownload}
|
||||||
|
isVisibleFilters={props.isVisibleFilters}
|
||||||
|
isVisiblePagination={props.isVisiblePagination}
|
||||||
|
isVisibleSearch={props.isVisibleSearch}
|
||||||
nextPageClick={props.nextPageClick}
|
nextPageClick={props.nextPageClick}
|
||||||
pageCount={pageCount}
|
pageCount={pageCount}
|
||||||
pageNo={props.pageNo}
|
pageNo={props.pageNo}
|
||||||
|
|
@ -213,6 +228,7 @@ export function Table(props: TableProps) {
|
||||||
</TableHeaderInnerWrapper>
|
</TableHeaderInnerWrapper>
|
||||||
</Scrollbars>
|
</Scrollbars>
|
||||||
</TableHeaderWrapper>
|
</TableHeaderWrapper>
|
||||||
|
)}
|
||||||
<div
|
<div
|
||||||
className={props.isLoading ? Classes.SKELETON : "tableWrap"}
|
className={props.isLoading ? Classes.SKELETON : "tableWrap"}
|
||||||
ref={tableWrapperRef}
|
ref={tableWrapperRef}
|
||||||
|
|
|
||||||
|
|
@ -110,34 +110,54 @@ interface TableHeaderProps {
|
||||||
compactMode?: CompactMode;
|
compactMode?: CompactMode;
|
||||||
updateCompactMode: (compactMode: CompactMode) => void;
|
updateCompactMode: (compactMode: CompactMode) => void;
|
||||||
tableSizes: TableSizes;
|
tableSizes: TableSizes;
|
||||||
|
isVisibleCompactMode?: boolean;
|
||||||
|
isVisibleDownload?: boolean;
|
||||||
|
isVisibleFilters?: boolean;
|
||||||
|
isVisiblePagination?: boolean;
|
||||||
|
isVisibleSearch?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
function TableHeader(props: TableHeaderProps) {
|
function TableHeader(props: TableHeaderProps) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
{props.isVisibleSearch && (
|
||||||
<SearchComponent
|
<SearchComponent
|
||||||
onSearch={props.searchTableData}
|
onSearch={props.searchTableData}
|
||||||
placeholder="Search..."
|
placeholder="Search..."
|
||||||
value={props.searchKey}
|
value={props.searchKey}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
|
{(props.isVisibleFilters ||
|
||||||
|
props.isVisibleDownload ||
|
||||||
|
props.isVisibleCompactMode) && (
|
||||||
<CommonFunctionsMenuWrapper tableSizes={props.tableSizes}>
|
<CommonFunctionsMenuWrapper tableSizes={props.tableSizes}>
|
||||||
|
{props.isVisibleFilters && (
|
||||||
<TableFilters
|
<TableFilters
|
||||||
applyFilter={props.applyFilter}
|
applyFilter={props.applyFilter}
|
||||||
columns={props.columns}
|
columns={props.columns}
|
||||||
editMode={props.editMode}
|
editMode={props.editMode}
|
||||||
filters={props.filters}
|
filters={props.filters}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{props.isVisibleDownload && (
|
||||||
<TableDataDownload
|
<TableDataDownload
|
||||||
columns={props.tableColumns}
|
columns={props.tableColumns}
|
||||||
data={props.tableData}
|
data={props.tableData}
|
||||||
widgetName={props.widgetName}
|
widgetName={props.widgetName}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{props.isVisibleCompactMode && (
|
||||||
<TableCompactMode
|
<TableCompactMode
|
||||||
compactMode={props.compactMode}
|
compactMode={props.compactMode}
|
||||||
updateCompactMode={props.updateCompactMode}
|
updateCompactMode={props.updateCompactMode}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
</CommonFunctionsMenuWrapper>
|
</CommonFunctionsMenuWrapper>
|
||||||
{props.serverSidePaginationEnabled && (
|
)}
|
||||||
|
|
||||||
|
{props.isVisiblePagination && props.serverSidePaginationEnabled && (
|
||||||
<PaginationWrapper>
|
<PaginationWrapper>
|
||||||
<PaginationItemWrapper
|
<PaginationItemWrapper
|
||||||
className="t--table-widget-prev-page"
|
className="t--table-widget-prev-page"
|
||||||
|
|
@ -162,7 +182,7 @@ function TableHeader(props: TableHeaderProps) {
|
||||||
</PaginationItemWrapper>
|
</PaginationItemWrapper>
|
||||||
</PaginationWrapper>
|
</PaginationWrapper>
|
||||||
)}
|
)}
|
||||||
{!props.serverSidePaginationEnabled && (
|
{props.isVisiblePagination && !props.serverSidePaginationEnabled && (
|
||||||
<PaginationWrapper>
|
<PaginationWrapper>
|
||||||
<RowWrapper className="show-page-items">
|
<RowWrapper className="show-page-items">
|
||||||
{props.tableData?.length} Records
|
{props.tableData?.length} Records
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,11 @@ interface ReactTableComponentProps {
|
||||||
columns: ReactTableColumnProps[];
|
columns: ReactTableColumnProps[];
|
||||||
compactMode?: CompactMode;
|
compactMode?: CompactMode;
|
||||||
updateCompactMode: (compactMode: CompactMode) => void;
|
updateCompactMode: (compactMode: CompactMode) => void;
|
||||||
|
isVisibleSearch?: boolean;
|
||||||
|
isVisibleFilters?: boolean;
|
||||||
|
isVisibleDownload?: boolean;
|
||||||
|
isVisibleCompactMode?: boolean;
|
||||||
|
isVisiblePagination?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
function ReactTableComponent(props: ReactTableComponentProps) {
|
function ReactTableComponent(props: ReactTableComponentProps) {
|
||||||
|
|
@ -81,6 +86,11 @@ function ReactTableComponent(props: ReactTableComponentProps) {
|
||||||
handleResizeColumn,
|
handleResizeColumn,
|
||||||
height,
|
height,
|
||||||
isLoading,
|
isLoading,
|
||||||
|
isVisibleCompactMode,
|
||||||
|
isVisibleDownload,
|
||||||
|
isVisibleFilters,
|
||||||
|
isVisiblePagination,
|
||||||
|
isVisibleSearch,
|
||||||
nextPageClick,
|
nextPageClick,
|
||||||
onRowClick,
|
onRowClick,
|
||||||
pageNo,
|
pageNo,
|
||||||
|
|
@ -230,6 +240,11 @@ function ReactTableComponent(props: ReactTableComponentProps) {
|
||||||
handleResizeColumn={handleResizeColumn}
|
handleResizeColumn={handleResizeColumn}
|
||||||
height={height}
|
height={height}
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
|
isVisibleCompactMode={isVisibleCompactMode}
|
||||||
|
isVisibleDownload={isVisibleDownload}
|
||||||
|
isVisibleFilters={isVisibleFilters}
|
||||||
|
isVisiblePagination={isVisiblePagination}
|
||||||
|
isVisibleSearch={isVisibleSearch}
|
||||||
nextPageClick={nextPageClick}
|
nextPageClick={nextPageClick}
|
||||||
pageNo={pageNo - 1}
|
pageNo={pageNo - 1}
|
||||||
pageSize={pageSize || 1}
|
pageSize={pageSize || 1}
|
||||||
|
|
@ -262,6 +277,11 @@ export default React.memo(ReactTableComponent, (prev, next) => {
|
||||||
prev.handleResizeColumn === next.handleResizeColumn &&
|
prev.handleResizeColumn === next.handleResizeColumn &&
|
||||||
prev.height === next.height &&
|
prev.height === next.height &&
|
||||||
prev.isLoading === next.isLoading &&
|
prev.isLoading === next.isLoading &&
|
||||||
|
prev.isVisibleCompactMode === next.isVisibleCompactMode &&
|
||||||
|
prev.isVisibleDownload === next.isVisibleDownload &&
|
||||||
|
prev.isVisibleFilters === next.isVisibleFilters &&
|
||||||
|
prev.isVisiblePagination === next.isVisiblePagination &&
|
||||||
|
prev.isVisibleSearch === next.isVisibleSearch &&
|
||||||
prev.nextPageClick === next.nextPageClick &&
|
prev.nextPageClick === next.nextPageClick &&
|
||||||
prev.onRowClick === next.onRowClick &&
|
prev.onRowClick === next.onRowClick &&
|
||||||
prev.pageNo === next.pageNo &&
|
prev.pageNo === next.pageNo &&
|
||||||
|
|
|
||||||
|
|
@ -263,6 +263,11 @@ const WidgetConfigResponse: WidgetConfigReducerState = {
|
||||||
step: 62,
|
step: 62,
|
||||||
status: 75,
|
status: 75,
|
||||||
},
|
},
|
||||||
|
isVisibleSearch: true,
|
||||||
|
isVisibleFilters: true,
|
||||||
|
isVisibleDownload: true,
|
||||||
|
isVisibleCompactMode: true,
|
||||||
|
isVisiblePagination: true,
|
||||||
version: 1,
|
version: 1,
|
||||||
},
|
},
|
||||||
DROP_DOWN_WIDGET: {
|
DROP_DOWN_WIDGET: {
|
||||||
|
|
|
||||||
|
|
@ -679,6 +679,57 @@ export default [
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
sectionName: "Header options",
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
helpText: "Toggle visibility of the search box",
|
||||||
|
propertyName: "isVisibleSearch",
|
||||||
|
label: "Search",
|
||||||
|
controlType: "SWITCH",
|
||||||
|
isJSConvertible: true,
|
||||||
|
isBindProperty: true,
|
||||||
|
isTriggerProperty: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
helpText: "Toggle visibility of the filters",
|
||||||
|
propertyName: "isVisibleFilters",
|
||||||
|
label: "Filters",
|
||||||
|
controlType: "SWITCH",
|
||||||
|
isJSConvertible: true,
|
||||||
|
isBindProperty: true,
|
||||||
|
isTriggerProperty: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
helpText: "Toggle visibility of the data download",
|
||||||
|
propertyName: "isVisibleDownload",
|
||||||
|
label: "Download",
|
||||||
|
controlType: "SWITCH",
|
||||||
|
isJSConvertible: true,
|
||||||
|
isBindProperty: true,
|
||||||
|
isTriggerProperty: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
helpText: "Toggle visibility of the compact mode",
|
||||||
|
propertyName: "isVisibleCompactMode",
|
||||||
|
label: "Compact Mode",
|
||||||
|
controlType: "SWITCH",
|
||||||
|
isJSConvertible: true,
|
||||||
|
isBindProperty: true,
|
||||||
|
isTriggerProperty: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
helpText: "Toggle visibility of the pagination",
|
||||||
|
propertyName: "isVisiblePagination",
|
||||||
|
label: "Pagination",
|
||||||
|
controlType: "SWITCH",
|
||||||
|
isJSConvertible: true,
|
||||||
|
isBindProperty: true,
|
||||||
|
isTriggerProperty: true,
|
||||||
|
validation: VALIDATION_TYPES.BOOLEAN,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
sectionName: "Actions",
|
sectionName: "Actions",
|
||||||
children: [
|
children: [
|
||||||
|
|
|
||||||
|
|
@ -632,6 +632,11 @@ class TableWidget extends BaseWidget<TableWidgetProps, WidgetState> {
|
||||||
handleResizeColumn={this.handleResizeColumn}
|
handleResizeColumn={this.handleResizeColumn}
|
||||||
height={componentHeight}
|
height={componentHeight}
|
||||||
isLoading={this.props.isLoading}
|
isLoading={this.props.isLoading}
|
||||||
|
isVisibleCompactMode={this.props.isVisibleCompactMode}
|
||||||
|
isVisibleDownload={this.props.isVisibleDownload}
|
||||||
|
isVisibleFilters={this.props.isVisibleFilters}
|
||||||
|
isVisiblePagination={this.props.isVisiblePagination}
|
||||||
|
isVisibleSearch={this.props.isVisibleSearch}
|
||||||
multiRowSelection={this.props.multiRowSelection}
|
multiRowSelection={this.props.multiRowSelection}
|
||||||
nextPageClick={this.handleNextPageClick}
|
nextPageClick={this.handleNextPageClick}
|
||||||
onCommandClick={this.onCommandClick}
|
onCommandClick={this.onCommandClick}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user