Commit 0fc9b731 authored by Ermolaev Timur's avatar Ermolaev Timur

#55 Начал изменять логику отображения

parent da037e57
...@@ -95,6 +95,33 @@ const CalendarRowDay = ({xs, hoursInDay, createTaskInCellHandler, currentTask, h ...@@ -95,6 +95,33 @@ const CalendarRowDay = ({xs, hoursInDay, createTaskInCellHandler, currentTask, h
return lines return lines
}, [availableTasks.length, hourFormat, hours, hoursInDay, sortedTasks]) }, [availableTasks.length, hourFormat, hours, hoursInDay, sortedTasks])
const getBoxesInLine = (line) => {
if (line) {
let xs = 12/hoursInDay.length
const boxes = []
for (let i = 0; i < line.length; i++) {
if (!isNaN(line[i])) {
if (boxes[boxes.length -1]?.task === null) {
boxes[boxes.length -1].xs += xs
} else {
boxes.push({xs: xs, task: null})
}
} else {
const task = sortedTasks[line[i].split('-')[1]]
const taskIsThere = boxes.find((taskFind)=>{
if (taskFind?.task?.id === task.id) return taskFind
})
if (taskIsThere) {
taskIsThere.xs +=xs
} else {
boxes.push({xs: xs, task: sortedTasks[line[i].split('-')[1]]})
}
}
}
return boxes
}
}
return <> return <>
<Grid <Grid
container container
...@@ -120,7 +147,7 @@ const CalendarRowDay = ({xs, hoursInDay, createTaskInCellHandler, currentTask, h ...@@ -120,7 +147,7 @@ const CalendarRowDay = ({xs, hoursInDay, createTaskInCellHandler, currentTask, h
handleOpen={handleOpen} handleOpen={handleOpen}
modal={modal} modal={modal}
> >
<CalendarTask {/* <CalendarTask
setCurrentTask={setCurrentTask} setCurrentTask={setCurrentTask}
hours={hour} hours={hour}
modal={modal} modal={modal}
...@@ -129,10 +156,24 @@ const CalendarRowDay = ({xs, hoursInDay, createTaskInCellHandler, currentTask, h ...@@ -129,10 +156,24 @@ const CalendarRowDay = ({xs, hoursInDay, createTaskInCellHandler, currentTask, h
currentTask={currentTask} currentTask={currentTask}
linesForCell={linesForCell.length ? linesForCell : null} linesForCell={linesForCell.length ? linesForCell : null}
sortedTasks={sortedTasks} sortedTasks={sortedTasks}
/> /> */}
</CalendarStandartCell> </CalendarStandartCell>
) )
})} })}
{linesInDay?.map((line)=>{
const boxes = getBoxesInLine(line)
return(
<Grid container sx={{backgroundColor: 'grey', height: '40px', borderBottom: '1px solid red'}}>
{boxes.map((box)=>{
if (box.task) {
return (<Grid item xs={box.xs} sx={{backgroundColor: 'green', height: '40px'}}></Grid>)
} else {
return (<Grid item xs={box.xs} sx={{backgroundColor: 'white', height: '40px'}}></Grid>)
}
})}
</Grid>)
})}
</Grid> </Grid>
</> </>
}; };
......
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