Skip to content

Commit be98eff

Browse files
committed
admin users: nest user detail panels and add clear/reset control
1 parent c9d8a45 commit be98eff

3 files changed

Lines changed: 36 additions & 4 deletions

File tree

web/admin.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ <h2>Users</h2>
9292
list="adminUserOptions"
9393
/>
9494
<button class="btn btn--primary" id="userSearchBtn" type="button">Find User</button>
95+
<button class="btn btn--link" id="userClearBtn" type="button" aria-label="Clear selected user data">X</button>
9596
</div>
9697
</div>
9798
<div id="usersPanelBody">
@@ -136,10 +137,7 @@ <h2>Users</h2>
136137
<span id="usersPageInfo" class="subtle">Page 1 of 1</span>
137138
<button class="btn" id="usersNextPage" type="button" disabled>Next →</button>
138139
</nav>
139-
</div>
140-
</section>
141-
142-
<section id="userDataSections" class="admin-grid is-hidden">
140+
<section id="userDataSections" class="admin-grid is-hidden">
143141
<section class="card admin-panel" id="recordsPanel">
144142
<div class="admin-panel-header">
145143
<div>
@@ -247,6 +245,8 @@ <h2>Budgets</h2>
247245
</div>
248246
</section>
249247
</section>
248+
</div>
249+
</section>
250250

251251
<section class="card admin-panel" id="settingsPanel">
252252
<div class="admin-panel-header">

web/scripts/admin.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const els = {
1414
usersStatus: document.getElementById("usersStatus"),
1515
userSearch: document.getElementById("userSearch"),
1616
userSearchBtn: document.getElementById("userSearchBtn"),
17+
userClearBtn: document.getElementById("userClearBtn"),
1718
userOptions: document.getElementById("adminUserOptions"),
1819
usersPrevPage: document.getElementById("usersPrevPage"),
1920
usersNextPage: document.getElementById("usersNextPage"),
@@ -1154,6 +1155,14 @@ function tryOpenUserDropdown() {
11541155
}
11551156
}
11561157

1158+
function clearSelectedUserPanels() {
1159+
if (els.userSearch) {
1160+
els.userSearch.value = "";
1161+
}
1162+
resetUserScopedData();
1163+
setStatus(els.usersStatus, "");
1164+
}
1165+
11571166
function bindEvents() {
11581167
document.querySelectorAll(".admin-sort-btn[data-table][data-key]").forEach((btn) => {
11591168
btn.addEventListener("click", () => {
@@ -1167,6 +1176,13 @@ function bindEvents() {
11671176
});
11681177
}
11691178

1179+
if (els.userClearBtn) {
1180+
els.userClearBtn.addEventListener("click", () => {
1181+
clearSelectedUserPanels();
1182+
loadUsers({ resetPage: true, evaluateSelection: false });
1183+
});
1184+
}
1185+
11701186
if (els.userSearch) {
11711187
els.userSearch.addEventListener("keydown", (event) => {
11721188
if (event.key === "Enter") {

web/styles/admin.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,22 @@
140140
min-width: 200px;
141141
}
142142

143+
#userClearBtn {
144+
min-width: 2rem;
145+
padding-inline: 0.55rem;
146+
color: #c81e1e;
147+
border: 1px solid color-mix(in srgb, #c81e1e 35%, var(--border));
148+
border-radius: var(--radius-sm);
149+
background: color-mix(in srgb, #fff 92%, #ffebeb);
150+
font-weight: 700;
151+
}
152+
153+
#userClearBtn:hover,
154+
#userClearBtn:focus-visible {
155+
color: #8f1414;
156+
border-color: color-mix(in srgb, #8f1414 45%, var(--border));
157+
}
158+
143159
.admin-form {
144160
display: grid;
145161
gap: var(--space-3);

0 commit comments

Comments
 (0)