Commit 53fe8f38 authored by Ermolaev Timur's avatar Ermolaev Timur

#135 Добавил мод редактирования

parent d56c1f40
...@@ -6,7 +6,6 @@ import CalendarStandartCell from "../../UI/CalendarStandartCell/CalendarStandart ...@@ -6,7 +6,6 @@ import CalendarStandartCell from "../../UI/CalendarStandartCell/CalendarStandart
import ModalTask from "../../UI/ModalTask/ModalTask" import ModalTask from "../../UI/ModalTask/ModalTask"
import MonthCalendarModalContent from "../../UI/CalendarModalTaskContent/CalendarModalTaskContent"; import MonthCalendarModalContent from "../../UI/CalendarModalTaskContent/CalendarModalTaskContent";
import CalendarRowDay from "./CalendarRowDay/CalendarRowDay"; import CalendarRowDay from "./CalendarRowDay/CalendarRowDay";
import { useSelector } from "react-redux";
function MonthCalendarBody({ month, year, tasks, createTaskInCellHandler, currentTask, setCurrentTask, hourFormat, setHourFormat, onChangeCurrentTaskHandler, sendNewTaskHandler, deleteTaskHandler, cellSizes, hoursInDay, daysInMonth, dragTaskHandler, createCopyTask, setCopyTask, copyTask}) { function MonthCalendarBody({ month, year, tasks, createTaskInCellHandler, currentTask, setCurrentTask, hourFormat, setHourFormat, onChangeCurrentTaskHandler, sendNewTaskHandler, deleteTaskHandler, cellSizes, hoursInDay, daysInMonth, dragTaskHandler, createCopyTask, setCopyTask, copyTask}) {
......
import { AppBar, Button, Toolbar, Typography } from '@mui/material'; import { AppBar, Toolbar, } from '@mui/material';
import { Box } from '@mui/system'; import { Box } from '@mui/system';
import ButtonSwapCalendar from '../../UI/ButtonSwapCalendar/ButtonSwapCalendar'; import ButtonSwapCalendar from '../../UI/ButtonSwapCalendar/ButtonSwapCalendar';
import CalendarUserDisplayName from '../../UI/CalendarUserDisplayName/CalendarUserDisplayName'; import CalendarUserDisplayName from '../../UI/CalendarUserDisplayName/CalendarUserDisplayName';
......
import Box from '@mui/material/Box'; import Box from '@mui/material/Box';
import Modal from '@mui/material/Modal'; import Modal from '@mui/material/Modal';
import { useCallback, useEffect, useMemo, useState } from 'react'; import { useCallback, useEffect, useState } from 'react';
export default function ModalTask({ modal, handleClose, children, week }) { export default function ModalTask({ modal, handleClose, children, week }) {
...@@ -38,7 +38,7 @@ export default function ModalTask({ modal, handleClose, children, week }) { ...@@ -38,7 +38,7 @@ export default function ModalTask({ modal, handleClose, children, week }) {
return modal.yClickСordinates - modal.yDiv - modal.yDivClick - ((modal.yClickСordinates + 470) - windowDimenion.winHeight) - 30 return modal.yClickСordinates - modal.yDiv - modal.yDivClick - ((modal.yClickСordinates + 470) - windowDimenion.winHeight) - 30
} }
} }
}, [windowDimenion.winHeight, modal]) }, [windowDimenion.winHeight, modal, week])
const getXCordinatesToModal = useCallback(() => { const getXCordinatesToModal = useCallback(() => {
if (windowDimenion.winWidth > modal.xClickСordinates + 270 + modal.xDiv) { if (windowDimenion.winWidth > modal.xClickСordinates + 270 + modal.xDiv) {
......
...@@ -94,7 +94,7 @@ function CalendarWeekTask({ height, width, left, top, task, zIndex, handleOpen, ...@@ -94,7 +94,7 @@ function CalendarWeekTask({ height, width, left, top, task, zIndex, handleOpen,
e.stopPropagation(); e.stopPropagation();
setCopyTask(task) setCopyTask(task)
}, [task, setCopyTask]) }, [task, setCopyTask])
console.log(tasksLength)
return ( return (
<Box <Box
draggable={true} draggable={true}
......
...@@ -22,6 +22,9 @@ import BasicSelect from "../../UI/Select/Select"; ...@@ -22,6 +22,9 @@ import BasicSelect from "../../UI/Select/Select";
import CalendarMonthIcon from '@mui/icons-material/CalendarMonth'; import CalendarMonthIcon from '@mui/icons-material/CalendarMonth';
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown'; import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
import KeyboardArrowUpIcon from '@mui/icons-material/KeyboardArrowUp'; import KeyboardArrowUpIcon from '@mui/icons-material/KeyboardArrowUp';
import { useNavigate } from "react-router-dom";
import { useDispatch } from "react-redux";
import { activateCreateCopyTasksMode } from "../../../store/actions/tasksActions";
const weekDays = ["Вс","Пн","Вт","Ср","Чт","Пт","Сб" ]; const weekDays = ["Вс","Пн","Вт","Ср","Чт","Пт","Сб" ];
...@@ -40,9 +43,10 @@ const TableRowTask= ({ ...@@ -40,9 +43,10 @@ const TableRowTask= ({
onToggleEditMode, onToggleEditMode,
onToggleEditModeDone, onToggleEditModeDone,
})=>{ })=>{
const [open, setOpen] = React.useState(false); const [open, setOpen] = React.useState(false);
const navigate = useNavigate()
const dispatch = useDispatch()
const roudHourUp =(dateIso)=>{ const roudHourUp =(dateIso)=>{
let m = moment(dateIso); let m = moment(dateIso);
let roundUp = m.minute() || m.second() || m.millisecond() ? m.add(1, 'hour').startOf('hour') : m.startOf('hour'); let roundUp = m.minute() || m.second() || m.millisecond() ? m.add(1, 'hour').startOf('hour') : m.startOf('hour');
...@@ -59,7 +63,7 @@ const TableRowTask= ({ ...@@ -59,7 +63,7 @@ const TableRowTask= ({
return weekDays[date.day()]; return weekDays[date.day()];
} }
const calendarOpen=(taskId)=>{ const calendarOpen=(taskId)=>{
console.log('task Id in Calendar Open' , taskId) dispatch(activateCreateCopyTasksMode(task, navigate))
} }
return ( return (
...@@ -159,11 +163,11 @@ const TableRowTask= ({ ...@@ -159,11 +163,11 @@ const TableRowTask= ({
user:user user:user
}} }}
/> />
{task.isEditMode && task.author.id===user.id ? ( {task.dateTimeTasks.length === 0 && task.author.id === user.id ? (
<TableCell> <TableCell>
<Tooltip title="Перейти в календарь"> <Tooltip title="Перейти в календарь">
<IconButton <IconButton
onClick={() => { calendarOpen(task.id)}} onClick={() => { calendarOpen(task)}}
> >
<CalendarMonthIcon /> <CalendarMonthIcon />
</IconButton> </IconButton>
...@@ -172,7 +176,7 @@ const TableRowTask= ({ ...@@ -172,7 +176,7 @@ const TableRowTask= ({
</TableCell> </TableCell>
) : ( ) : (
task.dateTimeTasks.length>1 ? task.dateTimeTasks.length >= 1 ?
<TableCell> <TableCell>
<IconButton <IconButton
aria-label="expand row" aria-label="expand row"
...@@ -286,7 +290,7 @@ const TableRowTask= ({ ...@@ -286,7 +290,7 @@ const TableRowTask= ({
</TableCell>):null} </TableCell>):null}
</TableRow> </TableRow>
{task.dateTimeTasks.length>1? {task.dateTimeTasks.length>=1?
<TableRow> <TableRow>
<TableCell style={{ paddingBottom: 0, paddingTop: 0 }} colSpan={11}> <TableCell style={{ paddingBottom: 0, paddingTop: 0 }} colSpan={11}>
<Collapse in={open} timeout="auto" unmountOnExit> <Collapse in={open} timeout="auto" unmountOnExit>
......
...@@ -189,7 +189,6 @@ export default function EnhancedTable() { ...@@ -189,7 +189,6 @@ export default function EnhancedTable() {
setRecievedTasks(tasksFilteredByProject) setRecievedTasks(tasksFilteredByProject)
setFilterProjectTumbler(true) setFilterProjectTumbler(true)
} }
// if ( // if (
// tasks && // tasks &&
// tasks?.length > 0 // tasks?.length > 0
......
...@@ -8,15 +8,15 @@ import DefaultModal from '../../components/UI/DefaultModal/DefaultModal'; ...@@ -8,15 +8,15 @@ import DefaultModal from '../../components/UI/DefaultModal/DefaultModal';
import { AllHoursOneHourFormat, AllHoursTwoHourFormat } from '../../constants'; import { AllHoursOneHourFormat, AllHoursTwoHourFormat } from '../../constants';
import { getWeekInfoString, getWeekFromCurrentDate, dateToISOLikeButLocal } from '../../helpers/CalendarHelpers'; import { getWeekInfoString, getWeekFromCurrentDate, dateToISOLikeButLocal } from '../../helpers/CalendarHelpers';
import { fetchAllUserProjects } from '../../store/actions/projectsActions'; import { fetchAllUserProjects } from '../../store/actions/projectsActions';
import { addCalendarTask, addCopyCalendarTask, deleteCalendarTask, editCalendarTask, fetchCalendarTasks } from '../../store/actions/tasksActions'; import { addCalendarTask, addCopyCalendarTask, deactivateCreateCopyTasksMode, deleteCalendarTask, editCalendarTask, fetchCalendarTasks } from '../../store/actions/tasksActions';
import { fetchCurrentCalendarDisplayName } from '../../store/actions/usersActions'; import { fetchCurrentCalendarDisplayName } from '../../store/actions/usersActions';
function WeekCalendar() { function WeekCalendar() {
const dispatch = useDispatch(); const dispatch = useDispatch();
const { calendarTasks } = useSelector(state => state.tasks); const { calendarTasks, copyMode } = useSelector(state => state.tasks);
const { user, currentCalendarDisplayName } = useSelector(state => state.users); const { user, currentCalendarDisplayName } = useSelector(state => state.users);
const { allUserProjects, project } = useSelector(state => state.projects) const { allUserProjects} = useSelector(state => state.projects)
console.log(copyMode)
const [weekGoal, setWeekGoal] = useState('Наладить режим сна') const [weekGoal, setWeekGoal] = useState('Наладить режим сна')
const [weekPriorities, setWeekPriorities] = useState({ priorityOne: 'Один', priorityTwo: 'Два', priorityThree: 'Три' }) const [weekPriorities, setWeekPriorities] = useState({ priorityOne: 'Один', priorityTwo: 'Два', priorityThree: 'Три' })
const [workerInfo, setWorkerInfo] = useState({ project: '', worker: '' }); const [workerInfo, setWorkerInfo] = useState({ project: '', worker: '' });
...@@ -33,8 +33,9 @@ function WeekCalendar() { ...@@ -33,8 +33,9 @@ function WeekCalendar() {
const month = new Date().getMonth() const month = new Date().getMonth()
const currentDay = moment().date() const currentDay = moment().date()
setDateNow({ year: year, month: month, currentDay: currentDay }) setDateNow({ year: year, month: month, currentDay: currentDay })
dispatch(fetchCalendarTasks(user.id)) return () =>{
dispatch(fetchAllUserProjects()) dispatch(deactivateCreateCopyTasksMode())
}
}, [dispatch, user.id]) }, [dispatch, user.id])
useEffect(() => { useEffect(() => {
......
...@@ -28,4 +28,7 @@ export const DELETE_DATETIMETASK_FAILURE = "DELETE_TASK_FAILURE"; ...@@ -28,4 +28,7 @@ export const DELETE_DATETIMETASK_FAILURE = "DELETE_TASK_FAILURE";
export const FETCH_ALL_TASKS_BY_MEMBERSHIP_REQUEST = "FETCH_ALL_TASKS_BY_MEMBERSHIP_REQUEST"; export const FETCH_ALL_TASKS_BY_MEMBERSHIP_REQUEST = "FETCH_ALL_TASKS_BY_MEMBERSHIP_REQUEST";
export const FETCH_ALL_TASKS_BY_MEMBERSHIP_SUCCESS = "FETCH_ALL_TASKS_BY_MEMBERSHIP_SUCCESS"; export const FETCH_ALL_TASKS_BY_MEMBERSHIP_SUCCESS = "FETCH_ALL_TASKS_BY_MEMBERSHIP_SUCCESS";
export const FETCH_ALL_TASKS_BY_MEMBERSHIP_FAILURE = "FETCH_ALL_TASKS_BY_MEMBERSHIP_FAILURE"; export const FETCH_ALL_TASKS_BY_MEMBERSHIP_FAILURE = "FETCH_ALL_TASKS_BY_MEMBERSHIP_FAILURE";
\ No newline at end of file
export const ACTIVATE_CREATE_COPY_TASKS_MODE = "ACTIVATE_CREATE_COPY_TASKS_MODE"
export const DEACTIVATE_CREATE_COPY_TASKS_MODE = "DEACTIVATE_CREATE_COPY_TASKS_MODE"
\ No newline at end of file
...@@ -18,7 +18,9 @@ import { ...@@ -18,7 +18,9 @@ import {
DELETE_DATETIMETASK_FAILURE, DELETE_DATETIMETASK_FAILURE,
DELETE_DATETIMETASK_SUCCESS, DELETE_DATETIMETASK_SUCCESS,
DELETE_DATETIMETASK_REQUEST, DELETE_DATETIMETASK_REQUEST,
FETCH_ALL_TASKS_BY_MEMBERSHIP_SUCCESS FETCH_ALL_TASKS_BY_MEMBERSHIP_SUCCESS,
DEACTIVATE_CREATE_COPY_TASKS_MODE,
ACTIVATE_CREATE_COPY_TASKS_MODE
} from "../actionTypes/tasksTypes"; } from "../actionTypes/tasksTypes";
import axios from '../../axiosPlanner' import axios from '../../axiosPlanner'
...@@ -294,4 +296,13 @@ export const addTaskToUserTasksTable = (task) => { ...@@ -294,4 +296,13 @@ export const addTaskToUserTasksTable = (task) => {
} }
} }
/** end */ /** end */
\ No newline at end of file
export const activateCreateCopyTasksMode = (task, navigate) => {
navigate('/')
return {type: ACTIVATE_CREATE_COPY_TASKS_MODE, task}
}
export const deactivateCreateCopyTasksMode = () => {
return {type: DEACTIVATE_CREATE_COPY_TASKS_MODE}
}
\ No newline at end of file
...@@ -18,10 +18,17 @@ import { ...@@ -18,10 +18,17 @@ import {
DELETE_DATETIMETASK_FAILURE, DELETE_DATETIMETASK_FAILURE,
DELETE_DATETIMETASK_SUCCESS, DELETE_DATETIMETASK_SUCCESS,
DELETE_DATETIMETASK_REQUEST, DELETE_DATETIMETASK_REQUEST,
FETCH_ALL_TASKS_BY_MEMBERSHIP_SUCCESS FETCH_ALL_TASKS_BY_MEMBERSHIP_SUCCESS,
ACTIVATE_CREATE_COPY_TASKS_MODE,
DEACTIVATE_CREATE_COPY_TASKS_MODE
} from "../actionTypes/tasksTypes"; } from "../actionTypes/tasksTypes";
const initialState = { const initialState = {
copyMode: {
working: false,
task: null,
},
tasks: [],
calendarTasks: [], calendarTasks: [],
loading: false, loading: false,
error: null, error: null,
...@@ -114,6 +121,10 @@ const tasksReduсer = (state = initialState, action) => { ...@@ -114,6 +121,10 @@ const tasksReduсer = (state = initialState, action) => {
return {...state, loading: true}; return {...state, loading: true};
case DELETE_DATETIMETASK_FAILURE: case DELETE_DATETIMETASK_FAILURE:
return {...state, loading: false, error: action.error}; return {...state, loading: false, error: action.error};
case ACTIVATE_CREATE_COPY_TASKS_MODE:
return {...state, copyMode: {working: true, task: action.task}}
case DEACTIVATE_CREATE_COPY_TASKS_MODE:
return {...state, copyMode: {working: false, task: null}}
default: default:
return state; return state;
} }
......
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