@ikas/storefront 4.0.0-alpha.31 → 4.0.0-alpha.33
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/package.json +11 -11
- package/src/components/page/index.tsx +5 -6
- package/src/components/page-editor/ThemeComponentEditor.tsx +15 -8
- package/src/components/page-editor/model.ts +40 -113
- package/src/models/data/cart/index.ts +1 -1
- package/src/models/data/checkout/index.ts +1 -1
- package/src/models/data/order/index.ts +11 -8
- package/src/models/ui/product-list/index.ts +26 -11
- package/src/page-data-init/index.ts +159 -404
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ikas/storefront",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.33",
|
|
4
4
|
"description": "Storefront functionality for ikas storefront themes.",
|
|
5
5
|
"author": "Umut Ozan Yıldırım",
|
|
6
6
|
"license": "ISC",
|
|
@@ -24,11 +24,11 @@
|
|
|
24
24
|
"libphonenumber-js": "^1.10.6"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@ikas/storefront-api": "^4.0.0-alpha.
|
|
28
|
-
"@ikas/storefront-config": "^4.0.0-alpha.
|
|
29
|
-
"@ikas/storefront-model-functions": "^4.0.0-alpha.
|
|
30
|
-
"@ikas/storefront-models": "^4.0.0-alpha.
|
|
31
|
-
"@ikas/storefront-providers": "^4.0.0-alpha.
|
|
27
|
+
"@ikas/storefront-api": "^4.0.0-alpha.33",
|
|
28
|
+
"@ikas/storefront-config": "^4.0.0-alpha.33",
|
|
29
|
+
"@ikas/storefront-model-functions": "^4.0.0-alpha.33",
|
|
30
|
+
"@ikas/storefront-models": "^4.0.0-alpha.33",
|
|
31
|
+
"@ikas/storefront-providers": "^4.0.0-alpha.33",
|
|
32
32
|
"@rollup/plugin-commonjs": "^22.0.0",
|
|
33
33
|
"@rollup/plugin-json": "^4.1.0",
|
|
34
34
|
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
@@ -52,11 +52,11 @@
|
|
|
52
52
|
"html-react-parser": "^1.4.0"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"@ikas/storefront-api": "^4.0.0-alpha.
|
|
56
|
-
"@ikas/storefront-config": "^4.0.0-alpha.
|
|
57
|
-
"@ikas/storefront-model-functions": "^4.0.0-alpha.
|
|
58
|
-
"@ikas/storefront-models": "^4.0.0-alpha.
|
|
59
|
-
"@ikas/storefront-providers": "^4.0.0-alpha.
|
|
55
|
+
"@ikas/storefront-api": "^4.0.0-alpha.33",
|
|
56
|
+
"@ikas/storefront-config": "^4.0.0-alpha.33",
|
|
57
|
+
"@ikas/storefront-model-functions": "^4.0.0-alpha.33",
|
|
58
|
+
"@ikas/storefront-models": "^4.0.0-alpha.33",
|
|
59
|
+
"@ikas/storefront-providers": "^4.0.0-alpha.33",
|
|
60
60
|
"mobx": "^6.1.3",
|
|
61
61
|
"mobx-react-lite": "^3.1.5",
|
|
62
62
|
"next": "12.2.0",
|
|
@@ -75,7 +75,11 @@ export const IkasPage: React.FC<IkasPageProps> = observer(
|
|
|
75
75
|
pageType,
|
|
76
76
|
isBrowser
|
|
77
77
|
);
|
|
78
|
-
return IkasPageDataInit.
|
|
78
|
+
return IkasPageDataInit.initPagePropValues(
|
|
79
|
+
propValues,
|
|
80
|
+
settings,
|
|
81
|
+
isBrowser
|
|
82
|
+
);
|
|
79
83
|
}, [isBrowser, propValues, pageType, settings, pageSpecificData]);
|
|
80
84
|
|
|
81
85
|
React.useEffect(() => {
|
|
@@ -183,11 +187,6 @@ async function handleAnalytics(
|
|
|
183
187
|
if (pageType === IkasThemeJsonPageType.PRODUCT) {
|
|
184
188
|
const product = pageSpecificData as IkasProduct;
|
|
185
189
|
|
|
186
|
-
const isBrowser = typeof window !== "undefined";
|
|
187
|
-
// if (isBrowser) {
|
|
188
|
-
// IkasPageDataInit._initProductOnBrowser(product);
|
|
189
|
-
// }
|
|
190
|
-
|
|
191
190
|
Analytics.productView(product);
|
|
192
191
|
|
|
193
192
|
//@ts-ignore
|
|
@@ -15,6 +15,11 @@ import {
|
|
|
15
15
|
import { IkasStorefrontConfig } from "@ikas/storefront-config";
|
|
16
16
|
import { IkasPageDataInit } from "../../page-data-init";
|
|
17
17
|
import { IkasBaseStore } from "../../store";
|
|
18
|
+
import {
|
|
19
|
+
IkasCheckout,
|
|
20
|
+
IkasOrderLineItem,
|
|
21
|
+
IkasCheckoutSettings,
|
|
22
|
+
} from "../../models/data";
|
|
18
23
|
|
|
19
24
|
type Props = {
|
|
20
25
|
vm: IkasPageEditorViewModel;
|
|
@@ -59,7 +64,7 @@ export class ThemeEditorComponent extends React.Component<Props> {
|
|
|
59
64
|
get pageComponentPropValue() {
|
|
60
65
|
const { vm, pageComponent } = this.props;
|
|
61
66
|
|
|
62
|
-
return vm.
|
|
67
|
+
return vm.initializedPropValues.find(
|
|
63
68
|
(pc) => pc.pageComponent.id === pageComponent.id
|
|
64
69
|
);
|
|
65
70
|
}
|
|
@@ -70,13 +75,16 @@ export class ThemeEditorComponent extends React.Component<Props> {
|
|
|
70
75
|
|
|
71
76
|
if (vm.page?.type === IkasThemeJsonPageType.CHECKOUT) {
|
|
72
77
|
const checkoutProps: IkasCheckoutPageProps = {
|
|
73
|
-
checkout: {
|
|
78
|
+
checkout: new IkasCheckout({
|
|
79
|
+
currencyCode: "TRY",
|
|
80
|
+
currencySymbol: "₺",
|
|
74
81
|
orderLineItems: [
|
|
75
|
-
{
|
|
82
|
+
new IkasOrderLineItem({
|
|
76
83
|
id: "",
|
|
77
84
|
createdAt: 0,
|
|
78
85
|
updatedAt: 0,
|
|
79
86
|
currencyCode: "TRY",
|
|
87
|
+
currencySymbol: "₺",
|
|
80
88
|
discount: null,
|
|
81
89
|
discountPrice: null,
|
|
82
90
|
finalPrice: 100,
|
|
@@ -106,11 +114,10 @@ export class ThemeEditorComponent extends React.Component<Props> {
|
|
|
106
114
|
variantValues: [],
|
|
107
115
|
},
|
|
108
116
|
orderedAt: 0,
|
|
109
|
-
|
|
110
|
-
},
|
|
117
|
+
}),
|
|
111
118
|
],
|
|
112
|
-
}
|
|
113
|
-
checkoutSettings: {
|
|
119
|
+
}),
|
|
120
|
+
checkoutSettings: new IkasCheckoutSettings({
|
|
114
121
|
createdAt: 0,
|
|
115
122
|
updatedAt: 0,
|
|
116
123
|
id: "",
|
|
@@ -126,7 +133,7 @@ export class ThemeEditorComponent extends React.Component<Props> {
|
|
|
126
133
|
showCheckoutNote: true,
|
|
127
134
|
showTermsAndConditionsCheckbox: true,
|
|
128
135
|
storefrontId: "",
|
|
129
|
-
},
|
|
136
|
+
}),
|
|
130
137
|
customizationProps: {
|
|
131
138
|
...propValues,
|
|
132
139
|
},
|
|
@@ -14,7 +14,10 @@ import {
|
|
|
14
14
|
IkasThemeJsonSettings,
|
|
15
15
|
IkasVariantValue,
|
|
16
16
|
} from "../../models";
|
|
17
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
IkasPageComponentPropValue,
|
|
19
|
+
IkasPageDataProvider,
|
|
20
|
+
} from "@ikas/storefront-providers";
|
|
18
21
|
import { makeAutoObservable, reaction } from "mobx";
|
|
19
22
|
import { NextRouter } from "next/router.js";
|
|
20
23
|
import { IkasPageDataInit } from "../../page-data-init";
|
|
@@ -24,6 +27,7 @@ import BlogStore from "../../store/blog";
|
|
|
24
27
|
import RaffleStore from "../../store/raffle";
|
|
25
28
|
import ProductStore from "../../store/product";
|
|
26
29
|
import { setAPIClientConfig } from "@ikas/storefront-api";
|
|
30
|
+
import { runInAction } from "mobx";
|
|
27
31
|
|
|
28
32
|
const PACKAGE_VERSION = "2.0.20";
|
|
29
33
|
// import { version as PACKAGE_VERSION } from "../../../package.json";
|
|
@@ -44,6 +48,7 @@ export default class IkasPageEditorViewModel {
|
|
|
44
48
|
pageParams: Record<string, any> = {};
|
|
45
49
|
apiKey?: string | null = null;
|
|
46
50
|
pageDataProvider?: IkasPageDataProvider | null = null;
|
|
51
|
+
initializedPropValues: IkasPageComponentPropValue[] = [];
|
|
47
52
|
|
|
48
53
|
router: NextRouter;
|
|
49
54
|
|
|
@@ -367,18 +372,20 @@ export default class IkasPageEditorViewModel {
|
|
|
367
372
|
this.pageParams
|
|
368
373
|
);
|
|
369
374
|
|
|
370
|
-
|
|
371
|
-
|
|
375
|
+
runInAction(() => {
|
|
376
|
+
IkasBaseStore.getInstance().currentPageType = pageType;
|
|
377
|
+
this.pageDataProvider = pageDataProvider;
|
|
372
378
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
379
|
+
if (pageType === IkasThemeJsonPageType.CUSTOM)
|
|
380
|
+
this.page = this.theme?.pages.find(
|
|
381
|
+
(p) => p.type === pageType && p.slug === this.pageParams.slug
|
|
382
|
+
);
|
|
383
|
+
else this.page = this.theme?.pages.find((p) => p.type === pageType);
|
|
378
384
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
385
|
+
requestAnimationFrame(() => {
|
|
386
|
+
document.body.scrollTop = 0;
|
|
387
|
+
if (document.scrollingElement) document.scrollingElement.scrollTop = 0;
|
|
388
|
+
});
|
|
382
389
|
});
|
|
383
390
|
|
|
384
391
|
this.sendMessage(BridgeMessageType.EDITOR_PAGE_CHANGE, {
|
|
@@ -505,8 +512,8 @@ export default class IkasPageEditorViewModel {
|
|
|
505
512
|
IkasPageDataInit.pageSpecificData = undefined;
|
|
506
513
|
}
|
|
507
514
|
|
|
508
|
-
|
|
509
|
-
pageDataProvider
|
|
515
|
+
this.initializedPropValues = IkasPageDataInit.initPagePropValues(
|
|
516
|
+
pageDataProvider.$pageComponentPropValues,
|
|
510
517
|
theme!.settings,
|
|
511
518
|
false
|
|
512
519
|
);
|
|
@@ -608,102 +615,31 @@ export default class IkasPageEditorViewModel {
|
|
|
608
615
|
|
|
609
616
|
if (!prop || !this.selectedPageComponent) return;
|
|
610
617
|
|
|
611
|
-
const pageComponentPropValues =
|
|
612
|
-
this.
|
|
613
|
-
|
|
614
|
-
|
|
618
|
+
const pageComponentPropValues = this.initializedPropValues.find(
|
|
619
|
+
(pv) => pv.pageComponent.id === this.selectedPageComponentId
|
|
620
|
+
);
|
|
621
|
+
if (!this.pageDataProvider || !pageComponentPropValues) return;
|
|
615
622
|
|
|
616
623
|
this.selectedPageComponent.propValues[propName] = value;
|
|
617
624
|
|
|
618
|
-
if (!this.pageDataProvider) return;
|
|
619
|
-
|
|
620
625
|
const propValue = await this.pageDataProvider.getPageComponentPropValue(
|
|
621
626
|
this.selectedPageComponent,
|
|
622
627
|
prop
|
|
623
628
|
);
|
|
624
629
|
|
|
625
|
-
|
|
630
|
+
if (
|
|
631
|
+
propValue &&
|
|
632
|
+
(propValue.linkType || JSON.stringify(propValue)?.includes("linkType"))
|
|
633
|
+
)
|
|
634
|
+
await this.pageDataProvider.setLinkSlugs();
|
|
626
635
|
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
true
|
|
635
|
-
);
|
|
636
|
-
} else if (prop.type === IkasThemeJsonComponentPropType.COMPONENT) {
|
|
637
|
-
IkasPageDataInit.initComponentPropValue(
|
|
638
|
-
prop,
|
|
639
|
-
propValue,
|
|
640
|
-
pageComponentPropValues,
|
|
641
|
-
this.theme!.settings,
|
|
642
|
-
true
|
|
643
|
-
);
|
|
644
|
-
} else if (prop.type === IkasThemeJsonComponentPropType.COMPONENT_LIST) {
|
|
645
|
-
IkasPageDataInit.initComponentListPropValue(
|
|
646
|
-
prop,
|
|
647
|
-
propValue,
|
|
648
|
-
pageComponentPropValues,
|
|
649
|
-
this.theme!.settings,
|
|
650
|
-
true
|
|
651
|
-
);
|
|
652
|
-
} else if (prop.type === IkasThemeJsonComponentPropType.PRODUCT_DETAIL) {
|
|
653
|
-
IkasPageDataInit.initProductPropValue(
|
|
654
|
-
prop,
|
|
655
|
-
propValue,
|
|
656
|
-
pageComponentPropValues
|
|
657
|
-
);
|
|
658
|
-
} else if (prop.type === IkasThemeJsonComponentPropType.PRODUCT_LIST) {
|
|
659
|
-
IkasPageDataInit.initProductListPropValue(
|
|
660
|
-
prop,
|
|
661
|
-
propValue,
|
|
662
|
-
pageComponentPropValues
|
|
663
|
-
);
|
|
664
|
-
} else if (prop.type === IkasThemeJsonComponentPropType.CATEGORY) {
|
|
665
|
-
IkasPageDataInit.initCategoryPropValue(
|
|
666
|
-
prop,
|
|
667
|
-
propValue,
|
|
668
|
-
pageComponentPropValues
|
|
669
|
-
);
|
|
670
|
-
} else if (prop.type === IkasThemeJsonComponentPropType.BRAND) {
|
|
671
|
-
IkasPageDataInit.initBrandPropValue(
|
|
672
|
-
prop,
|
|
673
|
-
propValue,
|
|
674
|
-
pageComponentPropValues
|
|
675
|
-
);
|
|
676
|
-
} else if (prop.type === IkasThemeJsonComponentPropType.BLOG) {
|
|
677
|
-
IkasPageDataInit.initBlogPropValue(
|
|
678
|
-
prop,
|
|
679
|
-
propValue,
|
|
680
|
-
pageComponentPropValues
|
|
681
|
-
);
|
|
682
|
-
} else if (prop.type === IkasThemeJsonComponentPropType.BLOG_CATEGORY) {
|
|
683
|
-
IkasPageDataInit.initBlogCategoryPropValue(
|
|
684
|
-
prop,
|
|
685
|
-
propValue,
|
|
686
|
-
pageComponentPropValues
|
|
687
|
-
);
|
|
688
|
-
} else if (prop.type === IkasThemeJsonComponentPropType.RAFFLE) {
|
|
689
|
-
IkasPageDataInit.initRafflePropValue(
|
|
690
|
-
prop,
|
|
691
|
-
propValue,
|
|
692
|
-
pageComponentPropValues
|
|
693
|
-
);
|
|
694
|
-
} else if (
|
|
695
|
-
prop.type === IkasThemeJsonComponentPropType.LINK ||
|
|
696
|
-
prop.type === IkasThemeJsonComponentPropType.LIST_OF_LINK
|
|
697
|
-
) {
|
|
698
|
-
IkasPageDataInit.initLinkPropValue(
|
|
699
|
-
prop,
|
|
700
|
-
propValue,
|
|
701
|
-
pageComponentPropValues
|
|
702
|
-
);
|
|
703
|
-
} else {
|
|
704
|
-
pageComponentPropValues.propValues[propName] = propValue;
|
|
705
|
-
}
|
|
706
|
-
}
|
|
636
|
+
pageComponentPropValues.propValues[propName] =
|
|
637
|
+
IkasPageDataInit.initPropValue(
|
|
638
|
+
prop,
|
|
639
|
+
propValue,
|
|
640
|
+
this.theme!.settings,
|
|
641
|
+
true
|
|
642
|
+
);
|
|
707
643
|
};
|
|
708
644
|
|
|
709
645
|
handleUpdatePageParams = async (data: any) => {
|
|
@@ -771,24 +707,15 @@ export default class IkasPageEditorViewModel {
|
|
|
771
707
|
const pageComponentPropValues =
|
|
772
708
|
await this.pageDataProvider!.getPageComponentPropValues(pageComponent);
|
|
773
709
|
|
|
774
|
-
const
|
|
775
|
-
(
|
|
776
|
-
);
|
|
777
|
-
|
|
778
|
-
customDataProps.forEach((customDataProp) => {
|
|
779
|
-
IkasPageDataInit.initCustomDataPropValue(
|
|
780
|
-
customDataProp,
|
|
781
|
-
pageComponentPropValues.propValues[customDataProp.name],
|
|
710
|
+
const initializedPageComponentPropValues =
|
|
711
|
+
IkasPageDataInit.initPageComponentPropValue(
|
|
782
712
|
pageComponentPropValues,
|
|
783
713
|
this.theme!.settings,
|
|
784
714
|
true
|
|
785
715
|
);
|
|
786
716
|
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
);
|
|
790
|
-
this.pageComponents.push(pageComponent);
|
|
791
|
-
});
|
|
717
|
+
this.initializedPropValues.push(initializedPageComponentPropValues);
|
|
718
|
+
this.pageComponents.push(pageComponent);
|
|
792
719
|
};
|
|
793
720
|
|
|
794
721
|
handleDeletePageComponent = (data: any) => {
|
|
@@ -12,7 +12,7 @@ export class IkasCart extends IkasOrder implements ICart {
|
|
|
12
12
|
shippingZoneRateId: string | null = null;
|
|
13
13
|
stockLocationId: string | null = null;
|
|
14
14
|
|
|
15
|
-
constructor(data: ICart) {
|
|
15
|
+
constructor(data: Partial<ICart>) {
|
|
16
16
|
super(data);
|
|
17
17
|
|
|
18
18
|
this.availableShippingMethods =
|
|
@@ -17,7 +17,7 @@ export class IkasCheckout extends IkasCart implements ICheckout {
|
|
|
17
17
|
selectedPaymentGateway?: IkasPaymentGateway | null = null;
|
|
18
18
|
masterPassPaymentGateway?: IkasPaymentGateway | null = null;
|
|
19
19
|
|
|
20
|
-
constructor(data: IkasCheckoutConstructorData) {
|
|
20
|
+
constructor(data: Partial<IkasCheckoutConstructorData>) {
|
|
21
21
|
super(data);
|
|
22
22
|
|
|
23
23
|
makeObservable(this, {
|
|
@@ -58,15 +58,15 @@ export class IkasOrder extends IkasBaseModel implements IOrder {
|
|
|
58
58
|
// Extra
|
|
59
59
|
refundSettings?: IkasOrderRefundSettings | null;
|
|
60
60
|
|
|
61
|
-
constructor(data: IOrderConstructorData) {
|
|
62
|
-
super(data);
|
|
61
|
+
constructor(data: Partial<IOrderConstructorData>) {
|
|
62
|
+
super(data as any);
|
|
63
63
|
|
|
64
64
|
this.billingAddress = data.billingAddress
|
|
65
65
|
? new IkasOrderAddress(data.billingAddress)
|
|
66
66
|
: null;
|
|
67
67
|
this.cancelReason = data.cancelReason || null;
|
|
68
68
|
this.cancelledAt = data.cancelledAt || null;
|
|
69
|
-
this.currencyCode = data.currencyCode;
|
|
69
|
+
this.currencyCode = data.currencyCode || "";
|
|
70
70
|
this.currencySymbol = data.currencySymbol || null;
|
|
71
71
|
this.customer = data.customer ? new IkasOrderCustomer(data.customer) : null;
|
|
72
72
|
this.customerId = data.customerId || null;
|
|
@@ -80,7 +80,9 @@ export class IkasOrder extends IkasBaseModel implements IOrder {
|
|
|
80
80
|
this.orderAdjustments =
|
|
81
81
|
data.orderAdjustments?.map((oa) => new IkasOrderAdjustment(oa)) || null;
|
|
82
82
|
this.orderLineItems =
|
|
83
|
-
data.orderLineItems
|
|
83
|
+
data.orderLineItems
|
|
84
|
+
?.map((oli) => new IkasOrderLineItem(oli))
|
|
85
|
+
.filter((i) => !i.deleted) || [];
|
|
84
86
|
this.orderNumber = data.orderNumber || null;
|
|
85
87
|
this.orderPackageStatus = data.orderPackageStatus || null;
|
|
86
88
|
this.orderPackages =
|
|
@@ -92,12 +94,13 @@ export class IkasOrder extends IkasBaseModel implements IOrder {
|
|
|
92
94
|
this.shippingAddress = data.shippingAddress
|
|
93
95
|
? new IkasOrderAddress(data.shippingAddress)
|
|
94
96
|
: null;
|
|
95
|
-
this.shippingMethod =
|
|
96
|
-
|
|
97
|
+
this.shippingMethod =
|
|
98
|
+
data.shippingMethod || IkasOrderShippingMethod.SHIPMENT;
|
|
99
|
+
this.status = data.status || IkasOrderStatus.CREATED;
|
|
97
100
|
this.taxLines =
|
|
98
101
|
data.taxLines?.map((tl) => new IkasOrderTaxLine(tl)) || null;
|
|
99
|
-
this.totalFinalPrice = data.totalFinalPrice;
|
|
100
|
-
this.totalPrice = data.totalPrice;
|
|
102
|
+
this.totalFinalPrice = data.totalFinalPrice ?? 0;
|
|
103
|
+
this.totalPrice = data.totalPrice ?? 0;
|
|
101
104
|
|
|
102
105
|
this.refundSettings = data.refundSettings;
|
|
103
106
|
|
|
@@ -56,31 +56,45 @@ export class IkasProductList {
|
|
|
56
56
|
private _fetchRequestTime = 0;
|
|
57
57
|
private router?: NextRouter | null = null;
|
|
58
58
|
|
|
59
|
-
constructor(
|
|
59
|
+
constructor(
|
|
60
|
+
data: IkasProductListParams | IkasProductList,
|
|
61
|
+
router?: NextRouter
|
|
62
|
+
) {
|
|
63
|
+
const _params = data as IkasProductListParams;
|
|
64
|
+
const _list = data as IkasProductList;
|
|
65
|
+
|
|
60
66
|
this.data = data.data ? data.data.map((d) => new IkasProduct(d)) : [];
|
|
61
67
|
this._type =
|
|
62
|
-
|
|
63
|
-
|
|
68
|
+
_params.type ||
|
|
69
|
+
_list._type ||
|
|
70
|
+
_params.productListPropValue.productListType ||
|
|
71
|
+
_list._productListPropValue.productListType ||
|
|
64
72
|
IkasProductListType.ALL;
|
|
65
73
|
this._pageType = data.pageType;
|
|
66
74
|
this._sort =
|
|
67
75
|
data.sort ||
|
|
68
76
|
data.productListPropValue.initialSort ||
|
|
69
77
|
IkasProductListSortType.LAST_ADDED;
|
|
70
|
-
|
|
71
|
-
|
|
78
|
+
this._limit =
|
|
79
|
+
data.limit ||
|
|
80
|
+
_params.productListPropValue.initialLimit ||
|
|
81
|
+
_list._productListPropValue.initialLimit ||
|
|
82
|
+
20;
|
|
72
83
|
this._page = data.page || 1;
|
|
73
84
|
this._minPage = data.minPage || null;
|
|
74
85
|
this._count = data.count || 0;
|
|
75
86
|
this._searchKeyword = data.searchKeyword || "";
|
|
76
|
-
this._productListPropValue =
|
|
87
|
+
this._productListPropValue =
|
|
88
|
+
_params.productListPropValue || _list._productListPropValue;
|
|
77
89
|
|
|
78
|
-
this._filterBrandId =
|
|
79
|
-
this._filterCategoryId =
|
|
90
|
+
this._filterBrandId = _params.filterBrandId || _list._filterBrandId || null;
|
|
91
|
+
this._filterCategoryId =
|
|
92
|
+
_params.filterCategoryId || _list._filterCategoryId || null;
|
|
80
93
|
|
|
81
|
-
this._relatedProductData =
|
|
94
|
+
this._relatedProductData =
|
|
95
|
+
_params.relatedProductData || _list._relatedProductData || null;
|
|
82
96
|
|
|
83
|
-
this._recommendFor =
|
|
97
|
+
this._recommendFor = _params.recommendFor || _list._recommendFor;
|
|
84
98
|
|
|
85
99
|
this.filters = data.filters
|
|
86
100
|
? data.filters.map((f) => new IkasProductFilter(f, this))
|
|
@@ -88,7 +102,8 @@ export class IkasProductList {
|
|
|
88
102
|
this._filterCategories = data.filterCategories
|
|
89
103
|
? data.filterCategories.map((c) => new IkasFilterCategory(c))
|
|
90
104
|
: null;
|
|
91
|
-
this.pageSpecificData =
|
|
105
|
+
this.pageSpecificData =
|
|
106
|
+
_params.pageSpecificData || _list.pageSpecificData || null;
|
|
92
107
|
|
|
93
108
|
this.router = router;
|
|
94
109
|
|
|
@@ -3,7 +3,6 @@ import { IkasCategoryListParams } from "../models/ui/category-list";
|
|
|
3
3
|
import { IkasAttributeList } from "../models/ui/product-attribute-list";
|
|
4
4
|
import { IkasProductListParams } from "../models/ui/product-list";
|
|
5
5
|
import { IkasRaffleListParams } from "../models/ui/raffle-list";
|
|
6
|
-
import { observable } from "mobx";
|
|
7
6
|
|
|
8
7
|
import {
|
|
9
8
|
IkasThemeJsonSettings,
|
|
@@ -54,7 +53,7 @@ import {
|
|
|
54
53
|
import _cloneDeep from "lodash/cloneDeep";
|
|
55
54
|
|
|
56
55
|
export class IkasPageDataInit {
|
|
57
|
-
static pageSpecificData: any =
|
|
56
|
+
static pageSpecificData: any = {};
|
|
58
57
|
|
|
59
58
|
static setPageSpecificData(
|
|
60
59
|
pageSpecificData: any,
|
|
@@ -71,7 +70,8 @@ export class IkasPageDataInit {
|
|
|
71
70
|
const product = pageSpecificData as IkasProduct;
|
|
72
71
|
IkasPageDataInit.pageSpecificData = new IkasProduct({
|
|
73
72
|
...product,
|
|
74
|
-
selectedVariantValues:
|
|
73
|
+
selectedVariantValues:
|
|
74
|
+
product.selectedVariantValues || product.variants[0].variantValues,
|
|
75
75
|
});
|
|
76
76
|
if (isBrowser) {
|
|
77
77
|
this._initProductOnBrowser(IkasPageDataInit.pageSpecificData);
|
|
@@ -112,215 +112,136 @@ export class IkasPageDataInit {
|
|
|
112
112
|
return typeof window === "undefined";
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
static
|
|
116
|
-
|
|
115
|
+
static initPagePropValues(
|
|
116
|
+
pageComponentPropValues: IkasPageComponentPropValue[],
|
|
117
117
|
settings: IkasThemeJsonSettings,
|
|
118
118
|
isBrowser?: boolean
|
|
119
119
|
) {
|
|
120
|
-
|
|
120
|
+
return pageComponentPropValues.map((pageComponentPropValue) =>
|
|
121
|
+
IkasPageDataInit.initPageComponentPropValue(
|
|
122
|
+
pageComponentPropValue,
|
|
123
|
+
settings,
|
|
124
|
+
isBrowser
|
|
125
|
+
)
|
|
126
|
+
);
|
|
127
|
+
}
|
|
121
128
|
|
|
122
|
-
|
|
123
|
-
|
|
129
|
+
static initPageComponentPropValue(
|
|
130
|
+
pageComponentPropValue: IkasPageComponentPropValue,
|
|
131
|
+
settings: IkasThemeJsonSettings,
|
|
132
|
+
isBrowser?: boolean
|
|
133
|
+
) {
|
|
134
|
+
const props = pageComponentPropValue.component.props;
|
|
135
|
+
const initializedPropValues: Record<string, any> = {};
|
|
124
136
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
if (propValue === null || propValue === undefined) return;
|
|
137
|
+
props.map((prop) => {
|
|
138
|
+
const propValue = pageComponentPropValue.propValues[prop.name];
|
|
128
139
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
break;
|
|
140
|
+
initializedPropValues[prop.name] = IkasPageDataInit.initPropValue(
|
|
141
|
+
prop,
|
|
142
|
+
propValue,
|
|
143
|
+
settings,
|
|
144
|
+
isBrowser
|
|
145
|
+
);
|
|
146
|
+
});
|
|
137
147
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
);
|
|
144
|
-
break;
|
|
148
|
+
return new IkasPageComponentPropValue({
|
|
149
|
+
...pageComponentPropValue,
|
|
150
|
+
propValues: initializedPropValues,
|
|
151
|
+
});
|
|
152
|
+
}
|
|
145
153
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
154
|
+
static initPropValue(
|
|
155
|
+
prop: IkasThemeJsonComponentProp,
|
|
156
|
+
propValue: any,
|
|
157
|
+
settings: IkasThemeJsonSettings,
|
|
158
|
+
isBrowser?: boolean
|
|
159
|
+
) {
|
|
160
|
+
if (propValue === null || propValue === undefined) return null;
|
|
153
161
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
propValue,
|
|
158
|
-
pageComponentPropValue
|
|
159
|
-
);
|
|
160
|
-
break;
|
|
162
|
+
switch (prop.type) {
|
|
163
|
+
case IkasThemeJsonComponentPropType.IMAGE:
|
|
164
|
+
return IkasPageDataInit.initImagePropValue(propValue);
|
|
161
165
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
prop,
|
|
165
|
-
propValue,
|
|
166
|
-
pageComponentPropValue
|
|
167
|
-
);
|
|
168
|
-
break;
|
|
166
|
+
case IkasThemeJsonComponentPropType.IMAGE_LIST:
|
|
167
|
+
return IkasPageDataInit.initImageListPropValue(propValue);
|
|
169
168
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
prop,
|
|
173
|
-
propValue,
|
|
174
|
-
pageComponentPropValue
|
|
175
|
-
);
|
|
176
|
-
break;
|
|
169
|
+
case IkasThemeJsonComponentPropType.BRAND:
|
|
170
|
+
return IkasPageDataInit.initBrandPropValue(propValue);
|
|
177
171
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
prop,
|
|
181
|
-
propValue,
|
|
182
|
-
pageComponentPropValue
|
|
183
|
-
);
|
|
184
|
-
break;
|
|
172
|
+
case IkasThemeJsonComponentPropType.BRAND_LIST:
|
|
173
|
+
return IkasPageDataInit.initBrandListPropValue(propValue);
|
|
185
174
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
prop,
|
|
189
|
-
propValue,
|
|
190
|
-
pageComponentPropValue
|
|
191
|
-
);
|
|
192
|
-
break;
|
|
175
|
+
case IkasThemeJsonComponentPropType.CATEGORY:
|
|
176
|
+
return IkasPageDataInit.initCategoryPropValue(propValue);
|
|
193
177
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
prop,
|
|
197
|
-
propValue,
|
|
198
|
-
pageComponentPropValue
|
|
199
|
-
);
|
|
200
|
-
break;
|
|
178
|
+
case IkasThemeJsonComponentPropType.CATEGORY_LIST:
|
|
179
|
+
return IkasPageDataInit.initCategoryListPropValue(propValue);
|
|
201
180
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
prop,
|
|
205
|
-
propValue,
|
|
206
|
-
pageComponentPropValue
|
|
207
|
-
);
|
|
208
|
-
break;
|
|
209
|
-
|
|
210
|
-
case IkasThemeJsonComponentPropType.LINK:
|
|
211
|
-
case IkasThemeJsonComponentPropType.LIST_OF_LINK:
|
|
212
|
-
IkasPageDataInit.initLinkPropValue(
|
|
213
|
-
prop,
|
|
214
|
-
propValue,
|
|
215
|
-
pageComponentPropValue
|
|
216
|
-
);
|
|
217
|
-
break;
|
|
218
|
-
|
|
219
|
-
case IkasThemeJsonComponentPropType.COMPONENT:
|
|
220
|
-
IkasPageDataInit.initComponentPropValue(
|
|
221
|
-
prop,
|
|
222
|
-
propValue,
|
|
223
|
-
pageComponentPropValue,
|
|
224
|
-
settings,
|
|
225
|
-
isBrowser
|
|
226
|
-
);
|
|
227
|
-
break;
|
|
228
|
-
|
|
229
|
-
case IkasThemeJsonComponentPropType.COMPONENT_LIST:
|
|
230
|
-
IkasPageDataInit.initComponentListPropValue(
|
|
231
|
-
prop,
|
|
232
|
-
propValue,
|
|
233
|
-
pageComponentPropValue,
|
|
234
|
-
settings,
|
|
235
|
-
isBrowser
|
|
236
|
-
);
|
|
237
|
-
break;
|
|
238
|
-
|
|
239
|
-
case IkasThemeJsonComponentPropType.CUSTOM:
|
|
240
|
-
IkasPageDataInit.initCustomDataPropValue(
|
|
241
|
-
prop,
|
|
242
|
-
propValue,
|
|
243
|
-
pageComponentPropValue,
|
|
244
|
-
settings,
|
|
245
|
-
isBrowser
|
|
246
|
-
);
|
|
247
|
-
break;
|
|
181
|
+
case IkasThemeJsonComponentPropType.PRODUCT_LIST:
|
|
182
|
+
return IkasPageDataInit.initProductListPropValue(propValue);
|
|
248
183
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
prop,
|
|
252
|
-
propValue,
|
|
253
|
-
pageComponentPropValue
|
|
254
|
-
);
|
|
255
|
-
break;
|
|
184
|
+
case IkasThemeJsonComponentPropType.PRODUCT_DETAIL:
|
|
185
|
+
return IkasPageDataInit.initProductPropValue(propValue);
|
|
256
186
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
prop,
|
|
260
|
-
propValue,
|
|
261
|
-
pageComponentPropValue
|
|
262
|
-
);
|
|
263
|
-
break;
|
|
187
|
+
case IkasThemeJsonComponentPropType.PRODUCT_ATTRIBUTE:
|
|
188
|
+
return IkasPageDataInit.initAttributePropValue(propValue);
|
|
264
189
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
prop,
|
|
268
|
-
propValue,
|
|
269
|
-
pageComponentPropValue
|
|
270
|
-
);
|
|
271
|
-
break;
|
|
190
|
+
case IkasThemeJsonComponentPropType.PRODUCT_ATTRIBUTE_LIST:
|
|
191
|
+
return IkasPageDataInit.initAttributeListPropValue(propValue);
|
|
272
192
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
propValue,
|
|
277
|
-
pageComponentPropValue
|
|
278
|
-
);
|
|
279
|
-
break;
|
|
193
|
+
case IkasThemeJsonComponentPropType.LINK:
|
|
194
|
+
case IkasThemeJsonComponentPropType.LIST_OF_LINK:
|
|
195
|
+
return IkasPageDataInit.initLinkPropValue(propValue);
|
|
280
196
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
break;
|
|
197
|
+
case IkasThemeJsonComponentPropType.COMPONENT:
|
|
198
|
+
return IkasPageDataInit.initComponentPropValue(
|
|
199
|
+
propValue,
|
|
200
|
+
settings,
|
|
201
|
+
isBrowser
|
|
202
|
+
);
|
|
288
203
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
break;
|
|
204
|
+
case IkasThemeJsonComponentPropType.COMPONENT_LIST:
|
|
205
|
+
return IkasPageDataInit.initComponentListPropValue(
|
|
206
|
+
propValue,
|
|
207
|
+
settings,
|
|
208
|
+
isBrowser
|
|
209
|
+
);
|
|
296
210
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
break;
|
|
211
|
+
case IkasThemeJsonComponentPropType.CUSTOM:
|
|
212
|
+
return IkasPageDataInit.initCustomDataPropValue(
|
|
213
|
+
propValue,
|
|
214
|
+
settings,
|
|
215
|
+
isBrowser
|
|
216
|
+
);
|
|
304
217
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
}
|
|
308
|
-
});
|
|
309
|
-
});
|
|
218
|
+
case IkasThemeJsonComponentPropType.BLOG:
|
|
219
|
+
return IkasPageDataInit.initBlogPropValue(propValue);
|
|
310
220
|
|
|
311
|
-
|
|
312
|
-
|
|
221
|
+
case IkasThemeJsonComponentPropType.BLOG_LIST:
|
|
222
|
+
return IkasPageDataInit.initBlogListPropValue(propValue);
|
|
313
223
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
224
|
+
case IkasThemeJsonComponentPropType.BLOG_CATEGORY:
|
|
225
|
+
return IkasPageDataInit.initBlogCategoryPropValue(propValue);
|
|
226
|
+
|
|
227
|
+
case IkasThemeJsonComponentPropType.BLOG_LIST:
|
|
228
|
+
return IkasPageDataInit.initBlogCategoryListPropValue(propValue);
|
|
229
|
+
|
|
230
|
+
case IkasThemeJsonComponentPropType.RAFFLE:
|
|
231
|
+
return IkasPageDataInit.initRafflePropValue(propValue);
|
|
232
|
+
|
|
233
|
+
case IkasThemeJsonComponentPropType.RAFFLE_LIST:
|
|
234
|
+
return IkasPageDataInit.initRaffleListPropValue(propValue);
|
|
235
|
+
|
|
236
|
+
case IkasThemeJsonComponentPropType.SLIDER:
|
|
237
|
+
return IkasPageDataInit.initSliderPropValue(propValue);
|
|
238
|
+
|
|
239
|
+
default:
|
|
240
|
+
return propValue;
|
|
241
|
+
}
|
|
321
242
|
}
|
|
322
243
|
|
|
323
|
-
static
|
|
244
|
+
static initBrandPropValue(propValue: IkasBrandPropValueData) {
|
|
324
245
|
if (propValue.brandPropValue.usePageData && this.pageSpecificData) {
|
|
325
246
|
return this.pageSpecificData;
|
|
326
247
|
}
|
|
@@ -332,29 +253,11 @@ export class IkasPageDataInit {
|
|
|
332
253
|
return getPlaceholderBrand();
|
|
333
254
|
}
|
|
334
255
|
|
|
335
|
-
static initBrandListPropValue(
|
|
336
|
-
prop: IkasThemeJsonComponentProp,
|
|
337
|
-
propValue: any,
|
|
338
|
-
pageComponentPropValue: IkasPageComponentPropValue
|
|
339
|
-
) {
|
|
340
|
-
pageComponentPropValue.propValues[prop.name] =
|
|
341
|
-
IkasPageDataInit._initBrandListPropValue(propValue);
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
static _initBrandListPropValue(propValue: IkasBrandListParams) {
|
|
256
|
+
static initBrandListPropValue(propValue: IkasBrandListParams) {
|
|
345
257
|
return new IkasBrandList(propValue);
|
|
346
258
|
}
|
|
347
259
|
|
|
348
|
-
static initCategoryPropValue(
|
|
349
|
-
prop: IkasThemeJsonComponentProp,
|
|
350
|
-
propValue: IkasCategoryPropValueData,
|
|
351
|
-
pageComponentPropValue: IkasPageComponentPropValue
|
|
352
|
-
) {
|
|
353
|
-
pageComponentPropValue.propValues[prop.name] =
|
|
354
|
-
IkasPageDataInit._initCategoryPropValue(propValue);
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
static _initCategoryPropValue(propValue: IkasCategoryPropValueData) {
|
|
260
|
+
static initCategoryPropValue(propValue: IkasCategoryPropValueData) {
|
|
358
261
|
if (propValue.categoryPropValue.usePageData && this.pageSpecificData) {
|
|
359
262
|
return this.pageSpecificData;
|
|
360
263
|
}
|
|
@@ -366,44 +269,15 @@ export class IkasPageDataInit {
|
|
|
366
269
|
return getPlaceholderCategory();
|
|
367
270
|
}
|
|
368
271
|
|
|
369
|
-
static initCategoryListPropValue(
|
|
370
|
-
prop: IkasThemeJsonComponentProp,
|
|
371
|
-
propValue: any,
|
|
372
|
-
pageComponentPropValue: IkasPageComponentPropValue
|
|
373
|
-
) {
|
|
374
|
-
const categoryList = new IkasCategoryList(
|
|
375
|
-
propValue as IkasCategoryListParams
|
|
376
|
-
);
|
|
377
|
-
pageComponentPropValue.propValues[prop.name] = categoryList;
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
static _initCategoryListPropValue(propValue: IkasCategoryListParams) {
|
|
272
|
+
static initCategoryListPropValue(propValue: IkasCategoryListParams) {
|
|
381
273
|
return new IkasCategoryList(propValue);
|
|
382
274
|
}
|
|
383
275
|
|
|
384
|
-
static initProductListPropValue(
|
|
385
|
-
prop: IkasThemeJsonComponentProp,
|
|
386
|
-
propValue: any,
|
|
387
|
-
pageComponentPropValue: IkasPageComponentPropValue
|
|
388
|
-
) {
|
|
389
|
-
pageComponentPropValue.propValues[prop.name] =
|
|
390
|
-
this._initProductListPropValue(propValue);
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
static _initProductListPropValue(propValue: IkasProductListParams) {
|
|
276
|
+
static initProductListPropValue(propValue: IkasProductListParams) {
|
|
394
277
|
return new IkasProductList(propValue);
|
|
395
278
|
}
|
|
396
279
|
|
|
397
|
-
static initProductPropValue(
|
|
398
|
-
prop: IkasThemeJsonComponentProp,
|
|
399
|
-
propValue: IkasProductPropValueData,
|
|
400
|
-
pageComponentPropValue: IkasPageComponentPropValue
|
|
401
|
-
) {
|
|
402
|
-
pageComponentPropValue.propValues[prop.name] =
|
|
403
|
-
this._initProductPropValue(propValue);
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
static _initProductPropValue(propValue: IkasProductPropValueData) {
|
|
280
|
+
static initProductPropValue(propValue: IkasProductPropValueData) {
|
|
407
281
|
let product: IkasProduct = new IkasProduct(getPlaceholderProduct() as any);
|
|
408
282
|
|
|
409
283
|
if (propValue.productDetailPropValue.usePageData && this.pageSpecificData) {
|
|
@@ -459,16 +333,7 @@ export class IkasPageDataInit {
|
|
|
459
333
|
}
|
|
460
334
|
}
|
|
461
335
|
|
|
462
|
-
static initAttributePropValue(
|
|
463
|
-
prop: IkasThemeJsonComponentProp,
|
|
464
|
-
propValue: IkasAttributePropValueData,
|
|
465
|
-
pageComponentPropValue: IkasPageComponentPropValue
|
|
466
|
-
) {
|
|
467
|
-
pageComponentPropValue.propValues[prop.name] =
|
|
468
|
-
IkasPageDataInit._initAttributePropValue(propValue);
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
static _initAttributePropValue(propValue: IkasAttributePropValueData) {
|
|
336
|
+
static initAttributePropValue(propValue: IkasAttributePropValueData) {
|
|
472
337
|
let product: IkasProduct | null = null;
|
|
473
338
|
|
|
474
339
|
if (propValue.attributePropValue.usePageData && this.pageSpecificData) {
|
|
@@ -485,18 +350,7 @@ export class IkasPageDataInit {
|
|
|
485
350
|
return new IkasAttributeDetail(product, propValue.attributePropValue);
|
|
486
351
|
}
|
|
487
352
|
|
|
488
|
-
static initAttributeListPropValue(
|
|
489
|
-
prop: IkasThemeJsonComponentProp,
|
|
490
|
-
propValue: IkasAttributeListPropValueData,
|
|
491
|
-
pageComponentPropValue: IkasPageComponentPropValue
|
|
492
|
-
) {
|
|
493
|
-
pageComponentPropValue.propValues[prop.name] =
|
|
494
|
-
IkasPageDataInit._initAttributeListPropValue(propValue);
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
static _initAttributeListPropValue(
|
|
498
|
-
propValue: IkasAttributeListPropValueData
|
|
499
|
-
) {
|
|
353
|
+
static initAttributeListPropValue(propValue: IkasAttributeListPropValueData) {
|
|
500
354
|
let product: IkasProduct | null = null;
|
|
501
355
|
|
|
502
356
|
if (propValue.attributeListPropValue.usePageData && this.pageSpecificData) {
|
|
@@ -514,15 +368,8 @@ export class IkasPageDataInit {
|
|
|
514
368
|
}
|
|
515
369
|
|
|
516
370
|
static initLinkPropValue(
|
|
517
|
-
|
|
518
|
-
propValue: any,
|
|
519
|
-
pageComponentPropValue: IkasPageComponentPropValue
|
|
371
|
+
propValue: IkasNavigationLink | IkasNavigationLink[]
|
|
520
372
|
) {
|
|
521
|
-
pageComponentPropValue.propValues[prop.name] =
|
|
522
|
-
this._initLinkPropValue(propValue);
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
static _initLinkPropValue(propValue: any) {
|
|
526
373
|
if (Array.isArray(propValue)) {
|
|
527
374
|
return (propValue as IkasNavigationLink[]).map(
|
|
528
375
|
(p) =>
|
|
@@ -538,41 +385,21 @@ export class IkasPageDataInit {
|
|
|
538
385
|
propValue.href,
|
|
539
386
|
propValue.label,
|
|
540
387
|
propValue.subLinks,
|
|
541
|
-
propValue.isExternal
|
|
388
|
+
propValue.isExternal || undefined
|
|
542
389
|
);
|
|
543
390
|
}
|
|
544
391
|
}
|
|
545
392
|
|
|
546
|
-
static initImagePropValue(
|
|
547
|
-
prop: IkasThemeJsonComponentProp,
|
|
548
|
-
propValue: any,
|
|
549
|
-
pageComponentPropValue: IkasPageComponentPropValue
|
|
550
|
-
) {
|
|
551
|
-
pageComponentPropValue.propValues[prop.name] =
|
|
552
|
-
this._initImagePropValue(propValue);
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
static _initImagePropValue(propValue: any) {
|
|
393
|
+
static initImagePropValue(propValue: IkasImage) {
|
|
556
394
|
return new IkasImage(propValue);
|
|
557
395
|
}
|
|
558
396
|
|
|
559
|
-
static initImageListPropValue(
|
|
560
|
-
prop: IkasThemeJsonComponentProp,
|
|
561
|
-
propValue: any,
|
|
562
|
-
pageComponentPropValue: IkasPageComponentPropValue
|
|
563
|
-
) {
|
|
564
|
-
pageComponentPropValue.propValues[prop.name] =
|
|
565
|
-
this._initImageListPropValue(propValue);
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
static _initImageListPropValue(propValue: any) {
|
|
397
|
+
static initImageListPropValue(propValue: IkasImage[]) {
|
|
569
398
|
return (propValue as IkasImage[]).map((i) => new IkasImage(i));
|
|
570
399
|
}
|
|
571
400
|
|
|
572
401
|
static initCustomDataPropValue(
|
|
573
|
-
prop: IkasThemeJsonComponentProp,
|
|
574
402
|
customDataValue: IkasCustomDataPropValueData | undefined,
|
|
575
|
-
pageComponentPropValue: IkasPageComponentPropValue,
|
|
576
403
|
settings: IkasThemeJsonSettings,
|
|
577
404
|
isBrowser?: boolean
|
|
578
405
|
) {
|
|
@@ -583,13 +410,12 @@ export class IkasPageDataInit {
|
|
|
583
410
|
)
|
|
584
411
|
return;
|
|
585
412
|
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
);
|
|
413
|
+
return this._initCustomDataPropValue(
|
|
414
|
+
customDataValue,
|
|
415
|
+
new IkasThemeJsonCustomData(customDataValue.customData as any),
|
|
416
|
+
settings,
|
|
417
|
+
isBrowser
|
|
418
|
+
);
|
|
593
419
|
}
|
|
594
420
|
|
|
595
421
|
static _initCustomDataPropValue(
|
|
@@ -605,58 +431,58 @@ export class IkasPageDataInit {
|
|
|
605
431
|
|
|
606
432
|
switch (customData.type) {
|
|
607
433
|
case IkasThemeJsonComponentPropType.BRAND:
|
|
608
|
-
return this.
|
|
434
|
+
return this.initBrandPropValue(propValue);
|
|
609
435
|
|
|
610
436
|
case IkasThemeJsonComponentPropType.BRAND_LIST:
|
|
611
|
-
return this.
|
|
437
|
+
return this.initBrandListPropValue(propValue);
|
|
612
438
|
|
|
613
439
|
case IkasThemeJsonComponentPropType.CATEGORY_LIST:
|
|
614
|
-
return this.
|
|
440
|
+
return this.initCategoryListPropValue(propValue);
|
|
615
441
|
|
|
616
442
|
case IkasThemeJsonComponentPropType.CATEGORY:
|
|
617
|
-
return this.
|
|
443
|
+
return this.initCategoryPropValue(propValue);
|
|
618
444
|
|
|
619
445
|
case IkasThemeJsonComponentPropType.IMAGE_LIST:
|
|
620
|
-
return this.
|
|
446
|
+
return this.initImageListPropValue(propValue);
|
|
621
447
|
|
|
622
448
|
case IkasThemeJsonComponentPropType.IMAGE:
|
|
623
|
-
return this.
|
|
449
|
+
return this.initImagePropValue(propValue);
|
|
624
450
|
|
|
625
451
|
case IkasThemeJsonComponentPropType.LINK:
|
|
626
|
-
return this.
|
|
452
|
+
return this.initLinkPropValue(propValue);
|
|
627
453
|
|
|
628
454
|
case IkasThemeJsonComponentPropType.PRODUCT_DETAIL:
|
|
629
|
-
return this.
|
|
455
|
+
return this.initProductPropValue(propValue);
|
|
630
456
|
|
|
631
457
|
case IkasThemeJsonComponentPropType.PRODUCT_LIST:
|
|
632
|
-
return this.
|
|
458
|
+
return this.initProductListPropValue(propValue);
|
|
633
459
|
|
|
634
460
|
case IkasThemeJsonComponentPropType.PRODUCT_ATTRIBUTE:
|
|
635
|
-
return this.
|
|
461
|
+
return this.initAttributePropValue(propValue);
|
|
636
462
|
|
|
637
463
|
case IkasThemeJsonComponentPropType.PRODUCT_ATTRIBUTE_LIST:
|
|
638
|
-
return this.
|
|
464
|
+
return this.initAttributeListPropValue(propValue);
|
|
639
465
|
|
|
640
466
|
case IkasThemeJsonComponentPropType.BLOG:
|
|
641
|
-
return this.
|
|
467
|
+
return this.initBlogPropValue(propValue);
|
|
642
468
|
|
|
643
469
|
case IkasThemeJsonComponentPropType.BLOG_LIST:
|
|
644
|
-
return this.
|
|
470
|
+
return this.initBlogListPropValue(propValue);
|
|
645
471
|
|
|
646
472
|
case IkasThemeJsonComponentPropType.BLOG_CATEGORY:
|
|
647
|
-
return this.
|
|
473
|
+
return this.initBlogCategoryPropValue(propValue);
|
|
648
474
|
|
|
649
475
|
case IkasThemeJsonComponentPropType.BLOG_CATEGORY_LIST:
|
|
650
|
-
return this.
|
|
476
|
+
return this.initBlogCategoryListPropValue(propValue);
|
|
651
477
|
|
|
652
478
|
case IkasThemeJsonComponentPropType.RAFFLE:
|
|
653
|
-
return this.
|
|
479
|
+
return this.initRafflePropValue(propValue);
|
|
654
480
|
|
|
655
481
|
case IkasThemeJsonComponentPropType.RAFFLE_LIST:
|
|
656
|
-
return this.
|
|
482
|
+
return this.initRaffleListPropValue(propValue);
|
|
657
483
|
|
|
658
484
|
case IkasThemeJsonComponentPropType.SLIDER:
|
|
659
|
-
return this.
|
|
485
|
+
return this.initSliderPropValue(propValue);
|
|
660
486
|
|
|
661
487
|
case IkasThemeJsonComponentPropType.OBJECT:
|
|
662
488
|
const objectValue: Record<string, any> = {};
|
|
@@ -708,10 +534,10 @@ export class IkasPageDataInit {
|
|
|
708
534
|
}
|
|
709
535
|
|
|
710
536
|
case IkasThemeJsonComponentPropType.COMPONENT:
|
|
711
|
-
return this.
|
|
537
|
+
return this.initComponentPropValue(propValue, settings, isBrowser);
|
|
712
538
|
|
|
713
539
|
case IkasThemeJsonComponentPropType.COMPONENT_LIST:
|
|
714
|
-
return this.
|
|
540
|
+
return this.initComponentListPropValue(propValue, settings, isBrowser);
|
|
715
541
|
|
|
716
542
|
default:
|
|
717
543
|
return propValue;
|
|
@@ -719,17 +545,11 @@ export class IkasPageDataInit {
|
|
|
719
545
|
}
|
|
720
546
|
|
|
721
547
|
static initComponentPropValue(
|
|
722
|
-
prop: IkasThemeJsonComponentProp,
|
|
723
548
|
propValue: IkasPageComponentPropValue[],
|
|
724
|
-
pageComponentPropValue: IkasPageComponentPropValue,
|
|
725
549
|
settings: IkasThemeJsonSettings,
|
|
726
550
|
isBrowser?: boolean
|
|
727
551
|
) {
|
|
728
|
-
|
|
729
|
-
propValue,
|
|
730
|
-
settings,
|
|
731
|
-
isBrowser
|
|
732
|
-
);
|
|
552
|
+
return this._initComponentPropValue(propValue, settings, isBrowser);
|
|
733
553
|
}
|
|
734
554
|
|
|
735
555
|
static _initComponentPropValue(
|
|
@@ -741,11 +561,12 @@ export class IkasPageDataInit {
|
|
|
741
561
|
if (!pValue) return;
|
|
742
562
|
|
|
743
563
|
const pageComponentPropValue = new IkasPageComponentPropValue(pValue);
|
|
744
|
-
const initializedPageComponentPropValues =
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
564
|
+
const initializedPageComponentPropValues =
|
|
565
|
+
IkasPageDataInit.initPagePropValues(
|
|
566
|
+
[pageComponentPropValue],
|
|
567
|
+
settings,
|
|
568
|
+
isBrowser
|
|
569
|
+
);
|
|
749
570
|
|
|
750
571
|
if (!initializedPageComponentPropValues.length) return;
|
|
751
572
|
|
|
@@ -755,14 +576,11 @@ export class IkasPageDataInit {
|
|
|
755
576
|
}
|
|
756
577
|
|
|
757
578
|
static initComponentListPropValue(
|
|
758
|
-
prop: IkasThemeJsonComponentProp,
|
|
759
579
|
propValue: IkasPageComponentPropValue[],
|
|
760
|
-
pageComponentPropValue: IkasPageComponentPropValue,
|
|
761
580
|
settings: IkasThemeJsonSettings,
|
|
762
581
|
isBrowser?: boolean
|
|
763
582
|
) {
|
|
764
|
-
|
|
765
|
-
this._initComponentListPropValue(propValue, settings, isBrowser);
|
|
583
|
+
return this._initComponentListPropValue(propValue, settings, isBrowser);
|
|
766
584
|
}
|
|
767
585
|
|
|
768
586
|
static _initComponentListPropValue(
|
|
@@ -774,7 +592,7 @@ export class IkasPageDataInit {
|
|
|
774
592
|
return propValue.map((p: IkasPageComponentPropValue) => {
|
|
775
593
|
const pageComponentPropValue = new IkasPageComponentPropValue(p);
|
|
776
594
|
const initializedPageComponentPropValues =
|
|
777
|
-
IkasPageDataInit.
|
|
595
|
+
IkasPageDataInit.initPagePropValues(
|
|
778
596
|
[pageComponentPropValue],
|
|
779
597
|
settings,
|
|
780
598
|
isBrowser
|
|
@@ -787,16 +605,7 @@ export class IkasPageDataInit {
|
|
|
787
605
|
return [];
|
|
788
606
|
}
|
|
789
607
|
|
|
790
|
-
static initBlogPropValue(
|
|
791
|
-
prop: IkasThemeJsonComponentProp,
|
|
792
|
-
propValue: IkasBlogPropValueData,
|
|
793
|
-
pageComponentPropValue: IkasPageComponentPropValue
|
|
794
|
-
) {
|
|
795
|
-
pageComponentPropValue.propValues[prop.name] =
|
|
796
|
-
IkasPageDataInit._initBlogPropValue(propValue);
|
|
797
|
-
}
|
|
798
|
-
|
|
799
|
-
static _initBlogPropValue(propValue: IkasBlogPropValueData) {
|
|
608
|
+
static initBlogPropValue(propValue: IkasBlogPropValueData) {
|
|
800
609
|
if (propValue.blogPropValue.usePageData && this.pageSpecificData) {
|
|
801
610
|
return this.pageSpecificData;
|
|
802
611
|
}
|
|
@@ -808,29 +617,11 @@ export class IkasPageDataInit {
|
|
|
808
617
|
return getPlaceholderBlog();
|
|
809
618
|
}
|
|
810
619
|
|
|
811
|
-
static initBlogListPropValue(
|
|
812
|
-
prop: IkasThemeJsonComponentProp,
|
|
813
|
-
propValue: any,
|
|
814
|
-
pageComponentPropValue: IkasPageComponentPropValue
|
|
815
|
-
) {
|
|
816
|
-
pageComponentPropValue.propValues[prop.name] =
|
|
817
|
-
this._initBlogListPropValue(propValue);
|
|
818
|
-
}
|
|
819
|
-
|
|
820
|
-
static _initBlogListPropValue(propValue: IkasBlogListParams) {
|
|
620
|
+
static initBlogListPropValue(propValue: IkasBlogListParams) {
|
|
821
621
|
return new IkasBlogList(propValue);
|
|
822
622
|
}
|
|
823
623
|
|
|
824
|
-
static initBlogCategoryPropValue(
|
|
825
|
-
prop: IkasThemeJsonComponentProp,
|
|
826
|
-
propValue: IkasBlogCategoryPropValueData,
|
|
827
|
-
pageComponentPropValue: IkasPageComponentPropValue
|
|
828
|
-
) {
|
|
829
|
-
pageComponentPropValue.propValues[prop.name] =
|
|
830
|
-
IkasPageDataInit._initBlogCategoryPropValue(propValue);
|
|
831
|
-
}
|
|
832
|
-
|
|
833
|
-
static _initBlogCategoryPropValue(propValue: IkasBlogCategoryPropValueData) {
|
|
624
|
+
static initBlogCategoryPropValue(propValue: IkasBlogCategoryPropValueData) {
|
|
834
625
|
if (propValue.blogCategoryPropValue.usePageData && this.pageSpecificData) {
|
|
835
626
|
return this.pageSpecificData;
|
|
836
627
|
}
|
|
@@ -842,29 +633,11 @@ export class IkasPageDataInit {
|
|
|
842
633
|
return getPlaceholderBlogCategory();
|
|
843
634
|
}
|
|
844
635
|
|
|
845
|
-
static initBlogCategoryListPropValue(
|
|
846
|
-
prop: IkasThemeJsonComponentProp,
|
|
847
|
-
propValue: any,
|
|
848
|
-
pageComponentPropValue: IkasPageComponentPropValue
|
|
849
|
-
) {
|
|
850
|
-
pageComponentPropValue.propValues[prop.name] =
|
|
851
|
-
this._initBlogCategoryListPropValue(propValue);
|
|
852
|
-
}
|
|
853
|
-
|
|
854
|
-
static _initBlogCategoryListPropValue(propValue: IkasBlogCategoryListParams) {
|
|
636
|
+
static initBlogCategoryListPropValue(propValue: IkasBlogCategoryListParams) {
|
|
855
637
|
return new IkasBlogCategoryList(propValue);
|
|
856
638
|
}
|
|
857
639
|
|
|
858
|
-
static initRafflePropValue(
|
|
859
|
-
prop: IkasThemeJsonComponentProp,
|
|
860
|
-
propValue: IkasRafflePropValueData,
|
|
861
|
-
pageComponentPropValue: IkasPageComponentPropValue
|
|
862
|
-
) {
|
|
863
|
-
pageComponentPropValue.propValues[prop.name] =
|
|
864
|
-
IkasPageDataInit._initRafflePropValue(propValue);
|
|
865
|
-
}
|
|
866
|
-
|
|
867
|
-
static _initRafflePropValue(propValue: IkasRafflePropValueData) {
|
|
640
|
+
static initRafflePropValue(propValue: IkasRafflePropValueData) {
|
|
868
641
|
if (propValue.rafflePropValue.usePageData && this.pageSpecificData) {
|
|
869
642
|
return this.pageSpecificData;
|
|
870
643
|
}
|
|
@@ -876,29 +649,11 @@ export class IkasPageDataInit {
|
|
|
876
649
|
return new IkasRaffle(getPlaceholderRaffle() as any);
|
|
877
650
|
}
|
|
878
651
|
|
|
879
|
-
static initRaffleListPropValue(
|
|
880
|
-
prop: IkasThemeJsonComponentProp,
|
|
881
|
-
propValue: any,
|
|
882
|
-
pageComponentPropValue: IkasPageComponentPropValue
|
|
883
|
-
) {
|
|
884
|
-
pageComponentPropValue.propValues[prop.name] =
|
|
885
|
-
this._initRaffleListPropValue(propValue);
|
|
886
|
-
}
|
|
887
|
-
|
|
888
|
-
static _initRaffleListPropValue(propValue: IkasRaffleListParams) {
|
|
652
|
+
static initRaffleListPropValue(propValue: IkasRaffleListParams) {
|
|
889
653
|
return new IkasRaffleList(propValue);
|
|
890
654
|
}
|
|
891
655
|
|
|
892
|
-
static initSliderPropValue(
|
|
893
|
-
prop: IkasThemeJsonComponentProp,
|
|
894
|
-
propValue: any,
|
|
895
|
-
pageComponentPropValue: IkasPageComponentPropValue
|
|
896
|
-
) {
|
|
897
|
-
pageComponentPropValue.propValues[prop.name] =
|
|
898
|
-
this._initSliderPropValue(propValue);
|
|
899
|
-
}
|
|
900
|
-
|
|
901
|
-
static _initSliderPropValue(propValue: IkasSliderPropValueData) {
|
|
656
|
+
static initSliderPropValue(propValue: IkasSliderPropValueData) {
|
|
902
657
|
return propValue;
|
|
903
658
|
}
|
|
904
659
|
}
|