btcpayserver/BTCPayServer/wwwroot/pos/admin.js
d11n 9b5c8a8254
POS: Add item list to keypad (#5814)
* Add admin option to show item list for keypad view

* Refactor common POS Vue mixin

* Add item list to POS keypad

* Add recent transactions to cart

* Keypad: Pass tip and discount as cart does

* Keypad and cart tests

* Improve offcanvas button

---------

Co-authored-by: Andrew Camilleri <evilkukka@gmail.com>
2024-03-14 11:11:54 +01:00

65 lines
2 KiB
JavaScript

const description = document.getElementById('description');
const products = document.getElementById('products');
const tips = document.getElementById('tips');
const cart = document.getElementById('cart-display');
const keypad = document.getElementById('keypad-display');
const discounts = document.getElementById('discounts');
const buttonPriceText = document.getElementById('button-price-text');
const customPayments = document.getElementById('custom-payments');
function hide(el) {
el.setAttribute('hidden', true);
}
function show(el) {
el.removeAttribute('hidden');
}
function updateFormForDefaultView(type) {
switch (type) {
case 'Static':
case 'Print':
hide(tips);
hide(cart);
hide(keypad);
hide(discounts);
hide(buttonPriceText);
show(description);
show(products);
show(customPayments);
break;
case 'Cart':
show(cart);
show(tips);
show(products);
show(discounts);
show(description);
show(buttonPriceText);
hide(customPayments);
hide(keypad);
break;
case 'Light':
show(tips);
show(discounts);
show(keypad);
hide(cart);
hide(description);
hide(buttonPriceText);
hide(customPayments);
document.getElementById('ShowItems').checked ? show(products) : hide(products);
break;
}
}
document.addEventListener('DOMContentLoaded', () => {
const defaultView = document.querySelector('input[name="DefaultView"]:checked');
if (defaultView) {
updateFormForDefaultView(defaultView.value);
}
});
delegate('change', 'input[name="DefaultView"]', e => {
updateFormForDefaultView(e.target.value);
});
delegate('change', 'input[name="ShowItems"]', e => {
e.target.checked ? show(products) : hide(products);
});