@designcrowd/library.brand-page 5.16.2 → 5.16.3-background-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/src/{CreatedOnBrandCrowd-de-de-Oj_ab97C.js → CreatedOnBrandCrowd-de-de-CKV5OfpA.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-en-us-GsCBx_Vo.js → CreatedOnBrandCrowd-en-us-CVeOIfuY.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-es-es-CWp_kHxD.js → CreatedOnBrandCrowd-es-es-Bky5jrsA.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-fr-fr-DrPrFgKC.js → CreatedOnBrandCrowd-fr-ca-vf78sk3H.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-fr-ca-DrPrFgKC.js → CreatedOnBrandCrowd-fr-fr-vf78sk3H.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-pt-pt-BgvbBOFa.js → CreatedOnBrandCrowd-pt-br-DhowdxCT.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-pt-br-BgvbBOFa.js → CreatedOnBrandCrowd-pt-pt-DhowdxCT.js} +1 -1
- package/lib/src/{CreatedOnDcom-de-de-BZRXmSAH.js → CreatedOnDcom-de-de-VM5ItYJf.js} +1 -1
- package/lib/src/{CreatedOnDcom-en-us-D_xjisVj.js → CreatedOnDcom-en-us-josxNhmK.js} +1 -1
- package/lib/src/{CreatedOnDcom-es-es-CJzkN8Oq.js → CreatedOnDcom-es-es-DiKAwjGC.js} +1 -1
- package/lib/src/{CreatedOnDcom-fr-ca-C5ilNf57.js → CreatedOnDcom-fr-ca-BGELaNHY.js} +1 -1
- package/lib/src/{CreatedOnDcom-fr-fr-CZypZWWq.js → CreatedOnDcom-fr-fr-3ReXfgyD.js} +1 -1
- package/lib/src/{CreatedOnDcom-pt-br-JZXunSWT.js → CreatedOnDcom-pt-br-QziCI0TB.js} +1 -1
- package/lib/src/{CreatedOnDcom-pt-pt-CjL1qKnl.js → CreatedOnDcom-pt-pt-BJwKSkn3.js} +1 -1
- package/lib/src/brand-page/components/page/Page.mixin.js +20 -15
- package/lib/src/brand-page/components/page/Page.stories.js +2 -2
- package/lib/src/brand-page/models/index.d.ts +1 -0
- package/lib/src/brand-page/models/index.js +2 -0
- package/lib/src/brand-page/utils/migration/migration-07.js +1 -1
- package/lib/src/brand-page/utils/view-model.util.d.ts +2 -1
- package/lib/src/brand-page/utils/view-model.util.js +27 -2
- package/lib/src/brand-page/view-models.d.ts +17 -2
- package/lib/src/brand-page-maker/components/action-bar/ActionBar.mixin.d.ts +3 -0
- package/lib/src/brand-page-maker/components/admin-background-settings/AdminBackgroundSettings.mixin.d.ts +7 -2
- package/lib/src/brand-page-maker/components/brand-page-maker/BrandPageMaker.mixin.d.ts +4 -0
- package/lib/src/brand-page-maker/components/brandpage-settings/ReplaceImageSettingsForBrandPageSettings.mixin.d.ts +3 -0
- package/lib/src/brand-page-maker/components/preview/Preview.stories.js +2 -2
- package/lib/src/brand-page-maker/components/template-preview/TemplatePreview.mixin.d.ts +244 -1
- package/lib/src/brand-page-maker/components/template-preview/TemplatePreview.mixin.js +68 -4
- package/lib/src/brand-page-maker/stores/brandpage-maker/brandpage-maker-store.js +9 -1
- package/lib/src/brand-page-maker/stores/user/user-store.d.ts +4 -0
- package/lib/src/brand-page-maker/stores/user/user-store.js +4 -0
- package/lib/src/bundled-translations-DEk3SiLd.js +161 -0
- package/lib/src/bundles/bundled-translations.json +3 -1
- package/lib/src/clients/design-template-client.d.ts +1 -0
- package/lib/src/clients/models.d.ts +1 -0
- package/lib/src/css/library.brand-page-brandCrowd.min.css +48 -20
- package/lib/src/css/library.brand-page-brandPage.min.css +48 -20
- package/lib/src/css/library.brand-page-designCom.min.css +48 -20
- package/lib/src/css/library.brand-page-preview.min.css +48 -20
- package/lib/src/index.mjs +1 -1
- package/lib/src/{lib-BCV7U_Bf.js → lib-DMBCLH_G.js} +13306 -13120
- package/lib/src/shared/background-settings/components/background-shapes/BackgroundShapeSettings.mixin.d.ts +10 -2
- package/lib/src/shared/background-settings/store/background-settings-store.d.ts +3 -0
- package/lib/src/shared/background-settings/store/background-settings-store.js +40 -2
- package/lib/src/shared/content-settings/components/content-settings/ReplaceImageSettingsForContent.mixin.d.ts +3 -0
- package/lib/src/shared/content-settings/components/content-settings-item/ContentSettingsItemField.mixin.d.ts +26 -0
- package/lib/src/shared/content-settings/components/content-settings-item/ContentSettingsItemField.mixin.js +6 -1
- package/lib/src/shared/content-settings/components/image-field/ImageField.mixin.js +3 -1
- package/lib/src/shared/content-settings/components/page-dropdown-field/PageDropdownField.mixin.d.ts +3 -0
- package/lib/src/shared/page-settings/components/delete-page-modal/DeletePageModal.mixin.d.ts +1 -1
- package/lib/src/shared/page-settings/components/page-settings/PageSettings.mixin.d.ts +3 -0
- package/lib/src/shared/side-bar/components/SideBar.mixin.d.ts +3 -0
- package/lib/src/shared/style-settings/components/StyleSettings.mixin.d.ts +5 -0
- package/lib/src/shared/template-settings/components/TemplatesSettings.mixin.d.ts +1 -0
- package/lib/src/shared/template-settings/models.d.ts +2 -0
- package/lib/src/shared/template-settings/store/template-settings-store.d.ts +6 -0
- package/lib/src/shared/template-settings/store/template-settings-store.js +109 -35
- package/package.json +1 -1
- package/src/brand-page/components/page/Page.mixin.ts +24 -15
- package/src/brand-page/components/page/Page.stories.ts +2 -1
- package/src/brand-page/components/page/Page.vue +18 -3
- package/src/brand-page/models/index.ts +3 -0
- package/src/brand-page/utils/__snapshots__/migration.util.test.ts.snap +3 -0
- package/src/brand-page/utils/__snapshots__/migration2.util.test.ts.snap +1 -0
- package/src/brand-page/utils/__snapshots__/model.util.test.ts.snap +2 -0
- package/src/brand-page/utils/migration/migration-07.ts +6 -4
- package/src/brand-page/utils/view-model.util.ts +42 -2
- package/src/brand-page/view-models.ts +23 -1
- package/src/brand-page-maker/components/preview/Preview.stories.ts +2 -1
- package/src/brand-page-maker/components/template-preview/TemplatePreview.mixin.ts +90 -5
- package/src/brand-page-maker/components/template-preview/TemplatePreview.vue +41 -4
- package/src/brand-page-maker/components/template-preview-with-state/TemplatePreviewWithState.vue +4 -6
- package/src/brand-page-maker/stores/brandpage-maker/brandpage-maker-store.ts +14 -1
- package/src/brand-page-maker/stores/user/user-store.ts +5 -0
- package/src/bundles/bundled-translations.json +3 -1
- package/src/clients/design-template-client.ts +1 -0
- package/src/clients/models.ts +1 -0
- package/src/shared/background-settings/components/BackgroundSettings.vue +28 -8
- package/src/shared/background-settings/components/ReplaceImageSettingsForBackgroundSettings.vue +9 -0
- package/src/shared/background-settings/components/i18n/background-settings.json +3 -1
- package/src/shared/background-settings/store/background-settings-store.ts +57 -2
- package/src/shared/content-settings/components/content-settings-item/ContentSettingsItemField.mixin.ts +9 -3
- package/src/shared/content-settings/components/image-field/ImageField.mixin.ts +4 -1
- package/src/shared/template-settings/models.ts +2 -0
- package/src/shared/template-settings/store/template-settings-store.ts +141 -41
- package/lib/src/bundled-translations-D9iHE5G9.js +0 -161
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
{{ backgroundSettingsTr(`addMedia`) }}
|
|
16
16
|
</h4>
|
|
17
17
|
|
|
18
|
-
<CollapsiblePanel :title="backgroundSettingsTr('
|
|
18
|
+
<CollapsiblePanel :title="backgroundSettingsTr('media')">
|
|
19
19
|
<ImageField
|
|
20
20
|
id="background-image"
|
|
21
21
|
name="backgroundImage"
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
placeholder="Add background image"
|
|
25
25
|
media-type="Content"
|
|
26
26
|
@on-intent-image-replace="onIntentImageReplace"
|
|
27
|
-
@update:model-value="
|
|
27
|
+
@update:model-value="onBackgroundMediaDeleted"
|
|
28
28
|
/>
|
|
29
29
|
</CollapsiblePanel>
|
|
30
30
|
<div
|
|
@@ -101,6 +101,7 @@ import {
|
|
|
101
101
|
useBrandPageMakerStore,
|
|
102
102
|
useBrandPageMakerUserStore,
|
|
103
103
|
useUiStore,
|
|
104
|
+
useVideoStore,
|
|
104
105
|
} from '../../../brand-page-maker/stores';
|
|
105
106
|
import { useUiBackgroundSettingsStore } from '../store';
|
|
106
107
|
import SideBarSettingsHeader from '../../common/SideBarSettingsHeader.vue';
|
|
@@ -109,7 +110,11 @@ import PersonalisationRoleField from '../../content-settings/components/personal
|
|
|
109
110
|
import { computed, onMounted, reactive } from 'vue';
|
|
110
111
|
import type { UserMediaItem } from '../../my-uploads/models';
|
|
111
112
|
import type { UpdateItemValuePayload } from '../../content-settings/models';
|
|
112
|
-
import {
|
|
113
|
+
import {
|
|
114
|
+
type GettyVideoMedia,
|
|
115
|
+
MEDIA_TYPES,
|
|
116
|
+
type PersonalisationRole,
|
|
117
|
+
} from '../../../brand-page';
|
|
113
118
|
import { backgroundSettingsTr } from '../../../composables/useTranslate';
|
|
114
119
|
import ReplaceImageSettingsForBackgroundSettings from './ReplaceImageSettingsForBackgroundSettings.vue';
|
|
115
120
|
|
|
@@ -122,6 +127,8 @@ const uiStore = useUiStore();
|
|
|
122
127
|
const backgroundStyles = computed(
|
|
123
128
|
() => backgroundSettingsStore.backgroundStyles,
|
|
124
129
|
);
|
|
130
|
+
|
|
131
|
+
console.log('this is the background styles: ', backgroundStyles.value);
|
|
125
132
|
const recommendedLogoColors = computed(
|
|
126
133
|
() => backgroundSettingsStore.recommendedLogoColors,
|
|
127
134
|
);
|
|
@@ -167,12 +174,19 @@ const personalisationRole = computed(() => {
|
|
|
167
174
|
// This hides the shape in the image field as there will be a future thumbnail for shapes
|
|
168
175
|
const imageFieldValue = computed(() => {
|
|
169
176
|
const backgroundImageUrl = backgroundStyles.value.backgroundImageUrl || '';
|
|
177
|
+
const media = backgroundStyles.value.media as GettyVideoMedia;
|
|
170
178
|
|
|
171
179
|
// If the background image is an SVG (shape), return empty string to hide it in the image field
|
|
172
180
|
if (backgroundImageUrl.endsWith('.svg')) {
|
|
173
181
|
return '';
|
|
174
182
|
}
|
|
175
183
|
|
|
184
|
+
if (media && media.type === 'getty-video') {
|
|
185
|
+
const videoStore = useVideoStore();
|
|
186
|
+
const videoUrls = videoStore.getVideoUrlsForToken(media.gettyToken);
|
|
187
|
+
return videoUrls?.previewImageUrl || ''; // Show the video thumbnail
|
|
188
|
+
}
|
|
189
|
+
|
|
176
190
|
return backgroundImageUrl;
|
|
177
191
|
});
|
|
178
192
|
|
|
@@ -227,16 +241,22 @@ const onBackgroundImageSelected = (image: UserMediaItem) => {
|
|
|
227
241
|
});
|
|
228
242
|
};
|
|
229
243
|
|
|
230
|
-
const
|
|
244
|
+
const onBackgroundMediaDeleted = (payload: {
|
|
231
245
|
id: string;
|
|
232
246
|
name: string;
|
|
233
247
|
value: string;
|
|
234
248
|
}) => {
|
|
249
|
+
console.log('Here deleting');
|
|
235
250
|
if (payload.value === '') {
|
|
236
251
|
backgroundSettingsStore.setBackgroundImageUrl({
|
|
237
252
|
backgroundImageUrl: '',
|
|
238
253
|
});
|
|
239
254
|
}
|
|
255
|
+
|
|
256
|
+
if (backgroundStyles.value?.media) {
|
|
257
|
+
console.log('Removing background video');
|
|
258
|
+
backgroundSettingsStore.removeBackgroundVideo();
|
|
259
|
+
}
|
|
240
260
|
};
|
|
241
261
|
|
|
242
262
|
const selectShapeTab = (tab: string) => {
|
|
@@ -265,10 +285,10 @@ const onIntentImageReplace = (payload: {
|
|
|
265
285
|
errorMessage: '',
|
|
266
286
|
isRequired: false,
|
|
267
287
|
replaceImageSettings: {
|
|
268
|
-
tabs: ['MY_UPLOADS', 'IMAGE_LIBRARY'],
|
|
269
|
-
buttonTitleAdd: backgroundSettingsTr(`
|
|
270
|
-
titleAdd: backgroundSettingsTr(`
|
|
271
|
-
titleReplace: backgroundSettingsTr(`
|
|
288
|
+
tabs: ['MY_UPLOADS', 'IMAGE_LIBRARY', 'VIDEO_LIBRARY'],
|
|
289
|
+
buttonTitleAdd: backgroundSettingsTr(`addMedia`),
|
|
290
|
+
titleAdd: backgroundSettingsTr(`addMedia`),
|
|
291
|
+
titleReplace: backgroundSettingsTr(`replaceMedia`),
|
|
272
292
|
contentMediaFieldName: payload.value ? 'backgroundImage' : '',
|
|
273
293
|
openByDefault: false,
|
|
274
294
|
mediaType: data.mediaType,
|
package/src/shared/background-settings/components/ReplaceImageSettingsForBackgroundSettings.vue
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
@on-design-selected="onDesignSelected"
|
|
13
13
|
@on-image-picked="onImageSelected"
|
|
14
14
|
@on-image-removed="onImageRemoved"
|
|
15
|
+
@on-video-selected="onVideoSelected"
|
|
15
16
|
/>
|
|
16
17
|
</div>
|
|
17
18
|
</template>
|
|
@@ -117,4 +118,12 @@ const onDesignSelected = (image: UserMediaItemWithDimensions) => {
|
|
|
117
118
|
backgroundMode: BRANDPAGE_SETTINGS_MODES.edit,
|
|
118
119
|
});
|
|
119
120
|
};
|
|
121
|
+
|
|
122
|
+
const onVideoSelected = (videoPayload: any) => {
|
|
123
|
+
backgroundSettingsStore.setBackgroundMedia(videoPayload);
|
|
124
|
+
|
|
125
|
+
backgroundSettingsStore.setBackgroundMode({
|
|
126
|
+
backgroundMode: BRANDPAGE_SETTINGS_MODES.edit,
|
|
127
|
+
});
|
|
128
|
+
};
|
|
120
129
|
</script>
|
|
@@ -4,7 +4,7 @@ import type {
|
|
|
4
4
|
BackgroundStyles,
|
|
5
5
|
PersonalisationRole,
|
|
6
6
|
} from '../../../brand-page';
|
|
7
|
-
import { PageStyles } from '../../../brand-page';
|
|
7
|
+
import { GettyVideoMedia, PageStyles } from '../../../brand-page';
|
|
8
8
|
import {
|
|
9
9
|
BRANDPAGE_SETTINGS_MODES,
|
|
10
10
|
type BrandPageSettingsMode,
|
|
@@ -20,7 +20,11 @@ import type {
|
|
|
20
20
|
} from '../models';
|
|
21
21
|
import { backgroundSettingsTabId } from '../models';
|
|
22
22
|
import { defineStore } from 'pinia';
|
|
23
|
-
import { useUiStore } from '../../../brand-page-maker/stores';
|
|
23
|
+
import { useUiStore, useVideoStore } from '../../../brand-page-maker/stores';
|
|
24
|
+
import type {
|
|
25
|
+
GettyVideoMediaSelectedPayload,
|
|
26
|
+
MediaBaseSelectedPayload,
|
|
27
|
+
} from '../../my-uploads/models';
|
|
24
28
|
|
|
25
29
|
export interface BackgroundSettingsState {
|
|
26
30
|
backgroundStyles: BackgroundStyles;
|
|
@@ -40,6 +44,7 @@ export const useUiBackgroundSettingsStore = defineStore(
|
|
|
40
44
|
backgroundShapeStyle: {},
|
|
41
45
|
backgroundShapes: [],
|
|
42
46
|
backgroundImageUrl: '',
|
|
47
|
+
media: undefined,
|
|
43
48
|
},
|
|
44
49
|
logoColors: [],
|
|
45
50
|
recommendedLogoColors: [],
|
|
@@ -208,6 +213,12 @@ export const useUiBackgroundSettingsStore = defineStore(
|
|
|
208
213
|
personalisationRole: backgroundStyles.personalisationRole,
|
|
209
214
|
});
|
|
210
215
|
|
|
216
|
+
if (backgroundStyles.media) {
|
|
217
|
+
this.backgroundStyles.media = backgroundStyles.media;
|
|
218
|
+
} else {
|
|
219
|
+
this.backgroundStyles.media = undefined;
|
|
220
|
+
}
|
|
221
|
+
|
|
211
222
|
this.onBackgroundChanged();
|
|
212
223
|
},
|
|
213
224
|
setBackgroundShapeSettings(payload: SetBackgroundShapeSettingsPayload) {
|
|
@@ -234,6 +245,50 @@ export const useUiBackgroundSettingsStore = defineStore(
|
|
|
234
245
|
setBackgroundMode(payload: { backgroundMode: BrandPageSettingsMode }) {
|
|
235
246
|
this.backgroundMode = payload.backgroundMode;
|
|
236
247
|
},
|
|
248
|
+
|
|
249
|
+
setBackgroundMedia(payload: MediaBaseSelectedPayload) {
|
|
250
|
+
console.log('Here in the background settings store', payload);
|
|
251
|
+
|
|
252
|
+
if (payload.type === 'getty-video') {
|
|
253
|
+
const gettyMedia = payload as GettyVideoMediaSelectedPayload;
|
|
254
|
+
const videoStore = useVideoStore();
|
|
255
|
+
|
|
256
|
+
videoStore.setVideoUrlsWithToken(
|
|
257
|
+
gettyMedia.token,
|
|
258
|
+
gettyMedia.videoSrc,
|
|
259
|
+
gettyMedia.imageSrc,
|
|
260
|
+
gettyMedia.assetId,
|
|
261
|
+
);
|
|
262
|
+
|
|
263
|
+
this.backgroundStyles.media = new GettyVideoMedia({
|
|
264
|
+
gettyToken: gettyMedia.token,
|
|
265
|
+
gettyAssetId: gettyMedia.assetId,
|
|
266
|
+
mimeType: gettyMedia.mimeType,
|
|
267
|
+
settings: {
|
|
268
|
+
autoPlay: gettyMedia.autoPlay,
|
|
269
|
+
},
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
// Clear any existing background image/shape
|
|
273
|
+
this.backgroundStyles.backgroundImageUrl = '';
|
|
274
|
+
|
|
275
|
+
// Default background style for videos
|
|
276
|
+
this.setBackgroundStyle({
|
|
277
|
+
backgroundStyle: {
|
|
278
|
+
backgroundRepeat: 'no-repeat',
|
|
279
|
+
backgroundPosition: 'center center',
|
|
280
|
+
backgroundSize: 'cover',
|
|
281
|
+
},
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
this.onBackgroundChanged();
|
|
285
|
+
}
|
|
286
|
+
},
|
|
287
|
+
removeBackgroundVideo() {
|
|
288
|
+
this.backgroundStyles.media = undefined;
|
|
289
|
+
|
|
290
|
+
this.onBackgroundChanged();
|
|
291
|
+
},
|
|
237
292
|
},
|
|
238
293
|
},
|
|
239
294
|
);
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
} from '../../../../brand-page-maker/models';
|
|
22
22
|
import { useUiPageSettingsStore } from '../../../page-settings/store';
|
|
23
23
|
import { PAGE_SECTIONS } from '../../../page-settings/models';
|
|
24
|
+
import { useUiLogoSettingsStore } from '../../../logo-settings/store';
|
|
24
25
|
|
|
25
26
|
const RTE_ALLOWED_SECTION_TYPES = [
|
|
26
27
|
'banner-section',
|
|
@@ -64,6 +65,7 @@ export default defineComponent({
|
|
|
64
65
|
const uiStore = useUiStore();
|
|
65
66
|
const sideBarStore = useUiSideBarStore();
|
|
66
67
|
const pageSettingsStore = useUiPageSettingsStore();
|
|
68
|
+
const uiLogoSettingsStore = useUiLogoSettingsStore();
|
|
67
69
|
|
|
68
70
|
return {
|
|
69
71
|
getFieldSettings: computed(() => contentSettingsStore.getFieldSettings),
|
|
@@ -85,6 +87,7 @@ export default defineComponent({
|
|
|
85
87
|
uiStore,
|
|
86
88
|
sideBarStore,
|
|
87
89
|
pageSettingsStore,
|
|
90
|
+
uiLogoSettingsStore,
|
|
88
91
|
};
|
|
89
92
|
},
|
|
90
93
|
data: () => ({
|
|
@@ -239,13 +242,16 @@ export default defineComponent({
|
|
|
239
242
|
) as ContentItem<LogoContent>;
|
|
240
243
|
|
|
241
244
|
if (logoContentItem) {
|
|
245
|
+
const logoImage = JSON.parse(
|
|
246
|
+
JSON.stringify(logoContentItem.settings.content.logoImage),
|
|
247
|
+
);
|
|
248
|
+
|
|
249
|
+
this.uiLogoSettingsStore.setSelectedLogoImage(logoImage);
|
|
242
250
|
[PAGE_SECTIONS.header, PAGE_SECTIONS.footer].forEach((section) => {
|
|
243
251
|
[VIEWPORTS.desktop, VIEWPORTS.mobile].forEach((viewPort) => {
|
|
244
252
|
this.pageSettingsStore.setPageSettingsSectionLogoImage({
|
|
245
253
|
sectionName: section,
|
|
246
|
-
logoImage:
|
|
247
|
-
JSON.stringify(logoContentItem.settings.content.logoImage),
|
|
248
|
-
),
|
|
254
|
+
logoImage: logoImage,
|
|
249
255
|
logoTemplateImage: undefined,
|
|
250
256
|
logoImageBase64Url:
|
|
251
257
|
logoContentItem.settings.content.logoImageBase64Url,
|
|
@@ -16,10 +16,11 @@ import {
|
|
|
16
16
|
BP_DEFAULT_TEMPLATE_TYPE_NAME,
|
|
17
17
|
SIDE_BAR_TAB_NAMES,
|
|
18
18
|
} from '../../../brand-page-maker/constants';
|
|
19
|
-
import { defineStore } from 'pinia';
|
|
19
|
+
import { defineStore, storeToRefs } from 'pinia';
|
|
20
20
|
import {
|
|
21
21
|
useBrandPageContainerStore,
|
|
22
22
|
useBrandPageMakerStore,
|
|
23
|
+
useBrandPageMakerUserStore,
|
|
23
24
|
useUiStore,
|
|
24
25
|
} from '../../../brand-page-maker/stores';
|
|
25
26
|
import { useUiSideBarStore } from '../../side-bar/store';
|
|
@@ -31,6 +32,7 @@ import {
|
|
|
31
32
|
templateSettingsTr,
|
|
32
33
|
getCurrentLocale,
|
|
33
34
|
} from '../../../composables/useTranslate';
|
|
35
|
+
import { watch } from 'vue';
|
|
34
36
|
|
|
35
37
|
export const DEFAULT_PAGE_SIZE = 6;
|
|
36
38
|
const LOAD_PAGE_RETRY_DELAY = 250;
|
|
@@ -54,40 +56,54 @@ export interface TemplatesSettingState {
|
|
|
54
56
|
selectedCategory: string | undefined;
|
|
55
57
|
searchTerm: string | undefined;
|
|
56
58
|
tabsWithTranslations: SelectedTabType[];
|
|
59
|
+
logoChangeWatcherInitialized: boolean;
|
|
60
|
+
renderAsImage: boolean;
|
|
57
61
|
}
|
|
58
62
|
|
|
59
63
|
export const useUiTemplateSettingsStore = defineStore('uiTemplateSettings', {
|
|
60
|
-
state: (): TemplatesSettingState =>
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
64
|
+
state: (): TemplatesSettingState => {
|
|
65
|
+
const brandPageContainerStore = useBrandPageContainerStore();
|
|
66
|
+
const brandPageMakerUserStore = useBrandPageMakerUserStore();
|
|
67
|
+
|
|
68
|
+
// Set renderAsImage to true if not admin AND not pre-purchase
|
|
69
|
+
const renderAsImage =
|
|
70
|
+
!brandPageMakerUserStore.isAdmin &&
|
|
71
|
+
!brandPageContainerStore.isPrePurchase;
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
isBusy: false,
|
|
75
|
+
pageCount: 0,
|
|
76
|
+
pageNo: 1,
|
|
77
|
+
pageNoLoaded: 0,
|
|
78
|
+
pageSize: DEFAULT_PAGE_SIZE,
|
|
79
|
+
templateType: BP_DEFAULT_TEMPLATE_TYPE_NAME,
|
|
80
|
+
templates: [],
|
|
81
|
+
selectedTab: {
|
|
77
82
|
key: 'all',
|
|
78
83
|
displayName: templateSettingsTr(`headerAll`),
|
|
79
84
|
},
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
85
|
+
searchTerm: undefined,
|
|
86
|
+
selectedCategory: undefined,
|
|
87
|
+
templateCategories: [],
|
|
88
|
+
tabsWithTranslations: [
|
|
89
|
+
{
|
|
90
|
+
key: 'all',
|
|
91
|
+
displayName: templateSettingsTr(`headerAll`),
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
key: 'categories',
|
|
95
|
+
displayName: templateSettingsTr(`headerCategories`),
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
key: 'ai',
|
|
99
|
+
displayName: templateSettingsTr(`headerAi`),
|
|
100
|
+
},
|
|
101
|
+
],
|
|
102
|
+
cachedTemplates: {},
|
|
103
|
+
logoChangeWatcherInitialized: false,
|
|
104
|
+
renderAsImage,
|
|
105
|
+
};
|
|
106
|
+
},
|
|
91
107
|
actions: {
|
|
92
108
|
_addTemplates({ templates }: { templates: TemplateSettingsTemplate[] }) {
|
|
93
109
|
this.templates = this.templates.concat(templates);
|
|
@@ -215,6 +231,7 @@ export const useUiTemplateSettingsStore = defineStore('uiTemplateSettings', {
|
|
|
215
231
|
async loadPageNo({ pageNo }: { pageNo: number }) {
|
|
216
232
|
const brandPageMakerStore = useBrandPageMakerStore();
|
|
217
233
|
const brandPageContainerStore = useBrandPageContainerStore();
|
|
234
|
+
const brandPageMakerUserStore = useBrandPageMakerUserStore();
|
|
218
235
|
const logoSettingsStore = useUiLogoSettingsStore();
|
|
219
236
|
const designTemplateToken = brandPageContainerStore.designTemplateToken;
|
|
220
237
|
|
|
@@ -261,6 +278,7 @@ export const useUiTemplateSettingsStore = defineStore('uiTemplateSettings', {
|
|
|
261
278
|
searchTerm: this.searchTerm,
|
|
262
279
|
logoDraftToken:
|
|
263
280
|
logoSettingsStore.selectedLogoImage.logoDraftToken,
|
|
281
|
+
logoVariation: logoSettingsStore.selectedLogoImage.logoVariation,
|
|
264
282
|
personalisable: this.selectedTab.key === TEMPLATE_TABS.AI,
|
|
265
283
|
selectedTemplateToken: designTemplateToken,
|
|
266
284
|
locale: currentLocale,
|
|
@@ -273,20 +291,57 @@ export const useUiTemplateSettingsStore = defineStore('uiTemplateSettings', {
|
|
|
273
291
|
|
|
274
292
|
this._setPageCount({ pageCount: result.pageCount });
|
|
275
293
|
|
|
276
|
-
const templates = (
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
294
|
+
const templates = await Promise.all(
|
|
295
|
+
result.paginatedItems.map(async (item) => {
|
|
296
|
+
try {
|
|
297
|
+
if (
|
|
298
|
+
brandPageContainerStore.isPrePurchase ||
|
|
299
|
+
brandPageMakerUserStore.isAdmin
|
|
300
|
+
) {
|
|
301
|
+
// Pre-purchase: full template with brandPageModel for live rendering
|
|
302
|
+
const template =
|
|
303
|
+
await designTemplateClient.getTemplateByTemplateToken(
|
|
304
|
+
item.designTemplateToken,
|
|
305
|
+
);
|
|
306
|
+
|
|
307
|
+
return this.safeMapToTemplateSettingsTemplate(template);
|
|
308
|
+
} else {
|
|
309
|
+
let personalisationContentIndex: number | undefined;
|
|
310
|
+
let contentKey: string | undefined;
|
|
311
|
+
|
|
312
|
+
if (uiStore.personalisationData?.length) {
|
|
313
|
+
personalisationContentIndex =
|
|
314
|
+
await getAiContentIndexByTemplateTokenAndNumberOfVariations(
|
|
315
|
+
item.designTemplateToken,
|
|
316
|
+
uiStore.personalisationData.length,
|
|
317
|
+
);
|
|
318
|
+
|
|
319
|
+
// Get the contentKey from the selected personalisation variation
|
|
320
|
+
// This is needed for the backend preview URL to show the correct variation
|
|
321
|
+
const selectedPersonalisation =
|
|
322
|
+
uiStore.personalisationData[personalisationContentIndex];
|
|
323
|
+
|
|
324
|
+
contentKey = selectedPersonalisation.contentKey;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
return {
|
|
328
|
+
id: item.designTemplateToken,
|
|
329
|
+
contentKey,
|
|
330
|
+
previewImageUrl: item.previewImageUrl,
|
|
331
|
+
} as TemplateSettingsTemplate;
|
|
332
|
+
}
|
|
333
|
+
} catch (error) {
|
|
334
|
+
return null;
|
|
335
|
+
}
|
|
336
|
+
}),
|
|
337
|
+
);
|
|
283
338
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
)
|
|
287
|
-
)
|
|
339
|
+
// Filter out null templates before adding
|
|
340
|
+
const validTemplates = templates.filter(
|
|
341
|
+
(t): t is TemplateSettingsTemplate => t !== null,
|
|
342
|
+
);
|
|
288
343
|
|
|
289
|
-
this._addTemplates({ templates });
|
|
344
|
+
this._addTemplates({ templates: validTemplates });
|
|
290
345
|
this._setPageNoLoaded({ pageNoLoaded: pageNo });
|
|
291
346
|
} finally {
|
|
292
347
|
this._setIsBusy({ isBusy: false });
|
|
@@ -361,6 +416,11 @@ export const useUiTemplateSettingsStore = defineStore('uiTemplateSettings', {
|
|
|
361
416
|
}
|
|
362
417
|
|
|
363
418
|
this.templateType = templateType;
|
|
419
|
+
|
|
420
|
+
if (!this.logoChangeWatcherInitialized) {
|
|
421
|
+
this.setupLogoChangeWatcher();
|
|
422
|
+
this.logoChangeWatcherInitialized = true;
|
|
423
|
+
}
|
|
364
424
|
},
|
|
365
425
|
async setTemplateCategories(payload: SetTemplateCategoriesPayload) {
|
|
366
426
|
await this._setTemplateCategories({
|
|
@@ -394,5 +454,45 @@ export const useUiTemplateSettingsStore = defineStore('uiTemplateSettings', {
|
|
|
394
454
|
this.templates.find((t) => t.id === id) || this.cachedTemplates[id]
|
|
395
455
|
);
|
|
396
456
|
},
|
|
457
|
+
/**
|
|
458
|
+
* re-fetch templates when the logo changes to regenerate preview images with the new logo.
|
|
459
|
+
*/
|
|
460
|
+
setupLogoChangeWatcher() {
|
|
461
|
+
const logoSettingsStore = useUiLogoSettingsStore();
|
|
462
|
+
const brandPageContainerStore = useBrandPageContainerStore();
|
|
463
|
+
const brandPageMakerUserStore = useBrandPageMakerUserStore();
|
|
464
|
+
const { selectedLogoImage } = storeToRefs(logoSettingsStore);
|
|
465
|
+
|
|
466
|
+
// Watch for changes to logoImage (token or variation changes)
|
|
467
|
+
watch(
|
|
468
|
+
() => selectedLogoImage.value,
|
|
469
|
+
async (newLogoImage, oldLogoImage) => {
|
|
470
|
+
// Skip initial load when oldLogoImage is undefined
|
|
471
|
+
if (!oldLogoImage) {
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
// Only refetch for post-purchase users and when logo actually changes
|
|
476
|
+
const hasLogoChanged =
|
|
477
|
+
newLogoImage.logoDraftToken !== oldLogoImage.logoDraftToken ||
|
|
478
|
+
newLogoImage.logoVariation !== oldLogoImage.logoVariation;
|
|
479
|
+
|
|
480
|
+
if (
|
|
481
|
+
!brandPageContainerStore.isPrePurchase &&
|
|
482
|
+
!brandPageMakerUserStore.isAdmin &&
|
|
483
|
+
newLogoImage.logoDraftToken &&
|
|
484
|
+
hasLogoChanged
|
|
485
|
+
) {
|
|
486
|
+
// Reset templates state and reload with new logo
|
|
487
|
+
// Use the same pattern as onCategorySelected and onSearch
|
|
488
|
+
await this._setTemplates({ templates: [] });
|
|
489
|
+
await this._setPageNoLoaded({ pageNoLoaded: 0 });
|
|
490
|
+
await this._setPageNo({ pageNo: 1 });
|
|
491
|
+
await this.loadPageNo({ pageNo: 1 });
|
|
492
|
+
}
|
|
493
|
+
},
|
|
494
|
+
{ deep: true },
|
|
495
|
+
);
|
|
496
|
+
},
|
|
397
497
|
},
|
|
398
498
|
});
|