diff --git a/development/issues/closed/316.html b/development/issues/closed/316.html index 8331ae4eac54b9a0eaabf250e0eb07bcd75d5732..7b440d898213faa3b09bfec3de897e2723c3ae63 100644 --- a/development/issues/closed/316.html +++ b/development/issues/closed/316.html @@ -15,6 +15,27 @@ </ul> <main> + + <h2>Select (multiselect)</h2> + + + <monster-select + data-monster-option-type="checkbox" + data-monster-option-filter-mode="remote" + data-monster-option-filter-position="popper" + data-monster-option-mapping-total="sys.total" + data-monster-option-filter-defaultvalue="" + value="2000" + data-monster-option-mapping-selector="dataset.*" + data-monster-option-remoteinfo-url="/issue-316.json?total" + data-monster-option-lookup-url="/issue-316.json?total" + data-monster-option-filter-defaultoptionsurl="/issue-316.json?default=true" + data-monster-option-url="/issue-316.json?q={filter}" + data-monster-option-mapping-labeltemplate="${name}" + data-monster-option-mapping-valuetemplate="${id}"> + </monster-select> + + <h2>Select (no url)</h2> diff --git a/development/issues/open/322.html b/development/issues/closed/322.html similarity index 97% rename from development/issues/open/322.html rename to development/issues/closed/322.html index f940ec28495430ad6731747578c709cf4a00f1a3..6df6382672ae1d03ef4fe3315280a394ea89cf12 100644 --- a/development/issues/open/322.html +++ b/development/issues/closed/322.html @@ -24,12 +24,11 @@ data-monster-option-features-emptyValueIfNoOptions="true" value="0" - data-monster-option-type="radio" data-monster-option-filter-mode="remote" data-monster-option-filter-position="popper" - data-monster-option-url="/issue-316.json?q={filter}" + data-monster-option-url="/issue-322.json?q={filter}" data-monster-option-lookup-url="/api/commerce/item/{filter}" data-monster-option-mapping-selector="dataset.*" data-monster-option-mapping-labeltemplate="${name} (${iid})" diff --git a/development/issues/open/322.mjs b/development/issues/closed/322.mjs similarity index 100% rename from development/issues/open/322.mjs rename to development/issues/closed/322.mjs diff --git a/development/mock/issue-322.js b/development/mock/issue-322.js index 7905ce2f8245d0fc1d5c94797d1a58be9a3f350c..61b3e9edd555e8dfcf3f270dc5bb292c1f250750 100644 --- a/development/mock/issue-322.js +++ b/development/mock/issue-322.js @@ -1,7 +1,7 @@ const json = `{ - "dataset": { - "a25c3d99-e94b-43b9-c38f-0b20f5f645e2": { + "dataset": [ + { "iid": 502, "name": "Versand", "masterNameLocale": [], @@ -9,234 +9,60 @@ const json = "masterSKU": "", "masterNotice": "", "masterDescription": "", - "masterRootitemIID": 0, - "masterRootitemCombine": "0", - "masterProductfamily1": "", - "masterProductfamily2": "", - "masterProductfamilyCombinde": "1", - "masterFollowingIID": "", - "active": false, - "variants": { - "__UNIQUE__": "" - }, - "variantsData": [ - { - "decription": "", - "number": "", - "text": { - "de": "", - "en": "" - }, - "hide": false, - "properties": null - } - ], - "packingUnits": [], - "salesAddon": 0, - "salesSetIID": "a:0:{}", - "salesChannel": [], - "salesStart": null, - "salesEnd": null, - "salesType": 30, - "salesCountry": [ - 0 - ], - "salesCountryMode": 0, - "salesAnnouncementOrderGroupGID": [ - 0 - ], - "salesAnnouncementOrderFlag": "0", - "salesAnnouncementOrderFrom": null, - "salesAnnouncementOrderTo": null, - "salesAnnouncementPriceFlag": "0", - "salesAnnouncementOrderTimegroupFlag": "0", - "salesPosition": 0, - "salesCompaniesRestriction": [], - "salesCompaniesAssignment": 0, - "salesCompaniesNoExport": "0", - "salesCompaniesShopFlag": "0", - "salesGroup": 100, - "salesQuantityRestriction": "", - "salesQuantityRestrictAmountPerOrder": 0, - "salesAffiliatesRestriction": [ - 0 - ], - "salesDisabledpayment": [], - "catalogingKeywords": [], - "catalogingDepartmentDID1": 0, - "catalogingDepartmentDID2": 0, - "catalogingBrandBID1": 0, - "catalogingBrandBID2": 0, - "catalogingGender": "", - "catalogingCategoryCID1": 0, - "catalogingCategoryCID2": 0, - "catalogingCategoryCID3": 0, - "catalogingCategoryCID4": [], - "catalogingCollectionCLID1": 0, - "catalogingCollectionCLID2": [ - 0 - ], - "catalogingAssignmentAAID1": 0, - "catalogingAssignmentABID2": [], - "catalogingAssignmentACID3": [], - "catalogingRasterRID1": 0, - "catalogingRasterRID2": [], - "catalogingImagesource": "", - "catalogingAudienceAUID1": 0, - "catalogingAudienceAUID2": [], - "catalogingSeasonSAID": 0, - "catalogingStyleSID1": 0, - "catalogingStyleSID2": 0, - "catalogingStyleSID3": 0, - "catalogingStyleSID4": [], - "specificationCOID1": 0, - "specificationCOID2": 0, - "specificationCOID3": 0, - "specificationCOID4": [], - "specificationWidth": 0, - "specificationWidthNormalizationFactor": null, - "specificationWidthViewNormalizationFactor": null, - "specificationHeight": 0, - "specificationHeightNormalizationFactor": null, - "specificationHeightViewNormalizationFactor": null, - "specificationDepth": 0, - "specificationDepthNormalizationFactor": null, - "specificationDepthViewNormalizationFactor": null, - "specificationWeight": 0, - "specificationWeightNormalizationFactor": null, - "specificationWeightViewNormalizationFactor": null, - "specificationWeightNet": 0, - "specificationWeightNetNormalizationFactor": null, - "specificationWeightNetViewNormalizationFactor": null, - "specificationMaterial": "a:1:{s:2:\\"de\\";s:0:\\"\\";}", - "specificationVolume": 0, - "specificationVolumeNormalizationFactor": null, - "specificationVolumeViewNormalizationFactor": null, - "specificationMaterialMAID": 0, - "specificationBasepriceReference": 0, - "sourcingPceControlSerialnumber": "0", - "sourcingPceControlChargenumber": "0", - "sourcingStockInventoryObligation": "0", - "sourcingDistributor1UID": 0, - "sourcingDistributor1Name": "", - "sourcingDistributor1Deliverytime": "0", - "sourcingDistributor1Number": "0", - "sourcingDistributor1DeliverytimeUnit": 0, - "sourcingDistributor1OrderPlugin": "", - "sourcingDistributor1ErpID": "", - "sourcingDistributor1ErpName": "", - "sourcingDistributor1ErpNumber": "", - "sourcingDistributor2UID": 0, - "sourcingDistributor2Name": "", - "sourcingDistributor2Deliverytime": "0", - "sourcingDistributor2Number": "0", - "sourcingDistributor2DeliverytimeUnit": 0, - "sourcingDistributor2OrderPlugin": "", - "sourcingDistributor2ErpID": "", - "sourcingDistributor2ErpName": "", - "sourcingDistributor2ErpNumber": "", - "sourcingDistributor3UID": 0, - "sourcingDistributor3Name": "", - "sourcingDistributor3Deliverytime": "", - "sourcingDistributor3Number": "", - "sourcingDistributor3DeliverytimeUnit": 0, - "sourcingDistributor3OrderPlugin": "", - "sourcingDistributor3ErpID": "", - "sourcingDistributor3ErpName": "", - "sourcingDistributor3ErpNumber": "", - "sourcingStockFlag": 16, - "sourcingStockMinCount": 0, - "sourcingStockEstimatedBalance": 0, - "shippingIncoterms": "", - "shippingNotOnPicklist": "0", - "shippingStoretype": 0, - "shippingHideOnDocument": "0", - "shippingPackaging": [], - "shippingPrePackagingUnit": 0, - "shippingPreventFromCosts": "0", - "manufacturerUID": 0, - "manufacturerName": "", - "manufacturerItemUrl": "", - "manufacturerColor": "", - "manufacturerOriginCountry": "", - "orderPreorder": 0, - "financesVat": { - "de": 0, - "gb": 0, - "fr": 0, - "at": 0, - "ch": 0, - "be": 0, - "cz": 0, - "gr": 0, - "hr": 0, - "it": 0, - "lu": 0, - "mc": 0, - "nl": 0, - "sk": 0, - "us": 0, - "sv": 0 - }, - "financesTaxcode": { - "de": "", - "gb": "", - "fr": "", - "at": "", - "ch": "", - "be": "", - "cz": "", - "gr": "", - "hr": "", - "it": "", - "lu": "", - "mc": "", - "nl": "", - "sk": "", - "us": "", - "sv": "" - }, - "financesBought": 0, - "financesDiscountable": 0, - "financesRevenueInland": "", - "financesRevenueAbroad": "", - "financesRevenueEU": "", - "financesRevenueEUID": "", - "financesCostInland": "", - "financesCostAbroad": "", - "financesCostEU": "", - "financesCostEUID": "", - "financesCustomsTariffNumber": "", - "financesCustomsTariffDescription1": "", - "financesCustomsTariffDescription2": "", - "sourcingStockEdiDeactivateSKUCheck": "", - "marketingAlsobought": "", - "marketingCommendation1": "", - "marketingCommendation2": "", - "marketingCommendation3": "", - "marketingCommendation4": "", - "marketingCommendation5": "", - "marketingCommendation6": "", - "marketingFlag": 0, - "marketingExtraUrl1": "", - "marketingExtraUrl2": "", - "marketingExtraPage": "", - "salesAnnouncementRestrictionGroupGID": "0", - "erpID": "", - "erpName": "", - "erpNumber": "", - "erpLastUpdate": "2025-04-10T07:12:53", - "erpCreation": null, - "archived": true, - "localStrings": { - "salesType": "Systemintern", - "salesGroup": "Versandkosten" - }, - "property": { - "dataset": [] - } + "masterRootitemIID": 0 + }, + { + "iid": 503, + "name": "Versand", + "masterNameLocale": [], + "masterNumber": "Versand", + "masterSKU": "", + "masterNotice": "", + "masterDescription": "", + "masterRootitemIID": 0 + }, + { + "iid": 504, + "name": "Versand", + "masterNameLocale": [], + "masterNumber": "Versand", + "masterSKU": "", + "masterNotice": "", + "masterDescription": "", + "masterRootitemIID": 0 + }, + { + "iid": 505, + "name": "Versand", + "masterNameLocale": [], + "masterNumber": "Versand", + "masterSKU": "", + "masterNotice": "", + "masterDescription": "", + "masterRootitemIID": 0 + }, + { + "iid": 506, + "name": "Versand", + "masterNameLocale": [], + "masterNumber": "Versand", + "masterSKU": "", + "masterNotice": "", + "masterDescription": "", + "masterRootitemIID": 0 + }, + { + "iid": 507, + "name": "Versand", + "masterNameLocale": [], + "masterNumber": "Versand", + "masterSKU": "", + "masterNotice": "", + "masterDescription": "", + "masterRootitemIID": 0 } - }, + + ], "sys": { "pagination": { "total": 1, @@ -269,19 +95,6 @@ export default [ res.end(json) }, 10); }, - }, - - { - url: '/issue-322', - method: 'post', - rawResponse: async (req, res) => { - res.setHeader('Content-Type', 'application/json') - res.statusCode = 400 - - setTimeout(function() { - res.end(json400Error) - }, 10); - }, } diff --git a/source/components/form/select.mjs b/source/components/form/select.mjs index 59e23f9cccec6ee0897decbf873976d08e9d44a8..4a0cd4e103186b13361ccf72c9c4e545be6ae53e 100644 --- a/source/components/form/select.mjs +++ b/source/components/form/select.mjs @@ -2438,20 +2438,42 @@ function gatherState() { throw new Error("no shadow-root is defined"); } - const selection = []; - const elements = this.shadowRoot.querySelectorAll( - `input[type=${type}]:checked`, - ); + let filteredSelection=[]; + if (type === "radio") { + + const selection = []; + const elements = this.shadowRoot.querySelectorAll( + `input[type=${type}]:checked`, + ); + + for (const e of elements) { + selection.push({ + label: getSelectionLabel.call(this, e.value), + value: e.value, + }); + } + + filteredSelection = selection; + + } else { + + const selection = [...this.getOption("selection", [])]; + const allElements = this.shadowRoot.querySelectorAll(`input[type=${type}]`); + const checkedElements = this.shadowRoot.querySelectorAll(`input[type=${type}]:checked`); + const currentInputValues = new Set(Array.from(allElements).map(el => el.value)); + filteredSelection = selection.filter(sel => !currentInputValues.has(sel.value)); + for (const input of checkedElements) { + filteredSelection.push({ + label: getSelectionLabel.call(this, input.value), + value: input.value, + }); + } - for (const e of elements) { - selection.push({ - label: getSelectionLabel.call(this, e.value), - value: e.value, - }); } + setSelection - .call(this, selection) + .call(this, filteredSelection) .then(() => { }) .catch((e) => {