Skip to content

Commit 34d2c2f

Browse files
committed
Move jury submission source edit details to modal
Previously, we always rendered the submission details (problem, language, entry point) form below the code editor. This prevents us from scaling the editor window to use all available height. We move this forum to a modal, triggered by a submit button on the top right of the IDE. This uses the same design as the proposed changes for the diff editor.
1 parent 26aeefa commit 34d2c2f

File tree

3 files changed

+39
-18
lines changed

3 files changed

+39
-18
lines changed

webapp/src/Controller/Jury/SubmissionController.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,12 +1039,17 @@ public function editSourceAction(Request $request, Submission $submission, #[Map
10391039
return $this->redirectToRoute('jury_submission', ['submitId' => $submittedSubmission->getSubmitid()]);
10401040
}
10411041

1042-
return $this->render('jury/submission_edit_source.html.twig', [
1042+
$twigData = [
10431043
'submission' => $submission,
10441044
'files' => $files,
10451045
'form' => $form,
10461046
'selected' => $rank,
1047-
]);
1047+
];
1048+
if ($request->isXmlHttpRequest()) {
1049+
return $this->render('jury/submission_edit_source_modal.html.twig', $twigData);
1050+
} else {
1051+
return $this->render('jury/submission_edit_source.html.twig', $twigData);
1052+
}
10481053
}
10491054

10501055
/**

webapp/templates/jury/submission_edit_source.html.twig

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
source files
1212
</h1>
1313

14-
{{ form_start(form) }}
15-
16-
<ul class="nav nav-tabs source-tab-nav">
14+
<ul class="nav nav-tabs source-tab-nav align-items-end">
1715
{%- for file in files %}
1816

1917
<li class="nav-item">
@@ -22,28 +20,35 @@
2220
</li>
2321
{%- endfor %}
2422

23+
<li class="nav-item flex-grow-1 text-end mb-1">
24+
<a class="btn btn-success btn-sm" data-ajax-modal data-ajax-modal-after="transferSourceToModal" href="{{ path('jury_submission_edit_source', {submission: submission.submitid}) }}">
25+
<i class="fas fa-cloud-upload-alt"></i> Submit
26+
</a>
27+
</li>
2528
</ul>
29+
30+
<script>
31+
function transferSourceToModal(elem) {
32+
{%- for idx, file in files %}
33+
(() => {
34+
const input = $('#form_source{{ file.rank }}');
35+
input.val($('#form_source_value{{ file.rank}}').val());
36+
// Hide the source in the modal
37+
input.closest('div.mb-3').hide();
38+
})();
39+
{%- endfor %}
40+
}
41+
</script>
2642
<div class="tab-content source-tab">
2743
{%- for idx, file in files %}
2844

2945
<div class="tab-pane fade {% if (selected is null and loop.first) or selected == file.rank %}show active{% endif %}"
3046
id="source-{{ file.rank }}" role="tabpanel">
31-
{{ file.sourcecode | codeEditor(idx, submission.language.editorLanguage, true, 'form_source' ~ file.rank) }}
32-
<script>
33-
$(function () {
34-
$('#form_source{{ file.rank }}').closest('div.mb-3').hide();
35-
});
36-
</script>
47+
{{ file.sourcecode | codeEditor(idx, submission.language.editorLanguage, true, 'form_source_value' ~ file.rank) }}
3748
</div>
49+
<input type="hidden" id="form_source_value{{ file.rank }}"/>
3850
{%- endfor %}
3951

4052
</div>
4153

42-
<div class="row">
43-
<div class="col-lg-4">
44-
{{ form_widget(form) }}
45-
</div>
46-
</div>
47-
{{ form_end(form) }}
48-
4954
{% endblock %}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{% extends "partials/modal.html.twig" %}
2+
3+
{% block title %}Submission details{% endblock %}
4+
5+
{% block content %}
6+
{{ form_start(form) }}
7+
8+
{{ form_widget(form) }}
9+
10+
{{ form_end(form) }}
11+
{% endblock %}

0 commit comments

Comments
 (0)