[ADF-4583] Upload dialog - RTL support (#4745)

* overwrite mat-drawer-content position

* set attributes based on direction and position

* add direction support

* update tests

* update doc

* fix direction description

* use native direction attribute

* bind to dir input

* update docs

* remove direction attribute

* listen to user preference textOrientation changes

* update tests

* remove unused import
This commit is contained in:
Cilibiu Bogdan
2019-05-20 17:45:10 +03:00
committed by Denys Vuika
parent 2f44c45903
commit bb0bdbfc1d
5 changed files with 93 additions and 18 deletions

View File

@@ -17,7 +17,9 @@
import { EventEmitter } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { FileModel, FileUploadCompleteEvent, FileUploadErrorEvent, UploadService, setupTestBed, CoreModule, AlfrescoApiService, AlfrescoApiServiceMock } from '@alfresco/adf-core';
import {
FileModel, FileUploadCompleteEvent, FileUploadErrorEvent, UploadService, setupTestBed, CoreModule, AlfrescoApiService, AlfrescoApiServiceMock, UserPreferencesService
} from '@alfresco/adf-core';
import { UploadModule } from '../upload.module';
import { FileUploadingDialogComponent } from './file-uploading-dialog.component';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
@@ -25,6 +27,7 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations';
describe('FileUploadingDialogComponent', () => {
let fixture: ComponentFixture<FileUploadingDialogComponent>;
let uploadService: UploadService;
let userPreferenceService: UserPreferencesService;
let component: FileUploadingDialogComponent;
let emitter: EventEmitter<any>;
let fileList: FileModel[];
@@ -36,7 +39,8 @@ describe('FileUploadingDialogComponent', () => {
UploadModule
],
providers: [
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock }
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
UserPreferencesService
]
});
@@ -45,6 +49,7 @@ describe('FileUploadingDialogComponent', () => {
component = fixture.componentInstance;
uploadService = TestBed.get(UploadService);
userPreferenceService = TestBed.get(UserPreferencesService);
uploadService.clearQueue();
emitter = new EventEmitter();
@@ -211,4 +216,51 @@ describe('FileUploadingDialogComponent', () => {
expect(uploadService.getQueue().length).toBe(0);
});
});
describe('direction position', () => {
beforeEach(() => {
uploadService.addToQueue(...fileList);
uploadService.uploadFilesInTheQueue(emitter);
});
describe('left position', () => {
beforeEach(() => {
component.position = 'left';
});
it('should be positioned to the left when direction is LTR', () => {
userPreferenceService.set('textOrientation', 'ltr');
fixture.detectChanges();
expect(document.body.querySelector('[adfuploaddialogleft]')).not.toBe(null);
});
it('should be positioned to the right when direction is RTL', () => {
userPreferenceService.set('textOrientation', 'rtl');
fixture.detectChanges();
expect(document.body.querySelector('[adfuploaddialogright]')).not.toBe(null);
});
});
describe('right position', () => {
beforeEach(() => {
component.position = 'right';
});
it('should be positioned to the right when direction is LTR', () => {
userPreferenceService.set('textOrientation', 'ltr');
fixture.detectChanges();
expect(document.body.querySelector('[adfuploaddialogright]')).not.toBe(null);
});
it('should be positioned to the left when direction is RTL', () => {
userPreferenceService.set('textOrientation', 'rtl');
fixture.detectChanges();
expect(document.body.querySelector('[adfuploaddialogleft]')).not.toBe(null);
});
});
});
});