Skip to content
Snippets Groups Projects
Verified Commit 2d7150f4 authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

fix: Add new HTML and JS files for issue #322 investigation.

- Created `322.html` which includes a select component for identifying issues with selecting an integer and an empty value.
- Added `322.mjs` script for handling the necessary imports and functionalities related to the select element.
- Introduced `issue-322.js` mock data file to simulate responses for testing the new functionality.
- Refactored some parts of existing `select.mjs` file to maintain coding consistency.
- The changes provide a clearer interface for understanding the interactions that occur when empty values are involved with the integer-select feature, facilitating debugging and further development.
parent 371c3c8b
No related branches found
No related tags found
No related merge requests found
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>investigate select with int and empty value #322</title>
<script src="./322.mjs" type="module"></script>
</head>
<body>
<h1>investigate select with int and empty value #322</h1>
<p></p>
<ul>
<li><a href="https://gitlab.schukai.com/oss/libraries/javascript/monster/-/issues/322">Issue #322</a></li>
<li><a href="/">Back to overview</a></li>
</ul>
<main style="margin-left:500px;width: 500px; border: 1px solid black; overflow: auto;">
<h2>Root Item</h2>
<monster-select
data-monster-bind="path:data.masterRootitemIID"
data-monster-bind-type="int"
data-monster-option-empty-equivalents="0"
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-lookup-url="/api/commerce/item/{filter}"
data-monster-option-mapping-selector="dataset.*"
data-monster-option-mapping-labeltemplate="${name} (${iid})"
data-monster-option-mapping-valuetemplate="${iid}"
>
</monster-select>
<!-- <monster-select data-monster-option-filter-mode="remote"-->
<!-- data-monster-option-filter-position="inline"-->
<!-- data-monster-option-mapping-total="sys.total"-->
<!-- data-monster-option-mapping-selector="dataset.*"-->
<!-- data-monster-option-filter-defaultvalue=""-->
<!-- data-monster-option-remoteinfo-url="/issue-316.json?total"-->
<!-- data-monster-option-placeholder-filter="You can search and it will load when you change the filter, not the value listed here."-->
<!-- data-monster-option-filter-defaultoptionsurl="/issue-322.json"-->
<!-- data-monster-option-url="/issue-316.json?q={filter}"-->
<!-- data-monster-option-mapping-labeltemplate="${name}"-->
<!-- data-monster-option-mapping-valuetemplate="${id}">-->
<!-- </monster-select>-->
</main>
</body>
</html>
/**
* @file development/issues/open/322.mjs
* @url https://gitlab.schukai.com/oss/libraries/javascript/monster/-/issues/322
* @description investigate select with int and empty value
* @issue 322
*/
import "../../../source/components/style/property.pcss";
import "../../../source/components/style/link.pcss";
import "../../../source/components/style/color.pcss";
import "../../../source/components/style/theme.pcss";
import "../../../source/components/style/normalize.pcss";
import "../../../source/components/style/typography.pcss";
import "../../../source/components/form/select.mjs";
const json =
`{
"dataset": {
"a25c3d99-e94b-43b9-c38f-0b20f5f645e2": {
"iid": 502,
"name": "Versand",
"masterNameLocale": [],
"masterNumber": "Versand",
"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": []
}
}
},
"sys": {
"pagination": {
"total": 1,
"currentPage": 1,
"objectsPerPage": 20,
"offset": 0,
"nextOffset": null,
"prevOffset": null,
"pages": 1
},
"message": "200 OK",
"code": 200
}
}`;
// check if json is valid
JSON.parse(json)
// check if json is valid
export default [
{
url: '/issue-322.json',
method: 'get',
rawResponse: async (req, res) => {
res.setHeader('Content-Type', 'application/json')
res.statusCode = 200
setTimeout(function() {
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);
},
}
];
\ No newline at end of file
......@@ -370,7 +370,8 @@ class Select extends CustomControl {
setSelection
.call(this, result.selection)
.then(() => {})
.then(() => {
})
.catch((e) => {
addErrorAttribute(this, e);
});
......@@ -588,7 +589,8 @@ class Select extends CustomControl {
} else {
self
.fetch()
.then(() => {})
.then(() => {
})
.catch((e) => {
addErrorAttribute(self, e);
});
......@@ -606,7 +608,8 @@ class Select extends CustomControl {
lastValue = n;
setSelection
.call(self, n)
.then(() => {})
.then(() => {
})
.catch((e) => {
addErrorAttribute(self, e);
});
......@@ -692,7 +695,15 @@ class Select extends CustomControl {
* @return {Promise}
*/
fetch(url) {
return fetchIt.call(this, url);
try {
const result = fetchIt.call(this, url);
if (result instanceof Promise) {
return result;
}
} catch (e) {
addErrorAttribute(this, e);
return Promise.reject(e);
}
}
/**
......@@ -874,7 +885,8 @@ function importOptionsIntern(data) {
setTimeout(() => {
setSelection
.call(this, this.getOption("selection"))
.then(() => {})
.then(() => {
})
.catch((e) => {
addErrorAttribute(this, e);
});
......@@ -1483,14 +1495,11 @@ function fetchIt(url, controlOptions) {
setStatusOrRemoveBadges.call(this, "error");
reject(new Error("invalid response"));
})
.catch((e) => {
}).catch((e) => {
setStatusOrRemoveBadges.call(this, "error");
reject(e);
});
})
.run()
.catch((e) => {
}).run().catch((e) => {
setStatusOrRemoveBadges.call(this, "error");
addErrorAttribute(this, e);
reject(e);
......@@ -1770,7 +1779,8 @@ function getDefaultTranslation() {
try {
const doc = getDocumentTranslations();
translation.locale = doc.locale;
} catch (e) {}
} catch (e) {
}
return translation;
}
......@@ -2250,11 +2260,10 @@ function filterFromRemoteByValue(optionUrl, value, openPopper) {
}
})
.catch((e) => {
throw e;
addErrorAttribute(this, e);
setStatusOrRemoveBadges.call(this, "error");
});
})
.run()
.catch((e) => {
}).run().catch((e) => {
throw e;
});
}
......@@ -2445,7 +2454,8 @@ function gatherState() {
setSelection
.call(this, selection)
.then(() => {})
.then(() => {
})
.catch((e) => {
addErrorAttribute(this, e);
});
......@@ -2474,7 +2484,8 @@ function clearSelection() {
setSelection
.call(this, [])
.then(() => {})
.then(() => {
})
.catch((e) => {
addErrorAttribute(this, e);
});
......@@ -2716,6 +2727,7 @@ function convertSelectionToValue(selection) {
* @returns {boolean}
*/
function isValueIsEmpty(value) {
debugger
let equivalents = this.getOption("empty.equivalents");
if (!isArray(equivalents)) {
if (equivalents === undefined) {
......@@ -3002,8 +3014,7 @@ function initDefaultOptionsFromUrl() {
importOptionsIntern.call(this, data);
setStatusOrRemoveBadges.call(this, "open");
initTotal.call(this, data);
})
.catch((e) => {
}).catch((e) => {
addErrorAttribute(this, e);
setStatusOrRemoveBadges.call(this, "error");
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment