From e5bf8c6bca0d1b3320eae027dcc7f0381d849b6a Mon Sep 17 00:00:00 2001 From: HoseinGhanbari Date: Fri, 13 Oct 2023 22:44:37 +0330 Subject: [PATCH] feat(admin-ui): Support dynamic ltr/rtl on ModalDialogComponent --- .../modal-dialog/modal-dialog.component.html | 32 ++++++++----------- .../modal-dialog/modal-dialog.component.ts | 28 ++++++++++++++-- 2 files changed, 40 insertions(+), 20 deletions(-) diff --git a/packages/admin-ui/src/lib/core/src/shared/components/modal-dialog/modal-dialog.component.html b/packages/admin-ui/src/lib/core/src/shared/components/modal-dialog/modal-dialog.component.html index 585238b266..e51e477ffc 100644 --- a/packages/admin-ui/src/lib/core/src/shared/components/modal-dialog/modal-dialog.component.html +++ b/packages/admin-ui/src/lib/core/src/shared/components/modal-dialog/modal-dialog.component.html @@ -1,18 +1,14 @@ - - - - - +
+ + + + + +
\ No newline at end of file diff --git a/packages/admin-ui/src/lib/core/src/shared/components/modal-dialog/modal-dialog.component.ts b/packages/admin-ui/src/lib/core/src/shared/components/modal-dialog/modal-dialog.component.ts index ebb55bfa43..4341849efc 100644 --- a/packages/admin-ui/src/lib/core/src/shared/components/modal-dialog/modal-dialog.component.ts +++ b/packages/admin-ui/src/lib/core/src/shared/components/modal-dialog/modal-dialog.component.ts @@ -2,14 +2,18 @@ import { Component, ContentChild, ContentChildren, + OnInit, QueryList, TemplateRef, Type, ViewChild, ViewChildren, } from '@angular/core'; -import { Observable, Subject } from 'rxjs'; +import { Observable, Subject, map } from 'rxjs'; +import { DataService } from '../../../data/providers/data.service'; +import { I18nService } from '../../../providers/i18n/i18n.service'; +import { LanguageCode } from '../../../common/generated-types'; import { Dialog, ModalOptions } from '../../../providers/modal/modal.types'; import { DialogButtonsDirective } from './dialog-buttons.directive'; @@ -23,13 +27,33 @@ import { DialogButtonsDirective } from './dialog-buttons.directive'; templateUrl: './modal-dialog.component.html', styleUrls: ['./modal-dialog.component.scss'], }) -export class ModalDialogComponent> { +export class ModalDialogComponent> implements OnInit { + uiLanguageAndLocale$: Observable<[LanguageCode, string | undefined]>; + direction$: Observable<'ltr' | 'rtl'>; + childComponentType: Type; closeModal: (result?: any) => void; titleTemplateRef$ = new Subject>(); buttonsTemplateRef$ = new Subject>(); options?: ModalOptions; + /** + * + */ + constructor(private i18nService: I18nService, private dataService: DataService) {} + + ngOnInit(): void { + this.uiLanguageAndLocale$ = this.dataService.client + .uiState() + .stream$.pipe(map(({ uiState }) => [uiState.language, uiState.locale ?? undefined])); + + this.direction$ = this.uiLanguageAndLocale$.pipe( + map(([languageCode]) => { + return this.i18nService.isRTL(languageCode) ? 'rtl' : 'ltr'; + }), + ); + } + /** * This callback is invoked when the childComponentType is instantiated in the * template by the {@link DialogComponentOutletComponent}.