import { a as __decorate, _ as __awaiter } from './tslib.es6-b53fb3ce.js';
|
import { ProgPropertyModel } from './prog-property.model.js';
|
import { PPPropertyComponent } from './pp-property.component.js';
|
import { PPPropertyValuesComponent } from './pp-property-values.component.js';
|
import { PPTheme } from './pp-container.component.js';
|
import { CacheService } from './cache.service.js';
|
import { PPUtilClass } from './pp-util.class.js';
|
import { PPLayerComponent } from './pp-layer.component.js';
|
import { e } from './custom-element-30fc6381.js';
|
import { i, r } from './query-assigned-elements-fea1f631.js';
|
|
var css_248z = i`:host{align-content:flex-start;display:flex;flex-flow:wrap}`;
|
|
var ProgPropertyFurnviewAccordionLayer_1;
|
let ProgPropertyFurnviewAccordionLayer = ProgPropertyFurnviewAccordionLayer_1 = class ProgPropertyFurnviewAccordionLayer extends PPLayerComponent {
|
static propertyCallback(layer, keyLists, componentsBuffer) {
|
const menuComponents = CacheService.get("progproperty_menu");
|
const itemsComponents = CacheService.get("progproperty_items");
|
let lastMenu = null;
|
let lastItems = null;
|
const containerComponent = layer.PPContainer;
|
return (manufacturerModel, programModel, progPropertyModel, progPropertyValueList, currentValue) => {
|
if (!progPropertyModel.name) {
|
return false;
|
}
|
const ppMenu = menuComponents[progPropertyModel.key] || new PPPropertyComponent({
|
title: progPropertyModel.name,
|
hideItemCount: containerComponent.hideItemCount || (containerComponent.disableNotSettable && progPropertyValueList.length === 1),
|
halfSize: containerComponent.halfSize
|
});
|
menuComponents[progPropertyModel.key] = ppMenu;
|
const menuKeyIndex = keyLists.menuKeys.indexOf(progPropertyModel.key);
|
if (menuKeyIndex !== -1)
|
keyLists.menuKeys.splice(menuKeyIndex, 1);
|
let currentPropertyValue = currentValue;
|
if (!currentValue) {
|
currentPropertyValue = progPropertyValueList.find((c) => {
|
return c.propertyKey === progPropertyModel.currentValue;
|
});
|
}
|
if (progPropertyValueList.length === 1) {
|
if (containerComponent.hideNotSettable) {
|
return false;
|
}
|
else if (containerComponent.disableNotSettable) {
|
ppMenu.setAttribute("disabled", "true");
|
}
|
currentPropertyValue = progPropertyValueList[0];
|
}
|
ppMenu.transparentPlaceholder = +containerComponent.theme === +PPTheme.FURNVIEW;
|
if (currentPropertyValue) {
|
ppMenu.currentName = currentPropertyValue.name;
|
ppMenu.currentImage = currentPropertyValue.alternativeImageUrl;
|
}
|
const ppItems = itemsComponents[progPropertyModel.key] || new PPPropertyValuesComponent();
|
itemsComponents[progPropertyModel.key] = ppItems;
|
const itemsKeyIndex = keyLists.itemsKeys.indexOf(progPropertyModel.key);
|
if (itemsKeyIndex !== -1)
|
keyLists.itemsKeys.splice(itemsKeyIndex, 1);
|
ppItems.id = "item_" + progPropertyModel.id;
|
if (!layer.contains(ppMenu)) {
|
ppMenu.addEventListener("click", (e) => {
|
e.stopPropagation();
|
e.preventDefault();
|
layer.querySelectorAll("fv-pp-property")
|
.forEach((property) => {
|
if (ppMenu !== property) {
|
property.classList[!ppMenu.active ? "add" : "remove"]("hidden");
|
}
|
});
|
ppMenu.active = !ppMenu.active;
|
ppItems.active = ppMenu.active;
|
});
|
}
|
if (lastItems && lastItems) {
|
componentsBuffer.splice(componentsBuffer.indexOf(lastItems) + 1, 0, ppMenu);
|
}
|
else {
|
componentsBuffer.push(ppMenu);
|
}
|
lastMenu = ppMenu;
|
if (lastMenu && lastMenu) {
|
componentsBuffer.splice(componentsBuffer.indexOf(lastMenu) + 1, 0, ppItems);
|
}
|
else {
|
componentsBuffer.push(ppItems);
|
}
|
lastItems = ppItems;
|
PPUtilClass.addItems({
|
menu: ppMenu,
|
items: ppItems,
|
containerComponent: containerComponent,
|
itemKeys: keyLists.itemKeys,
|
manufacturerModel: manufacturerModel,
|
programModel: programModel,
|
progPropertyModel: progPropertyModel,
|
progPropertyValueList: progPropertyValueList,
|
currentValue: currentValue,
|
currentPropertyValue: currentPropertyValue
|
});
|
};
|
}
|
getAccordionItems() {
|
return __awaiter(this, void 0, void 0, function* () {
|
const menuComponentsKeys = Object.keys(CacheService.get("progproperty_menu"));
|
const itemsComponentsKeys = Object.keys(CacheService.get("progproperty_items"));
|
const itemComponentsKeys = Object.keys(CacheService.get("progproperty_item"));
|
const componentsBuffer = [];
|
yield ProgPropertyModel.traverse({
|
propertyCallback: ProgPropertyFurnviewAccordionLayer_1.propertyCallback(this, {
|
menuKeys: menuComponentsKeys,
|
itemsKeys: itemsComponentsKeys,
|
itemKeys: itemComponentsKeys
|
}, componentsBuffer)
|
});
|
PPUtilClass.cleanup(this, menuComponentsKeys, "progproperty_menu");
|
PPUtilClass.cleanup(this, itemsComponentsKeys, "progproperty_items", "progproperty_menu");
|
PPUtilClass.cleanup(this, itemComponentsKeys, "progproperty_item");
|
return componentsBuffer;
|
});
|
}
|
};
|
ProgPropertyFurnviewAccordionLayer.styles = [(void 0).styles || [], r(css_248z)];
|
ProgPropertyFurnviewAccordionLayer = ProgPropertyFurnviewAccordionLayer_1 = __decorate([
|
e("fv-prog-property-furnview-accordion-layer")
|
], ProgPropertyFurnviewAccordionLayer);
|
const PpFurnviewAccordionLayerComponent = new ProgPropertyFurnviewAccordionLayer();
|
|
export { ProgPropertyFurnviewAccordionLayer as P, PpFurnviewAccordionLayerComponent as a, css_248z as c };
|