[PATCH v4 2/5] patch-list: move js code to separate file
Stephen Finucane
stephen at that.guru
Sat Nov 2 03:01:27 AEDT 2024
On Mon, 2021-08-23 at 18:28 +0000, Raxel Gutierrez wrote:
> 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 <raxel at google.com>
An easier one to resolve with respect to merge conflicts.
Reviewed-by: Stephen Finucane <stephen at that.guru>
...and applied
Stephen
> ---
> htdocs/README.rst | 6 ++++++
> htdocs/js/patch-list.js | 12 ++++++++++++
> .../patchwork/partials/patch-list.html | 19 ++++---------------
> 3 files changed, 22 insertions(+), 15 deletions(-)
> create mode 100644 htdocs/js/patch-list.js
>
> diff --git a/htdocs/README.rst b/htdocs/README.rst
> index d53619ad..6c435124 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..6ae13721
> --- /dev/null
> +++ b/htdocs/js/patch-list.js
> @@ -0,0 +1,12 @@
> +$( document ).ready(function() {
> + $("#patch-list").stickyTableHeaders();
> +
> + $("#check-all").change(function(e) {
> + if(this.checked) {
> + $("#patch-list > tbody").checkboxes("check");
> + } else {
> + $("#patch-list > tbody").checkboxes("uncheck");
> + }
> + e.preventDefault();
> + });
> +});
> \ No newline at end of file
> diff --git a/patchwork/templates/patchwork/partials/patch-list.html b/patchwork/templates/patchwork/partials/patch-list.html
> index 80ae6908..19b019cd 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 %}
> + <script src="{% static "js/patch-list.js" %}"></script>
> +{% endblock %}
> +
> {% include "patchwork/partials/filters.html" %}
>
> {% include "patchwork/partials/pagination.html" %}
> @@ -35,21 +39,6 @@
> </div>
> {% endif %}
>
> -<script type="text/javascript">
> -$(document).ready(function() {
> - $('#patchlist').stickyTableHeaders();
> -
> - $('#check-all').change(function(e) {
> - if(this.checked) {
> - $('#patchlist > tbody').checkboxes('check');
> - } else {
> - $('#patchlist > tbody').checkboxes('uncheck');
> - }
> - e.preventDefault();
> - });
> -});
> -</script>
> -
> <form method="post">
> {% csrf_token %}
> <input type="hidden" name="form" value="patch-list-form"/>
More information about the Patchwork
mailing list