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
Hide 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
{
Grid
,
TextField
,
Typography
}
from
"@mui/material"
;
import
React
,
{
useEffect
,
useState
}
from
"react"
;
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
getTaskInDayCell
=
(
tasks
,
day
,
hours
)
=>
{
const
hour
=
parseInt
(
hours
.
split
(
':'
)[
0
])
const
hour
=
parseInt
(
hours
.
split
(
':'
)[
0
])
let
hourDiffEnd
let
hourDiffEnd
...
@@ -26,6 +27,21 @@ const CalendarTask = ({year, month, tasks, day, hours, setCurrentTask, hourForma
...
@@ -26,6 +27,21 @@ const CalendarTask = ({year, month, tasks, day, hours, setCurrentTask, hourForma
return
tasksCell
return
tasksCell
}
}
const
tasksCell
=
getTaskInDayCell
(
tasks
,
day
,
hours
)
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
(
<>
return
(
<>
{
tasksCell
.
length
?
tasksCell
.
map
((
task
,
i
)
=>
{
tasksCell
.
length
?
tasksCell
.
map
((
task
,
i
)
=>
{
{
...
@@ -33,9 +49,9 @@ const CalendarTask = ({year, month, tasks, day, hours, setCurrentTask, hourForma
...
@@ -33,9 +49,9 @@ const CalendarTask = ({year, month, tasks, day, hours, setCurrentTask, hourForma
<
Grid
<
Grid
key
=
{
task
.
id
}
key
=
{
task
.
id
}
sx
=
{{
backgroundColor
:
'lightgreen'
,
whiteSpace
:
'nowrap'
,
overflow
:
'hidden'
,
textOverflow
:
'ellipsis'
,
padding
:
'10px'
,
borderBottom
:
'1px solid rgb(29, 161, 51);;'
}}
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
>
<
/Grid
>
)}
)}
)
)
...
...
planner-front/src/components/MonthCalendarBody/MonthCalendarBody.js
View file @
a601c1e6
...
@@ -130,6 +130,7 @@ function MonthCalendarBody({month, year, tasks, createTaskInCellHandler, current
...
@@ -130,6 +130,7 @@ function MonthCalendarBody({month, year, tasks, createTaskInCellHandler, current
hours
=
{
hours
}
hours
=
{
hours
}
hourFormat
=
{
hourFormat
}
hourFormat
=
{
hourFormat
}
handleOpen
=
{
handleOpen
}
handleOpen
=
{
handleOpen
}
currentTask
=
{
currentTask
}
/>
/>
<
/CalendarStandartCell
>
<
/CalendarStandartCell
>
)
)
...
...
planner-front/src/components/MonthCalendarModalContent/MonthCalendarModalContent.js
View file @
a601c1e6
...
@@ -33,7 +33,7 @@ function MonthCalendarModalContent({title, onChangeCurrentTaskHandler, descripti
...
@@ -33,7 +33,7 @@ function MonthCalendarModalContent({title, onChangeCurrentTaskHandler, descripti
name
=
'priority'
name
=
'priority'
onChange
=
{
onChangeCurrentTaskHandler
}
onChange
=
{
onChangeCurrentTaskHandler
}
>
>
<
MenuItem
value
=
""
>
<
MenuItem
value
=
{
null
}
>
<
em
>--
Выберите
Приоритет
--<
/em
>
<
em
>--
Выберите
Приоритет
--<
/em
>
<
/MenuItem
>
<
/MenuItem
>
<
MenuItem
value
=
{
"A"
}
>
A
<
/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';
...
@@ -3,7 +3,7 @@ import { useEffect, useState } from 'react';
import
{
useDispatch
,
useSelector
}
from
'react-redux'
;
import
{
useDispatch
,
useSelector
}
from
'react-redux'
;
import
MonthCalendarBody
from
'../../components/MonthCalendarBody/MonthCalendarBody'
;
import
MonthCalendarBody
from
'../../components/MonthCalendarBody/MonthCalendarBody'
;
import
MonthCalendarHeader
from
'../../components/MonthCalendarHeader/MonthCalendarHeader'
;
import
MonthCalendarHeader
from
'../../components/MonthCalendarHeader/MonthCalendarHeader'
;
import
{
addTask
,
fetchTasks
}
from
'../../store/actions/tasksActions'
;
import
{
addTask
,
editTask
,
fetchTasks
}
from
'../../store/actions/tasksActions'
;
function
MonthCalendar
()
{
function
MonthCalendar
()
{
const
dispatch
=
useDispatch
();
const
dispatch
=
useDispatch
();
...
@@ -14,8 +14,7 @@ function MonthCalendar() {
...
@@ -14,8 +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
:
''
,
dateTimeStart
:
''
,
dateTimeDue
:
''
})
const
[
currentTask
,
setCurrentTask
]
=
useState
({
title
:
''
,
description
:
''
,
priority
:
null
,
dateTimeStart
:
''
,
dateTimeDue
:
''
})
console
.
log
(
currentTask
)
useEffect
(()
=>
{
useEffect
(()
=>
{
setMonth
(
new
Date
().
getMonth
())
setMonth
(
new
Date
().
getMonth
())
setYear
(
new
Date
().
getFullYear
())
setYear
(
new
Date
().
getFullYear
())
...
@@ -83,7 +82,7 @@ function MonthCalendar() {
...
@@ -83,7 +82,7 @@ function MonthCalendar() {
const
newTask
=
{
const
newTask
=
{
title
:
"Задача"
,
title
:
"Задача"
,
description
:
"описание"
,
description
:
"описание"
,
priority
:
""
,
priority
:
null
,
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
)),
}
}
...
@@ -91,11 +90,26 @@ function MonthCalendar() {
...
@@ -91,11 +90,26 @@ function MonthCalendar() {
}
}
const
sendNewTask
=
async
()
=>
{
const
sendNewTask
=
async
()
=>
{
setCurrentTask
(({
...
currentTask
,
if
(
currentTask
.
id
)
{
priority
:
currentTask
.
priority
?
currentTask
.
priority
:
'C'
setCurrentTask
(()
=>
{
}))
return
{
await
dispatch
(
addTask
(
currentTask
))
...
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
(
return
(
...
...
planner-front/src/store/actionTypes/tasksTypes.js
View file @
a601c1e6
...
@@ -4,4 +4,8 @@ export const FETCH_TASKS_FAILURE = "FETCH_TASKS_FAILURE";
...
@@ -4,4 +4,8 @@ export const FETCH_TASKS_FAILURE = "FETCH_TASKS_FAILURE";
export
const
ADD_NEW_TASK_REQUEST
=
"ADD_NEW_TASK_REQUEST"
;
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_SUCCESS
=
"ADD_NEW_TASK_SUCCESS"
;
export
const
ADD_NEW_TASK_FAILURE
=
"ADD_NEW_TASK_FAILURE"
;
export
const
ADD_NEW_TASK_FAILURE
=
"ADD_NEW_TASK_FAILURE"
;
\ No newline at end of file
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'
import
axios
from
'../../axiosPlanner'
const
fetchTasksRequest
=
()
=>
{
const
fetchTasksRequest
=
()
=>
{
...
@@ -53,4 +53,34 @@ export const addTask = (task) => {
...
@@ -53,4 +53,34 @@ export const addTask = (task) => {
dispatch
(
addTaskFailure
(
error
.
response
.
data
));
dispatch
(
addTaskFailure
(
error
.
response
.
data
));
}
}
}
}
}
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
=
{
const
initialState
=
{
tasks
:
[],
tasks
:
[],
...
@@ -41,6 +41,18 @@ const tasksReduсer = (state = initialState, action) => {
...
@@ -41,6 +41,18 @@ const tasksReduсer = (state = initialState, action) => {
return
{...
state
,
loading
:
false
,
tasks
:
newArr
};
return
{...
state
,
loading
:
false
,
tasks
:
newArr
};
case
FETCH_TASKS_FAILURE
:
case
FETCH_TASKS_FAILURE
:
return
{...
state
,
loading
:
false
,
error
:
action
.
error
};
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
:
default
:
return
state
;
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