2026-07-10 13:43:53 +04:00
|
|
|
import { ChangeDetectionStrategy, Component, computed, inject } from '@angular/core';
|
|
|
|
|
import { FormsModule } from '@angular/forms';
|
|
|
|
|
import { ProjectEditorFacade } from '../facade/project-editor.facade';
|
|
|
|
|
import { TranslatePipe } from '../../../i18n/translate.pipe';
|
2026-07-17 16:57:43 +04:00
|
|
|
import { TranslateService } from '../../../i18n/translate.service';
|
feat(project-editor): adopt Design System primitives across editor sections
Applied app-input/app-form-field/app-button to 9 of 11 Project Editor
sections: general, branding, theme, footer, homepage, widgets, languages,
navigation, preview. header and features sections were left unchanged -
they contain only checkboxes and selects, and no Checkbox/Select primitive
exists yet.
Theme section's 8 color pickers stay native <input type=color> (app-input's
type union doesn't include 'color') but are now wrapped in app-form-field
for consistent label/hint treatment. Added app-form-field.full grid-column
rule to section.shared.scss (shared by all 11 sections) alongside the
existing label.full rule, since the custom element doesn't match that
selector.
Production build green, arch:check passes.
2026-07-15 07:55:38 +04:00
|
|
|
import { InputComponent } from '../../../shared/ui/input/input.component';
|
|
|
|
|
import { FormFieldComponent } from '../../../shared/ui/form-field/form-field.component';
|
2026-07-16 02:06:26 +04:00
|
|
|
import { SectionCardComponent } from '../../../shared/ui/section-card/section-card.component';
|
|
|
|
|
import { KeyValueEditorComponent } from '../../../shared/ui/key-value-editor/key-value-editor.component';
|
2026-07-17 15:22:45 +04:00
|
|
|
import { ImageFieldComponent } from '../../../shared/ui/image-field/image-field.component';
|
2026-07-16 02:06:26 +04:00
|
|
|
import { FooterPaymentIconConfig, FooterSocialLinkConfig } from '../../../shared/models/config';
|
2026-07-17 09:10:54 +04:00
|
|
|
import { isValidHttpUrl } from '../schema/validators/primitives';
|
2026-07-16 02:06:26 +04:00
|
|
|
|
2026-07-10 13:43:53 +04:00
|
|
|
@Component({
|
|
|
|
|
selector: 'app-project-editor-footer-section',
|
|
|
|
|
standalone: true,
|
2026-07-16 02:06:26 +04:00
|
|
|
imports: [
|
|
|
|
|
FormsModule,
|
|
|
|
|
TranslatePipe,
|
|
|
|
|
InputComponent,
|
|
|
|
|
FormFieldComponent,
|
|
|
|
|
SectionCardComponent,
|
|
|
|
|
KeyValueEditorComponent,
|
2026-07-17 15:22:45 +04:00
|
|
|
ImageFieldComponent
|
2026-07-16 02:06:26 +04:00
|
|
|
],
|
2026-07-10 13:43:53 +04:00
|
|
|
templateUrl: './footer-section.component.html',
|
|
|
|
|
styleUrls: ['./section.shared.scss'],
|
|
|
|
|
changeDetection: ChangeDetectionStrategy.OnPush
|
|
|
|
|
})
|
|
|
|
|
export class ProjectEditorFooterSectionComponent {
|
|
|
|
|
private readonly facade = inject(ProjectEditorFacade);
|
2026-07-17 16:57:43 +04:00
|
|
|
private readonly translate = inject(TranslateService);
|
2026-07-10 13:43:53 +04:00
|
|
|
readonly bootstrap = this.facade.bootstrap;
|
2026-07-17 16:57:43 +04:00
|
|
|
readonly fieldError = (key: string): string | null => {
|
|
|
|
|
const messageKey = this.facade.fieldError(key);
|
|
|
|
|
return messageKey ? this.translate.t(messageKey) : null;
|
|
|
|
|
};
|
2026-07-16 02:06:26 +04:00
|
|
|
|
2026-07-10 13:43:53 +04:00
|
|
|
readonly staticPagesValue = computed(() => (this.bootstrap()?.footer?.staticPageKeys ?? this.bootstrap()?.footer?.legalPageKeys ?? []).join(', '));
|
|
|
|
|
readonly copyrightValue = computed(() => {
|
|
|
|
|
const value = this.bootstrap()?.footer?.copyrightText;
|
|
|
|
|
return typeof value === 'string' ? value : '';
|
|
|
|
|
});
|
2026-07-16 02:06:26 +04:00
|
|
|
readonly paymentIconRows = computed<FooterPaymentIconConfig[]>(() => this.bootstrap()?.footer?.paymentIcons ?? []);
|
|
|
|
|
readonly socialLinkRows = computed<FooterSocialLinkConfig[]>(() => this.bootstrap()?.footer?.socialLinks ?? []);
|
|
|
|
|
|
|
|
|
|
readonly createPaymentIconRow = (): FooterPaymentIconConfig => ({ src: '', alt: '' });
|
|
|
|
|
|
|
|
|
|
readonly createSocialLinkRow = (): FooterSocialLinkConfig => {
|
|
|
|
|
const index = (this.bootstrap()?.footer?.socialLinks?.length ?? 0) + 1;
|
|
|
|
|
return { id: `social-${index}`, 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 } })); }
|
|
|
|
|
updateStaticPages(value: string): void {
|
|
|
|
|
const staticPageKeys = value.split(',').map(item => item.trim()).filter(Boolean);
|
|
|
|
|
this.facade.updateBootstrap(current => ({ ...current, footer: { ...current.footer, staticPageKeys, legalPageKeys: staticPageKeys } }));
|
|
|
|
|
}
|
2026-07-16 02:06:26 +04:00
|
|
|
|
|
|
|
|
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 {
|
2026-07-17 09:10:54 +04:00
|
|
|
return !url || isValidHttpUrl(url);
|
2026-07-16 02:06:26 +04:00
|
|
|
}
|
2026-07-10 13:43:53 +04:00
|
|
|
}
|