feat(builder): visual footer builder with drag-and-drop columns

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

P0 user feedback: footer static pages were comma-separated text; no way to add extra phones/emails for different countries.

- New FooterColumnConfig/FooterLinkConfig model (footer-config.model.ts): columns of links, each link pointing at an existing static page (resolved by key, so it survives route renames) or a custom URL
- Footer Builder UI: add/remove columns and links, per-link toggle between 'existing page' (dropdown of real static pages) and 'custom URL', drag-and-drop reordering of both columns and links via @angular/cdk/drag-drop (same primitive already used by the homepage section builder)
- Wired FooterResolverService (the service the real storefront footer actually renders through) to read footer.columns as the primary source when present - without this the builder would have saved data nobody ever displayed. Falls back to the existing legacy static-page auto-grouping when no columns are configured, so existing sites are unaffected
- CompanyContactConfig gains additionalPhones/additionalEmails (primary phone/email field unchanged) with add/remove UI for country-specific support lines
- Old comma-separated staticPageKeys input removed from the UI; field kept on the model as deprecated/read-compat only
- New builder.* i18n keys (en/ru/hy); fixed an accidental duplicate-key collision with pre-existing navigation-section addLink/removeLink keys during the rename pass
- Verified in browser: added column, added link, switched link source page->custom, added phone number - all reactive and error-free
This commit is contained in:
sdarbinyan
2026-07-19 13:58:57 +04:00
parent 3b955b116a
commit 726df0cee0
10 changed files with 420 additions and 16 deletions

View File

@@ -3,6 +3,7 @@ import { map, Observable } from 'rxjs';
import { ConfigService } from './config.service';
import {
BootstrapConfig,
FooterColumnConfig,
FooterConfig,
FooterNavigationGroupConfig,
FooterNavigationItemConfig,
@@ -63,6 +64,20 @@ export class FooterResolverService {
private resolveFooterGroups(bootstrap: BootstrapConfig): FooterResolvedGroup[] {
const footer = bootstrap.navigation?.footer ?? [];
const lang = this.languageService.currentLanguage();
// Footer Builder columns (admin/edit/footer) take priority over both the
// legacy grouped-navigation config and the auto-grouped-by-static-page
// fallback below - once a merchant builds columns, that's their footer.
if (bootstrap.footer?.columns?.length) {
const groups = this.resolveGroupsFromColumns(bootstrap.footer.columns, bootstrap, lang)
.filter(group => group.items.length > 0);
const social = this.resolveSocialGroup(bootstrap.footer);
if (social) {
groups.push(social);
}
return groups;
}
const contentPages = this.resolveBootstrapStaticPages(bootstrap, lang);
if (this.isGroupedFooter(footer)) {
@@ -118,13 +133,9 @@ export class FooterResolverService {
groups.get(groupId)!.items.push({ id: resolved.id, label: resolved.title, route: resolved.route });
}
const socialLinks = bootstrap.footer?.socialLinks ?? [];
if (socialLinks.length > 0) {
groups.set('footer-group-social', {
id: 'footer-group-social',
title: 'Social',
items: socialLinks.map(link => ({ id: link.id, label: link.label, route: link.url, external: true }))
});
const social = this.resolveSocialGroup(bootstrap.footer);
if (social) {
groups.set(social.id, social);
}
return [...groups.values()].map(group => ({
@@ -133,6 +144,41 @@ export class FooterResolverService {
}));
}
private resolveSocialGroup(footerConfig: FooterConfig | undefined): FooterResolvedGroup | null {
const socialLinks = footerConfig?.socialLinks ?? [];
if (socialLinks.length === 0) {
return null;
}
return {
id: 'footer-group-social',
title: 'Social',
items: socialLinks.map(link => ({ id: link.id, label: link.label, route: link.url, external: true }))
};
}
/** Footer Builder columns -> resolved groups. Page-linked entries resolve through StaticPageResolverService (so a page's route stays correct even if it changes); custom URLs pass through as external links. */
private resolveGroupsFromColumns(columns: FooterColumnConfig[], bootstrap: BootstrapConfig, lang: string): FooterResolvedGroup[] {
return columns.map((column, index) => ({
id: column.id || `footer-group-${index}`,
title: column.title,
items: column.links
.map((link): FooterResolvedItem | null => {
if (link.pageKey) {
const staticPage = this.staticPageResolver.resolveByKeyFromBootstrap(bootstrap, link.pageKey, lang);
if (!staticPage) {
return null;
}
return { id: link.id, label: link.label || staticPage.title, route: staticPage.route };
}
if (!link.url) {
return null;
}
return { id: link.id, label: link.label || link.url, route: link.url, external: true };
})
.filter((item): item is FooterResolvedItem => item !== null),
}));
}
private resolveGroupFromConfig(
group: FooterNavigationGroupConfig,
bootstrap: BootstrapConfig,