Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
Today KU
Commits
c0d95ac8
Commit
c0d95ac8
authored
Nov 12, 2021
by
Choi Ga Young
Browse files
삭제 모달 및 계획정렬
parent
b723b364
Changes
5
Show whitespace changes
Inline
Side-by-side
client/src/components/Modal/DeleteModal.js
0 → 100644
View file @
c0d95ac8
const
DeleteModal
=
({
handleClick
,
renListID
})
=>
{
return
(
<
div
className
=
"
modal fade
"
id
=
"
deleteModal
"
data
-
bs
-
backdrop
=
"
static
"
data
-
bs
-
keyboard
=
"
false
"
tabindex
=
"
-1
"
aria
-
labelledby
=
"
deleteModalLabel
"
aria
-
hidden
=
"
true
"
>
<
div
className
=
"
modal-dialog modal-dialog-centered
"
>
<
div
className
=
"
modal-content
"
>
<
div
className
=
"
modal-body text-center
"
>
<
p
>
관련
학업계획까지
삭제됩니다
.
<
/p
>
<
p
>
정말
삭제하시겠습니까
?
<
/p
>
<
/div
>
<
div
className
=
"
modal-footer
"
>
<
button
type
=
"
button
"
className
=
"
btn btn-secondary btn-sm
"
data
-
bs
-
dismiss
=
"
modal
"
>
취소
<
/button
>
<
button
type
=
"
button
"
className
=
"
btn btn-crimson btn-sm
"
data
-
bs
-
dismiss
=
"
modal
"
onClick
=
{(
e
)
=>
handleClick
(
e
,
renListID
)}
>
삭제
<
/button
>
<
/div
>
<
/div
>
<
/div
>
<
/div
>
)
}
export
default
DeleteModal
;
client/src/components/StudyPlan/StudyPlanCard.js
View file @
c0d95ac8
import
{
Link
}
from
"
react-router-dom
"
;
import
PlanLineList
from
"
./PlanLineList
"
;
import
DeleteModal
from
"
../Modal/DeleteModal
"
;
import
style
from
"
./studyplan.module.scss
"
;
const
StudyPlanCard
=
({
renList
,
handle
Click
,
handleEdi
t
})
=>
{
const
StudyPlanCard
=
({
renList
,
handle
Edit
,
delSubjec
t
})
=>
{
return
(
<>
<
Link
className
=
"
card text-decoration-none link-dark mb-3
"
to
=
{
`/studyplan/
${
renList
.
id
}
`
}
style
=
{{
width
:
"
20rem
"
}}
>
<
div
className
=
"
card-body
"
style
=
{{
height
:
"
150px
"
}}
>
<
div
className
=
"
d-flex
"
>
<
h5
className
=
"
card-title col-10 text-nowrap
"
style
=
{{
overflow
:
"
hidden
"
,
textOverflow
:
"
ellipsis
"
}}
>
{
renList
.
name
}
<
/h5
>
<
div
className
=
"
col-2 d-flex justify-content-end
"
>
<
Link
className
=
"
text-decoration-none link-dark
"
to
=
{
`/subject/edit/
${
renList
.
id
}
`
}
><
i
className
=
"
bi bi-pencil-square pe-2
"
><
/i></
Link
>
<
i
className
=
"
bi bi-trash
"
onClick
=
{(
e
)
=>
handleClick
(
e
,
renList
.
id
)}
>
<
i
className
=
"
bi bi-trash
"
data
-
bs
-
toggle
=
"
modal
"
data
-
bs
-
target
=
"
#deleteModal
"
onClick
=
{(
e
)
=>
e
.
preventDefault
(
)}
>
<
/i
>
<
/div
>
<
/div
>
...
...
@@ -21,6 +23,8 @@ const StudyPlanCard = ({ renList, handleClick, handleEdit }) => {
<
/div
>
<
/div
>
<
/Link
>
<
DeleteModal
handleClick
=
{
delSubject
}
renListID
=
{
renList
.
id
}
/
>
<
/
>
)
}
...
...
client/src/components/StudyPlan/StudyPlanList.js
View file @
c0d95ac8
...
...
@@ -58,7 +58,7 @@ const StudyPlanList = () => {
return
(
<
div
className
=
{
`mt-4
${
styles
.
list
}
`
}
>
<
div
className
=
"
d-flex flex-column align-items-center
"
>
{
renList
.
length
!==
0
?
renList
.
map
((
info
,
idx
)
=>
<
StudyPlanCard
key
=
{
idx
}
renList
=
{
info
}
handle
Click
=
{
delSubject
}
handleEdit
=
{
checkFn
}
/>
)
: null
}
{
renList
.
length
!==
0
?
renList
.
map
((
info
,
idx
)
=>
<
StudyPlanCard
key
=
{
idx
}
renList
=
{
info
}
handle
Edit
=
{
checkFn
}
delSubject
=
{
delSubject
}
/>
)
: null
}
<
Link
className
=
"
card text-decoration-none link-dark
"
to
=
"
/subject/edit
"
style
=
{{
width
:
"
20rem
"
}}
>
<
div
className
=
"
card-body d-flex flex-column bg-secondary bg-opacity-25
"
>
<
i
className
=
"
bi bi-plus-lg d-flex justify-content-center fs-3
"
><
/i
>
...
...
server/controllers/subject.controller.js
View file @
c0d95ac8
...
...
@@ -11,7 +11,7 @@ const findAll = async (req, res) => {
if
(
subjectId
)
findList
=
await
Subject
.
findAll
({
where
:
{
[
Op
.
and
]:
[{
id
:
subjectId
},
{
userId
:
userId
}]
},
order
:
[[
'
updatedAt
'
,
'
DESC
'
]]
})
else
findList
=
await
Subject
.
findAll
({
where
:
{
userId
:
userId
},
order
:
[[
'
updatedAt
'
,
'
DESC
'
]]
})
const
subjectAndPlan
=
await
Promise
.
all
(
findList
.
map
(
async
(
subjectInfo
)
=>
{
const
resPlan
=
await
Plan
.
findAll
({
where
:
{
subjectId
:
subjectInfo
.
id
},
order
:[[
sequelize
.
literal
(
'
checked, deadline
'
),
'
ASC
'
]]
})
const
resPlan
=
await
Plan
.
findAll
({
where
:
{
subjectId
:
subjectInfo
.
id
},
order
:
[[
sequelize
.
literal
(
'
checked, deadline
'
),
'
ASC
'
]]
})
subjectInfo
.
dataValues
.
planList
=
resPlan
return
subjectInfo
}))
...
...
@@ -63,8 +63,9 @@ const remove = async (req, res) => {
try
{
const
{
subjectId
}
=
req
.
query
const
userId
=
req
.
userId
const
deleted2
=
await
Plan
.
destroy
({
where
:
{
subjectId
:
subjectId
}
})
const
deleted
=
await
Subject
.
destroy
({
where
:
{
[
Op
.
and
]:
[{
id
:
subjectId
},
{
userId
:
userId
}]
}
})
if
(
!
deleted
)
throw
new
Error
(
"
해당 과목을 삭제하는데 실패하였습니다.
"
)
if
(
!
(
deleted
&&
deleted2
)
)
throw
new
Error
(
"
해당 과목을 삭제하는데 실패하였습니다.
"
)
else
return
res
.
send
(
200
)
}
catch
(
error
)
{
return
res
.
status
(
500
).
send
(
error
.
message
||
"
과목 삭제 에러 발생
"
)
...
...
server/db/index.js
View file @
c0d95ac8
...
...
@@ -34,11 +34,6 @@ const Plan = PlanModel(sequelize)
Schedule
.
belongsTo
(
User
)
Subject
.
belongsTo
(
User
)
Todo
.
belongsTo
(
User
)
Subject
.
hasOne
(
Plan
,
{
onDelete
:
"
CASCADE
"
})
Plan
.
belongsTo
(
Subject
)
export
{
...
...
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