2026-07-10 13:43:53 +04:00
|
|
|
import { ChangeDetectionStrategy, Component, computed, inject } from '@angular/core';
|
|
|
|
|
import { FormsModule } from '@angular/forms';
|
2026-07-19 08:53:10 +04:00
|
|
|
import { RouterLink } from '@angular/router';
|
2026-07-10 13:43:53 +04:00
|
|
|
import { ProjectEditorFacade } from '../facade/project-editor.facade';
|
|
|
|
|
import { TranslatePipe } from '../../../i18n/translate.pipe';
|
2026-07-17 02:07:14 +04:00
|
|
|
import { TranslateService } from '../../../i18n/translate.service';
|
2026-07-19 08:53:10 +04:00
|
|
|
import { LanguageService } from '../../../services/language.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 01:59:54 +04:00
|
|
|
import { SectionCardComponent } from '../../../shared/ui/section-card/section-card.component';
|
2026-07-10 13:43:53 +04:00
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'app-project-editor-general-section',
|
|
|
|
|
standalone: true,
|
2026-07-19 08:53:10 +04:00
|
|
|
imports: [FormsModule, RouterLink, TranslatePipe, InputComponent, FormFieldComponent, SectionCardComponent],
|
2026-07-10 13:43:53 +04:00
|
|
|
templateUrl: './general-section.component.html',
|
|
|
|
|
styleUrls: ['./section.shared.scss'],
|
|
|
|
|
changeDetection: ChangeDetectionStrategy.OnPush
|
|
|
|
|
})
|
|
|
|
|
export class ProjectEditorGeneralSectionComponent {
|
|
|
|
|
private readonly facade = inject(ProjectEditorFacade);
|
2026-07-17 02:07:14 +04:00
|
|
|
private readonly translate = inject(TranslateService);
|
2026-07-19 08:53:10 +04:00
|
|
|
private readonly languageService = inject(LanguageService);
|
|
|
|
|
|
2026-07-10 13:43:53 +04:00
|
|
|
readonly bootstrap = this.facade.bootstrap;
|
2026-07-17 02:07:14 +04:00
|
|
|
readonly fieldError = (key: string): string | null => {
|
|
|
|
|
const messageKey = this.facade.fieldError(key);
|
|
|
|
|
return messageKey ? this.translate.t(messageKey) : null;
|
|
|
|
|
};
|
2026-07-19 08:53:10 +04:00
|
|
|
|
|
|
|
|
/** Default locale first, so the chip list reads as "primary + others". */
|
|
|
|
|
readonly orderedLocales = computed(() => {
|
|
|
|
|
const localization = this.bootstrap()?.localization;
|
|
|
|
|
if (!localization) {
|
|
|
|
|
return [] as string[];
|
|
|
|
|
}
|
|
|
|
|
const rest = localization.supportedLocales.filter(code => code !== localization.defaultLocale);
|
|
|
|
|
return [localization.defaultLocale, ...rest];
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
readonly languagesRoute = computed(() => ['/', this.languageService.currentLanguage(), 'edit', 'languages']);
|
|
|
|
|
|
|
|
|
|
isDefaultLocale(code: string): boolean {
|
|
|
|
|
return code === this.bootstrap()?.localization.defaultLocale;
|
|
|
|
|
}
|
2026-07-10 13:43:53 +04:00
|
|
|
|
|
|
|
|
updateMarketplaceName(value: string): void {
|
|
|
|
|
this.facade.updateBootstrap(current => ({
|
|
|
|
|
...current,
|
|
|
|
|
branding: { ...current.branding, brandName: value },
|
|
|
|
|
tenant: { ...current.tenant, name: value }
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateDomain(value: string): void {
|
|
|
|
|
this.facade.updateBootstrap(current => ({
|
|
|
|
|
...current,
|
|
|
|
|
tenant: { ...current.tenant, host: value, websiteBaseUrl: `https://${value}` }
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateDescription(value: string): void {
|
|
|
|
|
this.facade.updateBootstrap(current => ({
|
|
|
|
|
...current,
|
|
|
|
|
seo: {
|
|
|
|
|
...current.seo,
|
|
|
|
|
default: {
|
|
|
|
|
...current.seo.default,
|
|
|
|
|
description: value
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
}
|