diff --git a/frontend/src/app/features/content/pages/content/content-page.component.html b/frontend/src/app/features/content/pages/content/content-page.component.html index 24a25d656..36dc4d6d6 100644 --- a/frontend/src/app/features/content/pages/content/content-page.component.html +++ b/frontend/src/app/features/content/pages/content/content-page.component.html @@ -56,7 +56,11 @@ - + + diff --git a/frontend/src/app/features/content/pages/content/content-page.component.ts b/frontend/src/app/features/content/pages/content/content-page.component.ts index f20f1b628..fd46780d8 100644 --- a/frontend/src/app/features/content/pages/content/content-page.component.ts +++ b/frontend/src/app/features/content/pages/content/content-page.component.ts @@ -9,7 +9,7 @@ import { Component, OnInit } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { Observable, of } from 'rxjs'; import { filter, map, tap } from 'rxjs/operators'; -import { ApiUrlConfig, AppLanguageDto, AppsState, AuthService, AutoSaveKey, AutoSaveService, CanComponentDeactivate, ContentDto, ContentsState, defined, DialogService, EditContentForm, LanguagesState, ModalModel, ResolveAssets, ResolveContents, ResourceOwner, SchemaDto, SchemasState, TempService, ToolbarService, Types, Version } from '@app/shared'; +import { ApiUrlConfig, AppLanguageDto, AppsState, AuthService, AutoSaveKey, AutoSaveService, CanComponentDeactivate, ContentDto, ContentsState, defined, DialogService, EditContentForm, LanguagesState, LocalStoreService, ModalModel, ResolveAssets, ResolveContents, ResourceOwner, SchemaDto, SchemasState, Settings, TempService, ToolbarService, Types, Version } from '@app/shared'; @Component({ selector: 'sqx-content-page', @@ -49,6 +49,7 @@ export class ContentPageComponent extends ResourceOwner implements CanComponentD private readonly autoSaveService: AutoSaveService, private readonly dialogs: DialogService, private readonly languagesState: LanguagesState, + private readonly localStore: LocalStoreService, private readonly route: ActivatedRoute, private readonly router: Router, private readonly schemasState: SchemasState, @@ -86,6 +87,13 @@ export class ContentPageComponent extends ResourceOwner implements CanComponentD .subscribe(schema => { this.schema = schema; + const languageKey = this.localStore.get(this.languageKey()); + const language = this.languages.find(x => x.iso2Code === languageKey); + + if (language) { + this.language = language; + } + this.contentForm = new EditContentForm(this.languages, this.schema, this.schemasState.schemaMap, this.formContext); })); @@ -217,6 +225,12 @@ export class ContentPageComponent extends ResourceOwner implements CanComponentD } } + public changeLanguage(language: AppLanguageDto) { + this.language = language; + + this.localStore.set(this.languageKey(), language.iso2Code); + } + public checkPendingChangesBeforePreview() { return this.checkPendingChanges('i18n:contents.pendingChangesTextToPreview'); } @@ -277,6 +291,10 @@ export class ContentPageComponent extends ResourceOwner implements CanComponentD this.contentForm.load(data, isInitial); this.contentForm.setEnabled(!this.content || this.content.canUpdate); } + + private languageKey(): any { + return Settings.Local.CONTENT_LANGUAGE(this.schema.id); + } } function isOtherContent(lhs: ContentDto | undefined | null, rhs: ContentDto | undefined | null) { diff --git a/frontend/src/app/features/content/pages/content/editor/content-field.component.ts b/frontend/src/app/features/content/pages/content/editor/content-field.component.ts index e20b0a263..266f27da4 100644 --- a/frontend/src/app/features/content/pages/content/editor/content-field.component.ts +++ b/frontend/src/app/features/content/pages/content/editor/content-field.component.ts @@ -74,7 +74,7 @@ export class ContentFieldComponent implements OnChanges { } public ngOnChanges(changes: SimpleChanges) { - this.showAllControls = this.localStore.getBoolean(this.configKey()); + this.showAllControls = this.localStore.getBoolean(this.showAllControlsKey()); if (changes['formModel'] && this.formModel) { this.isInvalid = invalid$(this.formModel.form); @@ -88,7 +88,7 @@ export class ContentFieldComponent implements OnChanges { public changeShowAllControls(showAllControls: boolean) { this.showAllControls = showAllControls; - this.localStore.setBoolean(this.configKey(), this.showAllControls); + this.localStore.setBoolean(this.showAllControlsKey(), this.showAllControls); } public copy() { @@ -164,7 +164,7 @@ export class ContentFieldComponent implements OnChanges { return language.iso2Code; } - private configKey() { + private showAllControlsKey() { return Settings.Local.FIELD_ALL(this.schema?.id, this.formModel.field.fieldId); } } diff --git a/frontend/src/app/features/content/pages/content/editor/content-section.component.ts b/frontend/src/app/features/content/pages/content/editor/content-section.component.ts index 5195926df..e0b79bc01 100644 --- a/frontend/src/app/features/content/pages/content/editor/content-section.component.ts +++ b/frontend/src/app/features/content/pages/content/editor/content-section.component.ts @@ -59,7 +59,7 @@ export class ContentSectionComponent extends StatefulComponent implements this.changes.subscribe(state => { if (this.formSection?.separator && this.schema) { - this.localStore.setBoolean(this.expandedKey(), state.isCollapsed); + this.localStore.setBoolean(this.isCollapsedKey(), state.isCollapsed); } }); } @@ -67,7 +67,7 @@ export class ContentSectionComponent extends StatefulComponent implements public ngOnChanges(changes: SimpleChanges) { if (changes['formSection' || changes['schema']]) { if (this.formSection?.separator && this.schema) { - const isCollapsed = this.localStore.getBoolean(this.expandedKey()); + const isCollapsed = this.localStore.getBoolean(this.isCollapsedKey()); this.next({ isCollapsed }); } @@ -89,7 +89,7 @@ export class ContentSectionComponent extends StatefulComponent implements return formState.field.fieldId; } - private expandedKey(): string { + private isCollapsedKey(): string { return Settings.Local.FIELD_COLLAPSED(this.schema?.id, this.formSection?.separator?.fieldId); } } diff --git a/frontend/src/app/features/content/pages/contents/contents-page.component.html b/frontend/src/app/features/content/pages/contents/contents-page.component.html index 108b4c52b..d226449d2 100644 --- a/frontend/src/app/features/content/pages/contents/contents-page.component.html +++ b/frontend/src/app/features/content/pages/contents/contents-page.component.html @@ -24,7 +24,11 @@
- + +