diff --git a/ietf/doc/tests.py b/ietf/doc/tests.py index 5141c12f6..e18c8a1d4 100644 --- a/ietf/doc/tests.py +++ b/ietf/doc/tests.py @@ -744,6 +744,12 @@ Man Expires September 22, 2015 [Page 3] q = PyQuery(r.content) self.assertEqual(q('title').text(), 'draft-ietf-mars-test-01') + # check that revision list has expected versions + self.assertEqual(len(q('#sidebar .revision-list .page-item.active a.page-link[href$="draft-ietf-mars-test-01"]')), 1) + + # check that diff dropdowns have expected versions + self.assertEqual(len(q('#sidebar option[value="draft-ietf-mars-test-00"][selected="selected"]')), 1) + rfc = WgRfcFactory() (Path(settings.RFC_PATH) / rfc.get_base_name()).touch() r = self.client.get(urlreverse("ietf.doc.views_doc.document_html", kwargs=dict(name=rfc.canonical_name()))) diff --git a/ietf/doc/views_doc.py b/ietf/doc/views_doc.py index 9bbb0068a..da5c9bfbd 100644 --- a/ietf/doc/views_doc.py +++ b/ietf/doc/views_doc.py @@ -533,6 +533,7 @@ def document_main(request, name, rev=None, document_html=False): review_assignments=review_assignments, no_review_from_teams=no_review_from_teams, due_date=due_date, + diff_revisions=get_diff_revisions(request, name, doc if isinstance(doc,Document) else doc.doc) if document_html else None )) if doc.type_id == "charter": @@ -901,44 +902,77 @@ def document_email(request,name): ) -def document_history(request, name): - doc = get_object_or_404(Document, docalias__name=name) - top = render_document_top(request, doc, "history", name) +def get_diff_revisions(request, name, doc): + diffable = any( + [ + name.startswith(prefix) + for prefix in [ + "rfc", + "draft", + "charter", + "conflict-review", + "status-change", + ] + ] + ) + + if not diffable: + return [] # pick up revisions from events diff_revisions = [] - diffable = [ name.startswith(prefix) for prefix in ["rfc", "draft", "charter", "conflict-review", "status-change", ]] - if any(diffable): - diff_documents = [ doc ] - diff_documents.extend(Document.objects.filter(docalias__relateddocument__source=doc, docalias__relateddocument__relationship="replaces")) + diff_documents = [doc] + diff_documents.extend( + Document.objects.filter( + docalias__relateddocument__source=doc, + docalias__relateddocument__relationship="replaces", + ) + ) - if doc.get_state_slug() == "rfc": - e = doc.latest_event(type="published_rfc") - aliases = doc.docalias.filter(name__startswith="rfc") - if aliases: - name = aliases[0].name - diff_revisions.append((name, "", e.time if e else doc.time, name)) + if doc.get_state_slug() == "rfc": + e = doc.latest_event(type="published_rfc") + aliases = doc.docalias.filter(name__startswith="rfc") + if aliases: + name = aliases[0].name + diff_revisions.append((name, "", e.time if e else doc.time, name)) - seen = set() - for e in NewRevisionDocEvent.objects.filter(type="new_revision", doc__in=diff_documents).select_related('doc').order_by("-time", "-id"): - if (e.doc.name, e.rev) in seen: - continue + seen = set() + for e in ( + NewRevisionDocEvent.objects.filter(type="new_revision", doc__in=diff_documents) + .select_related("doc") + .order_by("-time", "-id") + ): + if (e.doc.name, e.rev) in seen: + continue - seen.add((e.doc.name, e.rev)) + seen.add((e.doc.name, e.rev)) - url = "" - if name.startswith("charter"): - url = request.build_absolute_uri(urlreverse('ietf.doc.views_charter.charter_with_milestones_txt', kwargs=dict(name=e.doc.name, rev=e.rev))) - elif name.startswith("conflict-review"): - url = find_history_active_at(e.doc, e.time).get_href() - elif name.startswith("status-change"): - url = find_history_active_at(e.doc, e.time).get_href() - elif name.startswith("draft") or name.startswith("rfc"): - # rfcdiff tool has special support for IDs - url = e.doc.name + "-" + e.rev + url = "" + if name.startswith("charter"): + url = request.build_absolute_uri( + urlreverse( + "ietf.doc.views_charter.charter_with_milestones_txt", + kwargs=dict(name=e.doc.name, rev=e.rev), + ) + ) + elif name.startswith("conflict-review"): + url = find_history_active_at(e.doc, e.time).get_href() + elif name.startswith("status-change"): + url = find_history_active_at(e.doc, e.time).get_href() + elif name.startswith("draft") or name.startswith("rfc"): + # rfcdiff tool has special support for IDs + url = e.doc.name + "-" + e.rev - diff_revisions.append((e.doc.name, e.rev, e.time, url)) + diff_revisions.append((e.doc.name, e.rev, e.time, url)) + + return diff_revisions + + +def document_history(request, name): + doc = get_object_or_404(Document, docalias__name=name) + top = render_document_top(request, doc, "history", name) + diff_revisions = get_diff_revisions(request, name, doc) # grab event history events = doc.docevent_set.all().order_by("-time", "-id").select_related("by") diff --git a/ietf/static/css/document_html.scss b/ietf/static/css/document_html.scss index c8dfb05b9..7df07b617 100644 --- a/ietf/static/css/document_html.scss +++ b/ietf/static/css/document_html.scss @@ -206,6 +206,15 @@ tbody.meta tr { } } +.navbar { + + td:not(:first-child), + th:not(:first-child) { + padding-top: map.get($spacers, 3); + } + +} + // Add some padding when there are multiple buttons in a line that can wrap .buttonlist .btn { margin-bottom: map.get($spacers, 1); @@ -318,3 +327,15 @@ tbody.meta tr { display: none; } } + +// Select2 styling +@import "select2"; + +.select2-results__option, +.select2-search__field { + font-size: small !important; +} + +.select2-container--open { + z-index: 9999999; +} diff --git a/ietf/static/js/document_html.js b/ietf/static/js/document_html.js index 371e0e7b4..7b9b7d6cd 100644 --- a/ietf/static/js/document_html.js +++ b/ietf/static/js/document_html.js @@ -8,6 +8,7 @@ import { import Cookies from "js-cookie"; import { populate_nav } from "./nav.js"; +import "./select2.js"; const cookies = Cookies.withAttributes({ sameSite: "strict" }); @@ -48,7 +49,7 @@ document.addEventListener("DOMContentLoaded", function (event) { // activate pref buttons selected by pref cookies or localStorage const in_localStorage = ["deftab"]; - document.querySelectorAll(".btn-check") + document.querySelectorAll("#pref-tab-pane .btn-check") .forEach(btn => { const id = btn.id.replace("-radio", ""); diff --git a/ietf/static/js/select2.js b/ietf/static/js/select2.js index 5b9590f09..34611e1ef 100644 --- a/ietf/static/js/select2.js +++ b/ietf/static/js/select2.js @@ -109,4 +109,11 @@ $(document) return; setupSelect2Field($(this)); }); + + // Remove spurious title attribute (https://github.com/select2/select2/pull/3988) + $(".select2-selection__rendered") + .hover(function () { + $(this) + .removeAttr("title"); + }); }); diff --git a/ietf/templates/doc/document_history.html b/ietf/templates/doc/document_history.html index c984c773a..67e34d0cd 100644 --- a/ietf/templates/doc/document_history.html +++ b/ietf/templates/doc/document_history.html @@ -18,85 +18,7 @@ {{ top|safe }} {% if diff_revisions and diff_revisions|length > 1 or doc.name|rfcbis %}

