Files
marketplaces/src/app/features/project-editor/sections/footer-section.component.ts

229 lines
10 KiB
TypeScript
Raw Normal View History

2026-07-10 13:43:53 +04:00
import { ChangeDetectionStrategy, Component, computed, inject } from '@angular/core';
import { FormsModule } from '@angular/forms';
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
2026-07-19 13:58:57 +04:00
import { CdkDragDrop, DragDropModule, moveItemInArray } from '@angular/cdk/drag-drop';
2026-07-10 13:43:53 +04:00
import { ProjectEditorFacade } from '../facade/project-editor.facade';
import { TranslatePipe } from '../../../i18n/translate.pipe';
import { TranslateService } from '../../../i18n/translate.service';
import { InputComponent } from '../../../shared/ui/input/input.component';
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
2026-07-19 13:58:57 +04:00
import { ButtonComponent } from '../../../shared/ui/button/button.component';
import { FormFieldComponent } from '../../../shared/ui/form-field/form-field.component';
import { SectionCardComponent } from '../../../shared/ui/section-card/section-card.component';
import { KeyValueEditorComponent } from '../../../shared/ui/key-value-editor/key-value-editor.component';
import { ImageFieldComponent } from '../../../shared/ui/image-field/image-field.component';
import { IconComponent } from '../../../shared/ui/icon/icon.component';
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
2026-07-19 13:58:57 +04:00
import { FooterColumnConfig, FooterLinkConfig, FooterPaymentIconConfig, FooterSocialLinkConfig } from '../../../shared/models/config';
import { isValidHttpUrl } from '../schema/validators/primitives';
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
2026-07-19 13:58:57 +04:00
import { ContentPageService } from '../../content-management/services/content-page.service';
2026-07-10 13:43:53 +04:00
@Component({
selector: 'app-project-editor-footer-section',
standalone: true,
imports: [
FormsModule,
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
2026-07-19 13:58:57 +04:00
DragDropModule,
TranslatePipe,
InputComponent,
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
2026-07-19 13:58:57 +04:00
ButtonComponent,
FormFieldComponent,
SectionCardComponent,
KeyValueEditorComponent,
ImageFieldComponent,
IconComponent
],
2026-07-10 13:43:53 +04:00
templateUrl: './footer-section.component.html',
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
2026-07-19 13:58:57 +04:00
styleUrls: ['./section.shared.scss', './footer-section.component.scss'],
2026-07-10 13:43:53 +04:00
changeDetection: ChangeDetectionStrategy.OnPush
})
export class ProjectEditorFooterSectionComponent {
private readonly facade = inject(ProjectEditorFacade);
private readonly translate = inject(TranslateService);
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
2026-07-19 13:58:57 +04:00
private readonly contentPageService = inject(ContentPageService);
2026-07-10 13:43:53 +04:00
readonly bootstrap = this.facade.bootstrap;
readonly fieldError = (key: string): string | null => {
const messageKey = this.facade.fieldError(key);
return messageKey ? this.translate.t(messageKey) : null;
};
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
2026-07-19 13:58:57 +04:00
/** Existing static pages, offered as the primary way to link a footer column - stays correct if a page's route changes later. */
readonly availablePages = computed(() => this.contentPageService.normalizePages(this.bootstrap()?.staticPages));
2026-07-10 13:43:53 +04:00
readonly copyrightValue = computed(() => {
const value = this.bootstrap()?.footer?.copyrightText;
return typeof value === 'string' ? value : '';
});
readonly paymentIconRows = computed<FooterPaymentIconConfig[]>(() => this.bootstrap()?.footer?.paymentIcons ?? []);
readonly socialLinkRows = computed<FooterSocialLinkConfig[]>(() => this.bootstrap()?.footer?.socialLinks ?? []);
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
2026-07-19 13:58:57 +04:00
readonly columns = computed<FooterColumnConfig[]>(() => this.bootstrap()?.footer?.columns ?? []);
readonly additionalPhones = computed<string[]>(() => this.bootstrap()?.company.contacts.additionalPhones ?? []);
readonly additionalEmails = computed<string[]>(() => this.bootstrap()?.company.contacts.additionalEmails ?? []);
readonly createPaymentIconRow = (): FooterPaymentIconConfig => ({ src: '', alt: '' });
readonly createSocialLinkRow = (): FooterSocialLinkConfig => ({ id: `social-${Date.now()}`, label: '', url: '' });
2026-07-10 13:43:53 +04:00
updateCompanyName(value: string): void { this.facade.updateBootstrap(current => ({ ...current, company: { ...current.company, companyName: value } })); }
updateAddress(value: string): void { this.facade.updateBootstrap(current => ({ ...current, company: { ...current.company, address: { ...current.company.address, street: value } } })); }
updatePhone(value: string): void { this.facade.updateBootstrap(current => ({ ...current, company: { ...current.company, contacts: { ...current.company.contacts, phone: value } }, branding: { ...current.branding, supportPhone: value } })); }
updateEmail(value: string): void { this.facade.updateBootstrap(current => ({ ...current, company: { ...current.company, contacts: { ...current.company.contacts, email: value } }, branding: { ...current.branding, supportEmail: value } })); }
updateCopyright(value: string): void { this.facade.updateBootstrap(current => ({ ...current, footer: { ...current.footer, copyrightText: value } })); }
updateLogo(value: string): void {
this.facade.updateBootstrap(current => ({ ...current, footer: { ...current.footer, logoUrl: value } }));
}
onPaymentIconsChange(rows: FooterPaymentIconConfig[]): void {
this.facade.updateBootstrap(current => ({ ...current, footer: { ...current.footer, paymentIcons: rows } }));
}
updatePaymentIconSrc(index: number, src: string): void {
const rows = this.paymentIconRows().map((row, i) => (i === index ? { ...row, src } : row));
this.onPaymentIconsChange(rows);
}
updatePaymentIconAlt(index: number, alt: string): void {
const rows = this.paymentIconRows().map((row, i) => (i === index ? { ...row, alt } : row));
this.onPaymentIconsChange(rows);
}
onSocialLinksChange(rows: FooterSocialLinkConfig[]): void {
this.facade.updateBootstrap(current => ({ ...current, footer: { ...current.footer, socialLinks: rows } }));
}
updateSocialLinkLabel(index: number, label: string): void {
const rows = this.socialLinkRows().map((row, i) => (i === index ? { ...row, label } : row));
this.onSocialLinksChange(rows);
}
updateSocialLinkUrl(index: number, url: string): void {
const rows = this.socialLinkRows().map((row, i) => (i === index ? { ...row, url } : row));
this.onSocialLinksChange(rows);
}
isValidUrl(url: string): boolean {
return !url || isValidHttpUrl(url);
}
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
2026-07-19 13:58:57 +04:00
// --- Footer columns (replaces the old comma-separated static-page-keys input) ---
private setColumns(columns: FooterColumnConfig[]): void {
this.facade.updateBootstrap(current => ({ ...current, footer: { ...current.footer, columns } }));
}
addColumn(): void {
this.setColumns([...this.columns(), { id: `col-${Date.now()}`, title: '', links: [] }]);
}
removeColumn(columnId: string): void {
this.setColumns(this.columns().filter(column => column.id !== columnId));
}
updateColumnTitle(columnId: string, title: string): void {
this.setColumns(this.columns().map(column => column.id === columnId ? { ...column, title } : column));
}
dropColumn(event: CdkDragDrop<FooterColumnConfig[]>): void {
const columns = [...this.columns()];
moveItemInArray(columns, event.previousIndex, event.currentIndex);
this.setColumns(columns);
}
fix(builder): WCAG 2.1 AA accessibility fixes RC A11Y-01 audit pass, Builder (project-editor) + content-management static pages editor. Builds on 4ebc15f's composition pass without redoing it. - Skip link: Builder's /edit and /edit/:section routes render outside the storefront app-shell (isAdminRoute() branch has no skip link/landmark, only a bare router-outlet, unlike the storefront's app.html) - added a "skip to content" link targeting a new #builder-main-content landmark on project-editor-page.component, reusing the existing adminShell.skipToContent key and global .skip-link style. Nav landmark already had aria-label (builder.appName) from the prior pass, verified correct. - Save bar: added role="status"/aria-live="polite" to the save/publish status block and role="status" to the draft-restored notice so save/publish state changes and draft recovery are announced to screen readers (previously silent DOM updates). - Media picker (shared, used by both Builder and static-pages editor): upload error message had no aria-live wiring - added role="alert". - HTML editor (marketplace-html-editor): the contenteditable rich-text surface had no accessible role/name - added role="textbox", aria-multiline="true", aria-label. - Drag-and-drop keyboard fallback (WCAG 2.1.1): homepage-section's block list and footer-section's column list + per-column link list use Angular CDK drag-drop (cdkDrag/cdkDropList), which has no built-in keyboard reordering. Added move-up/move-down icon buttons (disabled at the first/last boundary), matching the existing pattern already used by widgets-section and navigation-section. - Color picker: the swatch <input type="color"> had no accessible name (only the paired text input was labelled via app-form-field) - added explicit ariaLabel bindings to all 8 color-picker instances in theme-section. - Languages: the new-locale code input relied on a placeholder ("de") as its only accessible name - added ariaLabel + new builder.newLanguageLabel i18n key (en/ru/hy). - Undefined CSS var --color-primary (never defined anywhere, silently used its hardcoded hex fallback and never responded to tenant theming - same recurring bug class as 4ebc15f) - remapped to the real --primary-color token in marketplace-html-editor, homepage-section, and section.shared (7 usages). - role="alert" added to all 11 validation-error <p class="editor-error"> occurrences across footer/homepage/languages/navigation/preview/widgets sections and the static-pages editor, so field/section validation messages are announced. - scope="col" added to preview-section's change-summary table headers. Flagged, not fixed (design-system decisions, matching the storefront pass's precedent): - Save bar's --warning-color/--error-color/--info-color text fail WCAG AA 4.5:1 in some themes - same genuine brand semantic colors flagged (not fixed) in fb1afb7's storefront pass; needs a deliberate token decision, not a Builder-specific issue. - locale-tabs (app-locale-tabs, shared) has role="tablist"/"tab" and aria-selected but no roving-tabindex/arrow-key navigation - matches the same partial-tablist pattern already accepted for product-tabs in the storefront pass; all tabs remain natively Tab-focusable, so this meets 4.1.2/2.1.1 without the full ARIA authoring-practice pattern. Verified: npx tsc --noEmit clean; npm run build green (only the pre-existing bundle-budget warning, unrelated to this pass). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-24 09:01:38 +04:00
/** Keyboard-operable fallback for the drag-and-drop column reorder above (WCAG 2.1.1). */
moveColumn(columnId: string, direction: -1 | 1): void {
const columns = [...this.columns()];
const index = columns.findIndex(column => column.id === columnId);
const targetIndex = index + direction;
if (index === -1 || targetIndex < 0 || targetIndex >= columns.length) {
return;
}
moveItemInArray(columns, index, targetIndex);
this.setColumns(columns);
}
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
2026-07-19 13:58:57 +04:00
addLink(columnId: string): void {
const link: FooterLinkConfig = { id: `link-${Date.now()}`, label: '', pageKey: this.availablePages()[0]?.id ?? '', url: '' };
this.setColumns(this.columns().map(column => column.id === columnId ? { ...column, links: [...column.links, link] } : column));
}
removeLink(columnId: string, linkId: string): void {
this.setColumns(this.columns().map(column => column.id === columnId ? { ...column, links: column.links.filter(link => link.id !== linkId) } : column));
}
updateLink(columnId: string, linkId: string, patch: Partial<FooterLinkConfig>): void {
this.setColumns(this.columns().map(column => column.id === columnId
? { ...column, links: column.links.map(link => link.id === linkId ? { ...link, ...patch } : link) }
: column));
}
dropLink(columnId: string, event: CdkDragDrop<FooterLinkConfig[]>): void {
const column = this.columns().find(c => c.id === columnId);
if (!column) {
return;
}
const links = [...column.links];
moveItemInArray(links, event.previousIndex, event.currentIndex);
this.setColumns(this.columns().map(c => c.id === columnId ? { ...c, links } : c));
}
fix(builder): WCAG 2.1 AA accessibility fixes RC A11Y-01 audit pass, Builder (project-editor) + content-management static pages editor. Builds on 4ebc15f's composition pass without redoing it. - Skip link: Builder's /edit and /edit/:section routes render outside the storefront app-shell (isAdminRoute() branch has no skip link/landmark, only a bare router-outlet, unlike the storefront's app.html) - added a "skip to content" link targeting a new #builder-main-content landmark on project-editor-page.component, reusing the existing adminShell.skipToContent key and global .skip-link style. Nav landmark already had aria-label (builder.appName) from the prior pass, verified correct. - Save bar: added role="status"/aria-live="polite" to the save/publish status block and role="status" to the draft-restored notice so save/publish state changes and draft recovery are announced to screen readers (previously silent DOM updates). - Media picker (shared, used by both Builder and static-pages editor): upload error message had no aria-live wiring - added role="alert". - HTML editor (marketplace-html-editor): the contenteditable rich-text surface had no accessible role/name - added role="textbox", aria-multiline="true", aria-label. - Drag-and-drop keyboard fallback (WCAG 2.1.1): homepage-section's block list and footer-section's column list + per-column link list use Angular CDK drag-drop (cdkDrag/cdkDropList), which has no built-in keyboard reordering. Added move-up/move-down icon buttons (disabled at the first/last boundary), matching the existing pattern already used by widgets-section and navigation-section. - Color picker: the swatch <input type="color"> had no accessible name (only the paired text input was labelled via app-form-field) - added explicit ariaLabel bindings to all 8 color-picker instances in theme-section. - Languages: the new-locale code input relied on a placeholder ("de") as its only accessible name - added ariaLabel + new builder.newLanguageLabel i18n key (en/ru/hy). - Undefined CSS var --color-primary (never defined anywhere, silently used its hardcoded hex fallback and never responded to tenant theming - same recurring bug class as 4ebc15f) - remapped to the real --primary-color token in marketplace-html-editor, homepage-section, and section.shared (7 usages). - role="alert" added to all 11 validation-error <p class="editor-error"> occurrences across footer/homepage/languages/navigation/preview/widgets sections and the static-pages editor, so field/section validation messages are announced. - scope="col" added to preview-section's change-summary table headers. Flagged, not fixed (design-system decisions, matching the storefront pass's precedent): - Save bar's --warning-color/--error-color/--info-color text fail WCAG AA 4.5:1 in some themes - same genuine brand semantic colors flagged (not fixed) in fb1afb7's storefront pass; needs a deliberate token decision, not a Builder-specific issue. - locale-tabs (app-locale-tabs, shared) has role="tablist"/"tab" and aria-selected but no roving-tabindex/arrow-key navigation - matches the same partial-tablist pattern already accepted for product-tabs in the storefront pass; all tabs remain natively Tab-focusable, so this meets 4.1.2/2.1.1 without the full ARIA authoring-practice pattern. Verified: npx tsc --noEmit clean; npm run build green (only the pre-existing bundle-budget warning, unrelated to this pass). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-24 09:01:38 +04:00
/** Keyboard-operable fallback for the drag-and-drop link reorder above (WCAG 2.1.1). */
moveLink(columnId: string, linkId: string, direction: -1 | 1): void {
const column = this.columns().find(c => c.id === columnId);
if (!column) {
return;
}
const links = [...column.links];
const index = links.findIndex(link => link.id === linkId);
const targetIndex = index + direction;
if (index === -1 || targetIndex < 0 || targetIndex >= links.length) {
return;
}
moveItemInArray(links, index, targetIndex);
this.setColumns(this.columns().map(c => c.id === columnId ? { ...c, links } : c));
}
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
2026-07-19 13:58:57 +04:00
linkSourceMode(link: FooterLinkConfig): 'page' | 'custom' {
return link.pageKey ? 'page' : 'custom';
}
setLinkSourceMode(columnId: string, linkId: string, mode: 'page' | 'custom'): void {
if (mode === 'page') {
this.updateLink(columnId, linkId, { pageKey: this.availablePages()[0]?.id ?? '', url: '' });
} else {
this.updateLink(columnId, linkId, { pageKey: '' });
}
}
// --- Multiple phones/emails ---
private setAdditionalPhones(phones: string[]): void {
this.facade.updateBootstrap(current => ({ ...current, company: { ...current.company, contacts: { ...current.company.contacts, additionalPhones: phones } } }));
}
private setAdditionalEmails(emails: string[]): void {
this.facade.updateBootstrap(current => ({ ...current, company: { ...current.company, contacts: { ...current.company.contacts, additionalEmails: emails } } }));
}
addPhone(): void {
this.setAdditionalPhones([...this.additionalPhones(), '']);
}
updatePhoneAt(index: number, value: string): void {
this.setAdditionalPhones(this.additionalPhones().map((phone, i) => i === index ? value : phone));
}
removePhoneAt(index: number): void {
this.setAdditionalPhones(this.additionalPhones().filter((_, i) => i !== index));
}
addEmail(): void {
this.setAdditionalEmails([...this.additionalEmails(), '']);
}
updateEmailAt(index: number, value: string): void {
this.setAdditionalEmails(this.additionalEmails().map((email, i) => i === index ? value : email));
}
removeEmailAt(index: number): void {
this.setAdditionalEmails(this.additionalEmails().filter((_, i) => i !== index));
}
2026-07-10 13:43:53 +04:00
}