ui can create transaction, submits text instead of html
parent
1345071f0a
commit
3e9349078c
|
|
@ -2,6 +2,15 @@
|
||||||
<header>
|
<header>
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/dark.css">
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/dark.css">
|
||||||
<style>
|
<style>
|
||||||
|
body > div {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.center {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.right {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
#transactions > tbody > tr > td:first-child input {
|
#transactions > tbody > tr > td:first-child input {
|
||||||
padding: 1ch;
|
padding: 1ch;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
|
@ -93,6 +102,25 @@
|
||||||
|
|
||||||
document.getElementById("transactions").innerHTML = innerHTML
|
document.getElementById("transactions").innerHTML = innerHTML
|
||||||
}
|
}
|
||||||
|
function newTransaction() {
|
||||||
|
var today = new Date()
|
||||||
|
var year = today.getFullYear()
|
||||||
|
var month = today.getMonth()+1
|
||||||
|
var day = today.getDate()
|
||||||
|
if (day < 10) {
|
||||||
|
day = `0${day}`
|
||||||
|
}
|
||||||
|
if (month < 10) {
|
||||||
|
month = `0${month}`
|
||||||
|
}
|
||||||
|
http("post", "/api/transactions", () => {init()}, JSON.stringify({
|
||||||
|
Date: `${year}-${month}-${day}`,
|
||||||
|
Description: "?",
|
||||||
|
Payer: "?",
|
||||||
|
Payee: "?",
|
||||||
|
Amount: 0,
|
||||||
|
}))
|
||||||
|
}
|
||||||
function saveTransaction(row) {
|
function saveTransaction(row) {
|
||||||
const inputs = row.getElementsByTagName("td")
|
const inputs = row.getElementsByTagName("td")
|
||||||
var kvs = {}
|
var kvs = {}
|
||||||
|
|
@ -101,7 +129,7 @@
|
||||||
if (!key) {
|
if (!key) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
const value = inputs[i].innerHTML
|
const value = (inputs[i].textContent || inputs[i].innerText).replaceAll("\n", " ").trim()
|
||||||
kvs[key] = value
|
kvs[key] = value
|
||||||
if (!isNaN(value))
|
if (!isNaN(value))
|
||||||
kvs[key] = parseFloat(value)
|
kvs[key] = parseFloat(value)
|
||||||
|
|
@ -145,6 +173,7 @@
|
||||||
<summary>Balances</summary>
|
<summary>Balances</summary>
|
||||||
<div id="balances"></div>
|
<div id="balances"></div>
|
||||||
</details>
|
</details>
|
||||||
|
<div class="right"><button onclick="newTransaction();">New Transaction</button></div>
|
||||||
<table id="transactions"></table>
|
<table id="transactions"></table>
|
||||||
</body>
|
</body>
|
||||||
<footer>
|
<footer>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue