[ADF-2338] PDF Thumbnail Pane - close button (#2977)

* close thumblist panel

* thumbnails template container
This commit is contained in:
Cilibiu Bogdan
2018-02-22 11:29:20 +02:00
committed by Eugenio Romano
parent ec3b208b84
commit 9bbdf4331e
9 changed files with 77 additions and 16 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 400 KiB

After

Width:  |  Height:  |  Size: 139 KiB

View File

@@ -306,7 +306,7 @@ export class CustomThumbnailsComponent {
``` ```
```html ```html
<ng-template let-pdfViewer="viewer" #customThumbnailsTemplate> <ng-template #customThumbnailsTemplate let-pdfViewer="viewer">
<custom-thumbnails [pdfViewer]="pdfViewer"></custom-thumbnails> <custom-thumbnails [pdfViewer]="pdfViewer"></custom-thumbnails>
</ng-template> </ng-template>

View File

@@ -16,16 +16,16 @@
} }
&__thumb:first-child { &__thumb:first-child {
margin-top: 14px; margin-top: 15px;
} }
&__thumb { &__thumb {
cursor: pointer; cursor: pointer;
display: block; display: block;
height: 140px; height: 114px;
width: 100px; width: 91px;
background: mat-color($background, background); background: mat-color($background, background);
margin-bottom: 14px; margin-bottom: 15px;
} }
&__thumb:hover { &__thumb:hover {

View File

@@ -81,7 +81,7 @@ describe('PdfThumbListComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
const renderedIds = component.renderItems.map(item => item.id); const renderedIds = component.renderItems.map(item => item.id);
const rangeIds = viewerMock._pages.slice(0, 5).map(item => item.id); const rangeIds = viewerMock._pages.slice(0, 7).map(item => item.id);
expect(renderedIds).toEqual(rangeIds); expect(renderedIds).toEqual(rangeIds);
}); });
@@ -91,7 +91,7 @@ describe('PdfThumbListComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
const renderedIds = component.renderItems.map(item => item.id); const renderedIds = component.renderItems.map(item => item.id);
const rangeIds = viewerMock._pages.slice(5, 10).map(item => item.id); const rangeIds = viewerMock._pages.slice(6, 14).map(item => item.id);
expect(renderedIds).toEqual(rangeIds); expect(renderedIds).toEqual(rangeIds);
}); });

View File

@@ -35,7 +35,7 @@ export class PdfThumbListComponent implements OnInit, AfterViewInit, OnDestroy {
renderItems = []; renderItems = [];
private items = []; private items = [];
private itemHeight: number = 140; private itemHeight: number = 114;
@ContentChild(TemplateRef) @ContentChild(TemplateRef)
template: any; template: any;

View File

@@ -1,13 +1,22 @@
<div class="adf-pdf-viewer__container"> <div class="adf-pdf-viewer__container">
<ng-container *ngIf="showThumbnails"> <ng-container *ngIf="showThumbnails">
<div class="adf-pdf-viewer__thumbnails"> <div class="adf-pdf-viewer__thumbnails">
<div class="thumbnails-template__container">
<div class="thumbnails-template__buttons">
<button mat-icon-button (click)="toggleThumbnails()">
<mat-icon>close</mat-icon>
</button>
</div>
<ng-container *ngIf="thumbnailsTemplate"> <ng-container *ngIf="thumbnailsTemplate">
<ng-container *ngTemplateOutlet="thumbnailsTemplate;context:pdfThumbnailsContext"></ng-container> <ng-container *ngTemplateOutlet="thumbnailsTemplate;context:pdfThumbnailsContext"></ng-container>
</ng-container> </ng-container>
<ng-container *ngIf="!thumbnailsTemplate"> <ng-container *ngIf="!thumbnailsTemplate">
<adf-pdf-thumbnails [pdfViewer]="pdfViewer"></adf-pdf-thumbnails> <adf-pdf-thumbnails [pdfViewer]="pdfViewer"></adf-pdf-thumbnails>
</ng-container> </ng-container>
</div> </div>
</div>
</ng-container> </ng-container>
<div class="adf-pdf-viewer__content"> <div class="adf-pdf-viewer__content">

View File

@@ -22,7 +22,25 @@
} }
&__thumbnails { &__thumbnails {
position: relative; height: 100%; width: 140px; background-color: rgba(0, 0, 0, 0.12); position: relative;
height: 100%;
width: 190px;
background-color: rgba(0, 0, 0, 0.12);
}
.thumbnails-template {
&__container {
display: flex;
flex-direction: column;
height: 100%;
}
&__buttons {
height: 45px;
justify-content: flex-end;
align-items: flex-end;
display: flex;
}
} }
&__container { &__container {

View File

@@ -388,4 +388,38 @@ describe('Test PdfViewer component', () => {
}); });
}); });
}); });
describe('Thumbnails', () => {
beforeEach(() => {
component.urlFile = require('../assets/fake-test-file.pdf');
component.showThumbnails = false;
fixture.detectChanges();
});
it('should have own context', (done) => {
component.ngOnChanges(null).then(() => {
fixture.detectChanges();
return fixture.whenStable().then(() => {
expect(component.pdfThumbnailsContext.viewer).not.toBeNull();
done();
});
});
});
it('should open thumbnails panel', (done) => {
expect(element.querySelector('.adf-pdf-viewer__thumbnails')).toBeNull();
component.ngOnChanges(null).then(() => {
fixture.detectChanges();
return fixture.whenStable().then(() => {
component.toggleThumbnails();
fixture.detectChanges();
expect(element.querySelector('.adf-pdf-viewer__thumbnails')).not.toBeNull();
done();
});
});
});
});
}); });

View File

@@ -67,7 +67,7 @@ export class PdfViewerComponent implements OnChanges, OnDestroy {
MIN_SCALE: number = 0.25; MIN_SCALE: number = 0.25;
MAX_SCALE: number = 10.0; MAX_SCALE: number = 10.0;
showThumbnails = false; showThumbnails: boolean = false;
pdfThumbnailsContext: { viewer: any } = { viewer: null }; pdfThumbnailsContext: { viewer: any } = { viewer: null };
get currentScaleText(): string { get currentScaleText(): string {