@designcrowd/library.brand-page 5.17.6 → 5.17.7
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-BI2KuOEF.js → CreatedOnBrandCrowd-de-de-BUQFMhZb.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-en-us-BYLJCjLJ.js → CreatedOnBrandCrowd-en-us-QS-5r4XI.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-es-es-Y_D6cuGE.js → CreatedOnBrandCrowd-es-es-CP2iH-n0.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-fr-fr-CqCBRjYh.js → CreatedOnBrandCrowd-fr-ca-qfD4NmQZ.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-fr-ca-CqCBRjYh.js → CreatedOnBrandCrowd-fr-fr-qfD4NmQZ.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-pt-pt-Bt0YF6DA.js → CreatedOnBrandCrowd-pt-br-CfmaB7zE.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-pt-br-Bt0YF6DA.js → CreatedOnBrandCrowd-pt-pt-CfmaB7zE.js} +1 -1
- package/lib/src/{CreatedOnDcom-de-de-CEk8FBEG.js → CreatedOnDcom-de-de-BxSUWfGN.js} +1 -1
- package/lib/src/{CreatedOnDcom-en-us-DWw4Tm2L.js → CreatedOnDcom-en-us-CSeUdR6v.js} +1 -1
- package/lib/src/{CreatedOnDcom-es-es-DpG-8o98.js → CreatedOnDcom-es-es-g7rCfAtP.js} +1 -1
- package/lib/src/{CreatedOnDcom-fr-ca-CEla7RmR.js → CreatedOnDcom-fr-ca-Bh_BTb-O.js} +1 -1
- package/lib/src/{CreatedOnDcom-fr-fr-DRXeVTlV.js → CreatedOnDcom-fr-fr-Clgd_Ujm.js} +1 -1
- package/lib/src/{CreatedOnDcom-pt-br-Bzu_phZc.js → CreatedOnDcom-pt-br-Dlgk0myX.js} +1 -1
- package/lib/src/{CreatedOnDcom-pt-pt-DWax8Er7.js → CreatedOnDcom-pt-pt-B14APfrn.js} +1 -1
- package/lib/src/brand-page/models/brand-page-context.model.d.ts +2 -1
- package/lib/src/brand-page/models/brand-page-context.model.js +5 -0
- package/lib/src/brand-page/models/index.d.ts +1 -0
- package/lib/src/brand-page-maker/components/brand-page-maker/BrandPageMaker.mixin.d.ts +62 -2
- package/lib/src/brand-page-maker/components/brand-page-maker/BrandPageMaker.mixin.js +1 -0
- package/lib/src/brand-page-maker/components/brandpage-maker-page/BrandPageMakerPage.mixin.d.ts +60 -2
- package/lib/src/brand-page-maker/components/preview/Preview.mixin.d.ts +30 -1
- package/lib/src/brand-page-maker/components/quick-link-bar/QuickLinkBar.mixin.d.ts +60 -2
- package/lib/src/brand-page-maker/components/seo-settings/SeoPageSettings.mixin.d.ts +60 -2
- package/lib/src/brand-page-maker/components/seo-settings/UrlSettings.mixin.d.ts +60 -2
- package/lib/src/brand-page-maker/components/seo-settings/UseExistingDomainModal.mixin.d.ts +60 -2
- package/lib/src/brand-page-maker/components/template-preview/TemplatePreview.mixin.d.ts +60 -2
- package/lib/src/brand-page-maker/components/upgrade-to-premium-button/UpgradeToPremiumButton.mixin.d.ts +60 -2
- package/lib/src/brand-page-maker/composables/ai-chat/useAiChat.js +3 -1
- package/lib/src/brand-page-maker/composables/ai-chat/useAiMetadataBuilder.d.ts +1 -1
- package/lib/src/brand-page-maker/composables/ai-chat/useAiMetadataBuilder.js +6 -6
- package/lib/src/brand-page-maker/composables/ai-chat/useAiWebsiteBuilderChat.d.ts +2 -0
- package/lib/src/brand-page-maker/composables/ai-chat/useAiWebsiteBuilderChat.js +258 -0
- package/lib/src/brand-page-maker/constants/sidebar-constant.d.ts +1 -0
- package/lib/src/brand-page-maker/constants/sidebar-constant.js +8 -0
- package/lib/src/brand-page-maker/stores/ai-thread/ai-website-builder-thread-store.d.ts +16 -0
- package/lib/src/brand-page-maker/stores/ai-thread/ai-website-builder-thread-store.js +14 -0
- package/lib/src/brand-page-maker/stores/brandpage-container/brand-page-container-store.d.ts +62 -3
- package/lib/src/brand-page-maker/stores/brandpage-maker/brandpage-maker-store.js +2 -0
- package/lib/src/brand-page-maker/stores/index.d.ts +1 -0
- package/lib/src/brand-page-maker/stores/index.js +1 -0
- package/lib/src/brand-page-maker/stores/snapshot/snapshot-store.d.ts +2 -0
- package/lib/src/brand-page-maker/stores/snapshot/snapshot-store.js +9 -0
- package/lib/src/clients/ai-assistant-client.d.ts +8 -0
- package/lib/src/clients/ai-assistant-client.js +11 -1
- package/lib/src/composables/useSnapshot.js +33 -0
- package/lib/src/css/library.brand-page-brandCrowd.min.css +19 -6
- package/lib/src/css/library.brand-page-brandPage.min.css +19 -6
- package/lib/src/css/library.brand-page-designCom.min.css +19 -6
- package/lib/src/css/library.brand-page-preview.min.css +19 -6
- package/lib/src/index.d.ts +1 -0
- package/lib/src/index.mjs +42 -41
- package/lib/src/{lib-DODSa6QK.js → lib-pOkCQP0J.js} +28820 -26841
- package/lib/src/lib.js +1 -0
- package/lib/src/metadata-builder/ai-metadata-executor.d.ts +1 -1
- package/lib/src/metadata-builder/ai-metadata-executor.js +68 -7
- package/lib/src/metadata-builder/builders/add-page-builder.d.ts +14 -0
- package/lib/src/metadata-builder/builders/add-page-builder.js +66 -0
- package/lib/src/metadata-builder/builders/remove-page-builder.d.ts +13 -0
- package/lib/src/metadata-builder/builders/remove-page-builder.js +50 -0
- package/lib/src/metadata-builder/builders/section-builders/about-section-builder.d.ts +6 -0
- package/lib/src/metadata-builder/builders/section-builders/about-section-builder.js +17 -0
- package/lib/src/metadata-builder/builders/section-builders/banner-section-builder.d.ts +6 -0
- package/lib/src/metadata-builder/builders/section-builders/banner-section-builder.js +25 -0
- package/lib/src/metadata-builder/builders/section-builders/base-section-builder.d.ts +40 -0
- package/lib/src/metadata-builder/builders/section-builders/base-section-builder.js +108 -0
- package/lib/src/metadata-builder/builders/section-builders/button-section-builder.d.ts +6 -0
- package/lib/src/metadata-builder/builders/section-builders/button-section-builder.js +16 -0
- package/lib/src/metadata-builder/builders/section-builders/contact-form-builder.d.ts +6 -0
- package/lib/src/metadata-builder/builders/section-builders/contact-form-builder.js +27 -0
- package/lib/src/metadata-builder/builders/section-builders/delete-section-builder.d.ts +13 -0
- package/lib/src/metadata-builder/builders/section-builders/delete-section-builder.js +37 -0
- package/lib/src/metadata-builder/builders/section-builders/divider-section-builder.d.ts +6 -0
- package/lib/src/metadata-builder/builders/section-builders/divider-section-builder.js +16 -0
- package/lib/src/metadata-builder/builders/section-builders/image-gallery-builder.d.ts +6 -0
- package/lib/src/metadata-builder/builders/section-builders/image-gallery-builder.js +76 -0
- package/lib/src/metadata-builder/builders/section-builders/image-section-builder.d.ts +6 -0
- package/lib/src/metadata-builder/builders/section-builders/image-section-builder.js +16 -0
- package/lib/src/metadata-builder/builders/section-builders/images-section-builder.d.ts +6 -0
- package/lib/src/metadata-builder/builders/section-builders/images-section-builder.js +158 -0
- package/lib/src/metadata-builder/builders/section-builders/index.d.ts +17 -0
- package/lib/src/metadata-builder/builders/section-builders/index.js +17 -0
- package/lib/src/metadata-builder/builders/section-builders/mailing-list-builder.d.ts +6 -0
- package/lib/src/metadata-builder/builders/section-builders/mailing-list-builder.js +17 -0
- package/lib/src/metadata-builder/builders/section-builders/mailing-list-section-builder.d.ts +6 -0
- package/lib/src/metadata-builder/builders/section-builders/mailing-list-section-builder.js +16 -0
- package/lib/src/metadata-builder/builders/section-builders/move-section-builder.d.ts +15 -0
- package/lib/src/metadata-builder/builders/section-builders/move-section-builder.js +62 -0
- package/lib/src/metadata-builder/builders/section-builders/profile-section-builder.d.ts +6 -0
- package/lib/src/metadata-builder/builders/section-builders/profile-section-builder.js +16 -0
- package/lib/src/metadata-builder/builders/section-builders/shapes-section-builder.d.ts +6 -0
- package/lib/src/metadata-builder/builders/section-builders/shapes-section-builder.js +162 -0
- package/lib/src/metadata-builder/builders/section-builders/social-links-builder.d.ts +6 -0
- package/lib/src/metadata-builder/builders/section-builders/social-links-builder.js +50 -0
- package/lib/src/metadata-builder/builders/section-builders/testimonial-section-builder.d.ts +6 -0
- package/lib/src/metadata-builder/builders/section-builders/testimonial-section-builder.js +133 -0
- package/lib/src/metadata-builder/builders/section-builders/text-section-builder.d.ts +6 -0
- package/lib/src/metadata-builder/builders/section-builders/text-section-builder.js +154 -0
- package/lib/src/metadata-builder/builders/section-content-factory.d.ts +3 -0
- package/lib/src/metadata-builder/builders/section-content-factory.js +13 -0
- package/lib/src/metadata-builder/builders/section-field-maps.d.ts +12 -0
- package/lib/src/metadata-builder/builders/section-field-maps.js +180 -0
- package/lib/src/metadata-builder/builders/section-field-utils.d.ts +11 -0
- package/lib/src/metadata-builder/builders/section-field-utils.js +109 -0
- package/lib/src/metadata-builder/helpers/rte.helpers.d.ts +6 -0
- package/lib/src/metadata-builder/helpers/rte.helpers.js +16 -1
- package/lib/src/metadata-builder/metadata-executor.js +71 -1
- package/lib/src/metadata-builder/models.d.ts +54 -0
- package/lib/src/metadata-builder/models.js +58 -0
- package/lib/src/metadata-builder/parsers/ai-toolcall-parser.d.ts +51 -3
- package/lib/src/metadata-builder/parsers/ai-toolcall-parser.js +110 -13
- package/lib/src/metadata-builder/parsers/section-tool-arguments.d.ts +285 -0
- package/lib/src/metadata-builder/parsers/section-tool-arguments.js +7 -0
- package/lib/src/shared/content-settings/components/payment-config-field/PaymentConfigField.mixin.d.ts +60 -2
- package/lib/src/shared/logo-settings/components/LogoSettings.mixin.d.ts +60 -2
- package/lib/src/shared/page-settings/components/page-settings/PageSettings.mixin.d.ts +60 -2
- package/lib/src/shared/page-settings/components/page-settings-section-styles/PageSettingsSectionStyles.mixin.d.ts +60 -2
- package/lib/src/shared/publish-brand-page-with-state/PublishBrandPageModalWithState.mixin.d.ts +90 -3
- package/lib/src/shared/side-bar/components/SideBar.mixin.d.ts +61 -2
- package/lib/src/shared/side-bar/components/SideBar.mixin.js +6 -0
- package/lib/src/shared/style-settings/components/StyleSettings.mixin.d.ts +60 -2
- package/lib/src/utils/minify-brand-page-metadata.d.ts +22 -0
- package/lib/src/utils/minify-brand-page-metadata.js +344 -0
- package/package.json +1 -1
- package/src/brand-page/models/brand-page-context.model.ts +12 -3
- package/src/brand-page/models/index.ts +1 -0
- package/src/brand-page-maker/components/ai-website-builder/AiWebsiteBuilder.vue +80 -0
- package/src/brand-page-maker/components/brand-page-maker/BrandPageMaker.mixin.ts +4 -0
- package/src/brand-page-maker/components/brand-page-maker/BrandPageMaker.vue +9 -2
- package/src/brand-page-maker/composables/ai-chat/useAiChat.ts +4 -1
- package/src/brand-page-maker/composables/ai-chat/useAiMetadataBuilder.ts +6 -6
- package/src/brand-page-maker/composables/ai-chat/useAiWebsiteBuilderChat.ts +363 -0
- package/src/brand-page-maker/constants/sidebar-constant.ts +8 -0
- package/src/brand-page-maker/stores/ai-thread/ai-website-builder-thread-store.ts +19 -0
- package/src/brand-page-maker/stores/brandpage-container/brand-page-container-store.ts +3 -1
- package/src/brand-page-maker/stores/brandpage-maker/brandpage-maker-store.ts +4 -0
- package/src/brand-page-maker/stores/index.ts +1 -0
- package/src/brand-page-maker/stores/snapshot/snapshot-store.ts +12 -0
- package/src/clients/ai-assistant-client.ts +17 -1
- package/src/composables/useSnapshot.ts +47 -0
- package/src/lib.ts +4 -0
- package/src/metadata-builder/ai-metadata-executor.ts +116 -26
- package/src/metadata-builder/builders/add-page-builder.ts +98 -0
- package/src/metadata-builder/builders/remove-page-builder.ts +83 -0
- package/src/metadata-builder/builders/section-builders/about-section-builder.ts +28 -0
- package/src/metadata-builder/builders/section-builders/banner-section-builder.ts +45 -0
- package/src/metadata-builder/builders/section-builders/base-section-builder.ts +160 -0
- package/src/metadata-builder/builders/section-builders/button-section-builder.ts +24 -0
- package/src/metadata-builder/builders/section-builders/contact-form-builder.ts +43 -0
- package/src/metadata-builder/builders/section-builders/delete-section-builder.ts +63 -0
- package/src/metadata-builder/builders/section-builders/divider-section-builder.ts +27 -0
- package/src/metadata-builder/builders/section-builders/image-gallery-builder.ts +111 -0
- package/src/metadata-builder/builders/section-builders/image-section-builder.ts +24 -0
- package/src/metadata-builder/builders/section-builders/images-section-builder.ts +223 -0
- package/src/metadata-builder/builders/section-builders/index.ts +21 -0
- package/src/metadata-builder/builders/section-builders/mailing-list-builder.ts +29 -0
- package/src/metadata-builder/builders/section-builders/mailing-list-section-builder.ts +27 -0
- package/src/metadata-builder/builders/section-builders/move-section-builder.ts +100 -0
- package/src/metadata-builder/builders/section-builders/profile-section-builder.ts +27 -0
- package/src/metadata-builder/builders/section-builders/shapes-section-builder.ts +231 -0
- package/src/metadata-builder/builders/section-builders/social-links-builder.ts +79 -0
- package/src/metadata-builder/builders/section-builders/testimonial-section-builder.ts +194 -0
- package/src/metadata-builder/builders/section-builders/text-section-builder.ts +234 -0
- package/src/metadata-builder/builders/section-content-factory.ts +20 -0
- package/src/metadata-builder/builders/section-field-maps.ts +235 -0
- package/src/metadata-builder/builders/section-field-utils.ts +157 -0
- package/src/metadata-builder/helpers/rte.helpers.ts +23 -1
- package/src/metadata-builder/metadata-executor.ts +96 -4
- package/src/metadata-builder/models.ts +62 -0
- package/src/metadata-builder/parsers/ai-toolcall-parser.ts +141 -17
- package/src/metadata-builder/parsers/section-tool-arguments.ts +417 -0
- package/src/shared/side-bar/components/SideBar.mixin.ts +10 -0
- package/src/utils/minify-brand-page-metadata.ts +407 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { BuilderResult } from '@src/metadata-builder/models';
|
|
2
|
+
import type {
|
|
3
|
+
BrandPageModel,
|
|
4
|
+
MailingListContent,
|
|
5
|
+
} from '../../../brand-page/models';
|
|
6
|
+
import { applyScalarFields } from '../section-field-utils';
|
|
7
|
+
import { BaseSectionBuilder } from './base-section-builder';
|
|
8
|
+
|
|
9
|
+
export class MailingListBuilder extends BaseSectionBuilder<MailingListContent> {
|
|
10
|
+
async buildAsync(model: BrandPageModel): Promise<BuilderResult> {
|
|
11
|
+
this.log('Build called');
|
|
12
|
+
|
|
13
|
+
const validation = await this.validateAsync();
|
|
14
|
+
|
|
15
|
+
if (validation.errors.length) {
|
|
16
|
+
return { request: this.request, model, errors: validation.errors };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const resolved = this.resolveContent(model);
|
|
20
|
+
|
|
21
|
+
if ('error' in resolved) return resolved.error;
|
|
22
|
+
|
|
23
|
+
const content = resolved.content;
|
|
24
|
+
|
|
25
|
+
applyScalarFields(content, this.args, this.sectionType);
|
|
26
|
+
|
|
27
|
+
return { request: this.request, model };
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
MailingListContent,
|
|
3
|
+
BrandPageModel,
|
|
4
|
+
} from '../../../brand-page/models';
|
|
5
|
+
import type { BuilderResult } from '../../models';
|
|
6
|
+
import { applyScalarFields } from '../section-field-utils';
|
|
7
|
+
import { BaseSectionBuilder } from './base-section-builder';
|
|
8
|
+
|
|
9
|
+
export class MailingListSectionBuilder extends BaseSectionBuilder<MailingListContent> {
|
|
10
|
+
async buildAsync(model: BrandPageModel): Promise<BuilderResult> {
|
|
11
|
+
this.log('Build called');
|
|
12
|
+
|
|
13
|
+
const validation = await this.validateAsync();
|
|
14
|
+
|
|
15
|
+
if (validation.errors.length) {
|
|
16
|
+
return { request: this.request, model, errors: validation.errors };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const resolved = this.resolveContent(model);
|
|
20
|
+
|
|
21
|
+
if ('error' in resolved) return resolved.error;
|
|
22
|
+
|
|
23
|
+
applyScalarFields(resolved.content, this.args, this.sectionType);
|
|
24
|
+
|
|
25
|
+
return { request: this.request, model };
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type { BrandPageModel } from '../../../brand-page/models';
|
|
2
|
+
import {
|
|
3
|
+
BaseMetadataBuilder,
|
|
4
|
+
type BuilderResult,
|
|
5
|
+
type MetadataBuilderRequest,
|
|
6
|
+
} from '../../models';
|
|
7
|
+
import type { Logger } from '../../logger';
|
|
8
|
+
|
|
9
|
+
export interface MoveSectionPayload {
|
|
10
|
+
contentId: string;
|
|
11
|
+
position: number;
|
|
12
|
+
targetPageId?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export class MoveSectionBuilder extends BaseMetadataBuilder<MoveSectionPayload> {
|
|
16
|
+
constructor(
|
|
17
|
+
request: MetadataBuilderRequest<MoveSectionPayload>,
|
|
18
|
+
logger?: Logger,
|
|
19
|
+
) {
|
|
20
|
+
super(request, logger);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async validateAsync(): Promise<{ errors: string[] }> {
|
|
24
|
+
const errors: string[] = [];
|
|
25
|
+
const payload = this.request.payload;
|
|
26
|
+
|
|
27
|
+
if (!payload?.contentId) {
|
|
28
|
+
errors.push('contentId is required for move_section');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (payload?.position === undefined || payload.position < 0) {
|
|
32
|
+
errors.push('position must be a non-negative integer');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return { errors };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async buildAsync(model: BrandPageModel): Promise<BuilderResult> {
|
|
39
|
+
this.log('Build called');
|
|
40
|
+
|
|
41
|
+
const validation = await this.validateAsync();
|
|
42
|
+
|
|
43
|
+
if (validation.errors.length) {
|
|
44
|
+
return { request: this.request, model, errors: validation.errors };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const { contentId, position, targetPageId } = this.request.payload!;
|
|
48
|
+
|
|
49
|
+
for (const page of model.pages) {
|
|
50
|
+
const currentIndex = page.contents.findIndex((c) => c.id === contentId);
|
|
51
|
+
|
|
52
|
+
if (currentIndex !== -1) {
|
|
53
|
+
const [section] = page.contents.splice(currentIndex, 1);
|
|
54
|
+
|
|
55
|
+
// Cross-page move: insert into target page
|
|
56
|
+
if (targetPageId && targetPageId !== page.id) {
|
|
57
|
+
const targetPage = model.pages.find((p) => p.id === targetPageId);
|
|
58
|
+
|
|
59
|
+
if (!targetPage) {
|
|
60
|
+
// Undo the splice and return an error
|
|
61
|
+
page.contents.splice(currentIndex, 0, section);
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
request: this.request,
|
|
65
|
+
model,
|
|
66
|
+
errors: [`Target page with ID "${targetPageId}" not found`],
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const targetIndex = Math.min(position, targetPage.contents.length);
|
|
71
|
+
|
|
72
|
+
targetPage.contents.splice(targetIndex, 0, section);
|
|
73
|
+
|
|
74
|
+
this.log({
|
|
75
|
+
message: `Moved section ${contentId} from page ${page.id} index ${currentIndex} to page ${targetPageId} index ${targetIndex}`,
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
return { request: this.request, model };
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Within-page reorder
|
|
82
|
+
const targetIndex = Math.min(position, page.contents.length);
|
|
83
|
+
|
|
84
|
+
page.contents.splice(targetIndex, 0, section);
|
|
85
|
+
|
|
86
|
+
this.log({
|
|
87
|
+
message: `Moved section ${contentId} from index ${currentIndex} to ${targetIndex} on page ${page.id}`,
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
return { request: this.request, model };
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return {
|
|
95
|
+
request: this.request,
|
|
96
|
+
model,
|
|
97
|
+
errors: [`Section with ID "${contentId}" not found`],
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ProfileContent,
|
|
3
|
+
BrandPageModel,
|
|
4
|
+
} from '../../../brand-page/models';
|
|
5
|
+
import type { BuilderResult } from '../../models';
|
|
6
|
+
import { applyScalarFields } from '../section-field-utils';
|
|
7
|
+
import { BaseSectionBuilder } from './base-section-builder';
|
|
8
|
+
|
|
9
|
+
export class ProfileSectionBuilder extends BaseSectionBuilder<ProfileContent> {
|
|
10
|
+
async buildAsync(model: BrandPageModel): Promise<BuilderResult> {
|
|
11
|
+
this.log('Build called');
|
|
12
|
+
|
|
13
|
+
const validation = await this.validateAsync();
|
|
14
|
+
|
|
15
|
+
if (validation.errors.length) {
|
|
16
|
+
return { request: this.request, model, errors: validation.errors };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const resolved = this.resolveContent(model);
|
|
20
|
+
|
|
21
|
+
if ('error' in resolved) return resolved.error;
|
|
22
|
+
|
|
23
|
+
applyScalarFields(resolved.content, this.args, this.sectionType);
|
|
24
|
+
|
|
25
|
+
return { request: this.request, model };
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ShapesSectionContent,
|
|
3
|
+
BrandPageModel,
|
|
4
|
+
} from '../../../brand-page/models';
|
|
5
|
+
import type {
|
|
6
|
+
ShapesSectionArguments,
|
|
7
|
+
ShapesSectionItem,
|
|
8
|
+
} from '../../parsers/section-tool-arguments';
|
|
9
|
+
import type { BuilderResult } from '../../models';
|
|
10
|
+
import {
|
|
11
|
+
applyScalarFields,
|
|
12
|
+
applyStyleFields,
|
|
13
|
+
applyRTEStyles,
|
|
14
|
+
} from '../section-field-utils';
|
|
15
|
+
import { BaseSectionBuilder } from './base-section-builder';
|
|
16
|
+
|
|
17
|
+
const applyShapeItems = (
|
|
18
|
+
content: ShapesSectionContent,
|
|
19
|
+
items: ShapesSectionItem[],
|
|
20
|
+
): void => {
|
|
21
|
+
content.items = items.map((item, index) => ({
|
|
22
|
+
imageUrl: item.shape_url || item.icon_image_url || '',
|
|
23
|
+
imageTitle: '',
|
|
24
|
+
width: 0,
|
|
25
|
+
height: 0,
|
|
26
|
+
mediaType: 'shape',
|
|
27
|
+
imageLink: '',
|
|
28
|
+
title: item.heading || '',
|
|
29
|
+
paragraph: item.text || '',
|
|
30
|
+
itemsId: index,
|
|
31
|
+
colorReplacements: [],
|
|
32
|
+
keepColor: item.keep_color ?? false,
|
|
33
|
+
}));
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const mergeShapeItems = (
|
|
37
|
+
content: ShapesSectionContent,
|
|
38
|
+
items: ShapesSectionItem[],
|
|
39
|
+
replaceAll: boolean,
|
|
40
|
+
): void => {
|
|
41
|
+
const hasIndexedItems = items.some((item) => item.item_index !== undefined);
|
|
42
|
+
|
|
43
|
+
if (hasIndexedItems) {
|
|
44
|
+
for (const item of items) {
|
|
45
|
+
const targetIndex = item.item_index;
|
|
46
|
+
|
|
47
|
+
if (
|
|
48
|
+
targetIndex === undefined ||
|
|
49
|
+
targetIndex < 0 ||
|
|
50
|
+
!content.items?.[targetIndex]
|
|
51
|
+
)
|
|
52
|
+
continue;
|
|
53
|
+
|
|
54
|
+
const existing = content.items[targetIndex];
|
|
55
|
+
|
|
56
|
+
if (item.shape_url !== undefined || item.icon_image_url !== undefined) {
|
|
57
|
+
existing.imageUrl =
|
|
58
|
+
item.shape_url ?? item.icon_image_url ?? existing.imageUrl;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (item.heading !== undefined) existing.title = item.heading;
|
|
62
|
+
|
|
63
|
+
if (item.text !== undefined) existing.paragraph = item.text;
|
|
64
|
+
|
|
65
|
+
if (item.keep_color !== undefined) {
|
|
66
|
+
(existing as any).keepColor = item.keep_color;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const updatedItems = items.map((item, index) => {
|
|
74
|
+
const existing = content.items?.[index];
|
|
75
|
+
const imageUrl =
|
|
76
|
+
item.shape_url ?? item.icon_image_url ?? existing?.imageUrl ?? '';
|
|
77
|
+
|
|
78
|
+
return {
|
|
79
|
+
...(existing || {}),
|
|
80
|
+
imageUrl,
|
|
81
|
+
imageTitle: existing?.imageTitle ?? '',
|
|
82
|
+
width: existing?.width ?? 0,
|
|
83
|
+
height: existing?.height ?? 0,
|
|
84
|
+
mediaType: existing?.mediaType ?? 'shape',
|
|
85
|
+
imageLink: existing?.imageLink ?? '',
|
|
86
|
+
title: item.heading ?? existing?.title ?? '',
|
|
87
|
+
paragraph: item.text ?? existing?.paragraph ?? '',
|
|
88
|
+
itemsId: existing?.itemsId ?? index,
|
|
89
|
+
colorReplacements: existing?.colorReplacements ?? [],
|
|
90
|
+
keepColor:
|
|
91
|
+
item.keep_color ??
|
|
92
|
+
(existing && 'keepColor' in existing ? existing.keepColor : false),
|
|
93
|
+
};
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
if (!replaceAll && content.items && content.items.length > items.length) {
|
|
97
|
+
const remaining = content.items.slice(items.length) as typeof updatedItems;
|
|
98
|
+
|
|
99
|
+
updatedItems.push(...remaining);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
content.items = updatedItems;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export class ShapesSectionBuilder extends BaseSectionBuilder<ShapesSectionContent> {
|
|
106
|
+
async buildAsync(model: BrandPageModel): Promise<BuilderResult> {
|
|
107
|
+
this.log('Build called');
|
|
108
|
+
|
|
109
|
+
const validation = await this.validateAsync();
|
|
110
|
+
|
|
111
|
+
if (validation.errors.length) {
|
|
112
|
+
return { request: this.request, model, errors: validation.errors };
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const resolved = this.resolveContent(model);
|
|
116
|
+
|
|
117
|
+
if ('error' in resolved) return resolved.error;
|
|
118
|
+
|
|
119
|
+
const content = resolved.content;
|
|
120
|
+
|
|
121
|
+
applyScalarFields(content, this.args, this.sectionType);
|
|
122
|
+
applyStyleFields(content, this.args, this.sectionType);
|
|
123
|
+
applyRTEStyles(content, this.args, this.sectionType);
|
|
124
|
+
|
|
125
|
+
const args = this.args as ShapesSectionArguments;
|
|
126
|
+
|
|
127
|
+
if (args.background_style && typeof args.background_style === 'object') {
|
|
128
|
+
const existing = content.backgroundStyle || {};
|
|
129
|
+
|
|
130
|
+
content.backgroundStyle = {
|
|
131
|
+
...existing,
|
|
132
|
+
...Object.fromEntries(
|
|
133
|
+
Object.entries(args.background_style).map(([k, v]) => [
|
|
134
|
+
k,
|
|
135
|
+
v === null ? '' : v,
|
|
136
|
+
]),
|
|
137
|
+
),
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (args.card_style && typeof args.card_style === 'object') {
|
|
142
|
+
const existing = content.cardStyle || {};
|
|
143
|
+
|
|
144
|
+
content.cardStyle = {
|
|
145
|
+
...existing,
|
|
146
|
+
...Object.fromEntries(
|
|
147
|
+
Object.entries(args.card_style).map(([k, v]) => [
|
|
148
|
+
k,
|
|
149
|
+
v === null ? '' : v,
|
|
150
|
+
]),
|
|
151
|
+
),
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (args.items && Array.isArray(args.items)) {
|
|
156
|
+
if (this.mode === 'create') {
|
|
157
|
+
applyShapeItems(content, args.items);
|
|
158
|
+
} else {
|
|
159
|
+
mergeShapeItems(content, args.items, !!args._replace_items);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Phase 2: Item operations (remove, insert, reorder)
|
|
164
|
+
if (args._remove_item_indices?.length && content.items) {
|
|
165
|
+
const sorted = [...args._remove_item_indices].sort((a, b) => b - a);
|
|
166
|
+
|
|
167
|
+
for (const idx of sorted) {
|
|
168
|
+
if (idx >= 0 && idx < content.items.length) {
|
|
169
|
+
content.items.splice(idx, 1);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (args.items && Array.isArray(args.items)) {
|
|
175
|
+
const insertItems = args.items.filter(
|
|
176
|
+
(item) => item.insert_at !== undefined && item.item_index === undefined,
|
|
177
|
+
);
|
|
178
|
+
// Process inserts in reverse order of insert_at to preserve indices
|
|
179
|
+
const sortedInserts = [...insertItems].sort(
|
|
180
|
+
(a, b) => (b.insert_at ?? 0) - (a.insert_at ?? 0),
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
for (const item of sortedInserts) {
|
|
184
|
+
const pos = Math.max(
|
|
185
|
+
0,
|
|
186
|
+
Math.min(item.insert_at ?? 0, content.items?.length ?? 0),
|
|
187
|
+
);
|
|
188
|
+
const newItem = {
|
|
189
|
+
imageUrl: item.shape_url ?? item.icon_image_url ?? '',
|
|
190
|
+
imageTitle: '',
|
|
191
|
+
width: 0,
|
|
192
|
+
height: 0,
|
|
193
|
+
mediaType: 'shape',
|
|
194
|
+
imageLink: '',
|
|
195
|
+
title: item.heading ?? '',
|
|
196
|
+
paragraph: item.text ?? '',
|
|
197
|
+
itemsId: pos,
|
|
198
|
+
colorReplacements: [],
|
|
199
|
+
keepColor: item.keep_color ?? false,
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
content.items = content.items ?? [];
|
|
203
|
+
content.items.splice(pos, 0, newItem as any);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (args._reorder_items?.length && content.items) {
|
|
208
|
+
const newOrder = args._reorder_items;
|
|
209
|
+
const unique = new Set(newOrder);
|
|
210
|
+
|
|
211
|
+
if (unique.size === newOrder.length) {
|
|
212
|
+
const reordered = newOrder
|
|
213
|
+
.filter((idx) => idx >= 0 && idx < content.items!.length)
|
|
214
|
+
.map((idx) => content.items![idx]);
|
|
215
|
+
|
|
216
|
+
if (reordered.length === content.items.length) {
|
|
217
|
+
content.items = reordered;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// Re-index itemsId after any item operations
|
|
223
|
+
if (content.items) {
|
|
224
|
+
content.items.forEach((item, i) => {
|
|
225
|
+
item.itemsId = i;
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return { request: this.request, model };
|
|
230
|
+
}
|
|
231
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
SocialLinksContent,
|
|
3
|
+
BrandPageModel,
|
|
4
|
+
} from '../../../brand-page/models';
|
|
5
|
+
import type {
|
|
6
|
+
SocialLink,
|
|
7
|
+
SocialLinksSectionArguments,
|
|
8
|
+
} from '../../parsers/section-tool-arguments';
|
|
9
|
+
import type { BuilderResult } from '../../models';
|
|
10
|
+
import { applyScalarFields } from '../section-field-utils';
|
|
11
|
+
import { BaseSectionBuilder } from './base-section-builder';
|
|
12
|
+
|
|
13
|
+
const applySocialLinks = (
|
|
14
|
+
content: SocialLinksContent,
|
|
15
|
+
links: SocialLink[],
|
|
16
|
+
): void => {
|
|
17
|
+
content.links = links.map((link) => ({
|
|
18
|
+
imageUrl: link.platform || '',
|
|
19
|
+
imageTitle: '',
|
|
20
|
+
width: 0,
|
|
21
|
+
height: 0,
|
|
22
|
+
imageLink: '',
|
|
23
|
+
url: link.url || '',
|
|
24
|
+
}));
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const mergeSocialLinks = (
|
|
28
|
+
content: SocialLinksContent,
|
|
29
|
+
links: SocialLink[],
|
|
30
|
+
replaceAll: boolean,
|
|
31
|
+
): void => {
|
|
32
|
+
const updatedLinks = links.map((link, index) => {
|
|
33
|
+
const existing = content.links?.[index];
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
...(existing || {}),
|
|
37
|
+
imageUrl: link.platform ?? existing?.imageUrl ?? '',
|
|
38
|
+
url: link.url ?? existing?.url ?? '',
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
if (!replaceAll && content.links && content.links.length > links.length) {
|
|
43
|
+
updatedLinks.push(...content.links.slice(links.length));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
content.links = updatedLinks;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export class SocialLinksBuilder extends BaseSectionBuilder<SocialLinksContent> {
|
|
50
|
+
async buildAsync(model: BrandPageModel): Promise<BuilderResult> {
|
|
51
|
+
this.log('Build called');
|
|
52
|
+
|
|
53
|
+
const validation = await this.validateAsync();
|
|
54
|
+
|
|
55
|
+
if (validation.errors.length) {
|
|
56
|
+
return { request: this.request, model, errors: validation.errors };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const resolved = this.resolveContent(model);
|
|
60
|
+
|
|
61
|
+
if ('error' in resolved) return resolved.error;
|
|
62
|
+
|
|
63
|
+
const content = resolved.content;
|
|
64
|
+
|
|
65
|
+
applyScalarFields(content, this.args, this.sectionType);
|
|
66
|
+
|
|
67
|
+
const args = this.args as SocialLinksSectionArguments;
|
|
68
|
+
|
|
69
|
+
if (args.links && Array.isArray(args.links)) {
|
|
70
|
+
if (this.mode === 'create') {
|
|
71
|
+
applySocialLinks(content, args.links);
|
|
72
|
+
} else {
|
|
73
|
+
mergeSocialLinks(content, args.links, !!args._replace_items);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return { request: this.request, model };
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
TestimonialSectionContent,
|
|
3
|
+
BrandPageModel,
|
|
4
|
+
} from '../../../brand-page/models';
|
|
5
|
+
import type {
|
|
6
|
+
TestimonialItem,
|
|
7
|
+
TestimonialSectionArguments,
|
|
8
|
+
} from '../../parsers/section-tool-arguments';
|
|
9
|
+
import type { BuilderResult } from '../../models';
|
|
10
|
+
import { applyScalarFields, applyStyleFields } from '../section-field-utils';
|
|
11
|
+
import { BaseSectionBuilder } from './base-section-builder';
|
|
12
|
+
|
|
13
|
+
const applyTestimonialItems = (
|
|
14
|
+
content: TestimonialSectionContent,
|
|
15
|
+
items: TestimonialItem[],
|
|
16
|
+
): void => {
|
|
17
|
+
content.items = items.map((item) => ({
|
|
18
|
+
imageUrl: item.avatar_image_url || '',
|
|
19
|
+
name: item.name || '',
|
|
20
|
+
position: item.position || '',
|
|
21
|
+
testimonials: item.testimonial || '',
|
|
22
|
+
colorReplacements: [],
|
|
23
|
+
mediaType: 'image',
|
|
24
|
+
}));
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const mergeTestimonialItems = (
|
|
28
|
+
content: TestimonialSectionContent,
|
|
29
|
+
items: TestimonialItem[],
|
|
30
|
+
replaceAll: boolean,
|
|
31
|
+
): void => {
|
|
32
|
+
const hasIndexedItems = items.some((item) => item.item_index !== undefined);
|
|
33
|
+
|
|
34
|
+
if (hasIndexedItems) {
|
|
35
|
+
for (const item of items) {
|
|
36
|
+
const targetIndex = item.item_index;
|
|
37
|
+
|
|
38
|
+
if (
|
|
39
|
+
targetIndex === undefined ||
|
|
40
|
+
targetIndex < 0 ||
|
|
41
|
+
!content.items?.[targetIndex]
|
|
42
|
+
)
|
|
43
|
+
continue;
|
|
44
|
+
|
|
45
|
+
const existing = content.items[targetIndex];
|
|
46
|
+
|
|
47
|
+
if (item.avatar_image_url !== undefined)
|
|
48
|
+
existing.imageUrl = item.avatar_image_url;
|
|
49
|
+
|
|
50
|
+
if (item.name !== undefined) existing.name = item.name;
|
|
51
|
+
|
|
52
|
+
if (item.position !== undefined) existing.position = item.position;
|
|
53
|
+
|
|
54
|
+
if (item.testimonial !== undefined)
|
|
55
|
+
existing.testimonials = item.testimonial;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const updatedItems = items.map((item, index) => {
|
|
62
|
+
const existing = content.items?.[index];
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
...(existing || {}),
|
|
66
|
+
imageUrl: item.avatar_image_url ?? existing?.imageUrl ?? '',
|
|
67
|
+
name: item.name ?? existing?.name ?? '',
|
|
68
|
+
position: item.position ?? existing?.position ?? '',
|
|
69
|
+
testimonials: item.testimonial ?? existing?.testimonials ?? '',
|
|
70
|
+
colorReplacements: existing?.colorReplacements ?? [],
|
|
71
|
+
mediaType: existing?.mediaType ?? 'image',
|
|
72
|
+
};
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
if (!replaceAll && content.items && content.items.length > items.length) {
|
|
76
|
+
updatedItems.push(...content.items.slice(items.length));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
content.items = updatedItems;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export class TestimonialSectionBuilder extends BaseSectionBuilder<TestimonialSectionContent> {
|
|
83
|
+
async buildAsync(model: BrandPageModel): Promise<BuilderResult> {
|
|
84
|
+
this.log('Build called');
|
|
85
|
+
|
|
86
|
+
const validation = await this.validateAsync();
|
|
87
|
+
|
|
88
|
+
if (validation.errors.length) {
|
|
89
|
+
return { request: this.request, model, errors: validation.errors };
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const resolved = this.resolveContent(model);
|
|
93
|
+
|
|
94
|
+
if ('error' in resolved) return resolved.error;
|
|
95
|
+
|
|
96
|
+
const content = resolved.content;
|
|
97
|
+
|
|
98
|
+
applyScalarFields(content, this.args, this.sectionType);
|
|
99
|
+
applyStyleFields(content, this.args, this.sectionType);
|
|
100
|
+
|
|
101
|
+
const args = this.args as TestimonialSectionArguments;
|
|
102
|
+
|
|
103
|
+
if (args.background_style && typeof args.background_style === 'object') {
|
|
104
|
+
const existing = content.backgroundStyle || {};
|
|
105
|
+
|
|
106
|
+
content.backgroundStyle = {
|
|
107
|
+
...existing,
|
|
108
|
+
...Object.fromEntries(
|
|
109
|
+
Object.entries(args.background_style).map(([k, v]) => [
|
|
110
|
+
k,
|
|
111
|
+
v === null ? '' : v,
|
|
112
|
+
]),
|
|
113
|
+
),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (args.card_style && typeof args.card_style === 'object') {
|
|
118
|
+
const existing = content.cardStyle || {};
|
|
119
|
+
|
|
120
|
+
content.cardStyle = {
|
|
121
|
+
...existing,
|
|
122
|
+
...Object.fromEntries(
|
|
123
|
+
Object.entries(args.card_style).map(([k, v]) => [
|
|
124
|
+
k,
|
|
125
|
+
v === null ? '' : v,
|
|
126
|
+
]),
|
|
127
|
+
),
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (args.items && Array.isArray(args.items)) {
|
|
132
|
+
if (this.mode === 'create') {
|
|
133
|
+
applyTestimonialItems(content, args.items);
|
|
134
|
+
} else {
|
|
135
|
+
mergeTestimonialItems(content, args.items, !!args._replace_items);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Phase 2: Item operations (remove, insert, reorder)
|
|
140
|
+
if (args._remove_item_indices?.length && content.items) {
|
|
141
|
+
const sorted = [...args._remove_item_indices].sort((a, b) => b - a);
|
|
142
|
+
|
|
143
|
+
for (const idx of sorted) {
|
|
144
|
+
if (idx >= 0 && idx < content.items.length) {
|
|
145
|
+
content.items.splice(idx, 1);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (args.items && Array.isArray(args.items)) {
|
|
151
|
+
const insertItems = args.items.filter(
|
|
152
|
+
(item) => item.insert_at !== undefined && item.item_index === undefined,
|
|
153
|
+
);
|
|
154
|
+
const sortedInserts = [...insertItems].sort(
|
|
155
|
+
(a, b) => (b.insert_at ?? 0) - (a.insert_at ?? 0),
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
for (const item of sortedInserts) {
|
|
159
|
+
const pos = Math.max(
|
|
160
|
+
0,
|
|
161
|
+
Math.min(item.insert_at ?? 0, content.items?.length ?? 0),
|
|
162
|
+
);
|
|
163
|
+
const newItem = {
|
|
164
|
+
imageUrl: item.avatar_image_url ?? '',
|
|
165
|
+
name: item.name ?? '',
|
|
166
|
+
position: item.position ?? '',
|
|
167
|
+
testimonials: item.testimonial ?? '',
|
|
168
|
+
colorReplacements: [],
|
|
169
|
+
mediaType: 'image',
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
content.items = content.items ?? [];
|
|
173
|
+
content.items.splice(pos, 0, newItem as any);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (args._reorder_items?.length && content.items) {
|
|
178
|
+
const newOrder = args._reorder_items;
|
|
179
|
+
const unique = new Set(newOrder);
|
|
180
|
+
|
|
181
|
+
if (unique.size === newOrder.length) {
|
|
182
|
+
const reordered = newOrder
|
|
183
|
+
.filter((idx) => idx >= 0 && idx < content.items!.length)
|
|
184
|
+
.map((idx) => content.items![idx]);
|
|
185
|
+
|
|
186
|
+
if (reordered.length === content.items.length) {
|
|
187
|
+
content.items = reordered;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return { request: this.request, model };
|
|
193
|
+
}
|
|
194
|
+
}
|