Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
zesje
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Works on my machine
zesje
Commits
9901eca5
Commit
9901eca5
authored
6 years ago
by
Joseph Weston
Committed by
Anton Akhmerov
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
implement exam deletion, use modal for confirming
parent
98698b01
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
client/App.jsx
+21
-7
21 additions, 7 deletions
client/App.jsx
client/components/NavBar.jsx
+3
-1
3 additions, 1 deletion
client/components/NavBar.jsx
client/views/Exam.jsx
+66
-47
66 additions, 47 deletions
client/views/Exam.jsx
with
90 additions
and
55 deletions
client/App.jsx
+
21
−
7
View file @
9901eca5
...
...
@@ -48,17 +48,19 @@ const Fail = Loadable({
loading
:
Loading
})
const
nullExam
=
()
=>
({
id
:
null
,
name
:
''
,
submissions
:
[],
problems
:
[],
widgets
:
[]
})
class
App
extends
React
.
Component
{
menu
=
React
.
createRef
();
state
=
{
exam
:
{
id
:
null
,
name
:
''
,
submissions
:
[],
problems
:
[],
widgets
:
[]
},
exam
:
nullExam
(),
grader
:
null
}
...
...
@@ -68,6 +70,17 @@ class App extends React.Component {
exam
:
ex
}))
}
deleteExam
=
(
examID
)
=>
{
api
.
del
(
'
exams/
'
+
examID
)
.
then
(()
=>
{
if
(
this
.
menu
.
current
)
{
return
this
.
menu
.
current
.
updateExamList
()
}
})
}
updateSubmission
=
(
index
,
sub
)
=>
{
if
(
index
===
undefined
)
{
api
.
get
(
'
submissions/
'
+
this
.
state
.
exam
.
id
)
...
...
@@ -129,6 +142,7 @@ class App extends React.Component {
exam
=
{
exam
}
examID
=
{
match
.
params
.
examID
}
updateExam
=
{
this
.
updateExam
}
deleteExam
=
{
this
.
deleteExam
}
updateSubmission
=
{
this
.
updateSubmission
}
/>
}
/>
<
Route
path
=
'/exams'
render
=
{
({
history
})
=>
<
AddExam
updateExamList
=
{
this
.
menu
.
current
?
this
.
menu
.
current
.
updateExamList
:
null
}
changeURL
=
{
history
.
push
}
/>
}
/>
...
...
This diff is collapsed.
Click to expand it.
client/components/NavBar.jsx
+
3
−
1
View file @
9901eca5
...
...
@@ -101,7 +101,9 @@ class NavBar extends React.Component {
this
.
setState
({
examList
:
exams
})
if
(
this
.
props
.
exam
.
id
===
null
&&
exams
.
length
)
this
.
props
.
updateExam
(
exams
[
exams
.
length
-
1
].
id
)
const
examIDs
=
exams
.
map
(
exam
=>
exam
.
id
)
const
examIsValid
=
this
.
props
.
exam
.
id
!==
null
&&
examIDs
.
includes
(
this
.
props
.
exam
.
id
)
if
(
!
examIsValid
&&
exams
.
length
)
this
.
props
.
updateExam
(
exams
[
exams
.
length
-
1
].
id
)
})
}
...
...
This diff is collapsed.
Click to expand it.
client/views/Exam.jsx
+
66
−
47
View file @
9901eca5
...
...
@@ -7,6 +7,7 @@ import PanelGenerate from '../components/PanelGenerate.jsx'
import
ExamEditor
from
'
./ExamEditor.jsx
'
import
update
from
'
immutability-helper
'
import
ExamFinalizeMarkdown
from
'
./ExamFinalize.md
'
import
ConfirmationModal
from
'
../components/ConfirmationModal.jsx
'
import
*
as
api
from
'
../api.jsx
'
...
...
@@ -17,7 +18,8 @@ class Exams extends React.Component {
numPages
:
null
,
selectedWidgetId
:
null
,
widgets
:
[],
previewing
:
false
previewing
:
false
,
deleting
:
false
}
static
getDerivedStateFromProps
=
(
newProps
,
prevState
)
=>
{
...
...
@@ -291,32 +293,41 @@ class Exams extends React.Component {
return
<
PanelGenerate
examID
=
{
this
.
state
.
examID
}
/>
}
let
actionsBody
if
(
this
.
state
.
previewing
)
{
actionsBody
=
<
this
.
PanelConfirm
onYesClick
=
{
()
=>
api
.
put
(
`exams/
${
this
.
props
.
examID
}
/finalized`
,
'
true
'
)
.
then
(()
=>
{
this
.
props
.
updateExam
(
this
.
props
.
examID
)
this
.
setState
({
previewing
:
false
})
})
}
onNoClick
=
{
()
=>
this
.
setState
({
previewing
:
false
})
}
/>
}
else
{
actionsBody
=
<
div
className
=
'panel-block field is-grouped'
>
<
this
.
Finalize
onFinalizeClicked
=
{
()
=>
this
.
setState
({
previewing
:
true
})
}
/>
,
<
this
.
Delete
onDeleteClicked
=
{
()
=>
this
.
props
.
deleteExam
(
this
.
props
.
examID
)
}
/>
</
div
>
}
return
(
<
nav
className
=
'panel'
>
<
p
className
=
'panel-heading'
>
Actions
</
p
>
<
div
className
=
'panel-block'
>
{
this
.
state
.
previewing
?
<
this
.
PanelConfirm
onYesClick
=
{
()
=>
api
.
put
(
`exams/
${
this
.
props
.
examID
}
/finalized`
,
'
true
'
)
.
then
(()
=>
{
this
.
props
.
updateExam
(
this
.
props
.
examID
)
this
.
setState
({
previewing
:
false
})
})
}
onNoClick
=
{
()
=>
this
.
setState
({
previewing
:
false
})
}
/>
:
<
this
.
Finalize
onFinalizeClicked
=
{
()
=>
this
.
setState
({
previewing
:
true
})
}
/>
}
</
div
>
{
actionsBody
}
</
nav
>
)
}
...
...
@@ -332,36 +343,41 @@ class Exams extends React.Component {
)
}
Delete
=
(
props
)
=>
{
return
(
<
button
className
=
'button is-link is-fullwidth is-danger'
onClick
=
{
()
=>
{
this
.
setState
({
deleting
:
true
})
}
}
>
Delete
</
button
>
)
}
PanelConfirm
=
(
props
)
=>
{
return
(
<
nav
className
=
'panel'
>
<
div
className
=
'content'
dangerouslySetInnerHTML
=
{
{
__html
:
ExamFinalizeMarkdown
}
}
/>
<
div
className
=
'panel-heading'
>
<
div
>
<
div
className
=
'panel-block'
>
<
label
className
=
'label'
>
Are you sure?
</
label
>
</
div
>
<
div
className
=
'panel-block'
>
<
div
className
=
'field has-addons'
>
<
div
className
=
'control'
>
<
button
disabled
=
{
props
.
disabled
}
className
=
'button is-danger'
onClick
=
{
()
=>
props
.
onYesClick
()
}
>
Yes
</
button
>
</
div
>
<
div
className
=
'control'
>
<
button
disabled
=
{
props
.
disabled
}
className
=
'button is-link'
onClick
=
{
()
=>
props
.
onNoClick
()
}
>
No
</
button
>
</
div
>
</
div
>
<
div
className
=
'content panel-block'
dangerouslySetInnerHTML
=
{
{
__html
:
ExamFinalizeMarkdown
}
}
/>
<
div
className
=
'panel-block field is-grouped'
>
<
button
disabled
=
{
props
.
disabled
}
className
=
'button is-danger is-link is-fullwidth'
onClick
=
{
()
=>
props
.
onYesClick
()
}
>
Yes
</
button
>
<
button
disabled
=
{
props
.
disabled
}
className
=
'button is-link is-fullwidth'
onClick
=
{
()
=>
props
.
onNoClick
()
}
>
No
</
button
>
</
div
>
</
na
v
>
</
di
v
>
)
}
...
...
@@ -387,6 +403,9 @@ class Exams extends React.Component {
</
div
>
</
div
>
</
section
>
<
ConfirmationModal
active
=
{
this
.
state
.
deleting
}
color
=
'is-danger'
confirmText
=
'Delete exam'
onCancel
=
{
()
=>
this
.
setState
({
deleting
:
false
})
}
onConfirm
=
{
this
.
onDeleteClicked
}
/>
</
div
>
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment