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

Implement filtering on Name, Address, Alt# and Created By column headings #1828

Merged
merged 7 commits into from
Sep 12, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import VisibilityPopup from "./VisibilityPopup";
import StatusPopup from "./StatusPopup";

const ProjectTableColumnHeader = ({
uniqueValues,
header,
criteria,
setCriteria,
Expand Down Expand Up @@ -70,6 +71,7 @@ const ProjectTableColumnHeader = ({
/>
) : header.popupType === "text" ? (
<TextPopup
selectOptions={uniqueValues}
close={close}
header={header}
criteria={criteria}
Expand Down Expand Up @@ -115,6 +117,7 @@ const ProjectTableColumnHeader = ({
};

ProjectTableColumnHeader.propTypes = {
uniqueValues: PropTypes.any,
header: PropTypes.any,
criteria: PropTypes.any,
setCriteria: PropTypes.func,
Expand Down
42 changes: 39 additions & 3 deletions client/src/components/Projects/ColumnHeaderPopups/TextPopup.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ import Button from "../../Button/Button";
import RadioButton from "../../UI/RadioButton";
import "react-datepicker/dist/react-datepicker.css";
import { MdClose } from "react-icons/md";
import SearchIcon from "../../../images/search.png";
import UniversalSelect from "../../UI/UniversalSelect.jsx";

const TextPopup = ({
selectOptions,
close,
header,
criteria,
Expand Down Expand Up @@ -37,6 +40,17 @@ const TextPopup = ({
setSelectAllChecked(false);
};

const placeholderComponent = (
<div>
<img
style={{ position: "absolute", left: "16 px", top: "14 px" }}
src={SearchIcon}
alt="Search Icon"
/>
<div style={{ marginLeft: "30px" }}> Search by Keyword</div>
</div>
);

return (
<div style={{ display: "flex", flexDirection: "column" }}>
<div style={{ display: "flex", justifyContent: "flex-end" }}>
Expand Down Expand Up @@ -67,15 +81,36 @@ const TextPopup = ({
/>
<hr style={{ width: "100%" }} />
</div>
<input
{/* <div>
<ul>
{textAllCurrentProjects.map((text, index) => (
<li key={index}>{text}</li>
))}
</ul>
</div> */}
{/* <input
type="text"
placeholder="Search by Partial Text"
onChange={e => {
setNewSearchString(e.target.value);
}}
value={newSearchString}
/>

/> */}
<UniversalSelect
options={selectOptions.map(text => ({
Copy link
Member

@entrotech entrotech Sep 7, 2024

Choose a reason for hiding this comment

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

I think the list would be more user-friendly if it was sorted alphabetically. You can do it here or in the ProjectPage component.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is completed.

value: text,
label: text
}))}
name="inputName"
disabled={false}
onChange={e => {
setNewSearchString(e.target.value);
}}
value={newSearchString}
defaultValue={newSearchString}
styles={{ maxHeight: 200 }}
placeholder={placeholderComponent}
></UniversalSelect>
<hr style={{ width: "100%" }} />
<div style={{ display: "flex" }}>
<Button onClick={setDefault} variant="text">
Expand All @@ -94,6 +129,7 @@ const TextPopup = ({
};

TextPopup.propTypes = {
selectOptions: PropTypes.any,
close: PropTypes.func,
header: PropTypes.any,
criteria: PropTypes.any,
Expand Down
8 changes: 8 additions & 0 deletions client/src/components/Projects/ProjectsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -735,9 +735,17 @@ const ProjectsPage = ({ contentContainerRef }) => {
<thead className={classes.thead}>
<tr className={classes.tr}>
{headerData.map(header => {
//header.id can be used to index the property of the project object except for author
const property =
header.id == "author" ? "fullname" : header.id;
return (
<td key={header.id}>
<ProjectTableColumnHeader
uniqueValues={[
...new Set(sortedProjects.map(p => p[property]))
]
.filter(value => value !== null)
.sort()}
header={header}
criteria={criteria}
setCriteria={setCriteria}
Expand Down
Loading