fix(budgets,tags,piggy-banks,dashboard): live buttons that answer in place, lucide icons, mobile wrapping
This commit is contained in:
1 parent
aba2509399
commit
f3a603648e
10 files changed
+102
-71
No files matched your search
@@ -30,6 +30,7 @@
|
||||
|
||||
const action = new Action();
|
||||
const values = $state<Record<string, string>>({});
|
||||
const fields: Record<string, HTMLElement> = {};
|
||||
|
||||
const links = $derived(
|
||||
(piggy.attributes.accounts ?? []).map((link) => {
|
||||
@@ -50,9 +51,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
function fail(message: string) {
|
||||
function fail(message: string, id = open[0]?.id ?? "") {
|
||||
action.failed = true;
|
||||
action.message = message;
|
||||
fields[id]?.focus();
|
||||
}
|
||||
|
||||
async function save() {
|
||||
@@ -64,11 +66,11 @@
|
||||
}
|
||||
const amount = evalAmount(raw);
|
||||
if (amount === null || amount <= 0) {
|
||||
return fail("Enter an amount above zero");
|
||||
return fail("Enter an amount above zero", link.id);
|
||||
}
|
||||
if (amount > link.max + 1e-9) {
|
||||
const max = formatMoney(piggyMoney(piggy.attributes, link.max));
|
||||
return fail(`${link.name} allows at most ${max}`);
|
||||
return fail(`${link.name} allows at most ${max}`, link.id);
|
||||
}
|
||||
deltas[link.id] = mode === "add" ? amount : -amount;
|
||||
}
|
||||
@@ -109,6 +111,7 @@
|
||||
onkeydown={onEscape}
|
||||
bind:value={values[link.id]}
|
||||
{@attach (node) => {
|
||||
fields[link.id] = node;
|
||||
if (i === 0) {
|
||||
node.focus();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user