Fix: Updated removed redundant filtering, and getting for single-page architecture, which this is not on all pages

This commit is contained in:
2024-11-14 12:58:57 +00:00
parent 70de7026d3
commit 8fc3d8a803
21 changed files with 136 additions and 659 deletions

View File

@@ -14,27 +14,10 @@ import OverlayError from "../components/common/temporary/overlay_error.js";
export default class TableBasePage extends BasePage {
// static hash
// static attrIdRowObject
// callFilterTableContent
// callSaveTableContent
constructor(router) {
super(router);
/*
if (!this.constructor.callFilterTableContent) {
throw new Error(`Class ${this.constructor.name} must have a static callFilterTableContent method attribute that takes a single argument - the filters as json.`);
}
if (!this.constructor.callSaveTableContent) {
throw new Error(`Class ${this.constructor.name} must have a static callSaveTableContent method attribute that takes 3 arguments - a list of records, the filters as json, and a comment for saving.`);
}
this.initialize();
// this.hookupFilters();
this.loadRowTable(null);
this.getJsonRow(null);
// this.hookupTableMain();
this.getTableRecords();
this.leave();
*/
// this.cursorXInitial = null;
this.cursorYInitial = null;
this.rowInitial = null;
this.placeholder = null;
@@ -67,7 +50,7 @@ export default class TableBasePage extends BasePage {
let formFilters = this.getFormFilters();
let filtersDefault = DOM.convertForm2JSON(formFilters);
if (!Validation.areEqualDicts(filters, filtersDefault)) {
this.callFilterTableContent(filters);
this.callFilterTableContent();
}
}
}
@@ -105,15 +88,18 @@ export default class TableBasePage extends BasePage {
});
}
getAndLoadFilteredTableContent() {
let formFilters = this.getFormFilters();
let filtersJson = DOM.convertForm2JSON(formFilters);
this.leave();
this.callFilterTableContent(filtersJson)
this.callFilterTableContent()
.catch(error => console.error('Error:', error));
}
getFormFilters() {
return document.querySelector(idFormFilters);
}
callFilterTableContent() {
let formFilters = this.getFormFilters();
let filtersJson = DOM.convertForm2JSON(formFilters);
this.leave();
API.goToHash(this.constructor.hash, filtersJson);
}
callbackLoadTableContent(response) {
let table = TableBasePage.getTableMain();
let bodyTable = table.querySelector('tbody');
@@ -132,9 +118,7 @@ export default class TableBasePage extends BasePage {
throw new Error("Subclass of TableBasePage must implement method loadRowTable().");
}
getAndLoadFilteredTableContentSinglePageApp() {
let formFilters = this.getFormFilters();
let filtersJson = DOM.convertForm2JSON(formFilters);
this.callFilterTableContent(filtersJson)
this.callFilterTableContent()
.then(data => {
if (_verbose) { console.log('Table data received:', data); }
this.callbackLoadTableContent(data);
@@ -979,7 +963,6 @@ import DOM from "../dom.js";
export class PageStoreProductCategories extends TableBasePage {
static hash = hashPageStoreProductCategories;
static attrIdRowObject = attrIdProductCategory;
callFilterTableContent = API.getCategoriesByFilters;
callSaveTableContent = API.saveCategories;
constructor() {}

View File

@@ -12,7 +12,6 @@ import StoreTableMixinPage from "./mixin_table.js";
export default class PageStoreManufacturingPurchaseOrders extends TableBasePage {
static hash = hashPageStoreManufacturingPurchaseOrders;
static attrIdRowObject = attrIdManufacturingPurchaseOrder;
callFilterTableContent = API.getManufacturingPurchaseOrdersByFilters;
callSaveTableContent = API.saveManufacturingPurchaseOrders;
constructor(router) {

View File

@@ -8,7 +8,6 @@ import StoreTableMixinPage from "./mixin_table.js";
export default class PageStoreProductCategories extends TableBasePage {
static hash = hashPageStoreProductCategories;
static attrIdRowObject = attrIdProductCategory;
callFilterTableContent = API.getCategoriesByFilters;
callSaveTableContent = API.saveCategories;
constructor(router) {

View File

@@ -11,7 +11,6 @@ import StoreTableMixinPage from "./mixin_table.js";
export default class PageStoreProductPermutations extends TableBasePage {
static hash = hashPageStoreProductPermutations;
static attrIdRowObject = attrIdProductPermutation;
callFilterTableContent = API.getProductPermutationsByFilters;
callSaveTableContent = API.saveProductPermutations;
constructor(router) {

View File

@@ -11,7 +11,6 @@ import StoreTableMixinPage from "./mixin_table.js";
export default class PageStoreProductVariations extends TableBasePage {
static hash = hashPageStoreProductVariations;
static attrIdRowObject = attrIdProductVariationType;
callFilterTableContent = API.getProductVariationsByFilters;
callSaveTableContent = API.saveProductVariations;
constructor(router) {

View File

@@ -9,7 +9,6 @@ import Utils from "../../lib/utils.js";
export default class PageStoreProducts extends TableBasePage {
static hash = hashPageStoreProducts;
static attrIdRowObject = attrIdProduct;
callFilterTableContent = API.getProductsByFilters;
callSaveTableContent = API.saveProducts;
constructor(router) {

View File

@@ -11,7 +11,6 @@ import StoreTableMixinPage from "./mixin_table.js";
export default class PageStoreStockItems extends TableBasePage {
static hash = hashPageStoreStockItems;
static attrIdRowObject = attrIdStockItem;
callFilterTableContent = API.getStockItemsByFilters;
callSaveTableContent = API.saveStockItems;
constructor(router) {

View File

@@ -12,7 +12,6 @@ import StoreTableMixinPage from "./mixin_table.js";
export default class PageStoreSupplierPurchaseOrders extends TableBasePage {
static hash = hashPageStoreSupplierPurchaseOrders;
static attrIdRowObject = attrIdSupplierPurchaseOrder;
callFilterTableContent = API.getSupplierPurchaseOrdersByFilters;
callSaveTableContent = API.saveSupplierPurchaseOrders;
constructor(router) {

View File

@@ -11,7 +11,6 @@ import StoreTableMixinPage from "./mixin_table.js";
export default class PageStoreSuppliers extends TableBasePage {
static hash = hashPageStoreSuppliers;
static attrIdRowObject = attrIdSupplier;
callFilterTableContent = API.getSuppliersByFilters;
callSaveTableContent = API.saveSuppliers;
constructor(router) {