Skip to content

Commit 3a6c951

Browse files
committed
Feat: Show children items on ItemPage
1 parent 1f44353 commit 3a6c951

3 files changed

Lines changed: 66 additions & 53 deletions

File tree

frontend/components/pages/ItemPage/ItemPage.js

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ import {
55
mdiDotsVertical,
66
mdiEarth,
77
mdiFileEditOutline,
8+
mdiFileTreeOutline,
89
mdiPackageDown,
910
mdiShare,
1011
mdiStar,
1112
mdiStarOutline,
12-
mdiUpload,
13+
mdiUpload
1314
} from "@mdi/js";
1415
import Icon from "@mdi/react";
1516
import {
@@ -22,7 +23,7 @@ import {
2223
MenuItem,
2324
Skeleton,
2425
Stack,
25-
Tooltip,
26+
Tooltip
2627
} from "@mui/material";
2728
import { push } from "connected-react-router";
2829
import R from "ramda";
@@ -33,6 +34,7 @@ import { useParams } from "react-router";
3334
import { Link } from "react-router-dom";
3435
import LinkComponent from "_atoms/LinkComponent";
3536
import TypeIcon from "_atoms/TypeIcon";
37+
import ItemList from "_frontend/components/organisms/ItemList";
3638
import { dateElapsed, dateToString } from "_frontend/utils/date";
3739
import BreadCrumbs from "_molecules/BreadCrumbs";
3840
import Editor from "_molecules/Editor";
@@ -42,12 +44,12 @@ import {
4244
attemptDeleteItem,
4345
attemptGetItem,
4446
attemptGetItemChildren,
45-
attemptPublishItem,
47+
attemptPublishItem
4648
} from "_thunks/item";
4749
import {
4850
attemptAddBookmark,
4951
attemptGetUser,
50-
attemptRemoveBookmark,
52+
attemptRemoveBookmark
5153
} from "_thunks/user";
5254
import { deepEqual } from "_utils/compare";
5355

@@ -127,11 +129,6 @@ export default function ItemPage() {
127129
dispatch(attemptGetItem(itemId))
128130
.then((item) => {
129131
setItem(item);
130-
if (item.type !== "card") {
131-
dispatch(attemptGetItemChildren(item.path)).then((items) => {
132-
setItemChildren(items);
133-
});
134-
}
135132
})
136133
.catch(() => setVisible(false));
137134
} else {
@@ -149,12 +146,6 @@ export default function ItemPage() {
149146
}
150147
})
151148
.catch(() => setVisible(false));
152-
153-
if (item.type !== "card" && itemChildren == null) {
154-
dispatch(attemptGetItemChildren(item.path)).then((children) => {
155-
setItemChildren(children);
156-
});
157-
}
158149
}
159150

160151
// setting recents of localstorage
@@ -177,6 +168,12 @@ export default function ItemPage() {
177168
setItemOwner(user);
178169
});
179170

171+
if (item.type !== "card") {
172+
dispatch(attemptGetItemChildren(item.path)).then((children) => {
173+
setItemChildren(children.filter(i => i._id != item._id));
174+
});
175+
}
176+
180177
switch (item.type) {
181178
case "cabinet": // will have 0 parents because it's the root item
182179
console.log("switch: case =", item.type, pathArray);
@@ -333,8 +330,10 @@ export default function ItemPage() {
333330
<TypeIcon type={item.type} size={1.5} opacity={0.7} />
334331
</Badge>
335332
</Tooltip>
333+
336334
{/* Item title */}
337-
<div className="item-title">{item.title}</div>
335+
<div className="item-header-title">{item.title}</div>
336+
338337
{/* Item action menus */}
339338
<Stack direction="row">
340339
<Tooltip title="북마크에 추가" arrow>
@@ -351,13 +350,18 @@ export default function ItemPage() {
351350
</Stack>
352351
</div>
353352
</Stack>
353+
354354
{/* Item BreadCrumbs */}
355355
{itemParents != null ? (
356356
<BreadCrumbs itemArray={[...itemParents, item]} />
357357
) : (
358358
<BreadCrumbs hierarchyLevel={hierarchyLevel[item.type]} />
359359
)}
360-
{/* Item owner profile */}
360+
361+
{/* Item content */}
362+
{item.content && <Editor content={item.content} editable={false} />}
363+
364+
{/* Item metadata (owner profile, created date) */}
361365
{itemOwner != null ? (
362366
<Stack className="item-profile">
363367
<img
@@ -381,7 +385,14 @@ export default function ItemPage() {
381385
<Skeleton width={200} height="1em" />
382386
</Stack>
383387
)}
384-
{item.content && <Editor content={item.content} editable={false} />}
388+
389+
{/* Item children */}
390+
{item.type !== "card" && <ItemList
391+
items={itemChildren}
392+
title="하위 항목"
393+
icon={mdiFileTreeOutline}
394+
/>}
395+
385396
<div>
386397
<div className="outer-div">
387398
<div className="grid-container">

frontend/styles/item-list-page.scss

Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -16,44 +16,41 @@
1616
}
1717
}
1818

19-
.item-list-page {
19+
.item-list-page-title {
20+
width: 100%;
21+
font-size: 2.5em;
22+
font-weight: bolder;
23+
white-space: nowrap;
24+
overflow: hidden;
25+
text-overflow: ellipsis;
26+
}
2027

21-
.item-list-page-title {
22-
width: 100%;
23-
font-size: 2.5em;
24-
font-weight: bolder;
28+
.item-list-header {
29+
display: flex;
30+
flex-direction: row;
31+
align-items: center;
32+
gap: 8px;
33+
padding: 8px 0;
34+
border-bottom: 1px solid rgba(0, 0, 0, 0.25);
35+
36+
svg {
37+
padding-bottom: 4px;
38+
}
39+
40+
.item-list-title {
41+
flex-grow: 1;
42+
font-size: 2em;
43+
font-weight: bold;
2544
white-space: nowrap;
2645
overflow: hidden;
2746
text-overflow: ellipsis;
2847
}
48+
}
2949

30-
.item-list-header {
31-
display: flex;
32-
flex-direction: row;
33-
align-items: center;
34-
gap: 8px;
35-
padding: 8px 0;
36-
border-bottom: 1px solid rgba(0, 0, 0, 0.25);
37-
38-
svg {
39-
padding-bottom: 4px;
40-
}
41-
42-
.item-list-title {
43-
flex-grow: 1;
44-
font-size: 2em;
45-
font-weight: bold;
46-
white-space: nowrap;
47-
overflow: hidden;
48-
text-overflow: ellipsis;
49-
}
50-
}
51-
52-
.item-list-content {
53-
height: $height;
54-
align-items: center;
55-
margin: 16px 0;
56-
gap: 8px;
57-
overflow-x: hidden;
58-
}
50+
.item-list-content {
51+
height: $height;
52+
align-items: center;
53+
margin: 16px 0;
54+
gap: 8px;
55+
overflow-x: hidden;
5956
}

frontend/styles/item-page.scss

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
margin-bottom: 8px;
2525
gap: 12px;
2626

27-
.item-title {
27+
.item-header-title {
2828
font-size: 2.5em;
2929
font-weight: bolder;
3030
flex-grow: 1;
@@ -42,6 +42,7 @@
4242
padding-top: 8px;
4343

4444
.item-profile-image {
45+
margin-left: auto;
4546
width: 24px;
4647
height: 24px;
4748
border-radius: 50%;
@@ -64,4 +65,8 @@
6465
}
6566
}
6667
}
68+
69+
.item-list {
70+
margin-top: 32px;
71+
}
6772
}

0 commit comments

Comments
 (0)