@useinsider/guido 3.18.1-beta.2b89365 → 3.18.1-beta.3826f39
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/dist/components/Guido.vue.js +3 -3
- package/dist/components/Guido.vue2.js +30 -30
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +13 -11
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +65 -53
- package/dist/components/organisms/onboarding/OnboardingWrapper.vue2.js +20 -18
- package/dist/components/organisms/onboarding/RecommendationStrategyOnboarding.vue.js +21 -0
- package/dist/components/organisms/onboarding/RecommendationStrategyOnboarding.vue2.js +47 -0
- package/dist/composables/useCustomInterfaceAppearance.js +46 -41
- package/dist/composables/useGuidoStateBridge.js +24 -29
- package/dist/composables/useHtmlValidator.js +84 -79
- package/dist/composables/useRecommendation.js +21 -18
- package/dist/composables/useStripo.js +12 -12
- package/dist/enums/extensions/recommendationBlock.js +38 -31
- package/dist/extensions/Blocks/Recommendation/block.js +43 -39
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +8 -8
- package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +80 -52
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +150 -73
- package/dist/extensions/Blocks/Recommendation/validation/requiredFields.js +21 -12
- package/dist/guido.css +1 -1
- package/dist/library.js +13 -15
- package/dist/src/components/organisms/onboarding/RecommendationStrategyOnboarding.vue.d.ts +2 -0
- package/dist/src/composables/useGuidoStateBridge.d.ts +7 -11
- package/dist/src/enums/extensions/recommendationBlock.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/strategy.d.ts +9 -0
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +61 -0
- package/dist/src/extensions/Blocks/Recommendation/validation/requiredFields.d.ts +4 -0
- package/dist/src/library.d.ts +0 -2
- package/dist/src/public/trackingIds.d.ts +2 -6
- package/dist/src/stores/editor.d.ts +0 -25
- package/dist/src/stores/guido-email-editor.d.ts +27 -27
- package/dist/src/stores/onboarding.d.ts +377 -0
- package/dist/static/styles/components/recommendation-strategy.css.js +51 -4
- package/dist/stores/editor.js +0 -4
- package/dist/stores/guido-email-editor.js +4 -0
- package/dist/stores/onboarding.js +41 -36
- package/dist/utils/templatePreparation.js +50 -50
- package/package.json +1 -5
- package/dist/public/editorState.js +0 -4
- package/dist/src/public/editorState.d.ts +0 -14
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { useConfig as
|
|
5
|
-
import { BlockId as
|
|
6
|
-
import { getMigrationBannerHtml as
|
|
7
|
-
import { Block as
|
|
8
|
-
import { CURRENT_CONFIG_VERSION as
|
|
1
|
+
var D = Object.defineProperty;
|
|
2
|
+
var y = (l, c, t) => c in l ? D(l, c, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[c] = t;
|
|
3
|
+
var f = (l, c, t) => y(l, typeof c != "symbol" ? c + "" : c, t);
|
|
4
|
+
import { useConfig as C } from "../../../composables/useConfig.js";
|
|
5
|
+
import { BlockId as b } from "../../../enums/block.js";
|
|
6
|
+
import { getMigrationBannerHtml as A } from "../../../utils/migrationBannerHtml.js";
|
|
7
|
+
import { Block as E, BlockCompositionType as S, ModificationDescription as g } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
8
|
+
import { CURRENT_CONFIG_VERSION as N, PRE_RRS_CONFIG_VERSION as O } from "./constants/defaultConfig.js";
|
|
9
9
|
import { RECOMMENDATION_ID_ATTR as m } from "./constants/selectors.js";
|
|
10
|
-
import { regenerateMobileProductRows as
|
|
11
|
-
import { ensureMobileCssRulesExist as
|
|
10
|
+
import { regenerateMobileProductRows as M } from "./controls/main/utils.js";
|
|
11
|
+
import { ensureMobileCssRulesExist as _, setMobileLayoutOptOut as I, hasMobileLayoutOptOut as w } from "./controls/mobileLayout/cssRules.js";
|
|
12
12
|
import { RecommendationConfigService as s } from "./services/configService.js";
|
|
13
13
|
import { useRecommendationExtensionStore as d } from "./store/recommendation.js";
|
|
14
|
-
import { getDefaultTemplate as
|
|
15
|
-
import { useRecommendationBlockWarning as
|
|
16
|
-
const
|
|
17
|
-
let
|
|
18
|
-
class
|
|
14
|
+
import { getDefaultTemplate as x } from "./templates/grid/template.js";
|
|
15
|
+
import { useRecommendationBlockWarning as H } from "./useRecommendationBlockWarning.js";
|
|
16
|
+
const k = b.Recommendation, u = "recommendation-block-v2", R = "hide-price";
|
|
17
|
+
let B = !1;
|
|
18
|
+
class j extends E {
|
|
19
19
|
constructor() {
|
|
20
20
|
super();
|
|
21
21
|
/**
|
|
22
22
|
* Stores the ID generated in getTemplate() so onCreated() can reuse it.
|
|
23
23
|
* This avoids generating a new (different) ID in onCreated().
|
|
24
24
|
*/
|
|
25
|
-
|
|
25
|
+
f(this, "_pendingBlockId", null);
|
|
26
26
|
}
|
|
27
27
|
getId() {
|
|
28
|
-
return
|
|
28
|
+
return k;
|
|
29
29
|
}
|
|
30
30
|
getIcon() {
|
|
31
31
|
return "recommendation-icon";
|
|
32
32
|
}
|
|
33
33
|
getBlockCompositionType() {
|
|
34
|
-
return
|
|
34
|
+
return S.CONTAINER;
|
|
35
35
|
}
|
|
36
36
|
getName() {
|
|
37
37
|
return this.api.translate("Recommendation Block");
|
|
@@ -42,8 +42,8 @@ class W extends b {
|
|
|
42
42
|
);
|
|
43
43
|
}
|
|
44
44
|
getSettingsPanelTitleHtml() {
|
|
45
|
-
return
|
|
46
|
-
|
|
45
|
+
return A(
|
|
46
|
+
k,
|
|
47
47
|
this.api.translate("Recommendation Block"),
|
|
48
48
|
this.api.translate("This block is switched from the Old Version to the New Version. We recommend you check the Recommendation block and test your message to ensure it works properly.")
|
|
49
49
|
);
|
|
@@ -66,7 +66,7 @@ class W extends b {
|
|
|
66
66
|
*/
|
|
67
67
|
getTemplate() {
|
|
68
68
|
const t = this._generateNextId();
|
|
69
|
-
return this._pendingBlockId = t,
|
|
69
|
+
return this._pendingBlockId = t, x(t);
|
|
70
70
|
}
|
|
71
71
|
/**
|
|
72
72
|
* Called when a new block is dropped into the template
|
|
@@ -89,23 +89,27 @@ class W extends b {
|
|
|
89
89
|
}
|
|
90
90
|
const i = this._pendingBlockId ?? this._generateNextId();
|
|
91
91
|
this._pendingBlockId = null, this._assignRecommendationId(t, i);
|
|
92
|
-
const { config:
|
|
92
|
+
const n = C().isFeatureEnabled("reusableRecommendationStrategy"), o = n && !s.hasConfig(t), { config: r, wasFreshDrop: a } = s.initializeConfig(
|
|
93
93
|
this.api,
|
|
94
94
|
t,
|
|
95
95
|
{
|
|
96
96
|
recommendationId: i,
|
|
97
|
-
configVersion:
|
|
97
|
+
configVersion: n ? N : O,
|
|
98
|
+
// An RRS block picks a strategy, not an algorithm, and its algorithm control is
|
|
99
|
+
// hidden. Keeping the `mostPopular` default would bake a most-popular feed URL
|
|
100
|
+
// at save for a block the user never configured.
|
|
101
|
+
...o ? { strategy: "" } : {}
|
|
98
102
|
}
|
|
99
|
-
),
|
|
100
|
-
if (
|
|
101
|
-
|
|
102
|
-
const
|
|
103
|
-
|
|
103
|
+
), p = d();
|
|
104
|
+
if (p.setCurrentBlock(i), this._stampHidePrice(t, r.priceHideIfSameAsDiscounted), a) {
|
|
105
|
+
_(this.api);
|
|
106
|
+
const h = this._getBlockElement(t);
|
|
107
|
+
h && (I(this.api, h, !0), M({
|
|
104
108
|
currentNode: t,
|
|
105
109
|
documentModifier: this.api.getDocumentModifier()
|
|
106
110
|
}));
|
|
107
111
|
}
|
|
108
|
-
|
|
112
|
+
p.patchCurrentBlockConfig({ language: r.language }, { triggerRefetch: !1 }), this._warnIfMultipleBlocks();
|
|
109
113
|
}
|
|
110
114
|
/**
|
|
111
115
|
* Called when the document changes or template is loaded
|
|
@@ -127,11 +131,11 @@ class W extends b {
|
|
|
127
131
|
}
|
|
128
132
|
this._healLingeringDuplicate(t), s.needsMigration(t) && this._migrateFromLegacy(t), this._healHidePriceAttr(t);
|
|
129
133
|
try {
|
|
130
|
-
|
|
134
|
+
B || (_(this.api), B = !0);
|
|
131
135
|
const e = s.getConfig(t), i = this._getBlockElement(t);
|
|
132
136
|
if (i) {
|
|
133
137
|
const n = !e.mobileLayoutEnabled;
|
|
134
|
-
|
|
138
|
+
w(i) !== n && I(this.api, i, n);
|
|
135
139
|
}
|
|
136
140
|
} catch {
|
|
137
141
|
}
|
|
@@ -161,7 +165,7 @@ class W extends b {
|
|
|
161
165
|
*/
|
|
162
166
|
_warnIfMultipleBlocks() {
|
|
163
167
|
try {
|
|
164
|
-
|
|
168
|
+
H().warnIfMultipleBlocks(this.api.getDocumentRootHtmlNode());
|
|
165
169
|
} catch {
|
|
166
170
|
}
|
|
167
171
|
}
|
|
@@ -211,9 +215,9 @@ class W extends b {
|
|
|
211
215
|
if (!o)
|
|
212
216
|
return;
|
|
213
217
|
let r = -1;
|
|
214
|
-
for (let
|
|
215
|
-
if (n[
|
|
216
|
-
r =
|
|
218
|
+
for (let a = 0; a < n.length; a++)
|
|
219
|
+
if (n[a] === o) {
|
|
220
|
+
r = a;
|
|
217
221
|
break;
|
|
218
222
|
}
|
|
219
223
|
if (r <= 0)
|
|
@@ -293,7 +297,7 @@ class W extends b {
|
|
|
293
297
|
*/
|
|
294
298
|
_stampHidePrice(t, e) {
|
|
295
299
|
const i = this._getBlockElement(t);
|
|
296
|
-
i && this.api.getDocumentModifier().modifyHtml(i).setAttribute(
|
|
300
|
+
i && this.api.getDocumentModifier().modifyHtml(i).setAttribute(R, String(e)).apply(new g("Stamp hide-price"));
|
|
297
301
|
}
|
|
298
302
|
/**
|
|
299
303
|
* Stamps `hide-price` from config only when the block lacks the attribute —
|
|
@@ -301,7 +305,7 @@ class W extends b {
|
|
|
301
305
|
*/
|
|
302
306
|
_healHidePriceAttr(t) {
|
|
303
307
|
const e = this._getBlockElement(t);
|
|
304
|
-
if (!e || !("getAttribute" in e) || e.getAttribute(
|
|
308
|
+
if (!e || !("getAttribute" in e) || e.getAttribute(R) !== null)
|
|
305
309
|
return;
|
|
306
310
|
const { priceHideIfSameAsDiscounted: i } = s.getConfig(t);
|
|
307
311
|
this._stampHidePrice(t, i);
|
|
@@ -338,6 +342,6 @@ class W extends b {
|
|
|
338
342
|
}
|
|
339
343
|
}
|
|
340
344
|
export {
|
|
341
|
-
|
|
342
|
-
|
|
345
|
+
k as BLOCK_ID,
|
|
346
|
+
j as RecommendationBlock
|
|
343
347
|
};
|
|
@@ -14,7 +14,7 @@ import { ALGORITHM_CONTROL_ID as ut } from "./algorithm.js";
|
|
|
14
14
|
import { CurrencyControl as P } from "./currency.js";
|
|
15
15
|
import { CURRENCY_CONTROL_ID as ht } from "./currency.js";
|
|
16
16
|
import { FiltersControl as S } from "./filters.js";
|
|
17
|
-
import { FILTERS_CONTROL_ID as
|
|
17
|
+
import { FILTERS_CONTROL_ID as ft } from "./filters.js";
|
|
18
18
|
import { LayoutOrientationControl as O } from "./layoutOrientation.js";
|
|
19
19
|
import { LAYOUT_ORIENTATION_CONTROL_ID as Ct } from "./layoutOrientation.js";
|
|
20
20
|
import { LocaleControl as L } from "./locale.js";
|
|
@@ -31,7 +31,7 @@ import { StrategyControl as w } from "./strategy.js";
|
|
|
31
31
|
import { STRATEGY_CONTROL_ID as Lt } from "./strategy.js";
|
|
32
32
|
import { setCurrencyAttributes as A, getBlockElement as v, isPartnerManagedBlock as x, updateProductContentInPlace as B, regenerateProductRowsWithStyles as U } from "./utils.js";
|
|
33
33
|
import { adjustProductsToSize as kt, formatProductPrice as Dt, getCardComposition as Ft, getCurrentLayout as wt, getMainContainerTbody as At, regenerateMobileProductRows as vt, updatePricesInPlace as xt, updateSingleProductContent as Bt } from "./utils.js";
|
|
34
|
-
import { useDebounceFn as
|
|
34
|
+
import { useDebounceFn as g } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
35
35
|
const $ = "ui-elements-recommendation-block";
|
|
36
36
|
class at extends N {
|
|
37
37
|
constructor() {
|
|
@@ -60,7 +60,7 @@ class at extends N {
|
|
|
60
60
|
/**
|
|
61
61
|
* Debounced product fetch to prevent rapid API calls during config changes
|
|
62
62
|
*/
|
|
63
|
-
n(this, "_debouncedFetchProducts",
|
|
63
|
+
n(this, "_debouncedFetchProducts", g(async () => {
|
|
64
64
|
try {
|
|
65
65
|
await this.store.fetchRecommendationProducts();
|
|
66
66
|
} finally {
|
|
@@ -78,7 +78,7 @@ class at extends N {
|
|
|
78
78
|
* count. The store pads products to the configured size, so in-place only
|
|
79
79
|
* fails when the size actually changed.
|
|
80
80
|
*/
|
|
81
|
-
n(this, "_debouncedRegenerateWithProducts",
|
|
81
|
+
n(this, "_debouncedRegenerateWithProducts", g(() => {
|
|
82
82
|
const t = this.store.recommendationProducts;
|
|
83
83
|
if (!this.currentNode || !this.api)
|
|
84
84
|
return;
|
|
@@ -149,7 +149,7 @@ class at extends N {
|
|
|
149
149
|
var o;
|
|
150
150
|
b(this.api);
|
|
151
151
|
const t = this._getRecommendationIdFromNode(this.currentNode), e = t ?? this.store.currentRecommendationId;
|
|
152
|
-
if (e !== null && this.store.setCurrentBlock(e), t !== null && this._syncNodeConfigIfChanged(t), this._listenStateUpdates(), this._showControlsForBlock(this.currentNode), e !== null && ((o = this.store.blockStates[e]) != null && o.isInitialized)) {
|
|
152
|
+
if (e !== null && this.store.setCurrentBlock(e), t !== null && this._syncNodeConfigIfChanged(t), this._listenStateUpdates(), this._showControlsForBlock(this.currentNode), t !== null && this.strategyControl && (this.strategyControl.api = this.api, this.strategyControl.currentNode = this.currentNode, this.strategyControl.onRender()), e !== null && ((o = this.store.blockStates[e]) != null && o.isInitialized)) {
|
|
153
153
|
this._initializeSubControls();
|
|
154
154
|
return;
|
|
155
155
|
}
|
|
@@ -408,8 +408,8 @@ class at extends N {
|
|
|
408
408
|
}
|
|
409
409
|
const s = t.$state.configVersion;
|
|
410
410
|
s !== o && (o = s, this._capturePendingNodeConfigWrite(), this._debouncedFetchProducts());
|
|
411
|
-
const u = t.recommendationProducts, d = u !== e,
|
|
412
|
-
d &&
|
|
411
|
+
const u = t.recommendationProducts, d = u !== e, f = Array.isArray(u) && u.length > 0;
|
|
412
|
+
d && f && (e = u, this._debouncedRegenerateWithProducts());
|
|
413
413
|
});
|
|
414
414
|
}
|
|
415
415
|
}
|
|
@@ -419,7 +419,7 @@ export {
|
|
|
419
419
|
$ as CONTROL_BLOCK_ID,
|
|
420
420
|
ht as CURRENCY_CONTROL_ID,
|
|
421
421
|
P as CurrencyControl,
|
|
422
|
-
|
|
422
|
+
ft as FILTERS_CONTROL_ID,
|
|
423
423
|
S as FiltersControl,
|
|
424
424
|
Ct as LAYOUT_ORIENTATION_CONTROL_ID,
|
|
425
425
|
yt as LOCALE_CONTROL_ID,
|
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { ACADEMY_LINKS as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
var u = Object.defineProperty;
|
|
2
|
+
var S = (o, n, t) => n in o ? u(o, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[n] = t;
|
|
3
|
+
var r = (o, n, t) => S(o, typeof n != "symbol" ? n + "" : n, t);
|
|
4
|
+
import { ACADEMY_LINKS as _ } from "../../../../../enums/academy.js";
|
|
5
|
+
import { useOnboardingStore as v } from "../../../../../stores/onboarding.js";
|
|
6
|
+
import { CommonControl as f } from "../../../common-control.js";
|
|
7
|
+
import { RecommendationConfigService as h } from "../../services/configService.js";
|
|
8
|
+
import { useRecommendationExtensionStore as b } from "../../store/recommendation.js";
|
|
9
|
+
const k = "recommendation-strategy-control";
|
|
10
|
+
class L extends f {
|
|
9
11
|
constructor() {
|
|
10
12
|
super(...arguments);
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
r(this, "store", b());
|
|
14
|
+
r(this, "onboardingStore", v());
|
|
15
|
+
r(this, "storeUnsubscription", () => {
|
|
13
16
|
});
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
r(this, "listeners", []);
|
|
18
|
+
r(this, "lastPaintedState", null);
|
|
16
19
|
}
|
|
17
20
|
getId() {
|
|
18
|
-
return
|
|
21
|
+
return k;
|
|
19
22
|
}
|
|
20
23
|
getTemplate() {
|
|
21
24
|
const t = this.api.translate(
|
|
@@ -23,21 +26,34 @@ class f extends h {
|
|
|
23
26
|
), e = this.api.translate("For more information, you can"), a = this.api.translate("visit Academy");
|
|
24
27
|
return `
|
|
25
28
|
<div class="strategy-control-container">
|
|
26
|
-
<div
|
|
27
|
-
<
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
<
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
</p>
|
|
29
|
+
<div data-strategy-loading-state>
|
|
30
|
+
<div class="strategy-control-header">
|
|
31
|
+
<span class="guido-skeleton guido-skeleton--strategy-title"></span>
|
|
32
|
+
</div>
|
|
33
|
+
<div class="strategy-control-description-row">
|
|
34
|
+
<span class="guido-skeleton guido-skeleton--strategy-description"></span>
|
|
35
|
+
</div>
|
|
36
|
+
<div class="strategy-control-skeleton-row">
|
|
37
|
+
<span class="guido-skeleton guido-skeleton--strategy-cta"></span>
|
|
38
|
+
<span class="guido-skeleton guido-skeleton--strategy-cta"></span>
|
|
39
|
+
</div>
|
|
38
40
|
</div>
|
|
39
|
-
<div data-strategy-
|
|
40
|
-
|
|
41
|
+
<div data-strategy-content style="display: none;">
|
|
42
|
+
<div class="strategy-control-header">
|
|
43
|
+
<h3 class="strategy-control-title">${this.api.translate("Recommendation Strategy")}</h3>
|
|
44
|
+
</div>
|
|
45
|
+
<div class="strategy-control-description-row">
|
|
46
|
+
<p class="strategy-control-description">
|
|
47
|
+
${t}
|
|
48
|
+
${e}
|
|
49
|
+
<a
|
|
50
|
+
href="${_.EMAIL_RECOMMENDATION_BLOCK}"
|
|
51
|
+
target="_blank"
|
|
52
|
+
rel="noopener noreferrer">${a}</a>.
|
|
53
|
+
</p>
|
|
54
|
+
</div>
|
|
55
|
+
<div data-strategy-empty-state style="display: none;">
|
|
56
|
+
${this._GuTwoColumns([
|
|
41
57
|
this._GuButton({
|
|
42
58
|
name: "assignStrategy",
|
|
43
59
|
label: this.api.translate("Assign Strategy"),
|
|
@@ -48,26 +64,28 @@ class f extends h {
|
|
|
48
64
|
name: "createStrategy",
|
|
49
65
|
label: this.api.translate("Create New Strategy"),
|
|
50
66
|
id: "guido__btn-create-strategy",
|
|
51
|
-
className: "strategy-control-cta primary"
|
|
52
|
-
disabled: !0
|
|
67
|
+
className: "strategy-control-cta primary"
|
|
53
68
|
})
|
|
54
69
|
], "strategy-control-cta-row")}
|
|
55
|
-
</div>
|
|
56
|
-
<div data-strategy-assigned-state style="display: none;">
|
|
57
|
-
<div class="strategy-control-name-band">
|
|
58
|
-
<span class="strategy-control-name" data-strategy-name></span>
|
|
59
70
|
</div>
|
|
60
|
-
<div
|
|
61
|
-
|
|
71
|
+
<div data-strategy-assigned-state style="display: none;">
|
|
72
|
+
<div class="strategy-control-name-band">
|
|
73
|
+
<span class="strategy-control-name" data-strategy-name></span>
|
|
74
|
+
<span
|
|
75
|
+
class="guido-skeleton guido-skeleton--strategy-name" data-strategy-name-skeleton></span>
|
|
76
|
+
</div>
|
|
77
|
+
<div class="strategy-control-actions">
|
|
78
|
+
${this._strategyAction({
|
|
62
79
|
id: "guido__btn-change-strategy",
|
|
63
80
|
label: this.api.translate("Change"),
|
|
64
81
|
modifier: "change"
|
|
65
82
|
})}
|
|
66
|
-
|
|
83
|
+
${this._strategyAction({
|
|
67
84
|
id: "guido__btn-remove-strategy",
|
|
68
85
|
label: this.api.translate("Remove"),
|
|
69
86
|
modifier: "remove"
|
|
70
87
|
})}
|
|
88
|
+
</div>
|
|
71
89
|
</div>
|
|
72
90
|
</div>
|
|
73
91
|
</div>
|
|
@@ -84,41 +102,51 @@ class f extends h {
|
|
|
84
102
|
`;
|
|
85
103
|
}
|
|
86
104
|
onRender() {
|
|
87
|
-
this._teardown(), this._setupButtonListeners(), this._renderState(), this.storeUnsubscription = this.store.$subscribe(() => {
|
|
105
|
+
this._teardown(), this.store.strategyPanelOpen = !0, this._setupButtonListeners(), this._renderState(), this.storeUnsubscription = this.store.$subscribe(() => {
|
|
88
106
|
this._renderState();
|
|
89
|
-
}), this.store.recommendationConfigs.strategyId && !this.store.
|
|
107
|
+
}), this.store.recommendationConfigs.strategyId && !this.store.strategiesFetched && this.store.fetchStrategies().catch(() => {
|
|
90
108
|
});
|
|
91
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* Whether the document itself says this block has no strategy.
|
|
112
|
+
*
|
|
113
|
+
* Read the node, not the store: when the main control cannot resolve the block id off the
|
|
114
|
+
* node it never syncs the persisted config, so the store still holds defaults (empty
|
|
115
|
+
* strategyId) for an assigned block.
|
|
116
|
+
*/
|
|
117
|
+
_isNodeUnassigned() {
|
|
118
|
+
return h.hasConfig(this.currentNode) && !h.getConfig(this.currentNode).strategyId;
|
|
119
|
+
}
|
|
92
120
|
onDestroy() {
|
|
93
121
|
this._teardown();
|
|
94
122
|
}
|
|
95
123
|
_teardown() {
|
|
96
|
-
this.storeUnsubscription(), this.storeUnsubscription = () => {
|
|
124
|
+
this.store.strategyPanelOpen = !1, this.storeUnsubscription(), this.storeUnsubscription = () => {
|
|
97
125
|
}, this.lastPaintedState = null, this.listeners.forEach(({ element: t, handler: e }) => t.removeEventListener("click", e)), this.listeners = [];
|
|
98
126
|
}
|
|
99
127
|
_setupButtonListeners() {
|
|
100
128
|
const t = this.getContainer();
|
|
101
129
|
if (!t)
|
|
102
130
|
return;
|
|
103
|
-
const e = (a,
|
|
104
|
-
const
|
|
105
|
-
|
|
131
|
+
const e = (a, i) => {
|
|
132
|
+
const s = t.querySelector(a);
|
|
133
|
+
s && (s.addEventListener("click", i), this.listeners.push({ element: s, handler: i }));
|
|
106
134
|
};
|
|
107
|
-
e("#guido__btn-assign-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-change-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-remove-strategy", () => this.store.openRemoveStrategyModal());
|
|
135
|
+
e("#guido__btn-assign-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-create-strategy", () => this.store.openStrategyCreation()), e("#guido__btn-change-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-remove-strategy", () => this.store.openRemoveStrategyModal());
|
|
108
136
|
}
|
|
109
137
|
_renderState() {
|
|
110
|
-
var
|
|
111
|
-
const { strategyId: t } = this.store.recommendationConfigs, e = t ? ((
|
|
112
|
-
if (
|
|
138
|
+
var p;
|
|
139
|
+
const { strategyId: t } = this.store.recommendationConfigs, e = t ? ((p = this.store.assignedStrategy) == null ? void 0 : p.name) ?? "" : "", a = !!t && !e && (this.store.strategiesLoading || !this.store.strategiesFetched), i = `${t}\0${e}\0${a}`;
|
|
140
|
+
if (i === this.lastPaintedState)
|
|
113
141
|
return;
|
|
114
|
-
const
|
|
115
|
-
if (!
|
|
142
|
+
const s = this.getContainer();
|
|
143
|
+
if (!s)
|
|
116
144
|
return;
|
|
117
|
-
const
|
|
118
|
-
!
|
|
145
|
+
const c = s.querySelector("[data-strategy-empty-state]"), g = s.querySelector("[data-strategy-assigned-state]"), l = s.querySelector("[data-strategy-loading-state]"), y = s.querySelector("[data-strategy-content]"), d = s.querySelector("[data-strategy-name]"), m = s.querySelector("[data-strategy-name-skeleton]");
|
|
146
|
+
!c || !g || (l && (l.style.display = "none"), y && (y.style.display = ""), c.style.display = t ? "none" : "", g.style.display = t ? "" : "none", !t && this._isNodeUnassigned() && this.onboardingStore.startOnboarding("recommendationStrategyOnboarding"), d && (d.style.display = a ? "none" : "", t && !a && (d.textContent = e || `#${t}`)), m && (m.style.display = a ? "block" : "none"), this.lastPaintedState = i);
|
|
119
147
|
}
|
|
120
148
|
}
|
|
121
149
|
export {
|
|
122
|
-
|
|
123
|
-
|
|
150
|
+
k as STRATEGY_CONTROL_ID,
|
|
151
|
+
L as StrategyControl
|
|
124
152
|
};
|