From 8cd011fc01b414227a259838d41c0c440c7f2cbd Mon Sep 17 00:00:00 2001 From: grey Date: Wed, 19 Mar 2025 23:15:12 +0100 Subject: [PATCH] added old transactions to payup view --- static/apiWrapper.js | 7 ++++++- static/pageDriver.js | 19 +++++++++++++++---- static/pages/payup.js | 5 +++++ views/payup.eta | 25 +++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 5 deletions(-) diff --git a/static/apiWrapper.js b/static/apiWrapper.js index 421ea48..af05e8a 100644 --- a/static/apiWrapper.js +++ b/static/apiWrapper.js @@ -172,7 +172,7 @@ function getApiDescriptionByTable(tableName) { } } -function returnTableDataByTableName(tableName, search="", orderBy="asc", sort="", take=-1, skip=0) { +function returnTableDataByTableName(tableName, search="", orderBy="asc", sort="", take=-1, skip=0, filters=[]) { var orderBy = orderBy.toLowerCase(); if(orderBy == "") { orderBy = "asc"; @@ -187,6 +187,10 @@ function returnTableDataByTableName(tableName, search="", orderBy="asc", sort="" if(skip > 0) { baseString += "&skip=" + skip; } + filterKeys = Object.keys(filters); + for(var i = 0; i < filterKeys.length; i++) { + baseString += "&" + filterKeys[i] + "=" + filters[filterKeys[i]]; + } if (search && search.length > 0) { return _api.get(baseString + '&search=' + search); @@ -214,6 +218,7 @@ async function getCountByTable(tableName, search="") { function _testPageFail(reason) { + return; document.getElementById('heroStatus').classList.remove('is-success'); document.getElementById('heroStatus').classList.add('is-danger'); diff --git a/static/pageDriver.js b/static/pageDriver.js index 070eeac..1c949fe 100644 --- a/static/pageDriver.js +++ b/static/pageDriver.js @@ -74,6 +74,9 @@ tables.forEach(async (table) => { refreshTable(table); }); }); + if(table.getAttribute("data-loadmode") == "manual") { + return; + } refreshTable(table); }); @@ -289,6 +292,7 @@ async function refreshTable(table) { }); let order = ''; let column = ''; + let filters = JSON.parse(table.getAttribute('data-filters')) || {}; ths.forEach((th) => { if (th.hasAttribute('data-order')) { order = th.getAttribute('data-order'); @@ -317,7 +321,7 @@ async function refreshTable(table) { if (searchField) { const value = searchField.value; const dbTable = table.getAttribute('data-dataSource'); - const result = await returnTableDataByTableName(dbTable, value, order, column, take=maxLinesPerPage, skip= start); + const result = await returnTableDataByTableName(dbTable, value, order, column, take=maxLinesPerPage, skip=start, filters); const totalResultCount = await getCountByTable(dbTable, value); paginationPassOnPre['dataLength'] = totalResultCount; var magMiddl = managePaginationMiddleware(result, paginationPassOnPre); @@ -326,7 +330,7 @@ async function refreshTable(table) { clearTable(table); writeDataToTable(table, data, paginationPassOn); } else { - const result = await returnTableDataByTableName(table.getAttribute('data-dataSource'), undefined, order, column, take= maxLinesPerPage, skip= start); + const result = await returnTableDataByTableName(table.getAttribute('data-dataSource'), undefined, order, column, take= maxLinesPerPage, skip= start, filters); const resultCount = await getCountByTable(table.getAttribute('data-dataSource')); paginationPassOnPre['dataLength'] = resultCount; var magMiddl = managePaginationMiddleware(result, paginationPassOnPre); @@ -510,8 +514,15 @@ function writeDataToTable(table, data, paginationPassOn) { if(header.getAttribute('data-type') == "bool") { td.innerHTML = row[column] ? '' : ''; - - } else { + + } else if(header.getAttribute('data-type') == "datetime"){ + if(row[column] == null) { + td.innerHTML = ""; + } else { + td.innerHTML = formatTimestamp(row[column]); + } + } + else { td.innerHTML = row[column]; } tr.appendChild(td); diff --git a/static/pages/payup.js b/static/pages/payup.js index 092df46..1d837b7 100644 --- a/static/pages/payup.js +++ b/static/pages/payup.js @@ -11,6 +11,8 @@ const btn_paynow = document.getElementById("paynow"); const btn_confirm = document.getElementById("confirmCheckout"); const btn_logout = document.getElementById("logout"); +const table_old = document.getElementById("alltransactions"); + errorIfAnyUndefined([isEmptyAlert, tableDiv, payTable, tableCnt, tableSum, modal_sum]) // Current user @@ -20,6 +22,9 @@ if(cookieUser == undefined) { createTemporaryNotification('Fehler: Nutzer nicht angemeldet.', 'is-danger'); window.location.href = '/user_select'; } +table_old.setAttribute('data-filters', `{"user_id": ${cookieUser}}`); +refreshTable(table_old); +console.log("Table refreshed"); let transactionIds = []; diff --git a/views/payup.eta b/views/payup.eta index 3ebee85..2fade8c 100644 --- a/views/payup.eta +++ b/views/payup.eta @@ -32,6 +32,28 @@ +
+ Alle Transaktionen + + + + + + + + + + + + + +
IdNameBezahltAusgestellt amBezahlt am
+ +
@@ -56,6 +78,9 @@ + + + <%~ include("partials/footer.eta") %> <%~ include("partials/base_foot.eta") %>