fix undefined
This will fix when you select all lots and you make change that clears list
This commit is contained in:
parent
c1829a657e
commit
6575e418e7
|
@ -18,7 +18,7 @@ $(document).ready(() => {
|
||||||
})
|
})
|
||||||
|
|
||||||
class TableController {
|
class TableController {
|
||||||
static #tableRows = table.activeRows;
|
static #tableRows = () => table.activeRows.length > 0 ? table.activeRows : [];
|
||||||
|
|
||||||
static #tableRowsPage = () => table.pages[table.rows().dt.currentPage - 1];
|
static #tableRowsPage = () => table.pages[table.rows().dt.currentPage - 1];
|
||||||
|
|
||||||
|
@ -26,7 +26,8 @@ class TableController {
|
||||||
* @returns Selected inputs from device list
|
* @returns Selected inputs from device list
|
||||||
*/
|
*/
|
||||||
static getSelectedDevices() {
|
static getSelectedDevices() {
|
||||||
return this.#tableRows
|
if (this.#tableRows() == undefined) return [];
|
||||||
|
return this.#tableRows()
|
||||||
.filter(element => element.querySelector("input").checked)
|
.filter(element => element.querySelector("input").checked)
|
||||||
.map(element => element.querySelector("input"))
|
.map(element => element.querySelector("input"))
|
||||||
}
|
}
|
||||||
|
@ -35,6 +36,7 @@ class TableController {
|
||||||
* @returns Selected inputs in current page from device list
|
* @returns Selected inputs in current page from device list
|
||||||
*/
|
*/
|
||||||
static getAllSelectedDevicesInCurrentPage() {
|
static getAllSelectedDevicesInCurrentPage() {
|
||||||
|
if (this.#tableRowsPage() == undefined) return [];
|
||||||
return this.#tableRowsPage()
|
return this.#tableRowsPage()
|
||||||
.filter(element => element.querySelector("input").checked)
|
.filter(element => element.querySelector("input").checked)
|
||||||
.map(element => element.querySelector("input"))
|
.map(element => element.querySelector("input"))
|
||||||
|
@ -44,7 +46,8 @@ class TableController {
|
||||||
* @returns All inputs from device list
|
* @returns All inputs from device list
|
||||||
*/
|
*/
|
||||||
static getAllDevices() {
|
static getAllDevices() {
|
||||||
return this.#tableRows
|
if (this.#tableRows() == undefined) return [];
|
||||||
|
return this.#tableRows()
|
||||||
.map(element => element.querySelector("input"))
|
.map(element => element.querySelector("input"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,6 +55,7 @@ class TableController {
|
||||||
* @returns All inputs from current page in device list
|
* @returns All inputs from current page in device list
|
||||||
*/
|
*/
|
||||||
static getAllDevicesInCurrentPage() {
|
static getAllDevicesInCurrentPage() {
|
||||||
|
if (this.#tableRowsPage() == undefined) return [];
|
||||||
return this.#tableRowsPage()
|
return this.#tableRowsPage()
|
||||||
.map(element => element.querySelector("input"))
|
.map(element => element.querySelector("input"))
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue