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
6fcaa7f7
Commit
6fcaa7f7
authored
Nov 17, 2022
by
Нелли Ибрагимова
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
наметила функцию добавления задачи
parent
80837de7
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
75 deletions
+68
-75
NewTaskForm.js
...ner-front/src/components/MyTasksCompoments/NewTaskForm.js
+53
-43
MyTasks.js
planner-front/src/containers/MyTasks/MyTasks.js
+15
-32
No files found.
planner-front/src/components/MyTasksCompoments/NewTaskForm.js
View file @
6fcaa7f7
...
...
@@ -20,58 +20,68 @@ import moment from "moment";
import
CustomTableCell
from
"../../components/MyTasksCompoments/CustomTableCell"
;
import
MaterialUIPickers
from
"../../components/MyTasksCompoments/DateTimePicker/DateTimePicker"
;
import
BasicSelect
from
"../../components/UI/Select/Select"
;
import
{
fetchAllTasks
,
deleteTask
,
editTask
,
addTask
}
from
"../../store/actions/tasksActions"
;
import
{
addTask
}
from
"../../store/actions/tasksActions"
;
export
default
function
NewTaskForm
(
props
)
{
const
dispatch
=
useDispatch
();
const
user
=
useSelector
((
state
)
=>
state
.
users
.
user
);
const
current
=
new
Date
();
const
date
=
`
${
current
.
getDate
()}
/
${
current
.
getMonth
()
+
1
}
/
${
current
.
getFullYear
()}
`
;
// const onToggleEditModeDone = (id) => {
// const newTasks = recievedTasks.map((task) => {
// if (task.id === id) {
// return {
// ...task,
// isEditMode: false,
// readOnly: true,
// };
// }
// return task;
// });
// setRecievedTasks(newTasks);
// };
const
task
=
{
const
[
task
,
setTask
]
=
useState
(
{
id
:
0
,
title
:
""
,
description
:
""
,
createdAt
:
""
,
createdAt
:
date
,
dateTimeStart
:
null
,
dateTimeDue
:
null
,
accomplish
:
""
,
priority
:
""
,
author
:
{
name
:
""
,
},
author
:
user
,
executors
:
[
{
name
:
""
}
],
isEditMode
:
false
,
readOnly
:
true
};
}
);
const
onToggleEditMode
=
(
id
)
=>
{
console
.
log
(
task
)
const
newTask
=
((
task
)
=>
{
if
(
task
.
id
===
id
)
{
return
{
...
task
,
isEditMode
:
true
,
readOnly
:
false
,
};
}
return
task
;
});
setTask
(
newTask
);
};
console
.
log
(
task
)
const
onToggleEditModeDone
=
(
id
)
=>
{
const
newTasks
=
(
task
)
=>
{
if
(
task
.
id
===
id
)
{
return
{
...
task
,
isEditMode
:
false
,
readOnly
:
true
,
};
}
return
task
;
};
setTask
(
newTasks
);
};
const
HandleAddTask
=
()
=>
{
console
.
log
(
task
)
dispatch
(
addTask
(
task
))
}
return
(
<
TableRow
hover
key
=
{
task
.
id
}
>
...
...
@@ -167,7 +177,7 @@ export default function NewTaskForm (props) {
{
task
.
isEditMode
?
(
<
IconButton
aria
-
label
=
"done"
onClick
=
{()
=>
{
props
.
onToggleEditModeDone
(
task
.
id
);
props
.
HandleEdit
Task
(
task
)
}}
onClick
=
{()
=>
{
onToggleEditModeDone
(
task
.
id
);
HandleAdd
Task
(
task
)
}}
>
<
Done
/>
<
/IconButton
>
...
...
@@ -181,7 +191,7 @@ export default function NewTaskForm (props) {
)}
<
/TableCell
>
<
TableCell
>
<
Tooltip
title
=
"Delete"
>
{
/*
<Tooltip title="Delete">
<IconButton
onClick={(id) => {
props.deleteHandle(task.id);
...
...
@@ -189,7 +199,7 @@ export default function NewTaskForm (props) {
>
<DeleteIcon />
</IconButton>
<
/Tooltip
>
</Tooltip>
*/
}
<
/TableCell
>
<
/TableRow
>
);
...
...
planner-front/src/containers/MyTasks/MyTasks.js
View file @
6fcaa7f7
...
...
@@ -56,6 +56,7 @@ function stableSort(array, comparator) {
}
export
default
function
EnhancedTable
()
{
const
dispatch
=
useDispatch
();
useEffect
(()
=>
{
...
...
@@ -63,18 +64,21 @@ export default function EnhancedTable() {
},
[
dispatch
]);
const
tasks
=
useSelector
((
state
)
=>
state
.
tasks
.
tasks
);
console
.
log
(
tasks
)
const
[
recievedTasks
,
setRecievedTasks
]
=
useState
([]);
const
[
order
,
setOrder
]
=
useState
(
"asc"
);
const
[
orderBy
,
setOrderBy
]
=
useState
(
"id"
);
const
[
page
,
setPage
]
=
useState
(
0
);
const
[
rowsPerPage
,
setRowsPerPage
]
=
useState
(
5
);
const
[
modal
,
setModal
]
=
useState
({
open
:
false
,
task
:
null
,
});
const
projects
=
[
"project1"
,
"project2"
,
"project3"
]
const
[
order
,
setOrder
]
=
React
.
useState
(
"asc"
);
const
[
orderBy
,
setOrderBy
]
=
React
.
useState
(
"id"
);
const
[
page
,
setPage
]
=
React
.
useState
(
0
);
const
[
rowsPerPage
,
setRowsPerPage
]
=
React
.
useState
(
5
);
console
.
log
(
tasks
)
const
handleRequestSort
=
(
event
,
property
)
=>
{
const
isAsc
=
orderBy
===
property
&&
order
===
"asc"
;
...
...
@@ -111,6 +115,7 @@ console.log(tasks)
const
name
=
e
.
target
.
name
;
const
{
id
}
=
task
;
const
newTasks
=
recievedTasks
.
map
((
task
)
=>
{
console
.
log
(
task
)
if
(
task
.
id
===
id
)
{
return
{
...
task
,
[
name
]:
value
};
}
...
...
@@ -182,32 +187,10 @@ console.log(tasks)
dispatch
(
editTask
(
task
))
}
const
addTask
=
()
=>
{
// let newTasks=[...tasks]
tasks
.
unshift
({
title
:
""
,
description
:
""
,
priority
:
""
,
author
:
""
,
executor
:
""
,
dateTimeStart
:
""
,
dateTimeDue
:
""
,
id
:
4
,
createdAt
:
""
,
accomplish
:
" "
,
});
// tasks=newTasks;
};
const
deleteHandle
=
(
id
)
=>
{
dispatch
(
deleteTask
(
id
));
};
const
[
modal
,
setModal
]
=
useState
({
open
:
false
,
task
:
null
,
});
const
onModalOpen
=
(
event
,
task
)
=>
{
event
.
stopPropagation
();
...
...
@@ -222,7 +205,7 @@ console.log(tasks)
const
[
projectName
,
setProjectName
]
=
React
.
useState
([]);
const
[
filter
,
setFilter
]
=
React
.
useState
(
false
);
const
onClose
=
(
projectName
)
=>
{
console
.
log
(
projectName
)
setFilter
(
true
)
}
useEffect
(()
=>
{
...
...
@@ -280,7 +263,7 @@ console.log(tasks)
</TableCell>
</TableRow> */
}
{
/*
<NewTaskForm
<
NewTaskForm
onChange
=
{
onChange
}
onModalOpen
=
{
onModalOpen
}
onAuthorChange
=
{
onAuthorChange
}
...
...
@@ -289,7 +272,7 @@ console.log(tasks)
onToggleEditModeDone
=
{
onToggleEditModeDone
}
HandleEditTask
=
{
HandleEditTask
}
deleteHandle
=
{
deleteHandle
}
/>
*/
}
/
>
{
stableSort
(
recievedTasks
,
getComparator
(
order
,
orderBy
))
.
slice
(
page
*
rowsPerPage
,
page
*
rowsPerPage
+
rowsPerPage
)
...
...
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