From 0cea2e4a9f418b2da7d8ca2a0236563ae737415c Mon Sep 17 00:00:00 2001 From: Raxel Gutierrez Date: Mon, 23 Aug 2021 18:28:30 +0000 Subject: [PATCH] views: Move js code to separate file Move patch-list related JS code to a new patch-list.js file, to make the JavaScript easy to read and change in one place. This makes automatic code formatting easier, makes it more straightforward to measure test coverage and discover opportunities for refactoring, and simplifies a possible future migration to TypeScript if the project chooses to go in that direction. No user-visible change should be noticed. Signed-off-by: Raxel Gutierrez Signed-off-by: Stephen Finucane [stephenfin: Addressed merged conflicts] --- htdocs/README.rst | 6 ++++++ htdocs/js/patch-list.js | 14 +++++++++++++ .../patchwork/partials/patch-list.html | 21 ++++--------------- 3 files changed, 24 insertions(+), 17 deletions(-) create mode 100644 htdocs/js/patch-list.js diff --git a/htdocs/README.rst b/htdocs/README.rst index 22fe58d1..9a521123 100644 --- a/htdocs/README.rst +++ b/htdocs/README.rst @@ -122,6 +122,12 @@ js :GitHub: https://github.com/js-cookie/js-cookie/ :Version: 3.0.0 +``patch-list.js.`` + Event helpers and other application logic for patch-list.html. These + support patch list manipulation. + + Part of Patchwork. + ``rest.js.`` Utility module for REST API requests to be used by other Patchwork JS files. diff --git a/htdocs/js/patch-list.js b/htdocs/js/patch-list.js new file mode 100644 index 00000000..6be031a4 --- /dev/null +++ b/htdocs/js/patch-list.js @@ -0,0 +1,14 @@ +$( document ).ready(function() { + $("#patch-list").stickyTableHeaders(); + + $("#patch-list").checkboxes("range", true); + + $("#check-all").change(function(e) { + if(this.checked) { + $("#patch-list > tbody").checkboxes("check"); + } else { + $("#patch-list > tbody").checkboxes("uncheck"); + } + e.preventDefault(); + }); +}); diff --git a/patchwork/templates/patchwork/partials/patch-list.html b/patchwork/templates/patchwork/partials/patch-list.html index 48b81f3d..1bdef36d 100644 --- a/patchwork/templates/patchwork/partials/patch-list.html +++ b/patchwork/templates/patchwork/partials/patch-list.html @@ -4,6 +4,10 @@ {% load project %} {% load static %} +{% block headers %} + +{% endblock %} + {% include "patchwork/partials/filters.html" %} {% include "patchwork/partials/pagination.html" %} @@ -32,23 +36,6 @@ {% endif %} - -
{% csrf_token %} -- 2.47.3