Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
planner-team-one
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
21
Issues
21
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Евгений Положенцев
planner-team-one
Commits
a601c1e6
Commit
a601c1e6
authored
Nov 11, 2022
by
Ermolaev Timur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#30
Реализовал изменение тайтла в уже существующей задачке
parent
84b37444
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
93 additions
and
16 deletions
+93
-16
CalendarTask.js
...components/MonthCalendarBody/CalendarTask/CalendarTask.js
+19
-3
MonthCalendarBody.js
...ont/src/components/MonthCalendarBody/MonthCalendarBody.js
+1
-0
MonthCalendarModalContent.js
...ts/MonthCalendarModalContent/MonthCalendarModalContent.js
+1
-1
MonthCalendar.js
planner-front/src/containers/MonthCalendar/MonthCalendar.js
+23
-9
tasksTypes.js
planner-front/src/store/actionTypes/tasksTypes.js
+5
-1
tasksActions.js
planner-front/src/store/actions/tasksActions.js
+31
-1
tasksReducer.js
planner-front/src/store/reducers/tasksReducer.js
+13
-1
No files found.
planner-front/src/components/MonthCalendarBody/CalendarTask/CalendarTask.js
View file @
a601c1e6
import
{
Grid
,
TextField
,
Typography
}
from
"@mui/material"
;
import
React
,
{
useEffect
,
useState
}
from
"react"
;
const
CalendarTask
=
({
year
,
month
,
tasks
,
day
,
hours
,
setCurrentTask
,
hourFormat
,
handleOpen
})
=>
{
const
CalendarTask
=
({
year
,
month
,
tasks
,
day
,
hours
,
setCurrentTask
,
hourFormat
,
handleOpen
,
currentTask
})
=>
{
const
[
thisCellCurrentTask
,
setThisCellCurrentTask
]
=
useState
({})
const
getTaskInDayCell
=
(
tasks
,
day
,
hours
)
=>
{
const
hour
=
parseInt
(
hours
.
split
(
':'
)[
0
])
let
hourDiffEnd
...
...
@@ -26,6 +27,21 @@ const CalendarTask = ({year, month, tasks, day, hours, setCurrentTask, hourForma
return
tasksCell
}
const
tasksCell
=
getTaskInDayCell
(
tasks
,
day
,
hours
)
useEffect
(()
=>
{
if
(
!
currentTask
.
title
)
{
setThisCellCurrentTask
({})
}
},
[
currentTask
])
const
renderText
=
(
i
,
task
)
=>
{
if
(
thisCellCurrentTask
&&
i
===
thisCellCurrentTask
.
i
)
{
return
(
<>
{
currentTask
.
title
}
<
/>
)
}
else
{
return
(
<>
{
task
.
title
}
<
/>
)
}
}
return
(
<>
{
tasksCell
.
length
?
tasksCell
.
map
((
task
,
i
)
=>
{
...
...
@@ -33,9 +49,9 @@ const CalendarTask = ({year, month, tasks, day, hours, setCurrentTask, hourForma
<
Grid
key
=
{
task
.
id
}
sx
=
{{
backgroundColor
:
'lightgreen'
,
whiteSpace
:
'nowrap'
,
overflow
:
'hidden'
,
textOverflow
:
'ellipsis'
,
padding
:
'10px'
,
borderBottom
:
'1px solid rgb(29, 161, 51);;'
}}
onClick
=
{(
e
)
=>
{
e
.
stopPropagation
();
setCurrentTask
(
task
);
handleOpen
(
e
)}}
onClick
=
{(
e
)
=>
{
e
.
stopPropagation
();
setCurrentTask
(
task
);
handleOpen
(
e
)
;
setThisCellCurrentTask
({...
task
,
i
:
i
})
}}
>
{
task
.
title
}
{
renderText
(
i
,
task
)
}
<
/Grid
>
)}
)
...
...
planner-front/src/components/MonthCalendarBody/MonthCalendarBody.js
View file @
a601c1e6
...
...
@@ -130,6 +130,7 @@ function MonthCalendarBody({month, year, tasks, createTaskInCellHandler, current
hours
=
{
hours
}
hourFormat
=
{
hourFormat
}
handleOpen
=
{
handleOpen
}
currentTask
=
{
currentTask
}
/>
<
/CalendarStandartCell
>
)
...
...
planner-front/src/components/MonthCalendarModalContent/MonthCalendarModalContent.js
View file @
a601c1e6
...
...
@@ -33,7 +33,7 @@ function MonthCalendarModalContent({title, onChangeCurrentTaskHandler, descripti
name
=
'priority'
onChange
=
{
onChangeCurrentTaskHandler
}
>
<
MenuItem
value
=
""
>
<
MenuItem
value
=
{
null
}
>
<
em
>--
Выберите
Приоритет
--<
/em
>
<
/MenuItem
>
<
MenuItem
value
=
{
"A"
}
>
A
<
/MenuItem
>
...
...
planner-front/src/containers/MonthCalendar/MonthCalendar.js
View file @
a601c1e6
...
...
@@ -3,7 +3,7 @@ import { useEffect, useState } from 'react';
import
{
useDispatch
,
useSelector
}
from
'react-redux'
;
import
MonthCalendarBody
from
'../../components/MonthCalendarBody/MonthCalendarBody'
;
import
MonthCalendarHeader
from
'../../components/MonthCalendarHeader/MonthCalendarHeader'
;
import
{
addTask
,
fetchTasks
}
from
'../../store/actions/tasksActions'
;
import
{
addTask
,
editTask
,
fetchTasks
}
from
'../../store/actions/tasksActions'
;
function
MonthCalendar
()
{
const
dispatch
=
useDispatch
();
...
...
@@ -14,8 +14,7 @@ function MonthCalendar() {
const
[
year
,
setYear
]
=
useState
(
''
)
const
[
worker
,
setWorker
]
=
useState
(
''
);
const
[
calendarType
,
setCalendarType
]
=
useState
(
'Месяц'
);
const
[
currentTask
,
setCurrentTask
]
=
useState
({
title
:
''
,
description
:
''
,
priority
:
''
,
dateTimeStart
:
''
,
dateTimeDue
:
''
})
console
.
log
(
currentTask
)
const
[
currentTask
,
setCurrentTask
]
=
useState
({
title
:
''
,
description
:
''
,
priority
:
null
,
dateTimeStart
:
''
,
dateTimeDue
:
''
})
useEffect
(()
=>
{
setMonth
(
new
Date
().
getMonth
())
setYear
(
new
Date
().
getFullYear
())
...
...
@@ -83,7 +82,7 @@ function MonthCalendar() {
const
newTask
=
{
title
:
"Задача"
,
description
:
"описание"
,
priority
:
""
,
priority
:
null
,
dateTimeStart
:
dateToISOLikeButLocal
(
new
Date
(
year
,
month
,
dayNumber
,
hour
,
0
)),
dateTimeDue
:
dateToISOLikeButLocal
(
new
Date
(
year
,
month
,
dayNumber
,
hourDue
,
59
)),
}
...
...
@@ -91,12 +90,27 @@ function MonthCalendar() {
}
const
sendNewTask
=
async
()
=>
{
setCurrentTask
(({
if
(
currentTask
.
id
)
{
setCurrentTask
(()
=>
{
return
{
...
currentTask
,
priority
:
currentTask
.
priority
?
currentTask
.
priority
:
'C'
}))
}}
)
delete
currentTask
.
infoForCell
await
dispatch
(
editTask
(
currentTask
))
}
else
{
setCurrentTask
(()
=>
{
return
{
...
currentTask
,
priority
:
currentTask
.
priority
?
currentTask
.
priority
:
'C'
}}
)
delete
currentTask
.
infoForCell
await
dispatch
(
addTask
(
currentTask
))
}
}
return
(
<>
...
...
planner-front/src/store/actionTypes/tasksTypes.js
View file @
a601c1e6
...
...
@@ -5,3 +5,7 @@ export const FETCH_TASKS_FAILURE = "FETCH_TASKS_FAILURE";
export
const
ADD_NEW_TASK_REQUEST
=
"ADD_NEW_TASK_REQUEST"
;
export
const
ADD_NEW_TASK_SUCCESS
=
"ADD_NEW_TASK_SUCCESS"
;
export
const
ADD_NEW_TASK_FAILURE
=
"ADD_NEW_TASK_FAILURE"
;
export
const
EDIT_TASK_REQUEST
=
"EDIT_TASK_REQUEST"
;
export
const
EDIT_TASK_SUCCESS
=
"EDIT_TASK_SUCCESS"
;
export
const
EDIT_TASK_FAILURE
=
"EDIT_TASK_FAILURE"
;
\ No newline at end of file
planner-front/src/store/actions/tasksActions.js
View file @
a601c1e6
import
{
ADD_NEW_TASK_FAILURE
,
ADD_NEW_TASK_REQUEST
,
ADD_NEW_TASK_SUCCESS
,
FETCH_TASKS_FAILURE
,
FETCH_TASKS_REQUEST
,
FETCH_TASKS_SUCCESS
}
from
"../actionTypes/tasksTypes"
;
import
{
ADD_NEW_TASK_FAILURE
,
ADD_NEW_TASK_REQUEST
,
ADD_NEW_TASK_SUCCESS
,
EDIT_TASK_FAILURE
,
EDIT_TASK_REQUEST
,
EDIT_TASK_SUCCESS
,
FETCH_TASKS_FAILURE
,
FETCH_TASKS_REQUEST
,
FETCH_TASKS_SUCCESS
}
from
"../actionTypes/tasksTypes"
;
import
axios
from
'../../axiosPlanner'
const
fetchTasksRequest
=
()
=>
{
...
...
@@ -54,3 +54,33 @@ export const addTask = (task) => {
}
}
}
const
editTaskRequest
=
()
=>
{
return
{
type
:
EDIT_TASK_REQUEST
}
};
const
editTaskSuccess
=
()
=>
{
return
{
type
:
EDIT_TASK_SUCCESS
}
};
const
editTaskFailure
=
(
error
)
=>
{
return
{
type
:
EDIT_TASK_FAILURE
,
error
}
};
export
const
editTask
=
(
task
)
=>
{
return
async
(
dispatch
,
getState
)
=>
{
dispatch
(
editTaskRequest
());
const
token
=
getState
().
users
?.
user
?.
token
;
try
{
await
axios
.
put
(
"/tasks"
,
task
,
{
headers
:
{
'Authorization'
:
'IwGVRaksGTWtnKlOZd7zJ'
}
});
dispatch
(
editTaskSuccess
())
dispatch
(
fetchTasks
())
}
catch
(
error
)
{
dispatch
(
editTaskFailure
(
error
.
response
.
data
));
}
}
}
\ No newline at end of file
planner-front/src/store/reducers/tasksReducer.js
View file @
a601c1e6
import
{
FETCH_TASKS_FAILURE
,
FETCH_TASKS_REQUEST
,
FETCH_TASKS_SUCCESS
}
from
"../actionTypes/tasksTypes"
;
import
{
ADD_NEW_TASK_FAILURE
,
ADD_NEW_TASK_REQUEST
,
ADD_NEW_TASK_SUCCESS
,
EDIT_TASK_FAILURE
,
EDIT_TASK_REQUEST
,
EDIT_TASK_SUCCESS
,
FETCH_TASKS_FAILURE
,
FETCH_TASKS_REQUEST
,
FETCH_TASKS_SUCCESS
}
from
"../actionTypes/tasksTypes"
;
const
initialState
=
{
tasks
:
[],
...
...
@@ -41,6 +41,18 @@ const tasksReduсer = (state = initialState, action) => {
return
{...
state
,
loading
:
false
,
tasks
:
newArr
};
case
FETCH_TASKS_FAILURE
:
return
{...
state
,
loading
:
false
,
error
:
action
.
error
};
case
ADD_NEW_TASK_SUCCESS
:
return
{...
state
,
loading
:
false
};
case
ADD_NEW_TASK_REQUEST
:
return
{...
state
,
loading
:
true
};
case
ADD_NEW_TASK_FAILURE
:
return
{...
state
,
loading
:
false
,
error
:
action
.
error
};
case
EDIT_TASK_SUCCESS
:
return
{...
state
,
loading
:
false
};
case
EDIT_TASK_REQUEST
:
return
{...
state
,
loading
:
true
};
case
EDIT_TASK_FAILURE
:
return
{...
state
,
loading
:
false
,
error
:
action
.
error
};
default
:
return
state
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment