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>
This commit is contained in:
sdarbinyan
2026-07-16 02:10:38 +04:00
parent 1c51a819ed
commit 0c9a855232
5 changed files with 61 additions and 21 deletions

View File

@@ -1,7 +1,7 @@
import { Injectable, computed, inject, signal } from '@angular/core';
import { take } from 'rxjs/operators';
import { BootstrapConfig, DEFAULT_CATALOG_CONFIG, DEFAULT_HEADER_CONFIG, DEFAULT_PRODUCT_PAGE_CONFIG, DEFAULT_USER_EXPERIENCE_CONFIG } from '../../../shared/models/config';
import { NavigationItemConfig } from '../../../shared/models/config';
import { NavigationItemConfig, NavigationLocalizedText } from '../../../shared/models/config';
import { ConfigService } from '../../../core/config/config.service';
import { ProjectEditorIoService } from '../services/project-editor-io.service';
import { ProjectEditorPreviewService } from '../services/project-editor-preview.service';
@@ -242,13 +242,14 @@ export class ProjectEditorFacade {
* If it's already a NavigationLocalizedText object, only the current default
* locale's key is overwritten; every other locale key is preserved untouched.
*/
updateNavLinkLabel(target: 'header' | 'footer', id: string, value: string): void {
updateNavLinkLabel(target: 'header' | 'footer', id: string, value: string, locale?: string): void {
this.updateBootstrap(current => {
const list = current.navigation[target];
if (!this.isFlatNavList(list)) {
return current;
}
const defaultLocale = current.localization.defaultLocale ?? 'en';
const targetLocale = locale ?? defaultLocale;
return {
...current,
navigation: {
@@ -258,9 +259,14 @@ export class ProjectEditorFacade {
return item;
}
const currentLabel = item.label;
const nextLabel = currentLabel && typeof currentLabel === 'object'
? { ...currentLabel, [defaultLocale]: value }
: value;
let nextLabel: string | NavigationLocalizedText;
if (currentLabel && typeof currentLabel === 'object') {
nextLabel = { ...currentLabel, [targetLocale]: value };
} else if (targetLocale === defaultLocale) {
nextLabel = value;
} else {
nextLabel = { [defaultLocale]: currentLabel ?? '', [targetLocale]: value };
}
return { ...item, label: nextLabel };
}),
},