DOMjudge / domjudge

DOMjudge programming contest jury system
https://www.domjudge.org
GNU General Public License v2.0
701 stars 249 forks source link

ui: problem_list: fix line break #2603

Closed undefined-moe closed 1 week ago

vmcj commented 2 weeks ago

Hi @undefined-moe,

Can you show a screenshot from the before and after so we can see why this is better?

cubercsl commented 2 weeks ago

I think </br> should be shown a new line, but it show as itself. You can verify this in demoweb.

cubercsl commented 2 weeks ago

Before: image After: image

vmcj commented 2 weeks ago

Yes that's indeed a bug.

I personally don't like to have Unicode chars for this but can't think of something else for now. Can you add a comment above explaining what it does (and/or explain the issue in your commit message)?

moesoha commented 2 weeks ago

I personally don't like to have Unicode chars for this but can't think of something else for now.

I recommend using something like {{ '\n' ~ label }} to prevent this.

nickygerritsen commented 2 weeks ago

I personally don't like to have Unicode chars for this but can't think of something else for now.

I recommend using something like {{ '\n' ~ label }} to prevent this.

Or even just {{ '\n' }}? I think I prefer that

vmcj commented 2 weeks ago

@undefined-moe can you squash the commits and rewrite your commit message?

undefined-moe commented 1 week ago

well there's "squash and merge" if you expand that dropdown besides "merge pull request" button.

nickygerritsen commented 1 week ago

We use merge queues, and then that button is not there anymore

cubercsl commented 1 week ago

Verified and this fixes the original issue.

It does not work on /jury/problems/problemset but we can look into that later.

@vmcj It looks like $('[data-bs-toggle="tooltip"]').tooltip(); is called in /jury/problems/problemset but not in /public and /team.

My suggestion is:

diff --git a/webapp/templates/partials/problem_list.html.twig b/webapp/templates/partials/problem_list.html.twig
index 0733241dd..bda100c09 100644
--- a/webapp/templates/partials/problem_list.html.twig
+++ b/webapp/templates/partials/problem_list.html.twig
@@ -92,9 +92,9 @@
                                                             <div
                                                                 class="problem-stats-item {{ itemClass }}"
                                                                 data-bs-toggle="tooltip"
-                                                                data-placement="top"
-                                                                data-html="true"
-                                                                title="Between {{ stat.start.timestamp | printtime(null, contest) }} and {{ stat.end.timestamp | printtime(null, contest) }}:{{ '\n' }}{{ label }}">
+                                                                data-bs-placement="top"
+                                                                data-bs-html="true"
+                                                                title="Between {{ stat.start.timestamp | printtime(null, contest) }} and {{ stat.end.timestamp | printtime(null, contest) }}:<br/>{{ label }}">
                                                             </div>
                                                         {% endfor %}
                                                     </div>
diff --git a/webapp/templates/public/problems.html.twig b/webapp/templates/public/problems.html.twig
index 17d1b5d12..d6f4a9d30 100644
--- a/webapp/templates/public/problems.html.twig
+++ b/webapp/templates/public/problems.html.twig
@@ -12,3 +12,11 @@
         problem_sample_zip_path: 'public_problem_sample_zip'
     } %}
 {% endblock %}
+
+{% block extrafooter %}
+<script>
+    $(function() {
+        $('[data-bs-toggle="tooltip"]').tooltip();
+    });
+</script>
+{% endblock %}
diff --git a/webapp/templates/team/problems.html.twig b/webapp/templates/team/problems.html.twig
index 9ceb23397..c64a88e1c 100644
--- a/webapp/templates/team/problems.html.twig
+++ b/webapp/templates/team/problems.html.twig
@@ -13,3 +13,11 @@
         show_submit_button: true
     } %}
 {% endblock %}
+
+{% block extrafooter %}
+<script>
+    $(function() {
+        $('[data-bs-toggle="tooltip"]').tooltip();
+    });
+</script>
+{% endblock %}
vmcj commented 1 week ago

@cubercsl, my remark was not meant that we need a fix now (as it was already broken before),

Feel free to create a PR for it. This does add the <br> back though? IIRC the newline did not work for the preview problemset page so I think that's that page we should change and not the other ones. Maybe this discussion works better in a new issue though as we're now commenting on a closed PR.