@useinsider/guido 3.16.0 → 3.17.0-beta.24a776b
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/README.md +1 -0
- package/dist/@types/config/schemas.js +12 -6
- package/dist/components/Guido.vue.js +6 -6
- package/dist/components/Guido.vue2.js +66 -63
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +18 -0
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +65 -0
- package/dist/composables/useConfig.js +37 -30
- package/dist/composables/useCustomInterfaceAppearance.js +52 -38
- package/dist/composables/useRecommendation.js +51 -42
- package/dist/composables/useStripo.js +30 -29
- package/dist/config/migrator/itemsBlockMigrator.js +1 -1
- package/dist/config/migrator/recommendation/settingsMapper.js +19 -17
- package/dist/config/migrator/recommendationMigrator.js +56 -37
- package/dist/enums/academy.js +2 -1
- package/dist/enums/date.js +4 -3
- package/dist/enums/extensions/recommendationBlock.js +4 -1
- package/dist/enums/recommendation.js +17 -17
- package/dist/extensions/Blocks/Items/enums/productEnums.js +45 -45
- package/dist/extensions/Blocks/Recommendation/block.js +26 -21
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +36 -34
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +96 -95
- package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +37 -26
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +147 -150
- package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +136 -0
- package/dist/extensions/Blocks/Recommendation/services/configService.js +35 -35
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +247 -107
- package/dist/extensions/Blocks/Recommendation/utils/productIds.js +6 -0
- package/dist/extensions/Blocks/common-control.js +22 -19
- package/dist/guido.css +1 -1
- package/dist/services/recommendationApi.js +72 -30
- package/dist/src/@types/config/schemas.d.ts +12 -0
- package/dist/src/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.d.ts +3 -0
- package/dist/src/composables/useConfig.d.ts +3 -0
- package/dist/src/composables/useRecommendation.d.ts +1 -0
- package/dist/src/enums/academy.d.ts +1 -0
- package/dist/src/enums/extensions/recommendationBlock.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +7 -6
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +9 -3
- package/dist/src/extensions/Blocks/Recommendation/controls/main/strategy.d.ts +29 -0
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +204 -10
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +6 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/productIds.d.ts +6 -0
- package/dist/src/extensions/Blocks/common-control.d.ts +4 -1
- package/dist/src/mock/api/recommendation-strategies.d.ts +63 -0
- package/dist/src/services/recommendationApi.d.ts +4 -1
- package/dist/src/stores/config.d.ts +18 -0
- package/dist/src/stores/template.d.ts +14 -0
- package/dist/src/utils/strategyInfoBox.d.ts +18 -0
- package/dist/static/assets/icons/line-change.svg.js +5 -0
- package/dist/static/assets/icons/line-delete.svg.js +5 -0
- package/dist/static/assets/icons/line-plus.svg.js +5 -0
- package/dist/static/styles/components/recommendation-strategy.css.js +172 -0
- package/dist/stores/template.js +13 -8
- package/dist/utils/dateUtil.js +23 -10
- package/dist/utils/strategyInfoBox.js +37 -0
- package/dist/utils/templatePreparation.js +37 -34
- package/package.json +2 -1
|
@@ -1,53 +1,57 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
var C = Object.defineProperty;
|
|
2
|
+
var g = (d, c, t) => c in d ? C(d, c, { enumerable: !0, configurable: !0, writable: !0, value: t }) : d[c] = t;
|
|
3
|
+
var n = (d, c, t) => g(d, typeof c != "symbol" ? c + "" : c, t);
|
|
4
|
+
import { useConfig as p } from "../../../../../composables/useConfig.js";
|
|
5
|
+
import { CommonControl as y } from "../../../common-control.js";
|
|
6
|
+
import { DEFAULT_NODE_CONFIG as a } from "../../constants/defaultConfig.js";
|
|
6
7
|
import { RecommendationConfigService as m } from "../../services/configService.js";
|
|
7
|
-
import { useRecommendationExtensionStore as
|
|
8
|
-
import { AlgorithmControl as
|
|
9
|
-
import { ALGORITHM_CONTROL_ID as
|
|
10
|
-
import { CurrencyControl as
|
|
11
|
-
import { CURRENCY_CONTROL_ID as
|
|
12
|
-
import { FiltersControl as
|
|
13
|
-
import { FILTERS_CONTROL_ID as
|
|
14
|
-
import { LayoutOrientationControl as
|
|
15
|
-
import { LAYOUT_ORIENTATION_CONTROL_ID as
|
|
8
|
+
import { useRecommendationExtensionStore as N } from "../../store/recommendation.js";
|
|
9
|
+
import { AlgorithmControl as _ } from "./algorithm.js";
|
|
10
|
+
import { ALGORITHM_CONTROL_ID as nt } from "./algorithm.js";
|
|
11
|
+
import { CurrencyControl as I } from "./currency.js";
|
|
12
|
+
import { CURRENCY_CONTROL_ID as st } from "./currency.js";
|
|
13
|
+
import { FiltersControl as R } from "./filters.js";
|
|
14
|
+
import { FILTERS_CONTROL_ID as ct } from "./filters.js";
|
|
15
|
+
import { LayoutOrientationControl as T } from "./layoutOrientation.js";
|
|
16
|
+
import { LAYOUT_ORIENTATION_CONTROL_ID as ut } from "./layoutOrientation.js";
|
|
16
17
|
import { LocaleControl as b } from "./locale.js";
|
|
17
|
-
import { LOCALE_CONTROL_ID as
|
|
18
|
-
import { PricePlacementControl as
|
|
19
|
-
import { PRICE_PLACEMENT_CONTROL_ID as
|
|
20
|
-
import { ProductCountControl as
|
|
21
|
-
import { PRODUCT_COUNT_CONTROL_ID as
|
|
22
|
-
import { ProductLayoutControl as
|
|
23
|
-
import { PRODUCT_LAYOUT_CONTROL_ID as
|
|
18
|
+
import { LOCALE_CONTROL_ID as mt } from "./locale.js";
|
|
19
|
+
import { PricePlacementControl as O } from "./pricePlacement.js";
|
|
20
|
+
import { PRICE_PLACEMENT_CONTROL_ID as ft } from "./pricePlacement.js";
|
|
21
|
+
import { ProductCountControl as S } from "./productCount.js";
|
|
22
|
+
import { PRODUCT_COUNT_CONTROL_ID as gt } from "./productCount.js";
|
|
23
|
+
import { ProductLayoutControl as P } from "./productLayout.js";
|
|
24
|
+
import { PRODUCT_LAYOUT_CONTROL_ID as yt } from "./productLayout.js";
|
|
24
25
|
import { ShuffleControl as L } from "./shuffle.js";
|
|
25
|
-
import { SHUFFLE_CONTROL_ID as
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
26
|
+
import { SHUFFLE_CONTROL_ID as _t } from "./shuffle.js";
|
|
27
|
+
import { StrategyControl as k } from "./strategy.js";
|
|
28
|
+
import { STRATEGY_CONTROL_ID as Rt } from "./strategy.js";
|
|
29
|
+
import { setCurrencyAttributes as D, getBlockElement as E, isPartnerManagedBlock as v, updateProductContentInPlace as A, regenerateProductRowsWithStyles as w } from "./utils.js";
|
|
30
|
+
import { adjustProductsToSize as bt, formatProductPrice as Ot, getCardComposition as St, getCurrentLayout as Pt, regenerateMobileProductRows as Lt, updatePricesInPlace as kt, updateSingleProductContent as Dt } from "./utils.js";
|
|
28
31
|
import { useDebounceFn as h } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
29
|
-
const
|
|
30
|
-
class
|
|
32
|
+
const x = "recommendation-id", B = "ui-elements-recommendation-block";
|
|
33
|
+
class et extends y {
|
|
31
34
|
constructor() {
|
|
32
35
|
super(...arguments);
|
|
33
|
-
|
|
34
|
-
|
|
36
|
+
n(this, "store", N());
|
|
37
|
+
n(this, "storeUnsubscription", () => {
|
|
35
38
|
});
|
|
36
|
-
|
|
39
|
+
n(this, "syncedBlockIds", /* @__PURE__ */ new Set());
|
|
37
40
|
// Sub-control instances for lifecycle management
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
n(this, "algorithmControl", null);
|
|
42
|
+
n(this, "localeControl", null);
|
|
43
|
+
n(this, "currencyControl", null);
|
|
44
|
+
n(this, "productCountControl", null);
|
|
45
|
+
n(this, "productLayoutControl", null);
|
|
46
|
+
n(this, "filtersControl", null);
|
|
47
|
+
n(this, "shuffleControl", null);
|
|
48
|
+
n(this, "pricePlacementControl", null);
|
|
49
|
+
n(this, "layoutOrientationControl", null);
|
|
50
|
+
n(this, "strategyControl", null);
|
|
47
51
|
/**
|
|
48
52
|
* Debounced product fetch to prevent rapid API calls during config changes
|
|
49
53
|
*/
|
|
50
|
-
|
|
54
|
+
n(this, "_debouncedFetchProducts", h(() => {
|
|
51
55
|
this.store.fetchRecommendationProducts();
|
|
52
56
|
}, 500));
|
|
53
57
|
/**
|
|
@@ -61,16 +65,16 @@ class Q extends g {
|
|
|
61
65
|
* count. The store pads products to the configured size, so in-place only
|
|
62
66
|
* fails when the size actually changed.
|
|
63
67
|
*/
|
|
64
|
-
|
|
68
|
+
n(this, "_debouncedRegenerateWithProducts", h(() => {
|
|
65
69
|
const t = this.store.recommendationProducts;
|
|
66
|
-
if (!this.currentNode || !this.api ||
|
|
70
|
+
if (!this.currentNode || !this.api || v(this.currentNode))
|
|
67
71
|
return;
|
|
68
72
|
const e = this.api.getDocumentModifier();
|
|
69
|
-
|
|
73
|
+
A({
|
|
70
74
|
currentNode: this.currentNode,
|
|
71
75
|
documentModifier: e,
|
|
72
76
|
products: t
|
|
73
|
-
}) ||
|
|
77
|
+
}) || w({
|
|
74
78
|
currentNode: this.currentNode,
|
|
75
79
|
documentModifier: e,
|
|
76
80
|
products: t
|
|
@@ -78,22 +82,40 @@ class Q extends g {
|
|
|
78
82
|
}, 100));
|
|
79
83
|
}
|
|
80
84
|
getId() {
|
|
81
|
-
return
|
|
85
|
+
return B;
|
|
82
86
|
}
|
|
83
|
-
|
|
84
|
-
|
|
87
|
+
/** Every sub-control the coordinator owns, in panel order. */
|
|
88
|
+
get _subControls() {
|
|
89
|
+
return [
|
|
90
|
+
this.layoutOrientationControl,
|
|
91
|
+
this.productCountControl,
|
|
85
92
|
this.algorithmControl,
|
|
86
93
|
this.localeControl,
|
|
87
94
|
this.currencyControl,
|
|
88
|
-
this.productCountControl,
|
|
89
95
|
this.productLayoutControl,
|
|
90
96
|
this.filtersControl,
|
|
91
97
|
this.shuffleControl,
|
|
92
98
|
this.pricePlacementControl,
|
|
93
|
-
this.
|
|
94
|
-
]
|
|
95
|
-
|
|
96
|
-
|
|
99
|
+
this.strategyControl
|
|
100
|
+
];
|
|
101
|
+
}
|
|
102
|
+
getTemplate() {
|
|
103
|
+
const t = p().isRrsSessionActive();
|
|
104
|
+
return this._subControls.forEach((e) => {
|
|
105
|
+
var o;
|
|
106
|
+
return (o = e == null ? void 0 : e.onDestroy) == null ? void 0 : o.call(e);
|
|
107
|
+
}), this.algorithmControl = t ? null : new _(), this.localeControl = new b(), this.currencyControl = new I(), this.productCountControl = t ? null : new S(), this.productLayoutControl = new P(), this.filtersControl = t ? null : new R(), this.shuffleControl = t ? null : new L(), this.pricePlacementControl = new O(), this.layoutOrientationControl = new T(), this.strategyControl = t ? new k() : null, this._subControls.forEach((e) => {
|
|
108
|
+
e && (e.api = this.api);
|
|
109
|
+
}), t ? `
|
|
110
|
+
<div class="recommendation-controls-container">
|
|
111
|
+
${this.strategyControl.getTemplate()}
|
|
112
|
+
${this.layoutOrientationControl.getTemplate()}
|
|
113
|
+
${this.localeControl.getTemplate()}
|
|
114
|
+
${this.currencyControl.getTemplate()}
|
|
115
|
+
${this.pricePlacementControl.getTemplate()}
|
|
116
|
+
${this.productLayoutControl.getTemplate()}
|
|
117
|
+
</div>
|
|
118
|
+
` : `
|
|
97
119
|
<div class="recommendation-controls-container">
|
|
98
120
|
${this.layoutOrientationControl.getTemplate()}
|
|
99
121
|
${this.productCountControl.getTemplate()}
|
|
@@ -117,40 +139,20 @@ class Q extends g {
|
|
|
117
139
|
await this._fetchBlockData(e), this._initializeSubControls();
|
|
118
140
|
}
|
|
119
141
|
onTemplateNodeUpdated(t) {
|
|
120
|
-
var
|
|
142
|
+
var o;
|
|
121
143
|
super.onTemplateNodeUpdated(t);
|
|
122
144
|
const e = this._getRecommendationIdFromNode(t);
|
|
123
|
-
e !== null && e !== this.store.currentRecommendationId && this.store.setCurrentBlock(e), e !== null && !this.syncedBlockIds.has(e) && (this.syncedBlockIds.add(e), this._syncNodeConfigToStore()), e !== null && !((
|
|
145
|
+
e !== null && e !== this.store.currentRecommendationId && this.store.setCurrentBlock(e), e !== null && !this.syncedBlockIds.has(e) && (this.syncedBlockIds.add(e), this._syncNodeConfigToStore()), e !== null && !((o = this.store.blockStates[e]) != null && o.isInitialized) && this._fetchBlockData(e).then(() => {
|
|
124
146
|
this._initializeSubControls();
|
|
125
|
-
}),
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
this.algorithmControl,
|
|
129
|
-
this.localeControl,
|
|
130
|
-
this.currencyControl,
|
|
131
|
-
this.productLayoutControl,
|
|
132
|
-
this.filtersControl,
|
|
133
|
-
this.shuffleControl,
|
|
134
|
-
this.pricePlacementControl
|
|
135
|
-
].forEach((n) => {
|
|
136
|
-
var i;
|
|
137
|
-
n != null && n.api && (n.currentNode = t, (i = n.onTemplateNodeUpdated) == null || i.call(n, t));
|
|
147
|
+
}), this._subControls.forEach((r) => {
|
|
148
|
+
var s;
|
|
149
|
+
r != null && r.api && (r.currentNode = t, (s = r.onTemplateNodeUpdated) == null || s.call(r, t));
|
|
138
150
|
});
|
|
139
151
|
}
|
|
140
152
|
onDestroy() {
|
|
141
|
-
this.storeUnsubscription(),
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
this.algorithmControl,
|
|
145
|
-
this.localeControl,
|
|
146
|
-
this.currencyControl,
|
|
147
|
-
this.productLayoutControl,
|
|
148
|
-
this.filtersControl,
|
|
149
|
-
this.shuffleControl,
|
|
150
|
-
this.pricePlacementControl
|
|
151
|
-
].forEach((e) => {
|
|
152
|
-
var o;
|
|
153
|
-
return (o = e == null ? void 0 : e.onDestroy) == null ? void 0 : o.call(e);
|
|
153
|
+
this.storeUnsubscription(), this._subControls.forEach((t) => {
|
|
154
|
+
var e;
|
|
155
|
+
return (e = t == null ? void 0 : t.onDestroy) == null ? void 0 : e.call(t);
|
|
154
156
|
});
|
|
155
157
|
}
|
|
156
158
|
/**
|
|
@@ -158,19 +160,9 @@ class Q extends g {
|
|
|
158
160
|
* Each sub-control manages its own form values and event listeners
|
|
159
161
|
*/
|
|
160
162
|
_initializeSubControls() {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
this.
|
|
164
|
-
this.algorithmControl,
|
|
165
|
-
this.localeControl,
|
|
166
|
-
this.currencyControl,
|
|
167
|
-
this.productLayoutControl,
|
|
168
|
-
this.filtersControl,
|
|
169
|
-
this.shuffleControl,
|
|
170
|
-
this.pricePlacementControl
|
|
171
|
-
].forEach((e) => {
|
|
172
|
-
var o;
|
|
173
|
-
e && (e.api = this.api, e.currentNode = this.currentNode, (o = e.onRender) == null || o.call(e));
|
|
163
|
+
this._subControls.forEach((t) => {
|
|
164
|
+
var e;
|
|
165
|
+
t && (t.api = this.api, t.currentNode = this.currentNode, (e = t.onRender) == null || e.call(t));
|
|
174
166
|
});
|
|
175
167
|
}
|
|
176
168
|
/**
|
|
@@ -189,6 +181,7 @@ class Q extends g {
|
|
|
189
181
|
const t = m.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((r = this.store.blockStates[e]) == null ? void 0 : r.isInitialized);
|
|
190
182
|
this.store.patchCurrentBlockConfig({
|
|
191
183
|
strategy: t.strategy,
|
|
184
|
+
strategyId: t.strategyId,
|
|
192
185
|
language: t.language,
|
|
193
186
|
size: t.size,
|
|
194
187
|
productIds: t.productIds,
|
|
@@ -250,35 +243,35 @@ class Q extends g {
|
|
|
250
243
|
if (!this.currentNode || !this.api)
|
|
251
244
|
return;
|
|
252
245
|
const t = m.getConfig(this.currentNode), e = {};
|
|
253
|
-
let o = null, r = null,
|
|
254
|
-
if (t.currency.code ===
|
|
246
|
+
let o = null, r = null, s = null;
|
|
247
|
+
if (t.currency.code === a.currency.code) {
|
|
255
248
|
const { currencyList: i } = this.store;
|
|
256
249
|
i.length > 0 && (i.some(
|
|
257
|
-
(u) => u.value === `price.${
|
|
250
|
+
(u) => u.value === `price.${a.currency.code}`
|
|
258
251
|
) || (o = i[0].value.replace("price.", ""), e.currency = {
|
|
259
|
-
...
|
|
252
|
+
...a.currency,
|
|
260
253
|
code: o,
|
|
261
254
|
symbol: o
|
|
262
255
|
}));
|
|
263
256
|
}
|
|
264
|
-
if (t.strategy ===
|
|
257
|
+
if (t.strategy === a.strategy) {
|
|
265
258
|
const i = this.store.getActivePredictiveAlgorithms;
|
|
266
259
|
i.length > 0 && (i.some(
|
|
267
|
-
(u) => u.value ===
|
|
260
|
+
(u) => u.value === a.strategy
|
|
268
261
|
) || (r = i[0].value, e.strategy = r));
|
|
269
262
|
}
|
|
270
|
-
if (t.language ===
|
|
263
|
+
if (t.language === a.language) {
|
|
271
264
|
const i = this.store.getLanguages;
|
|
272
265
|
i.length > 0 && (i.some(
|
|
273
|
-
(u) => u.value ===
|
|
274
|
-
) || (
|
|
266
|
+
(u) => u.value === a.language
|
|
267
|
+
) || (s = i[0].value, e.language = s));
|
|
275
268
|
}
|
|
276
|
-
!o && !r && !
|
|
269
|
+
!o && !r && !s || (m.updateConfig(
|
|
277
270
|
this.api,
|
|
278
271
|
this.currentNode,
|
|
279
272
|
e,
|
|
280
273
|
"Applied smart defaults"
|
|
281
|
-
), o && e.currency &&
|
|
274
|
+
), o && e.currency && D({
|
|
282
275
|
currentNode: this.currentNode,
|
|
283
276
|
documentModifier: this.api.getDocumentModifier(),
|
|
284
277
|
currency: e.currency
|
|
@@ -288,24 +281,24 @@ class Q extends g {
|
|
|
288
281
|
name: o,
|
|
289
282
|
value: o,
|
|
290
283
|
symbol: o,
|
|
291
|
-
alignment:
|
|
292
|
-
decimalCount:
|
|
293
|
-
decimalSeparator:
|
|
294
|
-
thousandSeparator:
|
|
284
|
+
alignment: a.currency.alignment === "before" ? "0" : "1",
|
|
285
|
+
decimalCount: a.currency.decimalCount.toString(),
|
|
286
|
+
decimalSeparator: a.currency.decimalSeparator,
|
|
287
|
+
thousandSeparator: a.currency.thousandSeparator
|
|
295
288
|
}
|
|
296
289
|
} : {},
|
|
297
290
|
...r ? { strategy: r } : {},
|
|
298
|
-
...
|
|
291
|
+
...s ? { language: s } : {}
|
|
299
292
|
}, { triggerRefetch: !1 }));
|
|
300
293
|
}
|
|
301
294
|
/**
|
|
302
295
|
* Reads the recommendation-id attribute from the block element within the node
|
|
303
296
|
*/
|
|
304
297
|
_getRecommendationIdFromNode(t) {
|
|
305
|
-
const e =
|
|
298
|
+
const e = E(t);
|
|
306
299
|
if (!e || !("getAttribute" in e))
|
|
307
300
|
return null;
|
|
308
|
-
const o = e.getAttribute(
|
|
301
|
+
const o = e.getAttribute(x);
|
|
309
302
|
if (!o)
|
|
310
303
|
return null;
|
|
311
304
|
const r = parseInt(o);
|
|
@@ -328,64 +321,68 @@ class Q extends g {
|
|
|
328
321
|
const { store: t } = this;
|
|
329
322
|
let e = t.recommendationProducts, o = t.$state.configVersion, r = t.currentRecommendationId;
|
|
330
323
|
this.storeUnsubscription = t.$subscribe(() => {
|
|
331
|
-
const
|
|
332
|
-
if (
|
|
333
|
-
r =
|
|
324
|
+
const s = t.currentRecommendationId;
|
|
325
|
+
if (s !== r) {
|
|
326
|
+
r = s, e = t.recommendationProducts, o = t.$state.configVersion;
|
|
334
327
|
return;
|
|
335
328
|
}
|
|
336
329
|
const i = t.$state.configVersion;
|
|
337
330
|
i !== o && (o = i, this._persistFiltersToNodeConfig(), this._debouncedFetchProducts());
|
|
338
|
-
const
|
|
339
|
-
u &&
|
|
331
|
+
const l = t.recommendationProducts, u = l !== e, f = Array.isArray(l) && l.length > 0;
|
|
332
|
+
u && f && (e = l, this._debouncedRegenerateWithProducts());
|
|
340
333
|
});
|
|
341
334
|
}
|
|
342
335
|
/**
|
|
343
|
-
* Persists
|
|
344
|
-
*
|
|
336
|
+
* Persists filter + strategy state to the Stripo node config so it survives
|
|
337
|
+
* save/reload (strategyId must reach esd-ext-config before any save).
|
|
338
|
+
* `size` rides along: assigning a strategy writes it to the store only, and a
|
|
339
|
+
* stale node config would rebuild the block against the old slot count.
|
|
345
340
|
*/
|
|
346
341
|
_persistFiltersToNodeConfig() {
|
|
347
342
|
if (!this.currentNode || !this.api)
|
|
348
343
|
return;
|
|
349
|
-
const { filters: t } = this.store.recommendationConfigs;
|
|
350
|
-
m.updateConfig(
|
|
344
|
+
const { filters: t, strategyId: e, size: o } = this.store.recommendationConfigs, r = m.getConfig(this.currentNode);
|
|
345
|
+
JSON.stringify(r.filters) === JSON.stringify(t) && r.strategyId === e && r.size === o || m.updateConfig(
|
|
351
346
|
this.api,
|
|
352
347
|
this.currentNode,
|
|
353
|
-
{ filters: t },
|
|
348
|
+
{ filters: t, strategyId: e, size: o },
|
|
354
349
|
"Update recommendation filters"
|
|
355
350
|
);
|
|
356
351
|
}
|
|
357
352
|
}
|
|
358
353
|
export {
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
354
|
+
nt as ALGORITHM_CONTROL_ID,
|
|
355
|
+
_ as AlgorithmControl,
|
|
356
|
+
B as CONTROL_BLOCK_ID,
|
|
357
|
+
st as CURRENCY_CONTROL_ID,
|
|
358
|
+
I as CurrencyControl,
|
|
359
|
+
ct as FILTERS_CONTROL_ID,
|
|
360
|
+
R as FiltersControl,
|
|
361
|
+
ut as LAYOUT_ORIENTATION_CONTROL_ID,
|
|
362
|
+
mt as LOCALE_CONTROL_ID,
|
|
363
|
+
T as LayoutOrientationControl,
|
|
369
364
|
b as LocaleControl,
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
365
|
+
ft as PRICE_PLACEMENT_CONTROL_ID,
|
|
366
|
+
gt as PRODUCT_COUNT_CONTROL_ID,
|
|
367
|
+
yt as PRODUCT_LAYOUT_CONTROL_ID,
|
|
368
|
+
O as PricePlacementControl,
|
|
369
|
+
S as ProductCountControl,
|
|
370
|
+
P as ProductLayoutControl,
|
|
371
|
+
et as RecommendationBlockControl,
|
|
372
|
+
_t as SHUFFLE_CONTROL_ID,
|
|
373
|
+
Rt as STRATEGY_CONTROL_ID,
|
|
378
374
|
L as ShuffleControl,
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
375
|
+
k as StrategyControl,
|
|
376
|
+
bt as adjustProductsToSize,
|
|
377
|
+
Ot as formatProductPrice,
|
|
378
|
+
E as getBlockElement,
|
|
379
|
+
St as getCardComposition,
|
|
380
|
+
Pt as getCurrentLayout,
|
|
381
|
+
v as isPartnerManagedBlock,
|
|
382
|
+
Lt as regenerateMobileProductRows,
|
|
383
|
+
w as regenerateProductRowsWithStyles,
|
|
384
|
+
D as setCurrencyAttributes,
|
|
385
|
+
kt as updatePricesInPlace,
|
|
386
|
+
A as updateProductContentInPlace,
|
|
387
|
+
Dt as updateSingleProductContent
|
|
391
388
|
};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
var g = Object.defineProperty;
|
|
2
|
+
var d = (n, s, t) => s in n ? g(n, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[s] = t;
|
|
3
|
+
var i = (n, s, t) => d(n, typeof s != "symbol" ? s + "" : s, t);
|
|
4
|
+
import { ACADEMY_LINKS as l } from "../../../../../enums/academy.js";
|
|
5
|
+
import { CommonControl as y } from "../../../common-control.js";
|
|
6
|
+
import { useRecommendationExtensionStore as m } from "../../store/recommendation.js";
|
|
7
|
+
const h = "recommendation-strategy-control";
|
|
8
|
+
class v extends y {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
i(this, "store", m());
|
|
12
|
+
i(this, "storeUnsubscription", () => {
|
|
13
|
+
});
|
|
14
|
+
i(this, "listeners", []);
|
|
15
|
+
}
|
|
16
|
+
getId() {
|
|
17
|
+
return h;
|
|
18
|
+
}
|
|
19
|
+
getTemplate() {
|
|
20
|
+
const t = this.api.translate(
|
|
21
|
+
"You can assign a recommendation strategy by selecting an existing one or creating a new one to show specific content."
|
|
22
|
+
), e = this.api.translate("For more information, you can"), a = this.api.translate("visit Academy");
|
|
23
|
+
return `
|
|
24
|
+
<div class="strategy-control-container">
|
|
25
|
+
<div class="strategy-control-header">
|
|
26
|
+
<h3 class="strategy-control-title">${this.api.translate("Recommendation Strategy")}</h3>
|
|
27
|
+
</div>
|
|
28
|
+
<div class="strategy-control-description-row">
|
|
29
|
+
<p class="strategy-control-description">
|
|
30
|
+
${t}
|
|
31
|
+
${e}
|
|
32
|
+
<a
|
|
33
|
+
href="${l.EMAIL_RECOMMENDATION_BLOCK}"
|
|
34
|
+
target="_blank"
|
|
35
|
+
rel="noopener noreferrer">${a}</a>.
|
|
36
|
+
</p>
|
|
37
|
+
</div>
|
|
38
|
+
<div data-strategy-empty-state>
|
|
39
|
+
${this._GuTwoColumns([
|
|
40
|
+
this._GuButton({
|
|
41
|
+
name: "assignStrategy",
|
|
42
|
+
label: this.api.translate("Assign Strategy"),
|
|
43
|
+
id: "guido__btn-assign-strategy",
|
|
44
|
+
className: "strategy-control-cta accent"
|
|
45
|
+
}),
|
|
46
|
+
// Create round-trip ships with SD-149916; until then the CTA
|
|
47
|
+
// stays inert at full contrast, as the design draws it.
|
|
48
|
+
this._GuButton({
|
|
49
|
+
name: "createStrategy",
|
|
50
|
+
label: this.api.translate("Create New Strategy"),
|
|
51
|
+
id: "guido__btn-create-strategy",
|
|
52
|
+
className: "strategy-control-cta primary",
|
|
53
|
+
disabled: !0
|
|
54
|
+
})
|
|
55
|
+
], "strategy-control-cta-row")}
|
|
56
|
+
</div>
|
|
57
|
+
<div data-strategy-assigned-state style="display: none;">
|
|
58
|
+
<div class="strategy-control-name-band">
|
|
59
|
+
<span class="strategy-control-name" data-strategy-name></span>
|
|
60
|
+
</div>
|
|
61
|
+
<div class="strategy-control-actions">
|
|
62
|
+
${this._strategyAction({
|
|
63
|
+
id: "guido__btn-change-strategy",
|
|
64
|
+
label: this.api.translate("Change"),
|
|
65
|
+
modifier: "change"
|
|
66
|
+
})}
|
|
67
|
+
${this._strategyAction({
|
|
68
|
+
id: "guido__btn-remove-strategy",
|
|
69
|
+
label: this.api.translate("Remove"),
|
|
70
|
+
modifier: "remove"
|
|
71
|
+
})}
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
`;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Change / Remove are icon+text actions in the design, not buttons — and
|
|
79
|
+
* `ue-button` cannot pair a caption with an arbitrary icon, so these are
|
|
80
|
+
* plain elements. Click wiring is by id, which works on any element.
|
|
81
|
+
*
|
|
82
|
+
* The icon is a CSS mask, not inline SVG: Stripo re-creates the control's
|
|
83
|
+
* markup through Angular, which rebuilds `<svg>` outside the SVG namespace
|
|
84
|
+
* (the view-box attribute comes back lowercased) and it never paints.
|
|
85
|
+
*/
|
|
86
|
+
_strategyAction({ id: t, label: e, modifier: a }) {
|
|
87
|
+
return `
|
|
88
|
+
<button
|
|
89
|
+
id="${t}"
|
|
90
|
+
type="button"
|
|
91
|
+
class="strategy-control-action strategy-control-action--${a}">
|
|
92
|
+
<span>${e}</span>
|
|
93
|
+
</button>
|
|
94
|
+
`;
|
|
95
|
+
}
|
|
96
|
+
onRender() {
|
|
97
|
+
this._teardown(), this._setupButtonListeners(), this._renderState(), this.storeUnsubscription = this.store.$subscribe(() => {
|
|
98
|
+
this._renderState();
|
|
99
|
+
}), this.store.recommendationConfigs.strategyId && !this.store.strategies.length && this.store.fetchStrategies().catch(() => {
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
onDestroy() {
|
|
103
|
+
this._teardown();
|
|
104
|
+
}
|
|
105
|
+
_teardown() {
|
|
106
|
+
this.storeUnsubscription(), this.storeUnsubscription = () => {
|
|
107
|
+
}, this.listeners.forEach(({ element: t, handler: e }) => t.removeEventListener("click", e)), this.listeners = [];
|
|
108
|
+
}
|
|
109
|
+
_setupButtonListeners() {
|
|
110
|
+
const t = this.getContainer();
|
|
111
|
+
if (!t)
|
|
112
|
+
return;
|
|
113
|
+
const e = (a, o) => {
|
|
114
|
+
const r = t.querySelector(a);
|
|
115
|
+
r && (r.addEventListener("click", o), this.listeners.push({ element: r, handler: o }));
|
|
116
|
+
};
|
|
117
|
+
e("#guido__btn-assign-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-change-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-remove-strategy", () => this.store.removeStrategy());
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Toggles empty vs assigned state from the store's current block config.
|
|
121
|
+
* Display name comes from the listing; falls back to the raw id while the
|
|
122
|
+
* listing loads (or when the strategy is no longer listed).
|
|
123
|
+
*/
|
|
124
|
+
_renderState() {
|
|
125
|
+
var c;
|
|
126
|
+
const t = this.getContainer();
|
|
127
|
+
if (!t)
|
|
128
|
+
return;
|
|
129
|
+
const e = t.querySelector("[data-strategy-empty-state]"), a = t.querySelector("[data-strategy-assigned-state]"), o = t.querySelector("[data-strategy-name]"), { strategyId: r } = this.store.recommendationConfigs;
|
|
130
|
+
!e || !a || (e.style.display = r ? "none" : "", a.style.display = r ? "" : "none", o && r && (o.textContent = ((c = this.store.assignedStrategy) == null ? void 0 : c.name) ?? `#${r}`));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
export {
|
|
134
|
+
h as STRATEGY_CONTROL_ID,
|
|
135
|
+
v as StrategyControl
|
|
136
|
+
};
|