Merge branch 'task-138-feature/filtration_active_tasks' into 'development'

Task 138 feature/filtration active tasks

See merge request !117
parents e5558375 8af00c58
...@@ -7,8 +7,9 @@ import Button from '@mui/material/Button'; ...@@ -7,8 +7,9 @@ import Button from '@mui/material/Button';
import MultipleSelect from '../../components/UI/MultipleSelect/MultipleSelect'; import MultipleSelect from '../../components/UI/MultipleSelect/MultipleSelect';
import Add from "@mui/icons-material/Add"; import Add from "@mui/icons-material/Add";
import Close from "@mui/icons-material/Close"; import Close from "@mui/icons-material/Close";
// import { TaskSharp } from '@mui/icons-material';
export default function MyTaskToolBar({projects,onClose,projectIdListForTaskSelect,setProjectIdListForTaskSelect,formStatus,onClick}) { export default function MyTaskToolBar({projects,onClickActiveTasks,activeTasksOn, onCloseFilterByProjects,projectIdListForTaskSelect,setProjectIdListForTaskSelect,formStatus,onClick}) {
let projectsFilter = let projectsFilter =
<></> <></>
...@@ -17,12 +18,13 @@ export default function MyTaskToolBar({projects,onClose,projectIdListForTaskSele ...@@ -17,12 +18,13 @@ export default function MyTaskToolBar({projects,onClose,projectIdListForTaskSele
projectsFilter= projectsFilter=
<MultipleSelect <MultipleSelect
projects={projects} projects={projects}
onClose={onClose} onCloseFilterByProjects={onCloseFilterByProjects}
projectName={projectIdListForTaskSelect} projectIdListForTaskSelect={projectIdListForTaskSelect}
setProjectName={setProjectIdListForTaskSelect} setProjectIdListForTaskSelect={setProjectIdListForTaskSelect}
/> />
} }
return ( return (
<Box sx={{ flexGrow: 1 }}> <Box sx={{ flexGrow: 1 }}>
...@@ -31,6 +33,18 @@ export default function MyTaskToolBar({projects,onClose,projectIdListForTaskSele ...@@ -31,6 +33,18 @@ export default function MyTaskToolBar({projects,onClose,projectIdListForTaskSele
<Typography variant="h6" component="div" sx={{ flexGrow: 1 }}> <Typography variant="h6" component="div" sx={{ flexGrow: 1 }}>
Мои задачи Мои задачи
</Typography> </Typography>
<Button
color={"inherit"}
style={{
backgroundColor: activeTasksOn === true ? "red" : "inherit",
}}
onClick={()=>onClickActiveTasks()}
>
Активные задачи
</Button>
{projectsFilter} {projectsFilter}
<Button <Button
......
...@@ -28,15 +28,15 @@ function getStyles(name, personName, theme) { ...@@ -28,15 +28,15 @@ function getStyles(name, personName, theme) {
}; };
} }
export default function MultipleSelect({projects,projectName,onClose,setProjectName}) { export default function MultipleSelect({projects,onCloseFilterByProjects}) {
const theme = useTheme(); const theme = useTheme();
const [listProjectIds, setListProjectIds ] = React.useState([])
const handleChange = (event) => { const handleChange = (event) => {
const { const {
target: { value }, target: { value },
} = event; } = event;
setProjectName( setListProjectIds(
// On autofill we get a stringified value. // On autofill we get a stringified value.
typeof value === 'string' ? value.split(',') : value, typeof value === 'string' ? value.split(',') : value,
); );
...@@ -55,18 +55,18 @@ export default function MultipleSelect({projects,projectName,onClose,setProjectN ...@@ -55,18 +55,18 @@ export default function MultipleSelect({projects,projectName,onClose,setProjectN
name='Choose Project' name='Choose Project'
id="demo-multiple-name" id="demo-multiple-name"
multiple multiple
value={projectName} value={listProjectIds}
onChange={handleChange} onChange={handleChange}
input={<OutlinedInput label="Name" />} input={<OutlinedInput label="Name" />}
MenuProps={MenuProps} MenuProps={MenuProps}
sx={{color:'white' }} sx={{color:'white' }}
onClose={(e)=>{onClose(projectName)}} onClose={(e)=>{onCloseFilterByProjects(listProjectIds)}}
> >
{projects?.map((project,index) => ( {projects?.map((project,index) => (
<MenuItem <MenuItem
key={index} key={index}
value={project.id} value={project.id}
style={getStyles(project.title, projectName, theme)} style={getStyles(project.title, listProjectIds, theme)}
> >
{project.title} {project.title}
</MenuItem> </MenuItem>
......
...@@ -34,6 +34,10 @@ export default function EnhancedTable() { ...@@ -34,6 +34,10 @@ export default function EnhancedTable() {
open: false, open: false,
task: null, task: null,
}); });
const [projectIdListForTaskSelect, setProjectIdListForTaskSelect] = React.useState([]);
// const [filterProjectTumbler, setFilterProjectTumbler] = React.useState(false);
// const[filteredActiveTasks, setActiveTasks] = React.useState([]);
const [activeTasksOn, setActiveTasksOn] = React.useState(false)
useEffect(() => { useEffect(() => {
...@@ -43,11 +47,27 @@ export default function EnhancedTable() { ...@@ -43,11 +47,27 @@ export default function EnhancedTable() {
} }
}, [ }, [
tasks?.length, tasks?.length,
addTaskForm, setAddTaskForm, dispatch]); addTaskForm, setAddTaskForm,
// onClickActiveTasks,
// activeTasksOn,
dispatch
]);
// console.log('tasks ', tasks, 'projects ', projects,"recievedTasks ", recievedTasks ) // console.log('tasks ', tasks, 'projects ', projects,"recievedTasks ", recievedTasks )
useEffect(() => {
let filteredTasks = tasks;
if (activeTasksOn) {
filteredTasks = filteredTasks.filter(task=>task.accomplish==='opened' || task.accomplish==='progress')
}
if (projectIdListForTaskSelect.length>0) {
filteredTasks = filteredTasks.filter(task=>projectIdListForTaskSelect.includes(task.project?.id))
}
setRecievedTasks(filteredTasks)
}, [activeTasksOn, projectIdListForTaskSelect]);
const handleRequestSort = ( property) => { const handleRequestSort = ( property) => {
const isAsc = orderBy === property && order === "asc"; const isAsc = orderBy === property && order === "asc";
...@@ -177,18 +197,30 @@ export default function EnhancedTable() { ...@@ -177,18 +197,30 @@ export default function EnhancedTable() {
}; };
// ++++++++фильтрация по проектам+++++++++++++++ // ++++++++фильтрация по проектам+++++++++++++++
const [projectIdListForTaskSelect, setProjectIdListForTaskSelect] = React.useState([]);
const [filterProjectTumbler, setFilterProjectTumbler] = React.useState(false);
const onCloseFilterByProjects=(listProjectIds)=>{
const onClose=(projectIdListForTaskSelect)=>{ setProjectIdListForTaskSelect(listProjectIds)
let tasksFilteredByProject = tasks
if (projectIdListForTaskSelect.length>0) {
tasksFilteredByProject = tasks.filter(task=>projectIdListForTaskSelect.includes(task.project?.id))
}
console.log('tasksFilteredByProject ', tasksFilteredByProject)
setRecievedTasks(tasksFilteredByProject)
setFilterProjectTumbler(true)
} }
const onClickActiveTasks= ()=>{
console.log('active tasts before switched to ', activeTasksOn)
// setActiveTasksOn((prevState)=>{return !prevState})
setActiveTasksOn(!activeTasksOn)
console.log('active tasts after switch ', activeTasksOn)
if (activeTasksOn) {
const activeTasks= recievedTasks.filter(recievedTask=>recievedTask.accomplish==='opened' || recievedTask.accomplish==='progress' )
console.log('received tasks in switch', recievedTasks)
setRecievedTasks(activeTasks)
} else {
setRecievedTasks(tasks)
}
}
// if ( // if (
// tasks && // tasks &&
// tasks?.length > 0 // tasks?.length > 0
...@@ -203,9 +235,11 @@ export default function EnhancedTable() { ...@@ -203,9 +235,11 @@ export default function EnhancedTable() {
onClick={() => setAddTaskForm(!addTaskForm)} onClick={() => setAddTaskForm(!addTaskForm)}
formStatus={addTaskForm} formStatus={addTaskForm}
projects={projects} projects={projects}
onClose={onClose} onCloseFilterByProjects={onCloseFilterByProjects}
projectIdListForTaskSelect={projectIdListForTaskSelect} projectIdListForTaskSelect={projectIdListForTaskSelect}
setProjectIdListForTaskSelect={setProjectIdListForTaskSelect} setProjectIdListForTaskSelect={setProjectIdListForTaskSelect}
onClickActiveTasks={onClickActiveTasks}
activeTasksOn={activeTasksOn}
/> />
{addTaskForm ? ( {addTaskForm ? (
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment