Commit ff131581 authored by Ermolaev Timur's avatar Ermolaev Timur

#30 Реализовал скрытие полного название задачи

parent 155ca9ab
import { Grid, TextField } from "@mui/material"; import { Grid, TextField, Typography } from "@mui/material";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
const CalendarStandartCell = ({children, xs, onClick, currentTask, hours, dayNumber, createTaskInCellHandler, handleOpen, modal}) => { const CalendarStandartCell = ({children, xs, currentTask, hours, dayNumber, createTaskInCellHandler, handleOpen, modal}) => {
const [isThisCell, setIsThisCell] = useState(false) const [isThisCell, setIsThisCell] = useState(false)
useEffect(()=>{ useEffect(()=>{
if(!modal) { if(!modal) {
...@@ -16,7 +16,7 @@ const CalendarStandartCell = ({children, xs, onClick, currentTask, hours, dayNum ...@@ -16,7 +16,7 @@ const CalendarStandartCell = ({children, xs, onClick, currentTask, hours, dayNum
{children} {children}
{isThisCell ? {isThisCell ?
<Grid <Grid
sx={{backgroundColor: 'lightgreen'}} sx={{backgroundColor: 'lightgreen', padding: '10px', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis'}}
> >
<span> <span>
{currentTask.title} {currentTask.title}
......
import { Grid, TextField } from "@mui/material"; import { Grid, TextField } from "@mui/material";
import React, { useEffect, useState } from "react"; import React, { useEffect, useState } from "react";
const CalendarTask = ({year, month, tasks, day, hours, setCurrentTask, onChange, hourFormat, handleOpen}) => { const CalendarTask = ({year, month, tasks, day, hours, setCurrentTask, hourFormat, handleOpen}) => {
const getTaskInDayCell = (tasks, day, hours) => { const getTaskInDayCell = (tasks, day, hours) => {
const hour = parseInt(hours.split(':')[0]) const hour = parseInt(hours.split(':')[0])
let hourDiffEnd let hourDiffEnd
...@@ -26,23 +26,19 @@ const CalendarTask = ({year, month, tasks, day, hours, setCurrentTask, onChange, ...@@ -26,23 +26,19 @@ const CalendarTask = ({year, month, tasks, day, hours, setCurrentTask, onChange,
return tasksCell return tasksCell
} }
const tasksCell = getTaskInDayCell(tasks, day, hours) const tasksCell = getTaskInDayCell(tasks, day, hours)
const returnText = (text) => {
return (<span>{text}</span>)
}
return (<> return (<>
{tasksCell.length ? tasksCell.map((task, i)=> {tasksCell.length ? tasksCell.map((task, i)=>
{ {
return ( return (
<Grid <Grid
key={task.id} key={task.id}
sx={{backgroundColor: 'lightgreen'}} sx={{backgroundColor: 'lightgreen', }}
onClick={(e)=>{e.stopPropagation(); setCurrentTask(task); handleOpen(e)}} onClick={(e)=>{e.stopPropagation(); setCurrentTask(task); handleOpen(e)}}
> >
<TextField {returnText(task.title)}
id={task.title}
variant="standard"
value={task.title}
name='title'
onChange={onChange}>
</TextField>
</Grid> </Grid>
)} )}
) )
......
...@@ -6,7 +6,7 @@ import CalendarStandartCell from "./CalendarStandartCell.js/CalendarStandartCell ...@@ -6,7 +6,7 @@ import CalendarStandartCell from "./CalendarStandartCell.js/CalendarStandartCell
import CalendarTask from "./CalendarTask/CalendarTask"; import CalendarTask from "./CalendarTask/CalendarTask";
import ModalTask from "../UI/ModalTask/ModalTask"; import ModalTask from "../UI/ModalTask/ModalTask";
function MonthCalendarBody({month, year, tasks, createTaskInCellHandler, onChangeCellTaskTitle, currentTask, setCurrentTask, hourFormat, setHourFormat, onChangeCurrentTaskHandler}) { function MonthCalendarBody({month, year, tasks, createTaskInCellHandler, currentTask, setCurrentTask, hourFormat, setHourFormat, onChangeCurrentTaskHandler, sendNewTask}) {
const [hoursInDay, setHoursInDay] = useState(['8:00', '10:00', '12:00', '14:00', '16:00', '18:00', '20:00', '22:00']) const [hoursInDay, setHoursInDay] = useState(['8:00', '10:00', '12:00', '14:00', '16:00', '18:00', '20:00', '22:00'])
const [daysInMonth, setDaysInMonth] = useState([]) const [daysInMonth, setDaysInMonth] = useState([])
...@@ -121,7 +121,6 @@ function MonthCalendarBody({month, year, tasks, createTaskInCellHandler, onChang ...@@ -121,7 +121,6 @@ function MonthCalendarBody({month, year, tasks, createTaskInCellHandler, onChang
> >
<CalendarTask <CalendarTask
setCurrentTask={setCurrentTask} setCurrentTask={setCurrentTask}
onChange={(e)=>{onChangeCellTaskTitle(e)}}
year={year} year={year}
month={month} month={month}
tasks={tasks} tasks={tasks}
...@@ -161,26 +160,25 @@ function MonthCalendarBody({month, year, tasks, createTaskInCellHandler, onChang ...@@ -161,26 +160,25 @@ function MonthCalendarBody({month, year, tasks, createTaskInCellHandler, onChang
onChange={(e)=>{onChangeCurrentTaskHandler(e)}} onChange={(e)=>{onChangeCurrentTaskHandler(e)}}
/> />
<FormControl variant="outlined" sx={{width: '160px', marginBottom: '30px'}}> <FormControl variant="outlined" sx={{width: '160px', marginBottom: '30px'}}>
<InputLabel id="calendar-type-label">Приоритет</InputLabel> <InputLabel id="priority-type-label">Приоритет</InputLabel>
<Select <Select
labelId="calendar-type-label" labelId="priority-type-label"
id="calendar-type" id="priority-type"
onChange={()=>{}}
label="Приоритет" label="Приоритет"
sx={{width: '160px'}} sx={{width: '160px'}}
value={currentTask.priority} value={currentTask.priority}
name='priority' name='priority'
// onChange={(e)=>{onChangeCurrentTaskHandler(e)}} onChange={(e)=>{onChangeCurrentTaskHandler(e)}}
> >
<MenuItem value=""> <MenuItem value="">
<em>-- Выберите Приоритет --</em> <em>-- Выберите Приоритет --</em>
</MenuItem> </MenuItem>
<MenuItem value={"C"}>C</MenuItem>
<MenuItem value={"B"}>B</MenuItem>
<MenuItem value={"A"}>A</MenuItem> <MenuItem value={"A"}>A</MenuItem>
<MenuItem value={"B"}>B</MenuItem>
<MenuItem value={"C"}>C</MenuItem>
</Select> </Select>
</FormControl> </FormControl>
<Button sx={{marginRight: '40px'}}>Сохранить</Button> <Button sx={{marginRight: '40px'}} onClick={()=>{sendNewTask()}}>Сохранить</Button>
<Button>Удалить</Button> <Button>Удалить</Button>
</ModalTask> </ModalTask>
</> </>
......
...@@ -14,7 +14,7 @@ function MonthCalendar() { ...@@ -14,7 +14,7 @@ function MonthCalendar() {
const [year, setYear] = useState('') const [year, setYear] = useState('')
const [worker, setWorker] = useState(''); const [worker, setWorker] = useState('');
const [calendarType, setCalendarType] = useState('Месяц'); const [calendarType, setCalendarType] = useState('Месяц');
const [currentTask, setCurrentTask] = useState({title: '', description: '', priority: ''}) const [currentTask, setCurrentTask] = useState({title: '', description: '', priority: '', dateTimeStart: '', dateTimeDue:''})
useEffect(()=>{ useEffect(()=>{
setMonth(new Date().getMonth()) setMonth(new Date().getMonth())
...@@ -83,19 +83,19 @@ function MonthCalendar() { ...@@ -83,19 +83,19 @@ function MonthCalendar() {
const newTask = { const newTask = {
title:"Задача", title:"Задача",
description:"описание", description:"описание",
priority: "C", priority: "",
dateTimeStart: dateToISOLikeButLocal(new Date(year, month, dayNumber, hour, 0)), dateTimeStart: dateToISOLikeButLocal(new Date(year, month, dayNumber, hour, 0)),
dateTimeDue: dateToISOLikeButLocal(new Date(year, month, dayNumber, hourDue, 59)), dateTimeDue: dateToISOLikeButLocal(new Date(year, month, dayNumber, hourDue, 59)),
} }
// dispatch(addTask(newTask))
setCurrentTask((newTask)) setCurrentTask((newTask))
} }
const onChangeCellTaskTitle = (e) => { const sendNewTask = async () => {
e.stopPropagation() setCurrentTask(({
const value = e.target.value; ...currentTask,
const name = e.target.name; priority: currentTask.priority ? currentTask.priority : 'C'
setCurrentTask({ ...currentTask, [name]: value }) }))
await dispatch(addTask(currentTask))
} }
return ( return (
...@@ -116,12 +116,12 @@ function MonthCalendar() { ...@@ -116,12 +116,12 @@ function MonthCalendar() {
year={year} year={year}
tasks={tasks} tasks={tasks}
createTaskInCellHandler={createTaskInCellHandler} createTaskInCellHandler={createTaskInCellHandler}
onChangeCellTaskTitle={onChangeCellTaskTitle}
setCurrentTask={setCurrentTask} setCurrentTask={setCurrentTask}
hourFormat={hourFormat} hourFormat={hourFormat}
setHourFormat={setHourFormat} setHourFormat={setHourFormat}
currentTask={currentTask} currentTask={currentTask}
onChangeCurrentTaskHandler={onChangeCurrentTaskHandler} onChangeCurrentTaskHandler={onChangeCurrentTaskHandler}
sendNewTask={sendNewTask}
/> />
</> </>
); );
......
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