mirror of
https://github.com/cloudmaker97/DurstRechner.git
synced 2025-12-05 23:48:39 +00:00
Tab-States zurücksetzen
This commit is contained in:
parent
4e74cab1cc
commit
edc52a2caa
1 changed files with 25 additions and 2 deletions
|
|
@ -399,6 +399,9 @@ class CartManager {
|
||||||
*/
|
*/
|
||||||
registerCartResetEvent() {
|
registerCartResetEvent() {
|
||||||
Element.getCartButton().addEventListener('click', () => {
|
Element.getCartButton().addEventListener('click', () => {
|
||||||
|
CartHistoryManager.addToTotal(this.cartLines.reduce((acc, cartLine) => {
|
||||||
|
return acc + (cartLine.product.price * cartLine.quantity);
|
||||||
|
}, 0));
|
||||||
this.cartLines = [];
|
this.cartLines = [];
|
||||||
this.renderCart();
|
this.renderCart();
|
||||||
});
|
});
|
||||||
|
|
@ -518,11 +521,12 @@ class TabManager {
|
||||||
*/
|
*/
|
||||||
static toggleTab() {
|
static toggleTab() {
|
||||||
if(!TabManager.isSettingsTabActive) {
|
if(!TabManager.isSettingsTabActive) {
|
||||||
|
TabManager.isSettingsTabActive = true;
|
||||||
this.switchTab('settings');
|
this.switchTab('settings');
|
||||||
} else {
|
} else {
|
||||||
this.switchTab('products');
|
this.switchTab('products');
|
||||||
|
TabManager.isSettingsTabActive = false;
|
||||||
}
|
}
|
||||||
TabManager.isSettingsTabActive = !TabManager.isSettingsTabActive;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -573,10 +577,29 @@ class ThemeManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define the CartHistoryManager class to manage the cart history.
|
||||||
|
*/
|
||||||
|
class CartHistoryManager {
|
||||||
|
static getTotal() {
|
||||||
|
return localStorage.getItem('cart-total-value') || 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static setTotal(value) {
|
||||||
|
localStorage.setItem('cart-total-value', value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static addToTotal(value) {
|
||||||
|
const total = parseFloat(CartHistoryManager.getTotal()) + value;
|
||||||
|
CartHistoryManager.setTotal(total);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main function to initialize the application.
|
* Main function to initialize the application.
|
||||||
*/
|
*/
|
||||||
const cartManager = new CartManager();
|
const cartManager = new CartManager();
|
||||||
const productManager = new ProductManager();
|
const productManager = new ProductManager();
|
||||||
const tabManager = new TabManager();
|
const tabManager = new TabManager();
|
||||||
const themeManager = new ThemeManager();
|
const themeManager = new ThemeManager();
|
||||||
|
const cartHistoryManager = new CartHistoryManager();
|
||||||
Loading…
Reference in a new issue