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
4b9c6870
Commit
4b9c6870
authored
Jan 12, 2023
by
Ermolaev Timur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#149
Разделил дефолтную таблицу по компонентам
parent
7f55d5c6
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
79 additions
and
70 deletions
+79
-70
UsersTasksTableBody.js
...TableContainer/UsersTasksTableBody/UsersTasksTableBody.js
+36
-0
helpers.js
...s/UsersTasksTableContainer/UsersTasksTableBody/helpers.js
+27
-0
UsersTasksTableContainer.js
...ents/UsersTasksTableContainer/UsersTasksTableContainer.js
+12
-65
UsersTasksTableHead.js
...TableContainer/UsersTasksTableHead/UsersTasksTableHead.js
+3
-3
UsersTasks.js
planner-front/src/containers/UsersTasks/UsersTasks.js
+1
-2
No files found.
planner-front/src/components/UsersTasksCompoments/UsersTasksTableContainer/UsersTasksTableBody/UsersTasksTableBody.js
0 → 100644
View file @
4b9c6870
import
{
TableBody
,
TableCell
,
TableRow
}
from
"@mui/material"
;
import
{
memo
}
from
"react"
;
import
{
getComparator
,
stableSort
}
from
"./helpers"
;
function
UsersTasksTableBody
({
rows
,
page
,
rowsPerPage
,
order
,
orderBy
})
{
return
(
<
TableBody
>
{
stableSort
(
rows
,
getComparator
(
order
,
orderBy
))
.
slice
(
page
*
rowsPerPage
,
page
*
rowsPerPage
+
rowsPerPage
)
.
map
((
row
,
index
)
=>
{
return
(
<
TableRow
hover
tabIndex
=
{
-
1
}
key
=
{
row
.
name
}
>
<
TableCell
component
=
"th"
scope
=
"row"
padding
=
"none"
>
{
row
.
name
}
<
/TableCell
>
<
TableCell
align
=
"right"
>
{
row
.
calories
}
<
/TableCell
>
<
TableCell
align
=
"right"
>
{
row
.
fat
}
<
/TableCell
>
<
TableCell
align
=
"right"
>
{
row
.
carbs
}
<
/TableCell
>
<
TableCell
align
=
"right"
>
{
row
.
protein
}
<
/TableCell
>
<
/TableRow
>
);
})}
<
/TableBody
>
);
}
export
default
memo
(
UsersTasksTableBody
)
\ No newline at end of file
planner-front/src/components/UsersTasksCompoments/UsersTasksTableContainer/UsersTasksTableBody/helpers.js
0 → 100644
View file @
4b9c6870
function
descendingComparator
(
a
,
b
,
orderBy
)
{
if
(
b
[
orderBy
]
<
a
[
orderBy
])
{
return
-
1
;
}
if
(
b
[
orderBy
]
>
a
[
orderBy
])
{
return
1
;
}
return
0
;
}
export
function
getComparator
(
order
,
orderBy
)
{
return
order
===
'desc'
?
(
a
,
b
)
=>
descendingComparator
(
a
,
b
,
orderBy
)
:
(
a
,
b
)
=>
-
descendingComparator
(
a
,
b
,
orderBy
);
}
export
function
stableSort
(
array
,
comparator
)
{
const
stabilizedThis
=
array
.
map
((
el
,
index
)
=>
[
el
,
index
]);
stabilizedThis
.
sort
((
a
,
b
)
=>
{
const
order
=
comparator
(
a
[
0
],
b
[
0
]);
if
(
order
!==
0
)
{
return
order
;
}
return
a
[
1
]
-
b
[
1
];
});
return
stabilizedThis
.
map
((
el
)
=>
el
[
0
]);
}
planner-front/src/components/UsersTasksCompoments/UsersTasksTableContainer/UsersTasksTableContainer.js
View file @
4b9c6870
import
{
Table
,
Table
Body
,
TableCell
,
TableContainer
,
TableRow
}
from
"@mui/material"
;
import
{
Table
,
Table
Container
,
}
from
"@mui/material"
;
import
{
memo
}
from
"react"
;
import
UsersTasksTableHead
from
"../UsersTasksTableHead/UsersTasksTableHead"
;
import
UsersTasksTableBody
from
"./UsersTasksTableBody/UsersTasksTableBody"
;
import
UsersTasksTableHead
from
"./UsersTasksTableHead/UsersTasksTableHead"
;
function
getComparator
(
order
,
orderBy
)
{
return
order
===
'desc'
?
(
a
,
b
)
=>
descendingComparator
(
a
,
b
,
orderBy
)
:
(
a
,
b
)
=>
-
descendingComparator
(
a
,
b
,
orderBy
);
}
function
stableSort
(
array
,
comparator
)
{
const
stabilizedThis
=
array
.
map
((
el
,
index
)
=>
[
el
,
index
]);
stabilizedThis
.
sort
((
a
,
b
)
=>
{
const
order
=
comparator
(
a
[
0
],
b
[
0
]);
if
(
order
!==
0
)
{
return
order
;
}
return
a
[
1
]
-
b
[
1
];
});
return
stabilizedThis
.
map
((
el
)
=>
el
[
0
]);
}
function
descendingComparator
(
a
,
b
,
orderBy
)
{
if
(
b
[
orderBy
]
<
a
[
orderBy
])
{
return
-
1
;
}
if
(
b
[
orderBy
]
>
a
[
orderBy
])
{
return
1
;
}
return
0
;
}
function
UsersTasksTableContainer
({
order
,
orderBy
,
handleRequestSort
,
rows
,
page
,
rowsPerPage
})
{
const
emptyRows
=
page
>
0
?
Math
.
max
(
0
,
(
1
+
page
)
*
rowsPerPage
-
rows
.
length
)
:
0
;
function
UsersTasksTableContainer
({
order
,
orderBy
,
handleRequestSort
,
rows
,
page
,
rowsPerPage
})
{
return
(
<
TableContainer
>
...
...
@@ -43,39 +14,15 @@ function UsersTasksTableContainer({order, orderBy, handleRequestSort, rows, page
<
UsersTasksTableHead
order
=
{
order
}
orderBy
=
{
orderBy
}
onRequestSort
=
{
handleRequestSort
}
handleRequestSort
=
{
handleRequestSort
}
/
>
<
UsersTasksTableBody
order
=
{
order
}
orderBy
=
{
orderBy
}
rows
=
{
rows
}
page
=
{
page
}
rowsPerPage
=
{
rowsPerPage
}
/
>
<
TableBody
>
{
stableSort
(
rows
,
getComparator
(
order
,
orderBy
))
.
slice
(
page
*
rowsPerPage
,
page
*
rowsPerPage
+
rowsPerPage
)
.
map
((
row
,
index
)
=>
{
return
(
<
TableRow
hover
tabIndex
=
{
-
1
}
key
=
{
row
.
name
}
>
<
TableCell
component
=
"th"
scope
=
"row"
padding
=
"none"
>
{
row
.
name
}
<
/TableCell
>
<
TableCell
align
=
"right"
>
{
row
.
calories
}
<
/TableCell
>
<
TableCell
align
=
"right"
>
{
row
.
fat
}
<
/TableCell
>
<
TableCell
align
=
"right"
>
{
row
.
carbs
}
<
/TableCell
>
<
TableCell
align
=
"right"
>
{
row
.
protein
}
<
/TableCell
>
<
/TableRow
>
);
})}
{
emptyRows
>
0
&&
(
<
TableRow
>
<
TableCell
colSpan
=
{
6
}
/
>
<
/TableRow
>
)}
<
/TableBody
>
<
/Table
>
<
/TableContainer
>
);
...
...
planner-front/src/components/UsersTasksCompoments/UsersTasksTableHead/UsersTasksTableHead.js
→
planner-front/src/components/UsersTasksCompoments/UsersTasksTable
Container/UsersTasksTable
Head/UsersTasksTableHead.js
View file @
4b9c6870
...
...
@@ -6,7 +6,7 @@ const headCells = [
{
id
:
'name'
,
numeric
:
false
,
disablePadding
:
tru
e
,
disablePadding
:
fals
e
,
label
:
'Dessert (100g serving)'
,
},
{
...
...
@@ -35,9 +35,9 @@ const headCells = [
},
];
function
UsersTasksTableHead
({
order
,
orderBy
,
on
RequestSort
})
{
function
UsersTasksTableHead
({
order
,
orderBy
,
handle
RequestSort
})
{
const
createSortHandler
=
(
property
)
=>
(
event
)
=>
{
on
RequestSort
(
event
,
property
);
handle
RequestSort
(
event
,
property
);
};
return
(
...
...
planner-front/src/containers/UsersTasks/UsersTasks.js
View file @
4b9c6870
import
*
as
React
from
'react'
;
import
Box
from
'@mui/material/Box'
;
import
Paper
from
'@mui/material/Paper'
;
import
UsersTasksTableToolbar
from
'../../components/UsersTasksCompoments/UsersTasksTableToolbar/UsersTasksTableToolbar'
;
import
UsersTasksTablePagination
from
'../../components/UsersTasksCompoments/UsersTasksTablePagination/UsersTasksTablePagination'
;
...
...
@@ -58,7 +57,7 @@ export default function EnhancedTable() {
<
UsersTasksTableContainer
order
=
{
order
}
orderBy
=
{
orderBy
}
on
RequestSort
=
{
handleRequestSort
}
handle
RequestSort
=
{
handleRequestSort
}
rows
=
{
rows
}
page
=
{
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