Revision differences

-
-
- -
- -
-
-
- -
- -
-
-
- -
-
- - - - - - - - -
-
-
- -
+ {% include "doc/document_history_form.html" with doc=doc diff_revisions=diff_revisions action=rfcdiff_base_url only %} {% endif %}

Document history

{% if can_add_comment %} diff --git a/ietf/templates/doc/document_history_form.html b/ietf/templates/doc/document_history_form.html new file mode 100644 index 000000000..0045a70d9 --- /dev/null +++ b/ietf/templates/doc/document_history_form.html @@ -0,0 +1,97 @@ +{# Copyright The IETF Trust 2015-2022, All Rights Reserved #} +{% load origin %} +{% load ietf_filters %} +{% origin %} +
+{% if not document_html %} +
+ +
+{% endif %} + +{% if not document_html %} +
+
+
+ +
+{% endif %} + +{% if not document_html %} +
+
+
+ +
+{% endif %} + + {% if not document_html %} + + + {% endif %} + +{% if not document_html %} +
+
+{% endif %} +
\ No newline at end of file diff --git a/ietf/templates/doc/document_info.html b/ietf/templates/doc/document_info.html index d994af559..25de5b633 100644 --- a/ietf/templates/doc/document_info.html +++ b/ietf/templates/doc/document_info.html @@ -79,14 +79,13 @@ {% include "doc/revisions_list.html" with document_html=document_html %} - {% if doc.rev != "00" %} + {% if diff_revisions|length > 1 %} Compare versions - Inline - Side-by-side + {% include "doc/document_history_form.html" with doc=doc diff_revisions=diff_revisions action=rfcdiff_base_url document_html=document_html only %} {% endif %}