import { ArticlesByCategoriesCardAppConnection, ArticleDimension } from './articles-by-categories.card.app.connection.js';
|
import { CardFetchMethod, FilterSelectionStrategy, CardContainerUpdate } from './card-container-definitions.js';
|
import './card-container-events.js';
|
import { CardDataUpdateEvent } from './card-data-service-update-events.js';
|
import { C as ComponentService } from './base.component-813fc7cf.js';
|
import { E as EventHandlerService } from './modal.component-7c440789.js';
|
import { CardDataService } from './card.data.service.js';
|
import { DimensionHelper } from './dimension-helper.class.js';
|
import './old-generated-catalog-base.card.app.connection.js';
|
import './base.card.app.connection.js';
|
import './catalog.service.js';
|
import './manu-prog.service.js';
|
import './query-assigned-elements-fea1f631.js';
|
import './custom-element-30fc6381.js';
|
import '@dh-software/furnview-icons';
|
import './class-map-a0fb5d87.js';
|
import './event.handler.model.js';
|
import './loading.component.js';
|
import './dimmer.component.js';
|
import './query-1c86d710.js';
|
import './dot-flashing-loader.component.js';
|
import './rotating-dots-loader.component.js';
|
import './key-frame-effect.service.js';
|
import './toolbar.component.js';
|
import './toggle-toolbar.component.js';
|
import './style.helper.js';
|
import './image.service.js';
|
import './svg-icon.component.js';
|
import './popup.component.js';
|
import './popup-closer.component.js';
|
import './hr-item.component.js';
|
import './hr-list.component.js';
|
import './query-all-828de4b2.js';
|
import './hr-theme.model.js';
|
import './configurator.form.component.js';
|
import './configurator.form.base.element.component.js';
|
import './scene-helper.service.js';
|
import './async.base.component.js';
|
import './card-container-settings.js';
|
import './card-container-states.js';
|
import './card-container-additional-data.js';
|
import './card-containers-shared-data.js';
|
import './input.mask.component.js';
|
import './mask.component.js';
|
import './information.mask.component.js';
|
import './open-cloud-id.mask.component.js';
|
import './share-link-per-mail.component.js';
|
import './request-appointment.component.js';
|
import './prog-property.model.js';
|
import './interface.js';
|
import './reset.mask.component.js';
|
import './configuration.service.js';
|
import './step-based.mask.component.js';
|
import './container-mask.component.js';
|
import './messageNoCalc.mask.component.js';
|
import './button.component.js';
|
import './iwoFurn.mask.component.js';
|
import './input.component.js';
|
import './base-input.js';
|
import './save-dialog.mask.component.js';
|
import './cloud-id.service.js';
|
import './send-offer-request-mask.component.js';
|
import './file-upload-mask.component.js';
|
import './label.component.js';
|
import './sass.default-1ca9b57f.js';
|
import './accordion.component.js';
|
import './accordion-item.component.js';
|
import './accordion-layer.component.js';
|
import './slider.component.js';
|
import './equipment-list.component.js';
|
import './state-7ee0cf4f.js';
|
import './confirming-button.component.js';
|
import './fitting-item.component.js';
|
import './proptrans-item.component.js';
|
import './shoppingcart-item.component.js';
|
import './prog-context.model.js';
|
import './step-child.component.js';
|
import './clock.controller.js';
|
|
var __async = (__this, __arguments, generator) => {
|
return new Promise((resolve, reject) => {
|
var fulfilled = (value) => {
|
try {
|
step(generator.next(value));
|
} catch (e) {
|
reject(e);
|
}
|
};
|
var rejected = (value) => {
|
try {
|
step(generator.throw(value));
|
} catch (e) {
|
reject(e);
|
}
|
};
|
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
step((generator = generator.apply(__this, __arguments)).next());
|
});
|
};
|
class ArticlesByCategoriesDimensionCardAppConnection extends ArticlesByCategoriesCardAppConnection {
|
constructor() {
|
super();
|
this.clickActive = false;
|
this.Method = CardFetchMethod.ArticlesByCategoriesDimensions;
|
}
|
getFetchDimension(context) {
|
const dimension = context.settings.Fetch.parameters["dimension"];
|
const dimensionIndex = context.settings.Fetch.parameters["automatic-dimension-order-index"];
|
if (dimension) {
|
return dimension;
|
}
|
if (dimensionIndex !== void 0) {
|
return DimensionHelper.getDimensionNameFromIndex(dimensionIndex);
|
}
|
return void 0;
|
}
|
CheckUpdate(event, eventParameters, context) {
|
return __async(this, null, function* () {
|
if (event == CardDataUpdateEvent.LastPOLoaded) {
|
return CardContainerUpdate.FILTER;
|
}
|
if (event == CardDataUpdateEvent.CardContainerVisible) {
|
return CardContainerUpdate.FETCH;
|
}
|
return CardContainerUpdate.NONE;
|
});
|
}
|
GetDisabledDimensions(fetch, articleDimensions) {
|
return __async(this, null, function* () {
|
const cardContainerDisableSource = fetch.parameters ? fetch.parameters["card-container-disable-source-selector"] : void 0;
|
if (cardContainerDisableSource != void 0) {
|
const filteredArticleDimensionValues = new Array();
|
const disableSource = ComponentService.find(cardContainerDisableSource.tag, cardContainerDisableSource.query);
|
if (disableSource != void 0) {
|
yield disableSource.CheckFetchPromise();
|
if (disableSource.FilteredFetchResult != void 0) {
|
const articles = disableSource.FilteredFetchResult.articles;
|
for (const article of articles) {
|
const articleDimension = new ArticleDimension(article, "width");
|
filteredArticleDimensionValues.push([
|
articleDimension.All.width,
|
articleDimension.All.depth,
|
articleDimension.All.height
|
]);
|
}
|
}
|
}
|
const result = new Array();
|
for (const articleDimension of articleDimensions) {
|
let any = false;
|
for (const value of filteredArticleDimensionValues) {
|
if (value.includes(articleDimension.Value)) {
|
any = true;
|
break;
|
}
|
}
|
if (any == false) {
|
result.push(articleDimension.Value);
|
}
|
}
|
return result;
|
}
|
const disablePrecheckSelectors = fetch.parameters ? fetch.parameters["disable-precheck-selectors"] : void 0;
|
if (disablePrecheckSelectors != void 0) {
|
const result = new Array();
|
for (const selector of disablePrecheckSelectors) {
|
const disablePrecheckElements = ComponentService.findAll(selector.tag, selector.query);
|
for (const element of disablePrecheckElements) {
|
yield element.CheckFetchPromise();
|
if (element.CardData) {
|
for (const level of element.CardData) {
|
for (const articleDimension of articleDimensions) {
|
if (level[1].additional && level[1].additional.articles) {
|
const filterResult = this.FilterByButtons([{
|
filter: [articleDimension.Value],
|
strategy: FilterSelectionStrategy.AND,
|
"additional-params": { "filter-type": "dimension", "dimension": articleDimension.Dimension }
|
}], level[1].additional.articles);
|
if (filterResult.length < 1 && result.includes(articleDimension.Value) == false) {
|
result.push(articleDimension.Value);
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
return result;
|
}
|
return new Array();
|
});
|
}
|
Fetch(context) {
|
var __superGet = (key) => super[key];
|
return __async(this, null, function* () {
|
const dimension = this.getFetchDimension(context);
|
if (dimension == void 0) {
|
console.error("articles-by-categories-dimension.card.app.connection> Fetch failed! No dimension provided in fetch.parameters.dimension");
|
return {};
|
}
|
let result = yield __superGet("Fetch").call(this, context);
|
result = __superGet("Filter").call(this, result, context, []);
|
if (result.articles) {
|
result["article-dimensions"] = new Array();
|
for (const article of result.articles) {
|
result["article-dimensions"].push(new ArticleDimension(article, dimension));
|
}
|
if (context.states.SuspendDisableSource) {
|
result["disabled-dimensions"] = new Array();
|
} else {
|
result["disabled-dimensions"] = yield this.GetDisabledDimensions(context.settings.Fetch, result["article-dimensions"]);
|
}
|
const dimensions = new Array();
|
for (const articleDimension of result["article-dimensions"]) {
|
if (dimensions.includes(articleDimension.Value) == false) {
|
dimensions.push(articleDimension.Value);
|
}
|
}
|
result["dimensions"] = dimensions;
|
}
|
return result;
|
});
|
}
|
Filter(unfiltered, context, active) {
|
const filtered = unfiltered;
|
const options = active;
|
for (const option of options) {
|
if (typeof option == "number") {
|
if (filtered.dimensions.includes(option) == false) {
|
const index = active.indexOf(option);
|
active = active.splice(index, 1);
|
}
|
}
|
}
|
filtered["active"] = active;
|
return filtered;
|
}
|
CreateCards(filtered, context) {
|
const fetchResult = filtered;
|
const rootLevel = { title: "", cards: [] };
|
const groupings = new Map();
|
if (fetchResult.dimensions) {
|
if (fetchResult.dimensions.length > 0) {
|
fetchResult.dimensions.sort((a, b) => {
|
return a - b;
|
});
|
const dimensionScale = fetchResult["dimension-scale"];
|
let fractionDigits = context.settings.Fetch.parameters["fraction-digits"] ? context.settings.Fetch.parameters["fraction-digits"] : 1;
|
if (typeof fractionDigits != "number") {
|
fractionDigits = 1;
|
}
|
const valueGroupRange = context.settings.Fetch.parameters["value-group-range"] ? context.settings.Fetch.parameters["value-group-range"] : 1e3;
|
const disabledDimensions = fetchResult["disabled-dimensions"];
|
const active = fetchResult["active"];
|
const rangeGroups = new Array();
|
let currentGroup = new Array();
|
let groupRangeMax = valueGroupRange;
|
for (const dimension of fetchResult.dimensions) {
|
if (dimension > groupRangeMax + 1e-3) {
|
rangeGroups.push(currentGroup);
|
currentGroup = new Array();
|
groupRangeMax += valueGroupRange;
|
}
|
currentGroup.push(dimension);
|
}
|
if (rangeGroups.includes(currentGroup) == false) {
|
rangeGroups.push(currentGroup);
|
}
|
const maxSizeAdjustedGroups = new Array();
|
const valueGroupMaxSize = context.settings.Fetch.parameters["value-group-max-size"];
|
if (valueGroupMaxSize != void 0) {
|
for (const group of rangeGroups) {
|
if (group.length > valueGroupMaxSize) {
|
const leftHalf = group.splice(0, Math.ceil(group.length * 0.5));
|
maxSizeAdjustedGroups.push(leftHalf);
|
}
|
maxSizeAdjustedGroups.push(group);
|
}
|
} else {
|
maxSizeAdjustedGroups.push(...rangeGroups);
|
}
|
const groups = new Array();
|
const valueGroupMinSplitSize = context.settings.Fetch.parameters["value-group-min-split-size"];
|
if (valueGroupMinSplitSize != void 0 && valueGroupMinSplitSize > maxSizeAdjustedGroups.length) {
|
let mergedGroup = void 0;
|
for (const group of maxSizeAdjustedGroups) {
|
if (mergedGroup != void 0) {
|
mergedGroup.push(...group);
|
if (mergedGroup.length > valueGroupMinSplitSize) {
|
groups.push(mergedGroup);
|
mergedGroup = void 0;
|
}
|
continue;
|
}
|
if (group.length < valueGroupMinSplitSize) {
|
mergedGroup = new Array();
|
mergedGroup.push(...group);
|
continue;
|
}
|
groups.push(group);
|
}
|
} else {
|
groups.push(...maxSizeAdjustedGroups);
|
}
|
if (groups.length == 1) {
|
const group = groups.at(0);
|
if (group && group.length > 0) {
|
for (const option of group) {
|
const optionDisabled = disabledDimensions.includes(option);
|
let optionActive = false;
|
if (active.includes(option)) {
|
optionActive = true;
|
}
|
rootLevel.cards.push({
|
txt: { title: (option * dimensionScale).toFixed(fractionDigits) },
|
click: {
|
"previous-level-key": context.settings.Fetch["root-level"],
|
"level-key": option,
|
"next-level-key": ""
|
},
|
active: optionActive,
|
disabled: optionDisabled
|
});
|
}
|
}
|
} else {
|
for (const group of groups) {
|
if (group.length > 0) {
|
const first = group.at(0) * dimensionScale;
|
const last = group.at(group.length - 1) * dimensionScale;
|
const groupLevelKey = `${first.toFixed(fractionDigits)} - ${last.toFixed(fractionDigits)}`;
|
rootLevel.cards.push({
|
txt: { title: groupLevelKey },
|
click: {
|
"previous-level-key": "",
|
"level-key": context.settings.Fetch["root-level"],
|
"next-level-key": groupLevelKey
|
}
|
});
|
const groupLevel = { title: groupLevelKey, cards: [] };
|
for (const option of group) {
|
const optionDisabled = disabledDimensions.includes(option);
|
let optionActive = false;
|
if (active.includes(option)) {
|
optionActive = true;
|
}
|
groupLevel.cards.push({
|
txt: { title: (option * dimensionScale).toFixed(fractionDigits) },
|
click: {
|
"previous-level-key": groupLevelKey,
|
"level-key": option,
|
"next-level-key": ""
|
},
|
active: optionActive,
|
disabled: optionDisabled
|
});
|
}
|
groupings.set(groupLevelKey, groupLevel);
|
}
|
}
|
}
|
}
|
}
|
if (context.settings.Fetch.parameters["force-single-option-as-empty"] == true) {
|
if (rootLevel.cards.length < 2 && groupings.size < 1) {
|
rootLevel.cards = [];
|
}
|
}
|
if (groupings.size == 1) {
|
rootLevel.cards = [];
|
for (const grouping of groupings) {
|
rootLevel.cards.push(...grouping[1].cards);
|
}
|
groupings.clear();
|
}
|
const result = new Map();
|
result.set(context.settings.Fetch["root-level"], rootLevel);
|
for (const group of groupings) {
|
result.set(group[0], group[1]);
|
}
|
return result;
|
}
|
Click(card, context) {
|
var __superGet = (key) => super[key];
|
return __async(this, null, function* () {
|
if (this.clickActive)
|
return;
|
this.clickActive = true;
|
yield __superGet("Click").call(this, card, context);
|
if (context.filter != void 0) {
|
const dimension = this.getFetchDimension(context);
|
if (dimension) {
|
context.filter.AdditionalParams = {
|
"filter-type": "dimension",
|
"dimension": dimension
|
};
|
}
|
context.filter.Strategy = FilterSelectionStrategy.OR;
|
if (card.disabled == false && card.click != void 0) {
|
if (typeof card.click["level-key"] == "number") {
|
context.filter.Toggle(card.click["level-key"]);
|
}
|
}
|
yield EventHandlerService.dispatchAsyncEvent("refresh-all-card-containers", {
|
refetch: true,
|
"include-hidden": false
|
});
|
yield CardDataService.WaitForAllCardContainerFetchPromises();
|
if (context.settings.Fetch.parameters["disabled-reset-selection"]) {
|
if (context.cards != void 0 && card.click != void 0) {
|
for (const level of context.cards) {
|
for (const cardInLevel of level[1].cards) {
|
if (cardInLevel.click == void 0)
|
continue;
|
if (cardInLevel.click["level-key"] == card.click["level-key"]) {
|
if (cardInLevel.disabled == false && cardInLevel.active == false) {
|
context.filter.Add(card.click["level-key"]);
|
break;
|
}
|
}
|
}
|
}
|
}
|
yield EventHandlerService.dispatchAsyncEvent("refresh-all-card-containers", {
|
refetch: true,
|
"include-hidden": false
|
});
|
yield CardDataService.WaitForAllCardContainerFetchPromises();
|
}
|
}
|
this.clickActive = false;
|
});
|
}
|
InitFilterSelectionParams(context) {
|
if (context.filter != void 0) {
|
const dimension = this.getFetchDimension(context);
|
if (dimension) {
|
context.filter.AdditionalParams = {
|
"filter-type": "dimension",
|
"dimension": dimension
|
};
|
}
|
context.settings.Filter["selection-strategy"] = FilterSelectionStrategy.OR;
|
}
|
}
|
}
|
CardDataService.RegisterAppConnection(new ArticlesByCategoriesDimensionCardAppConnection());
|
|
export { ArticlesByCategoriesDimensionCardAppConnection };
|