@aptos-scp/scp-component-store-selling-features-domain-model 1.29.0 → 1.30.0
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.
- package/lib/domain/model/IStoreItemSummary.d.ts +4 -0
- package/lib/domain/model/IStoreItemSummary.js +3 -0
- package/lib/domain/model/StoreItem.js +10 -31
- package/lib/domain/model/index.d.ts +1 -0
- package/lib/domain/utility/index.d.ts +1 -0
- package/lib/domain/utility/index.js +1 -0
- package/lib/domain/utility/itemImageUtils.d.ts +3 -0
- package/lib/domain/utility/itemImageUtils.js +26 -0
- package/package.json +1 -1
|
@@ -7,7 +7,7 @@ const scp_component_store_items_1 = require("@aptos-scp/scp-component-store-item
|
|
|
7
7
|
const scp_component_store_selling_core_1 = require("@aptos-scp/scp-component-store-selling-core");
|
|
8
8
|
const scp_types_commerce_transaction_1 = require("@aptos-scp/scp-types-commerce-transaction");
|
|
9
9
|
const ErrorCodes_1 = require("../../config/ErrorCodes");
|
|
10
|
-
const
|
|
10
|
+
const utility_1 = require("../utility");
|
|
11
11
|
const logger = scp_component_logging_1.LogManager.getLogger("com.aptos.storesellingfeatures.domain.model.StoreItem");
|
|
12
12
|
var SourceType;
|
|
13
13
|
(function (SourceType) {
|
|
@@ -115,7 +115,7 @@ function getProductAttributeTranslation(attribute, locale = "en") {
|
|
|
115
115
|
if (!attribute.translations) {
|
|
116
116
|
return undefined;
|
|
117
117
|
}
|
|
118
|
-
const localeToUse =
|
|
118
|
+
const localeToUse = utility_1.getLocaleCodeForTranslationSet(attribute.translations, locale);
|
|
119
119
|
let translation = localeToUse && attribute.translations[localeToUse];
|
|
120
120
|
if (!translation) {
|
|
121
121
|
const defaultLocale = "en";
|
|
@@ -128,7 +128,7 @@ function getMerchandiseHierarchyNodeNameTranslation(node, locale = "en") {
|
|
|
128
128
|
if (!node.translations) {
|
|
129
129
|
return { name: node.nodeInLevelId };
|
|
130
130
|
}
|
|
131
|
-
const localeToUse =
|
|
131
|
+
const localeToUse = utility_1.getLocaleCodeForTranslationSet(node.translations, locale);
|
|
132
132
|
let translation = localeToUse && node.translations[localeToUse];
|
|
133
133
|
if (!translation) {
|
|
134
134
|
const defaultLocale = "en";
|
|
@@ -178,7 +178,7 @@ class ColorAttribute {
|
|
|
178
178
|
constructor(attribute, locale) {
|
|
179
179
|
this.id = attribute.id;
|
|
180
180
|
this.code = attribute.code;
|
|
181
|
-
const localeCodeToUse = attribute.translations &&
|
|
181
|
+
const localeCodeToUse = attribute.translations && utility_1.getLocaleCodeForTranslationSet(attribute.translations, locale);
|
|
182
182
|
const translations = localeCodeToUse && attribute.translations[localeCodeToUse];
|
|
183
183
|
if (translations) {
|
|
184
184
|
this.name = translations.name;
|
|
@@ -194,7 +194,7 @@ class StyleAttribute {
|
|
|
194
194
|
constructor(attribute, locale) {
|
|
195
195
|
this.id = attribute.id;
|
|
196
196
|
this.code = attribute.code;
|
|
197
|
-
const localeCodeToUse = attribute.translations &&
|
|
197
|
+
const localeCodeToUse = attribute.translations && utility_1.getLocaleCodeForTranslationSet(attribute.translations, locale);
|
|
198
198
|
const translations = localeCodeToUse && attribute.translations[localeCodeToUse];
|
|
199
199
|
if (translations) {
|
|
200
200
|
this.name = translations.name;
|
|
@@ -211,7 +211,7 @@ class SizeAttribute {
|
|
|
211
211
|
this.id = attribute.id;
|
|
212
212
|
this.code = attribute.code;
|
|
213
213
|
this.subcode = attribute.subcode;
|
|
214
|
-
const localeCodeToUse = attribute.translations &&
|
|
214
|
+
const localeCodeToUse = attribute.translations && utility_1.getLocaleCodeForTranslationSet(attribute.translations, locale);
|
|
215
215
|
const translations = localeCodeToUse && attribute.translations[localeCodeToUse];
|
|
216
216
|
if (translations) {
|
|
217
217
|
this.name = translations.name;
|
|
@@ -355,30 +355,9 @@ class StoreItem {
|
|
|
355
355
|
storeItem.itemType = item.type && findItemType(item.type);
|
|
356
356
|
//sourceIndicator
|
|
357
357
|
storeItem.source = sourceIndicator;
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
switch (imageSource) {
|
|
362
|
-
case "ImageFromItemData":
|
|
363
|
-
let imageUrl = undefined;
|
|
364
|
-
if (item.images && item.images.length > 0) {
|
|
365
|
-
const primaryImages = item.images.filter((x) => x.primaryImage === true);
|
|
366
|
-
imageUrl = (primaryImages.length > 0 ? primaryImages : item.images)[0].imageUrl;
|
|
367
|
-
}
|
|
368
|
-
return imageUrl;
|
|
369
|
-
case "ImageFromUrlPattern":
|
|
370
|
-
let urlPattern = lineItemImageConfiguration.urlPattern;
|
|
371
|
-
const aSkuKey = item.lookupKeys.find((aKey) => aKey.keyType === scp_component_store_items_1.KeyType.SKU);
|
|
372
|
-
if (aSkuKey) {
|
|
373
|
-
urlPattern = urlPattern.replace(/{{SKU}}/g, aSkuKey.value);
|
|
374
|
-
}
|
|
375
|
-
return urlPattern;
|
|
376
|
-
default:
|
|
377
|
-
return undefined;
|
|
378
|
-
}
|
|
379
|
-
};
|
|
380
|
-
storeItem.imageUrl = getImageUrl(lineItemImageConfiguration.imageSource);
|
|
381
|
-
if (lineItemImageConfiguration.imageSource === "ImageFromItemData" &&
|
|
358
|
+
storeItem.imageUrl = utility_1.getImageUrlForItem(configurationManager, item);
|
|
359
|
+
if (configurationManager.getFunctionalBehaviorValues().lineItemImage.imageSource ===
|
|
360
|
+
"ImageFromItemData" &&
|
|
382
361
|
item.images &&
|
|
383
362
|
item.images.length > 0) {
|
|
384
363
|
storeItem.images = item.images;
|
|
@@ -698,7 +677,7 @@ class StoreItem {
|
|
|
698
677
|
static updateLocalizableTextsFromItemAttributeObject(storeItem, sourceItem, locale) {
|
|
699
678
|
let useDefaultValues = true;
|
|
700
679
|
if (!!locale && locale !== sourceItem.language && sourceItem.translations) {
|
|
701
|
-
const localeToUse =
|
|
680
|
+
const localeToUse = utility_1.getLocaleCodeForTranslationSet(sourceItem.translations, locale);
|
|
702
681
|
if (localeToUse) {
|
|
703
682
|
// ... language-specific values
|
|
704
683
|
const itemTranslationAttribute = sourceItem.translations[localeToUse];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const scp_component_store_items_1 = require("@aptos-scp/scp-component-store-items");
|
|
4
|
+
function getImageUrlForItem(configurationManager, item) {
|
|
5
|
+
var _a, _b;
|
|
6
|
+
const lineItemImageConfig = configurationManager.getFunctionalBehaviorValues().lineItemImage;
|
|
7
|
+
switch (lineItemImageConfig.imageSource) {
|
|
8
|
+
case "ImageFromItemData":
|
|
9
|
+
if ((_a = item.images) === null || _a === void 0 ? void 0 : _a.length) {
|
|
10
|
+
const primaryImages = item.images.filter((x) => x.primaryImage);
|
|
11
|
+
return (primaryImages.length > 0 ? primaryImages : item.images)[0].imageUrl;
|
|
12
|
+
}
|
|
13
|
+
return undefined;
|
|
14
|
+
case "ImageFromUrlPattern":
|
|
15
|
+
const urlPattern = lineItemImageConfig.urlPattern;
|
|
16
|
+
const aSkuKey = (_b = item.lookupKeys) === null || _b === void 0 ? void 0 : _b.find((aKey) => aKey.keyType === scp_component_store_items_1.KeyType.SKU);
|
|
17
|
+
if (aSkuKey) {
|
|
18
|
+
return urlPattern.replace(/{{SKU}}/g, aSkuKey.value);
|
|
19
|
+
}
|
|
20
|
+
return urlPattern;
|
|
21
|
+
default:
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.getImageUrlForItem = getImageUrlForItem;
|
|
26
|
+
//# sourceMappingURL=itemImageUtils.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aptos-scp/scp-component-store-selling-features-domain-model",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.30.0",
|
|
4
4
|
"description": "This component library provides the common components to handle the coordination of processing the business events from the UI.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|