mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-4579] Layout - RTL support (#4741)
* single contentAnimation state * fine tune contentAnimation state based on direction and position * tets * fix mock component inputs * use native direction attribute * update docs * pass direction to calculate sidenav layout * update test * fix unit test * remove dialogs directionality workaround * set document directionality service * remove context menu direction workaround * remove unneeded dependencies * remove direction style workaround * remove permission icon direction * remove sidenav layout direction attribute * update docs * update sidenav layout direction * test * remove document type * update test dependencies * clear storage before test * test * fix dl gap * try to fix Uncaught QuotaExceededError * fix QuotaExceededError * fix tests * fix tests
This commit is contained in:
committed by
Eugenio Romano
parent
f3e90298e6
commit
9cf6f5519c
@@ -20,12 +20,9 @@ import { Overlay } from '@angular/cdk/overlay';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { CoreTestingModule } from '../testing/core.testing.module';
|
||||
import { ContextMenuOverlayService } from './context-menu-overlay.service';
|
||||
import { UserPreferencesService } from '../services/user-preferences.service';
|
||||
import { Injector } from '@angular/core';
|
||||
import { of } from 'rxjs';
|
||||
|
||||
describe('ContextMenuService', () => {
|
||||
let userPreferencesService: UserPreferencesService;
|
||||
let contextMenuOverlayService: ContextMenuOverlayService;
|
||||
let overlay: Overlay;
|
||||
let injector: Injector;
|
||||
@@ -40,13 +37,9 @@ describe('ContextMenuService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopAnimationsModule, CoreTestingModule],
|
||||
providers: [
|
||||
Overlay,
|
||||
UserPreferencesService
|
||||
]
|
||||
providers: [ Overlay ]
|
||||
});
|
||||
|
||||
userPreferencesService = TestBed.get(UserPreferencesService);
|
||||
overlay = TestBed.get(Overlay);
|
||||
injector = TestBed.get(Injector);
|
||||
});
|
||||
@@ -55,8 +48,7 @@ describe('ContextMenuService', () => {
|
||||
beforeEach(() => {
|
||||
contextMenuOverlayService = new ContextMenuOverlayService(
|
||||
injector,
|
||||
overlay,
|
||||
userPreferencesService
|
||||
overlay
|
||||
);
|
||||
});
|
||||
|
||||
@@ -71,32 +63,5 @@ describe('ContextMenuService', () => {
|
||||
|
||||
expect(document.querySelector('adf-context-menu')).not.toBe(null);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('Overlay direction', () => {
|
||||
it('should have default LTR direction value', () => {
|
||||
contextMenuOverlayService = new ContextMenuOverlayService(
|
||||
injector,
|
||||
overlay,
|
||||
userPreferencesService
|
||||
);
|
||||
contextMenuOverlayService.open(overlayConfig);
|
||||
|
||||
expect(document.body.querySelector('div[dir="ltr"]')).not.toBe(null);
|
||||
});
|
||||
|
||||
it('should be created with textOrientation event value', () => {
|
||||
spyOn(userPreferencesService, 'select').and.returnValue(of('rtl'));
|
||||
|
||||
contextMenuOverlayService = new ContextMenuOverlayService(
|
||||
injector,
|
||||
overlay,
|
||||
userPreferencesService
|
||||
);
|
||||
contextMenuOverlayService.open(overlayConfig);
|
||||
|
||||
expect(document.body.querySelector('div[dir="rtl"]')).not.toBe(null);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -22,8 +22,6 @@ import { ContextMenuOverlayRef } from './context-menu-overlay';
|
||||
import { ContextMenuOverlayConfig } from './interfaces';
|
||||
import { CONTEXT_MENU_DATA } from './context-menu.tokens';
|
||||
import { ContextMenuListComponent } from './context-menu-list.component';
|
||||
import { UserPreferencesService } from '../services/user-preferences.service';
|
||||
import { Direction } from '@angular/cdk/bidi';
|
||||
|
||||
const DEFAULT_CONFIG: ContextMenuOverlayConfig = {
|
||||
panelClass: 'cdk-overlay-pane',
|
||||
@@ -35,17 +33,11 @@ const DEFAULT_CONFIG: ContextMenuOverlayConfig = {
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ContextMenuOverlayService {
|
||||
private direction: Direction;
|
||||
|
||||
constructor(
|
||||
private injector: Injector,
|
||||
private overlay: Overlay,
|
||||
private userPreferencesService: UserPreferencesService
|
||||
) {
|
||||
this.userPreferencesService.select('textOrientation').subscribe((textOrientation) => {
|
||||
this.direction = textOrientation;
|
||||
});
|
||||
}
|
||||
private overlay: Overlay
|
||||
) {}
|
||||
|
||||
open(config: ContextMenuOverlayConfig): ContextMenuOverlayRef {
|
||||
const overlayConfig = { ...DEFAULT_CONFIG, ...config };
|
||||
@@ -134,8 +126,7 @@ export class ContextMenuOverlayService {
|
||||
backdropClass: config.backdropClass,
|
||||
panelClass: config.panelClass,
|
||||
scrollStrategy: this.overlay.scrollStrategies.close(),
|
||||
positionStrategy,
|
||||
direction: this.direction
|
||||
positionStrategy
|
||||
});
|
||||
|
||||
return overlayConfig;
|
||||
|
Reference in New Issue
Block a user