From 80bae4167f544796afdcc518bf3d4ffa55b9a358 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Mon, 21 Aug 2023 22:48:47 +0200 Subject: [PATCH] Added button to inverse part selection in tables Fix issue #346 --- .../elements/datatables/datatables_controller.js | 12 ++++++++++++ templates/components/datatables.macro.html.twig | 4 +++- translations/messages.en.xlf | 6 ++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/assets/controllers/elements/datatables/datatables_controller.js b/assets/controllers/elements/datatables/datatables_controller.js index 3f339302..c53db751 100644 --- a/assets/controllers/elements/datatables/datatables_controller.js +++ b/assets/controllers/elements/datatables/datatables_controller.js @@ -239,4 +239,16 @@ export default class extends Controller { return this.element.dataset.select ?? false; } + invertSelection() { + //Do nothing if the datatable is not selectable + if(!this.isSelectable()) { + return; + } + + //Invert the selected rows on the datatable + const selected_rows = this._dt.rows({selected: true}); + this._dt.rows().select(); + selected_rows.deselect(); + } + } diff --git a/templates/components/datatables.macro.html.twig b/templates/components/datatables.macro.html.twig index dadfad69..9c88e461 100644 --- a/templates/components/datatables.macro.html.twig +++ b/templates/components/datatables.macro.html.twig @@ -32,6 +32,8 @@ {# #}
+ {% trans with {'%count%': ''} %}part_list.action.part_count{% endtrans %} @@ -75,7 +77,7 @@ {# This is left empty, as this will be filled by Javascript #} - +
diff --git a/translations/messages.en.xlf b/translations/messages.en.xlf index b1387196..bfb76b98 100644 --- a/translations/messages.en.xlf +++ b/translations/messages.en.xlf @@ -11615,5 +11615,11 @@ Please note, that you can not impersonate a disabled user. If you try you will g If this option is selected, the given withdraw quantities are used as given, no matter if more or less parts are actually required to build this project. + + + part_list.action.invert_selection + Invert selection + +