Transactions: show ID on Edit page and add Copy ID button

Co-authored-by:Codex-CLI-Agent
codex-cli@users.noreply.local
This commit is contained in:
AJ
2025-10-19 00:07:41 -04:00
parent fa142288b6
commit eb31039bc8

View File

@@ -1,11 +1,11 @@
@page "{id:long}" @page "{id:long}"
@model MoneyMap.Pages.EditTransactionModel @model MoneyMap.Pages.EditTransactionModel
@{ @{
ViewData["Title"] = "Edit Transaction"; ViewData["Title"] = "Edit Transaction";
} }
<div class="d-flex justify-content-between align-items-center mb-3"> <div class="d-flex justify-content-between align-items-center mb-3">
<h2>Edit Transaction</h2> <h2 class="mb-0">Edit Transaction <small class="text-muted">#@Model.Transaction.Id</small> <button type="button" class="btn btn-sm btn-outline-secondary ms-2" onclick="copyTransactionId()">Copy ID</button></h2>
<a asp-page="/Transactions" class="btn btn-outline-secondary">Back to Transactions</a> <a asp-page="/Transactions" class="btn btn-outline-secondary">Back to Transactions</a>
</div> </div>
@@ -159,7 +159,7 @@
</div> </div>
<small class="text-muted"> <small class="text-muted">
@((item.Receipt.FileSizeBytes / 1024.0).ToString("F1")) KB @((item.Receipt.FileSizeBytes / 1024.0).ToString("F1")) KB
· @item.Receipt.UploadedAtUtc.ToLocalTime().ToString("MMM d, yyyy") · @item.Receipt.UploadedAtUtc.ToLocalTime().ToString("MMM d, yyyy")
</small> </small>
@if (!string.IsNullOrWhiteSpace(item.Receipt.Merchant)) @if (!string.IsNullOrWhiteSpace(item.Receipt.Merchant))
{ {
@@ -308,4 +308,23 @@
handleMerchantChange(); handleMerchantChange();
}); });
</script> </script>
} }
<script>
function copyTransactionId() {
var id = '@Model.Transaction.Id';
if (navigator.clipboard && window.isSecureContext) {
navigator.clipboard.writeText(id.toString());
} else {
var ta = document.createElement('textarea');
ta.value = id;
document.body.appendChild(ta);
ta.select();
document.execCommand('copy');
document.body.removeChild(ta);
}
var btns = document.querySelectorAll('button[onclick="copyTransactionId()"]');
btns.forEach(function(btn){ var old=btn.textContent; btn.textContent='Copied!'; setTimeout(function(){ btn.textContent=old; }, 1500); });
}
</script>