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

PSP-9837 : UI UX Clean Up - Manage Tables - Create Buttons - move to the top #4604

Merged
merged 4 commits into from
Jan 20, 2025
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 @@ -9,7 +9,6 @@ export interface IContactManagerModalProps {
setDisplay?: (display: boolean) => void;
setSelectedRows: (selectedContacts: IContactSearchResult[]) => void;
selectedRows: IContactSearchResult[];
showAddButton?: boolean;
showActiveSelector?: boolean;
handleModalOk?: () => void;
handleModalCancel?: () => void;
Expand All @@ -36,7 +35,6 @@ export const ContactManagerModal: React.FunctionComponent<
<ContactManagerView
setSelectedRows={props.setSelectedRows}
selectedRows={props.selectedRows}
showAddButton={props.showAddButton}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

showAddButton should be removed from ContactManagerModal props as it is just passing it down to the view and the view no longer needs it

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

showActiveSelector={props.showActiveSelector}
noInitialSearch={props.selectedRows.length === 0}
isSingleSelect={props.isSingleSelect}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import { useEffect } from 'react';
import { Col, Row } from 'react-bootstrap';
import { FaPlus } from 'react-icons/fa';
import { useHistory } from 'react-router';
import { toast } from 'react-toastify';

import { StyledAddButton } from '@/components/common/styles';
import { Claims } from '@/constants/claims';
import { useApiContacts } from '@/hooks/pims-api/useApiContacts';
import { useKeycloakWrapper } from '@/hooks/useKeycloakWrapper';
import { useSearch } from '@/hooks/useSearch';
import { fromContactSummary, IContactSearchResult } from '@/interfaces';
import { ApiGen_Concepts_ContactSummary } from '@/models/api/generated/ApiGen_Concepts_ContactSummary';
Expand All @@ -27,7 +22,6 @@ interface IContactManagerViewProps {
isSummary?: boolean;
noInitialSearch?: boolean;
className?: string;
showAddButton?: boolean;
showActiveSelector?: boolean;
isSingleSelect?: boolean;
restrictContactType?: RestrictContactType;
Expand All @@ -43,13 +37,10 @@ const ContactManagerView = ({
isSummary,
noInitialSearch,
showSelectedRowCount,
showAddButton,
showActiveSelector,
isSingleSelect,
restrictContactType,
}: IContactManagerViewProps) => {
const history = useHistory();
const { hasClaim } = useKeycloakWrapper();
const { getContacts } = useApiContacts();

const initialFilter: IContactFilter = (
Expand Down Expand Up @@ -97,16 +88,6 @@ const ContactManagerView = ({
/>
</Col>
</Row>
<Row>
{showAddButton && hasClaim(Claims.CONTACT_ADD) && (
<Col xs="auto" xl="3" className="pl-0">
<StyledAddButton onClick={() => history.push('/contact/new')} className="m-4">
<FaPlus className="mr-3" />
&nbsp;Add New Contact
</StyledAddButton>
</Col>
)}
</Row>
<div>
<ContactResultComponent
loading={loading}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -741,9 +741,6 @@ exports[`ContactManagerView > matches snapshot 1`] = `
</form>
</div>
</div>
<div
class="row"
/>
<div>
<div
class="table"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Col, Row } from 'react-bootstrap';
import { FaFileExcel, FaPlus } from 'react-icons/fa';
import { useHistory } from 'react-router';
import { toast } from 'react-toastify';
import styled from 'styled-components';

import AcquisitionFileIcon from '@/assets/images/acquisition-icon.svg?react';
import { StyledIconButton } from '@/components/common/buttons/IconButton';
Expand Down Expand Up @@ -98,8 +99,18 @@ export const AcquisitionListView: React.FunctionComponent<
<Styled.ListPage>
<Styled.Scrollable>
<CommonStyled.H1>
<AcquisitionFileIcon title="Acquisition file icon" fill="currentColor" />
<span className="ml-2">Acquisition Files</span>
<FlexDiv>
<div>
<AcquisitionFileIcon title="Acquisition file icon" fill="currentColor" />
<span className="ml-2">Acquisition Files</span>
</div>
{hasClaim(Claims.ACQUISITION_ADD) && (
<StyledAddButton onClick={() => history.push('/mapview/sidebar/acquisition/new')}>
<FaPlus />
&nbsp;Create an Acquisition File
</StyledAddButton>
)}
</FlexDiv>
</CommonStyled.H1>
<Styled.PageToolbar>
<Row>
Expand All @@ -119,12 +130,7 @@ export const AcquisitionListView: React.FunctionComponent<
</Col>
</Row>
</Styled.PageToolbar>
{hasClaim(Claims.ACQUISITION_ADD) && (
<StyledAddButton onClick={() => history.push('/mapview/sidebar/acquisition/new')}>
<FaPlus />
&nbsp;Create an acquisition file
</StyledAddButton>
)}

<AcquisitionSearchResults
results={results.map(a => AcquisitionSearchResultModel.fromApi(a))}
totalItems={totalItems}
Expand All @@ -143,3 +149,11 @@ export const AcquisitionListView: React.FunctionComponent<
};

export default AcquisitionListView;

const FlexDiv = styled.div`
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
margin-bottom: 0.25rem;
`;
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React, { useCallback, useEffect, useMemo } from 'react';
import { Col, Row } from 'react-bootstrap';
import { FaPlus } from 'react-icons/fa';
import { useHistory } from 'react-router';
import styled from 'styled-components';

import AdminIcon from '@/assets/images/admin-icon.svg?react';
import * as CommonStyled from '@/components/common/styles';
Expand Down Expand Up @@ -100,8 +101,23 @@ export const FinancialCodeListView: React.FC = () => {
<Styled.ListPage>
<Styled.Scrollable>
<CommonStyled.H1>
<AdminIcon title="Admin Tools icon" width="2.6rem" height="2.6rem" fill="currentColor" />
<span className="ml-2">Financial Codes</span>
<FlexDiv>
<div>
<AdminIcon
title="Admin Tools icon"
width="2.6rem"
height="2.6rem"
fill="currentColor"
/>
<span className="ml-2">Financial Codes</span>
</div>
{hasRole(Roles.SYSTEM_ADMINISTRATOR) && (
<StyledAddButton onClick={() => history.push('/admin/financial-code/new')}>
<FaPlus />
&nbsp;Add a Financial Code
</StyledAddButton>
)}
</FlexDiv>
</CommonStyled.H1>
<Styled.PageToolbar>
<Row>
Expand All @@ -110,12 +126,7 @@ export const FinancialCodeListView: React.FC = () => {
</Col>
</Row>
</Styled.PageToolbar>
{hasRole(Roles.SYSTEM_ADMINISTRATOR) && (
<StyledAddButton onClick={() => history.push('/admin/financial-code/new')}>
<FaPlus />
&nbsp;Create financial code
</StyledAddButton>
)}

<FinancialCodeResults
results={sortedFilteredFinancialCodes}
loading={financialCodesLoading}
Expand All @@ -128,3 +139,11 @@ export const FinancialCodeListView: React.FC = () => {
};

export default FinancialCodeListView;

const FlexDiv = styled.div`
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
margin-bottom: 0.25rem;
`;
52 changes: 32 additions & 20 deletions source/frontend/src/features/contacts/list/ContactListPage.tsx
Original file line number Diff line number Diff line change
@@ -1,38 +1,50 @@
import { FaPlus } from 'react-icons/fa';
import { useHistory } from 'react-router';
import styled from 'styled-components';

import ContactIcon from '@/assets/images/contact-icon.svg?react';
import { Scrollable as ScrollableBase } from '@/components/common/Scrollable/Scrollable';
import * as CommonStyled from '@/components/common/styles';
import { StyledAddButton } from '@/components/common/styles';
import ContactManagerView from '@/components/contact/ContactManagerView/ContactManagerView';
import Claims from '@/constants/claims';
import useKeycloakWrapper from '@/hooks/useKeycloakWrapper';

import * as Styled from '../styles';

/**
* Page that displays a list of contacts.
*/
export const ContactListPage = () => {
const history = useHistory();
const { hasClaim } = useKeycloakWrapper();

return (
<StyledListPage>
<StyledScrollable>
<Styled.ListPage>
<Styled.Scrollable>
<CommonStyled.H1>
<ContactIcon title="Contact manager icon" fill="currentColor" />
<span className="ml-2">Contacts</span>
<FlexDiv>
<div>
<ContactIcon title="Contact manager icon" fill="currentColor" />
<span className="ml-2">Contacts</span>
</div>
{hasClaim(Claims.CONTACT_ADD) && (
<StyledAddButton onClick={() => history.push('/contact/new')}>
<FaPlus />
&nbsp;Add a New Contact
</StyledAddButton>
)}
</FlexDiv>
</CommonStyled.H1>
<ContactManagerView showActiveSelector showAddButton />
</StyledScrollable>
</StyledListPage>
<ContactManagerView showActiveSelector />
</Styled.Scrollable>
</Styled.ListPage>
);
};

const StyledListPage = styled.div`
const FlexDiv = styled.div`
display: flex;
flex-direction: column;
flex-grow: 1;
width: 100%;
font-size: 14px;
gap: 2.5rem;
padding: 0;
`;

const StyledScrollable = styled(ScrollableBase)`
padding: 1.6rem 3.2rem;
width: 100%;
flex-direction: row;
justify-content: space-between;
align-items: center;
margin-bottom: 0.25rem;
`;
Loading
Loading