mirror of
https://github.com/kbenestad/ClubLedger.git
synced 2026-06-18 09:44:33 +00:00
Remove product search from bar tab
Removed product search field, results list, barProductLookup(), and selectProduct() from the bar view in index.html, bar.html, app.js, and bar.js. Backend /products endpoints are unchanged. https://claude.ai/code/session_01JuRTR5Xjx8emQsyerBgGU7
This commit is contained in:
parent
6c155d00bb
commit
79d51973cd
4 changed files with 0 additions and 93 deletions
|
|
@ -232,8 +232,6 @@ function selectBarMember(id, name, number, balance, balanceDisplay) {
|
|||
document.getElementById('barSelected').innerHTML =
|
||||
`<strong>${esc(name)}</strong> #${esc(number)} Balance: <span class="${balanceClass(balance)}">${esc(balanceDisplay)}</span>`;
|
||||
document.getElementById('barForm').classList.remove('hidden');
|
||||
document.getElementById('barProductSearch').value = '';
|
||||
document.getElementById('barProductResults').innerHTML = '';
|
||||
setMsg('barMsg', '', '');
|
||||
}
|
||||
|
||||
|
|
@ -243,46 +241,9 @@ function clearBarSelection() {
|
|||
document.getElementById('barAmount').value = '';
|
||||
document.getElementById('barPin').value = '';
|
||||
document.getElementById('barNote').value = '';
|
||||
document.getElementById('barProductSearch').value = '';
|
||||
document.getElementById('barProductResults').innerHTML = '';
|
||||
setMsg('barMsg', '', '');
|
||||
}
|
||||
|
||||
let productTimer = null;
|
||||
async function barProductLookup() {
|
||||
clearTimeout(productTimer);
|
||||
productTimer = setTimeout(async () => {
|
||||
const q = document.getElementById('barProductSearch').value.trim();
|
||||
if (!q) { document.getElementById('barProductResults').innerHTML = ''; return; }
|
||||
try {
|
||||
const products = await apiFetch(`/products?q=${encodeURIComponent(q)}`);
|
||||
const div = document.getElementById('barProductResults');
|
||||
if (!products.length) {
|
||||
div.innerHTML = '<div style="color:#888;font-size:.88rem;padding:4px">No products found</div>';
|
||||
return;
|
||||
}
|
||||
div.innerHTML = products.map(p => `
|
||||
<div class="product-item" onclick="selectProduct(${p.price},${p.member_price || p.price},'${esc(p.name)}${p.brand ? ' – ' + esc(p.brand) : ''}')">
|
||||
<div>
|
||||
<strong>${esc(p.name)}</strong>${p.brand ? ` <span style="color:#888">– ${esc(p.brand)}</span>` : ''}
|
||||
${p.search_tags ? `<div style="font-size:.78rem;color:#aaa">${esc(p.search_tags)}</div>` : ''}
|
||||
</div>
|
||||
<div>
|
||||
<span class="product-price">${esc(p.price_display)}</span>
|
||||
${p.member_price_display ? `<span style="font-size:.82rem;color:#34d399;margin-left:6px">mbr: ${esc(p.member_price_display)}</span>` : ''}
|
||||
</div>
|
||||
</div>`).join('');
|
||||
} catch (e) { console.error(e); }
|
||||
}, 250);
|
||||
}
|
||||
|
||||
function selectProduct(price, memberPrice, label) {
|
||||
document.getElementById('barAmount').value = memberPrice;
|
||||
document.getElementById('barNote').value = label;
|
||||
document.getElementById('barProductResults').innerHTML = '';
|
||||
document.getElementById('barProductSearch').value = '';
|
||||
}
|
||||
|
||||
async function doCharge() {
|
||||
if (!barMember) return;
|
||||
const amount = parseInt(document.getElementById('barAmount').value, 10);
|
||||
|
|
|
|||
|
|
@ -27,12 +27,6 @@
|
|||
<div id="barForm" class="hidden">
|
||||
<div class="selected-member-box" id="barSelected"></div>
|
||||
|
||||
<div class="form-row">
|
||||
<label>Product Search</label>
|
||||
<input type="text" id="barProductSearch" placeholder="Search products…" oninput="barProductLookup()">
|
||||
</div>
|
||||
<div id="barProductResults" class="product-results"></div>
|
||||
|
||||
<div class="form-row">
|
||||
<label>Amount (<span class="currency-unit"></span>)</label>
|
||||
<input type="number" id="barAmount" placeholder="e.g. 350" min="1" step="1">
|
||||
|
|
|
|||
|
|
@ -35,8 +35,6 @@ function selectBarMember(id, name, number, balance, balanceDisplay) {
|
|||
document.getElementById('barSelected').innerHTML =
|
||||
`<strong>${esc(name)}</strong> #${esc(number)} Balance: <span class="${balanceClass(balance)}">${esc(balanceDisplay)}</span>`;
|
||||
document.getElementById('barForm').classList.remove('hidden');
|
||||
document.getElementById('barProductSearch').value = '';
|
||||
document.getElementById('barProductResults').innerHTML = '';
|
||||
setMsg('barMsg', '', '');
|
||||
}
|
||||
|
||||
|
|
@ -46,49 +44,9 @@ function clearBarSelection() {
|
|||
document.getElementById('barAmount').value = '';
|
||||
document.getElementById('barPin').value = '';
|
||||
document.getElementById('barNote').value = '';
|
||||
document.getElementById('barProductSearch').value = '';
|
||||
document.getElementById('barProductResults').innerHTML = '';
|
||||
setMsg('barMsg', '', '');
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Product search
|
||||
// ---------------------------------------------------------------------------
|
||||
let productTimer = null;
|
||||
async function barProductLookup() {
|
||||
clearTimeout(productTimer);
|
||||
productTimer = setTimeout(async () => {
|
||||
const q = document.getElementById('barProductSearch').value.trim();
|
||||
if (!q) { document.getElementById('barProductResults').innerHTML = ''; return; }
|
||||
try {
|
||||
const products = await apiFetch(`/products?q=${encodeURIComponent(q)}`);
|
||||
const div = document.getElementById('barProductResults');
|
||||
if (!products.length) {
|
||||
div.innerHTML = '<div style="color:#888;font-size:.88rem;padding:4px">No products found</div>';
|
||||
return;
|
||||
}
|
||||
div.innerHTML = products.map(p => `
|
||||
<div class="product-item" onclick="selectProduct(${p.price},${p.member_price || p.price},'${esc(p.name)}${p.brand ? ' – ' + esc(p.brand) : ''}')">
|
||||
<div>
|
||||
<strong>${esc(p.name)}</strong>${p.brand ? ` <span style="color:#888">– ${esc(p.brand)}</span>` : ''}
|
||||
${p.search_tags ? `<div style="font-size:.78rem;color:#aaa">${esc(p.search_tags)}</div>` : ''}
|
||||
</div>
|
||||
<div>
|
||||
<span class="product-price">${esc(p.price_display)}</span>
|
||||
${p.member_price_display ? `<span style="font-size:.82rem;color:#34d399;margin-left:6px">mbr: ${esc(p.member_price_display)}</span>` : ''}
|
||||
</div>
|
||||
</div>`).join('');
|
||||
} catch (e) { console.error(e); }
|
||||
}, 250);
|
||||
}
|
||||
|
||||
function selectProduct(price, memberPrice, label) {
|
||||
document.getElementById('barAmount').value = memberPrice;
|
||||
document.getElementById('barNote').value = label;
|
||||
document.getElementById('barProductResults').innerHTML = '';
|
||||
document.getElementById('barProductSearch').value = '';
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Charge
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -108,12 +108,6 @@
|
|||
<div id="barForm" class="hidden">
|
||||
<div class="selected-member-box" id="barSelected"></div>
|
||||
|
||||
<div class="form-row">
|
||||
<label>Product Search</label>
|
||||
<input type="text" id="barProductSearch" placeholder="Search products…" oninput="barProductLookup()">
|
||||
</div>
|
||||
<div id="barProductResults" class="product-results"></div>
|
||||
|
||||
<div class="form-row">
|
||||
<label>Amount (<span class="currency-unit"></span>)</label>
|
||||
<input type="number" id="barAmount" placeholder="e.g. 350" min="1" step="1">
|
||||
|
|
|
|||
Loading…
Reference in a new issue