intelica-library-components 1.1.92 → 1.1.93
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -8289,13 +8289,40 @@ class GlobalMenuService {
|
|
|
8289
8289
|
selectedProduct = this._selectedProduct.asReadonly();
|
|
8290
8290
|
eventMenu = "MenuBarEvent";
|
|
8291
8291
|
eventProducts = "SelectedProductMenuEvent";
|
|
8292
|
+
COOKIE_PRODUCT = "intelica:selected-product";
|
|
8293
|
+
COOKIE_MENU = "intelica:menu-visible";
|
|
8294
|
+
initialized = false;
|
|
8292
8295
|
initialize() {
|
|
8296
|
+
if (this.initialized)
|
|
8297
|
+
return;
|
|
8293
8298
|
this.listenMenuEvents();
|
|
8299
|
+
this.hydrateFromCookies();
|
|
8300
|
+
this.initialized = true;
|
|
8301
|
+
}
|
|
8302
|
+
hydrateFromCookies() {
|
|
8303
|
+
const productCookie = getCookie(this.COOKIE_PRODUCT);
|
|
8304
|
+
if (productCookie) {
|
|
8305
|
+
try {
|
|
8306
|
+
const parsed = JSON.parse(productCookie);
|
|
8307
|
+
this._selectedProduct.set({
|
|
8308
|
+
product: parsed.product ?? "",
|
|
8309
|
+
icon: parsed.icon ?? "",
|
|
8310
|
+
productId: parsed.productId ?? "",
|
|
8311
|
+
});
|
|
8312
|
+
}
|
|
8313
|
+
catch { }
|
|
8314
|
+
}
|
|
8315
|
+
const menuCookie = getCookie(this.COOKIE_MENU);
|
|
8316
|
+
if (menuCookie !== undefined) {
|
|
8317
|
+
this._isMenuVisible.set(menuCookie === "true");
|
|
8318
|
+
}
|
|
8294
8319
|
}
|
|
8295
8320
|
setMenuVisibility(isVisible) {
|
|
8321
|
+
setCookie(this.COOKIE_MENU, String(isVisible)); // 👈 NUEVO
|
|
8296
8322
|
this.emitMenuEvent(isVisible);
|
|
8297
8323
|
}
|
|
8298
8324
|
setSelectedProduct(product) {
|
|
8325
|
+
setCookie(this.COOKIE_PRODUCT, JSON.stringify(product)); // 👈 NUEVO
|
|
8299
8326
|
this.emitSelectedProductEvent(product);
|
|
8300
8327
|
}
|
|
8301
8328
|
listenMenuEvents() {
|
|
@@ -8304,8 +8331,10 @@ class GlobalMenuService {
|
|
|
8304
8331
|
}
|
|
8305
8332
|
onMenuEvent = (event) => {
|
|
8306
8333
|
const { menuIsVisible } = event.detail ?? {};
|
|
8307
|
-
if (typeof menuIsVisible === "boolean")
|
|
8334
|
+
if (typeof menuIsVisible === "boolean") {
|
|
8308
8335
|
this._isMenuVisible.set(menuIsVisible);
|
|
8336
|
+
setCookie(this.COOKIE_MENU, String(menuIsVisible)); // 👈 NUEVO
|
|
8337
|
+
}
|
|
8309
8338
|
};
|
|
8310
8339
|
onSelectedProductEvent = (event) => {
|
|
8311
8340
|
const detail = event.detail;
|
|
@@ -8313,7 +8342,9 @@ class GlobalMenuService {
|
|
|
8313
8342
|
return;
|
|
8314
8343
|
const { product, icon, productId: authClient } = detail;
|
|
8315
8344
|
if (typeof product === "string" && typeof icon === "string" && typeof authClient === "string") {
|
|
8316
|
-
|
|
8345
|
+
const normalized = { product, icon, productId: authClient };
|
|
8346
|
+
this._selectedProduct.set(normalized);
|
|
8347
|
+
setCookie(this.COOKIE_PRODUCT, JSON.stringify(normalized)); // 👈 NUEVO
|
|
8317
8348
|
}
|
|
8318
8349
|
};
|
|
8319
8350
|
emitMenuEvent(isVisible) {
|