-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1594 from fedspendingtransparency/FDG-9970
FDG-9970 Data table - All Tables Selected
- Loading branch information
Showing
30 changed files
with
667 additions
and
341 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
...ata-preview/data-preview-chart-table-display/data-preview-chart-table-display.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
$cell-height: 2.125rem; | ||
|
||
.tableNotice { | ||
position: absolute; | ||
top: calc($cell-height * 4); | ||
width: 100%; | ||
} |
18 changes: 18 additions & 0 deletions
18
...ts/data-preview/data-preview-chart-table-display/data-preview-chart-table-display.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from 'react'; | ||
import ChartTableDisplay from './data-preview-chart-table-display'; | ||
import { render } from '@testing-library/react'; | ||
|
||
describe('Chart Table Display', () => { | ||
it('displays table', () => { | ||
const mockTable = <table></table>; | ||
const { getByRole } = render(<ChartTableDisplay table={mockTable} allTablesSelected={false} />); | ||
expect(getByRole('table')).toBeInTheDocument(); | ||
}); | ||
|
||
it(`display "All Data Tables" banner when all tables is selected`, () => { | ||
const mockTable = <table></table>; | ||
const { getByText } = render(<ChartTableDisplay table={mockTable} allTablesSelected={true} />); | ||
expect(getByText('The current "All Data Tables" selection is for download only')).toBeInTheDocument(); | ||
expect(getByText("To download the data, select the 'Download' button and choose the desired format.")).toBeInTheDocument(); | ||
}); | ||
}); |
56 changes: 56 additions & 0 deletions
56
...onents/data-preview/data-preview-chart-table-display/data-preview-chart-table-display.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import React, { FunctionComponent } from 'react'; | ||
import NotShownMessage from '../../dataset-data/table-section-container/not-shown-message/not-shown-message'; | ||
import { getMessageForDefaultApiFilter, getMessageForUnmatchedUserFilter } from '../../filter-download-container/user-filter/user-filter'; | ||
import { allTablesSelectedBody, emptyDataMessageBody } from '../../dataset-data/chart-table-toggle/chart-table-toggle'; | ||
import TableNotice from './table-notice/table-notice'; | ||
import EmptyTable from './empty-table/empty-table'; | ||
import { tableNotice } from './data-preview-chart-table-display.module.scss'; | ||
import { pxToNumber } from '../../../helpers/styles-helper/styles-helper'; | ||
import { breakpointLg } from '../../../variables.module.scss'; | ||
|
||
const ChartTableDisplay: FunctionComponent = ({ | ||
table, | ||
allTablesSelected, | ||
selectedTable, | ||
emptyData, | ||
unchartable, | ||
legend, | ||
selectedTab, | ||
chart, | ||
userFilterUnmatchedForDateRange, | ||
apiFilterDefault, | ||
pivotSelected, | ||
width, | ||
}) => { | ||
let emptyDataMessage = null; | ||
|
||
const allTableHeading = 'The current "All Data Tables" selection is for download only'; | ||
const allTableBody = "To download the data, select the 'Download' button and choose the desired format."; | ||
|
||
if (allTablesSelected) { | ||
emptyDataMessage = <TableNotice heading={allTableHeading} bodyText={allTableBody} />; | ||
} | ||
//TODO: Add in additional cases for the table notice | ||
// else if (userFilterUnmatchedForDateRange) { | ||
// emptyDataMessage = getMessageForUnmatchedUserFilter(selectedTable); | ||
// } else if (apiFilterDefault) { | ||
// emptyDataMessage = getMessageForDefaultApiFilter(selectedTable); | ||
// } else if (emptyData) { | ||
// emptyDataMessage = <NotShownMessage heading="Change selections in order to preview data" bodyText={emptyDataMessageBody} />; | ||
// } | ||
|
||
return ( | ||
<> | ||
{emptyDataMessage ? ( | ||
<> | ||
<EmptyTable mobileDisplay={width < pxToNumber(breakpointLg)} /> | ||
<div className={tableNotice}>{emptyDataMessage}</div> | ||
</> | ||
) : ( | ||
table | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export default ChartTableDisplay; |
25 changes: 25 additions & 0 deletions
25
...ponents/data-preview/data-preview-chart-table-display/empty-table/empty-table.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
@import 'src/variables.module'; | ||
$cell-height: 2.125rem; | ||
|
||
.emptyTable { | ||
opacity: 40%; | ||
width: 100%; | ||
border-spacing: 0; | ||
border: $table-border-style; | ||
border-collapse: collapse; | ||
|
||
th, | ||
td { | ||
height: $cell-height; | ||
border-right: $table-border-style; | ||
} | ||
|
||
tr:not(:last-child) td { | ||
border-bottom: $table-border-style; | ||
} | ||
|
||
th { | ||
background-color: #f1f1f1; | ||
border-bottom: $table-border-style; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/components/data-preview/data-preview-chart-table-display/empty-table/empty-table.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React from 'react'; | ||
import EmptyTable from './empty-table'; | ||
import { render } from '@testing-library/react'; | ||
|
||
describe('Empty Table', () => { | ||
it('renders a table', () => { | ||
const { getByRole, getAllByRole } = render(<EmptyTable />); | ||
|
||
expect(getByRole('table')).toBeInTheDocument(); | ||
expect(getAllByRole('row')).toHaveLength(11); | ||
}); | ||
|
||
it('renders a table with specified number of rows', () => { | ||
const { getByRole, getAllByRole } = render(<EmptyTable rowCount={5} />); | ||
|
||
expect(getByRole('table')).toBeInTheDocument(); | ||
expect(getAllByRole('row')).toHaveLength(6); | ||
}); | ||
}); |
36 changes: 36 additions & 0 deletions
36
src/components/data-preview/data-preview-chart-table-display/empty-table/empty-table.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React, { FunctionComponent } from 'react'; | ||
import { emptyTable } from './empty-table.module.scss'; | ||
import DataTableFooter from '../../../data-table/data-table-footer/data-table-footer'; | ||
|
||
const EmptyTable: FunctionComponent = ({ rowCount = 10, mobileDisplay }) => { | ||
const columnCount = mobileDisplay ? 2 : 6; | ||
|
||
return ( | ||
<> | ||
<table className={emptyTable}> | ||
<tbody> | ||
<tr> | ||
{Array.from({ length: columnCount }, (_, index) => ( | ||
<th key={`header-${index}`} /> | ||
))} | ||
</tr> | ||
{Array.from({ length: rowCount }, (_, index) => ( | ||
<tr key={`row-${index}`}> | ||
{Array.from({ length: columnCount }, (_, index) => ( | ||
<td key={`cell-${index}`} /> | ||
))} | ||
</tr> | ||
))} | ||
</tbody> | ||
</table> | ||
<DataTableFooter | ||
rowsShowing={{ begin: 0, end: 0 }} | ||
manualPagination={true} | ||
pagingProps={{ maxRows: 0, itemsPerPage: rowCount, disablePerPage: true, showWhenEmpty: true, currentPage: 1, maxPage: 1 }} | ||
showPaginationControls={true} | ||
/> | ||
</> | ||
); | ||
}; | ||
|
||
export default EmptyTable; |
35 changes: 35 additions & 0 deletions
35
...nents/data-preview/data-preview-chart-table-display/table-notice/table-notice.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
@import 'src/variables.module.scss'; | ||
|
||
.container { | ||
text-align: center; | ||
} | ||
|
||
.info { | ||
display: inline-flex; | ||
padding: 1.5rem 2rem; | ||
background-color: $table-notice-color; | ||
text-align: left; | ||
max-width: 47.5rem; | ||
} | ||
|
||
.icon { | ||
color: $primary; | ||
font-size: $font-size-16; | ||
margin-right: 0.75rem; | ||
margin-top: 0.125rem; | ||
} | ||
|
||
.notShownHeading { | ||
@include headingStyle6; | ||
margin-bottom: 0.5rem; | ||
} | ||
|
||
.notShownBodyText { | ||
@include bodyStyleRegular; | ||
} | ||
|
||
@media screen and (max-width: $breakpoint-lg - 1) { | ||
.container { | ||
margin: 0 1.5rem; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...omponents/data-preview/data-preview-chart-table-display/table-notice/table-notice.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import React from 'react'; | ||
import TableNotice from './table-notice'; | ||
import { render } from '@testing-library/react'; | ||
|
||
describe('Table Notice', () => { | ||
it('renders the table notice', () => { | ||
const heading = 'Mock Heading!'; | ||
const bodyText = 'Mock body text.'; | ||
const { getByText } = render(<TableNotice heading={heading} bodyText={bodyText} />); | ||
|
||
expect(getByText(heading)).toBeInTheDocument(); | ||
expect(getByText(bodyText)).toBeInTheDocument(); | ||
}); | ||
}); |
33 changes: 33 additions & 0 deletions
33
src/components/data-preview/data-preview-chart-table-display/table-notice/table-notice.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React, { FunctionComponent } from 'react'; | ||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; | ||
import { faInfoCircle } from '@fortawesome/free-solid-svg-icons'; | ||
import { container, icon, info, notShownBodyText, notShownHeading } from './table-notice.module.scss'; | ||
|
||
interface iTableMessage { | ||
heading: string; | ||
bodyText: string; | ||
} | ||
|
||
const TableNotice: FunctionComponent<iTableMessage> = ({ heading, bodyText }) => { | ||
return ( | ||
<div className={container} data-testid="container"> | ||
<div className={info}> | ||
<div className={icon}> | ||
<FontAwesomeIcon icon={faInfoCircle} /> | ||
</div> | ||
<div> | ||
{heading && ( | ||
<div className={notShownHeading} data-testid="heading"> | ||
{heading} | ||
</div> | ||
)} | ||
<div className={notShownBodyText} data-testid="bodyText"> | ||
{bodyText} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default TableNotice; |
1 change: 0 additions & 1 deletion
1
...-preview-data-table/data-preview-data-table-body/data-preview-data-table-body.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
...view-data-table/data-preview-data-table-header/data-preview-data-table-header.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
src/components/data-preview/data-preview-data-table/data-preview-data-table.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
...ponents/data-preview/data-preview-dropdown/data-preview-table-select-dropdown.module.scss
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 9 additions & 3 deletions
12
src/components/data-preview/data-preview-filter-section/column-filter/column-filter.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.