UI Alignment in Service Card view.
This commit is contained in:
parent
92d17167b1
commit
822ff1a7e4
@ -89,7 +89,7 @@ const ServiceProjectCard = ({ project, isCore = true }) => {
|
|||||||
>
|
>
|
||||||
{project?.shortName ? project?.shortName : project?.name}
|
{project?.shortName ? project?.shortName : project?.name}
|
||||||
</h5>
|
</h5>
|
||||||
<div className="client-info text-body">
|
<div className="client-info text-body text-start">
|
||||||
<span>{project?.shortName ? project?.name : ""}</span>
|
<span>{project?.shortName ? project?.name : ""}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import React, { createContext, useContext, useEffect, useState } from "react";
|
import React, { createContext, useContext, useEffect, useRef, useState } from "react";
|
||||||
import Breadcrumb from "../../components/common/Breadcrumb";
|
import Breadcrumb from "../../components/common/Breadcrumb";
|
||||||
import {
|
import {
|
||||||
ITEMS_PER_PAGE,
|
ITEMS_PER_PAGE,
|
||||||
@ -36,7 +36,7 @@ const ProjectPage = () => {
|
|||||||
isOpen: false,
|
isOpen: false,
|
||||||
project: null,
|
project: null,
|
||||||
});
|
});
|
||||||
|
const dropdownRef = useRef(null);
|
||||||
const [projectList, setProjectList] = useState([]);
|
const [projectList, setProjectList] = useState([]);
|
||||||
const [listView, setListView] = useState(false);
|
const [listView, setListView] = useState(false);
|
||||||
const [searchTerm, setSearchTerm] = useState("");
|
const [searchTerm, setSearchTerm] = useState("");
|
||||||
@ -46,6 +46,7 @@ const ProjectPage = () => {
|
|||||||
});
|
});
|
||||||
const HasManageProject = useHasUserPermission(MANAGE_PROJECT);
|
const HasManageProject = useHasUserPermission(MANAGE_PROJECT);
|
||||||
const [currentPage, setCurrentPage] = useState(1);
|
const [currentPage, setCurrentPage] = useState(1);
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
const [selectedStatuses, setSelectedStatuses] = useState(
|
const [selectedStatuses, setSelectedStatuses] = useState(
|
||||||
PROJECT_STATUS.map((s) => s.id)
|
PROJECT_STATUS.map((s) => s.id)
|
||||||
@ -70,6 +71,16 @@ const ProjectPage = () => {
|
|||||||
sessionStorage.setItem("whichProjectDisplay", String(value));
|
sessionStorage.setItem("whichProjectDisplay", String(value));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const handleClickOutside = (event) => {
|
||||||
|
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
||||||
|
setOpen(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
document.addEventListener("mousedown", handleClickOutside);
|
||||||
|
return () => document.removeEventListener("mousedown", handleClickOutside);
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ProjectContext.Provider value={contextDispatcher}>
|
<ProjectContext.Provider value={contextDispatcher}>
|
||||||
<div className="container-fluid">
|
<div className="container-fluid">
|
||||||
@ -89,8 +100,7 @@ const ProjectPage = () => {
|
|||||||
{/* Service Project Button */}
|
{/* Service Project Button */}
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className={`btn px-2 py-1 rounded-0 text-tiny ${
|
className={`btn px-2 py-1 rounded-0 text-tiny ${!coreProjects ? "btn-primary text-white" : ""
|
||||||
!coreProjects ? "btn-primary text-white" : ""
|
|
||||||
}`}
|
}`}
|
||||||
onClick={() => handleToggleProject(false)}
|
onClick={() => handleToggleProject(false)}
|
||||||
>
|
>
|
||||||
@ -99,8 +109,7 @@ const ProjectPage = () => {
|
|||||||
{/* Organization Project Button */}
|
{/* Organization Project Button */}
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className={`btn px-2 py-1 rounded-0 text-tiny ${
|
className={`btn px-2 py-1 rounded-0 text-tiny ${coreProjects ? "btn-primary text-white" : ""
|
||||||
coreProjects ? "btn-primary text-white" : ""
|
|
||||||
}`}
|
}`}
|
||||||
onClick={() => handleToggleProject(true)}
|
onClick={() => handleToggleProject(true)}
|
||||||
>
|
>
|
||||||
@ -129,8 +138,7 @@ const ProjectPage = () => {
|
|||||||
<div className="d-flex gap-2">
|
<div className="d-flex gap-2">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className={`btn btn-sm p-1 ${
|
className={`btn btn-sm p-1 ${!listView ? "btn-primary" : "btn-outline-primary"
|
||||||
!listView ? "btn-primary" : "btn-outline-primary"
|
|
||||||
}`}
|
}`}
|
||||||
onClick={() => setListView(false)}
|
onClick={() => setListView(false)}
|
||||||
title="Card View"
|
title="Card View"
|
||||||
@ -140,8 +148,7 @@ const ProjectPage = () => {
|
|||||||
|
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className={`btn btn-sm p-1 ${
|
className={`btn btn-sm p-1 ${listView ? "btn-primary" : "btn-outline-primary"
|
||||||
listView ? "btn-primary" : "btn-outline-primary"
|
|
||||||
}`}
|
}`}
|
||||||
onClick={() => setListView(true)}
|
onClick={() => setListView(true)}
|
||||||
title="List View"
|
title="List View"
|
||||||
@ -151,17 +158,36 @@ const ProjectPage = () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Dropdown Filter */}
|
{/* Dropdown Filter */}
|
||||||
<div className="dropdown me-2">
|
<div className="dropdown me-2 position-relative">
|
||||||
<a
|
<div
|
||||||
className="dropdown-toggle hide-arrow cursor-pointer p-1"
|
className="cursor-pointer p-1"
|
||||||
data-bs-toggle="dropdown"
|
onClick={() => setOpen(!open)}
|
||||||
aria-expanded="false"
|
|
||||||
title="Filter"
|
|
||||||
>
|
>
|
||||||
<i className="bx bx-slider-alt fs-5"></i>
|
<i
|
||||||
</a>
|
className={`bx bx-slider-alt fs-5 ${selectedStatuses.length !== PROJECT_STATUS.length ? "text-primary" : ""
|
||||||
|
}`}
|
||||||
|
></i>
|
||||||
|
|
||||||
<ul className="dropdown-menu p-2 text-capitalize">
|
{selectedStatuses.length !== PROJECT_STATUS.length && (
|
||||||
|
<span className="badge bg-warning text-white rounded-pill position-absolute"
|
||||||
|
style={{
|
||||||
|
top: "-4px",
|
||||||
|
right: "-4px",
|
||||||
|
fontSize: "0.6rem",
|
||||||
|
padding: "2px 5px",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{PROJECT_STATUS.length - selectedStatuses.length}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{open && (
|
||||||
|
<ul
|
||||||
|
ref={dropdownRef}
|
||||||
|
className="dropdown-menu show p-2 text-capitalize"
|
||||||
|
onMouseDown={(e) => e.stopPropagation()} // IMPORTANT
|
||||||
|
>
|
||||||
{PROJECT_STATUS.map(({ id, label }) => (
|
{PROJECT_STATUS.map(({ id, label }) => (
|
||||||
<li key={id}>
|
<li key={id}>
|
||||||
<div className="form-check">
|
<div className="form-check">
|
||||||
@ -169,15 +195,25 @@ const ProjectPage = () => {
|
|||||||
className="form-check-input"
|
className="form-check-input"
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
checked={selectedStatuses.includes(id)}
|
checked={selectedStatuses.includes(id)}
|
||||||
|
onClick={(e) => e.stopPropagation()} // IMPORTANT
|
||||||
onChange={() => handleStatusChange(id)}
|
onChange={() => handleStatusChange(id)}
|
||||||
/>
|
/>
|
||||||
<label className="form-check-label">{label}</label>
|
<label
|
||||||
|
className="form-check-label"
|
||||||
|
onClick={(e) => e.stopPropagation()} // OPTIONAL
|
||||||
|
>
|
||||||
|
{label}
|
||||||
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{HasManageProject && (
|
{HasManageProject && (
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user