From 7503895a4fea65bb7f97b94a9336aca045e21034 Mon Sep 17 00:00:00 2001 From: RubenPX Date: Fri, 29 Apr 2022 13:34:45 +0200 Subject: [PATCH] Adds selector by pages --- ereuse_devicehub/static/js/main_inventory.js | 23 ++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/ereuse_devicehub/static/js/main_inventory.js b/ereuse_devicehub/static/js/main_inventory.js index 74ef3196..0d902a0b 100644 --- a/ereuse_devicehub/static/js/main_inventory.js +++ b/ereuse_devicehub/static/js/main_inventory.js @@ -19,9 +19,11 @@ $(document).ready(() => { class TableController { static #tableRows = table.rows().dt.activeRows; + + static #tableRowsPage = table.rows().dt.pages[table.rows().dt.currentPage - 1]; /** - * @returns This will return all input attributes from selected devices + * @returns Selected inputs from device list */ static getSelectedDevices() { return this.#tableRows @@ -30,13 +32,30 @@ class TableController { } /** - * @returns This will return all input attributes from all devices in list + * @returns Selected inputs in current page from device list + */ + static getAllSelectedDevicesInCurrentPage() { + return this.#tableRowsPage + .filter(element => element.querySelector("input").checked) + .map(element => element.querySelector("input")) + } + + /** + * @returns All inputs from device list */ static getAllDevices() { return this.#tableRows .map(element => element.querySelector("input")) } + /** + * @returns All inputs from current page in device list + */ + static getAllDevicesInCurrentPage() { + return this.#tableRows + .map(element => element.querySelector("input")) + } + /** * * @param {HTMLElement} DOMElements