Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NOREF] - Revised sort on filter view ops table, added bottom border to last row #984

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ const BodyContent = ({
<Divider className="margin-top-8" />
<h2 className="margin-top-5">{opSolutionsT('headingReadOnly')}</h2>
<OperationalNeedsTable
className="margin-bottom-5"
modelID={modelID}
type="needs"
readOnly
Expand All @@ -121,7 +122,7 @@ const BodyContent = ({
</div>
)}

<div className="margin-top-4 padding-top-4 border-top-1px border-base-light">
<div className="margin-top-4 padding-top-5 border-top-1px border-base-light">
<Alert type="info" noIcon headingLevel="h4">
<span className="margin-y-0 font-body-sm text-bold display-block">
{t('alert.bodyContentHeading')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,21 +211,21 @@ exports[`Operational Solutions Home > matches snapshot 1`] = `
class="padding-x-1"
role="cell"
scope="row"
style="padding-left: 0px; white-space: normal;"
style="padding-left: 0px; border-bottom: 1px solid black; white-space: normal;"
>
Recruit participants
</th>
<td
class=""
role="cell"
style="padding-left: 0px; white-space: normal; max-width: 275px;"
style="padding-left: 0px; white-space: normal; max-width: 275px; border-bottom: 1px solid black;"
>
Participants and Providers
</td>
<td
class=""
role="cell"
style="padding-left: 0px; white-space: normal; max-width: auto;"
style="padding-left: 0px; white-space: normal; max-width: auto; border-bottom: 1px solid black;"
>
<span
class="mint-tag line-height-body-1 text-bold bg-transparent border-2px text-base"
Expand All @@ -237,7 +237,7 @@ exports[`Operational Solutions Home > matches snapshot 1`] = `
<td
class=""
role="cell"
style="padding-left: 0px; white-space: normal; max-width: auto;"
style="padding-left: 0px; white-space: normal; max-width: auto; border-bottom: 1px solid black;"
>
<a
class="usa-link"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ type OperationalNeedsTableProps = {
readOnly?: boolean;
hideGlobalFilter?: boolean;
filterSolutions?: OperationalSolutionKey[];
className?: string;
};

const OperationalNeedsTable = ({
Expand All @@ -80,7 +81,8 @@ const OperationalNeedsTable = ({
type,
readOnly,
hideGlobalFilter,
filterSolutions
filterSolutions,
className
}: OperationalNeedsTableProps) => {
const { t } = useTranslation('itSolutions');

Expand Down Expand Up @@ -286,6 +288,11 @@ const OperationalNeedsTable = ({
[needsColumns[0], needsColumns[1]] = [needsColumns[1], needsColumns[0]];
}

const sortColumn = type === 'needs' && !filterSolutions ? 'needName' : 'name';
const initialSort = useMemo(() => [{ id: sortColumn, asc: true }], [
sortColumn
]);

const {
getTableProps,
getTableBodyProps,
Expand Down Expand Up @@ -318,11 +325,10 @@ const OperationalNeedsTable = ({
globalFilter: useMemo(() => globalFilterCellText, []),
autoResetSortBy: false,
autoResetPage: true,
// Remove sort on filterSolutions because its accessor is a function and can't be passed a proper id for initial sort.
// https://github.com/TanStack/table/issues/2641
initialState: {
sortBy: useMemo(
() => [{ id: type === 'needs' ? 'needName' : 'name', asc: true }],
[type]
),
sortBy: filterSolutions ? [] : initialSort,
pageIndex: 0
}
},
Expand Down Expand Up @@ -376,7 +382,10 @@ const OperationalNeedsTable = ({
}

return (
<div className="model-plan-table" data-testid={`${type}-table`}>
<div
className={classNames(className, 'model-plan-table')}
data-testid={`${type}-table`}
>
{!hideGlobalFilter && (
<div className="mint-header__basic">
<GlobalClientFilter
Expand Down Expand Up @@ -459,7 +468,9 @@ const OperationalNeedsTable = ({
style={{
paddingLeft: '0',
borderBottom:
index === page.length - 1 ? 'none' : 'auto',
index === page.length - 1
? '1px solid black'
: 'auto',
whiteSpace: 'normal'
}}
>
Expand All @@ -478,7 +489,9 @@ const OperationalNeedsTable = ({
whiteSpace: 'normal',
maxWidth: i === 1 ? '275px' : 'auto',
borderBottom:
index === page.length - 1 ? 'none' : 'auto'
index === page.length - 1
? '1px solid black'
: 'auto'
}}
>
{cell.render('Cell')}
Expand Down