Files
marketplaces/src/app/features/project-editor/sections/languages-section.component.ts
sdarbinyan 0c9a855232 fix(project-editor): editable nav link labels per locale, add LocaleTabs
- navigation-section: add LocaleTabs; label input now reads/writes the
  active locale's translation via a new editableLabel() helper instead of
  always the default locale. facade.updateNavLinkLabel() gained an optional
  locale param (defaults to current default locale, so existing callers
  are unaffected) and correctly promotes a plain-string label into a
  per-locale map when writing a non-default locale.
- languages-section: wrap in SectionCard, add LocaleTabs for consistency.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-16 02:10:38 +04:00

53 lines
2.0 KiB
TypeScript

import { ChangeDetectionStrategy, Component, computed, inject, signal } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { ProjectEditorFacade } from '../facade/project-editor.facade';
import { TranslatePipe } from '../../../i18n/translate.pipe';
import { ButtonComponent } from '../../../shared/ui/button/button.component';
import { InputComponent } from '../../../shared/ui/input/input.component';
import { SectionCardComponent } from '../../../shared/ui/section-card/section-card.component';
import { LocaleTabsComponent } from '../../../shared/ui/locale-tabs/locale-tabs.component';
@Component({
selector: 'app-project-editor-languages-section',
standalone: true,
imports: [FormsModule, TranslatePipe, ButtonComponent, InputComponent, SectionCardComponent, LocaleTabsComponent],
templateUrl: './languages-section.component.html',
styleUrls: ['./section.shared.scss'],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class ProjectEditorLanguagesSectionComponent {
private readonly facade = inject(ProjectEditorFacade);
readonly bootstrap = this.facade.bootstrap;
readonly locales = computed(() => this.bootstrap()?.localization.supportedLocales ?? []);
readonly defaultLocale = computed(() => this.bootstrap()?.localization.defaultLocale ?? '');
readonly supportedLocales = computed(() => this.bootstrap()?.tenant.supportedLocales ?? []);
readonly tenantDefaultLocale = computed(() => this.bootstrap()?.tenant.defaultLocale ?? '');
readonly activeLocale = signal<string | null>(null);
readonly newLocale = signal('');
onActiveLocaleChange(locale: string): void {
this.activeLocale.set(locale);
}
updateNewLocale(value: string): void {
this.newLocale.set(value);
}
addLocale(): void {
const code = this.newLocale().trim();
if (!code) {
return;
}
this.facade.addLocale(code);
this.newLocale.set('');
}
removeLocale(code: string): void {
this.facade.removeLocale(code);
}
setDefault(code: string): void {
this.facade.setDefaultLocale(code);
}
}