mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-2338] PDF Thumbnail Pane - close button (#2977)
* close thumblist panel * thumbnails template container
This commit is contained in:
committed by
Eugenio Romano
parent
ec3b208b84
commit
9bbdf4331e
Binary file not shown.
Before Width: | Height: | Size: 400 KiB After Width: | Height: | Size: 139 KiB |
@@ -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>
|
||||||
|
|
||||||
|
@@ -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 {
|
||||||
|
@@ -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);
|
||||||
});
|
});
|
||||||
|
@@ -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;
|
||||||
|
@@ -1,12 +1,21 @@
|
|||||||
<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">
|
||||||
<ng-container *ngIf="thumbnailsTemplate">
|
<div class="thumbnails-template__container">
|
||||||
<ng-container *ngTemplateOutlet="thumbnailsTemplate;context:pdfThumbnailsContext"></ng-container>
|
<div class="thumbnails-template__buttons">
|
||||||
</ng-container>
|
<button mat-icon-button (click)="toggleThumbnails()">
|
||||||
<ng-container *ngIf="!thumbnailsTemplate">
|
<mat-icon>close</mat-icon>
|
||||||
<adf-pdf-thumbnails [pdfViewer]="pdfViewer"></adf-pdf-thumbnails>
|
</button>
|
||||||
</ng-container>
|
</div>
|
||||||
|
|
||||||
|
<ng-container *ngIf="thumbnailsTemplate">
|
||||||
|
<ng-container *ngTemplateOutlet="thumbnailsTemplate;context:pdfThumbnailsContext"></ng-container>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<ng-container *ngIf="!thumbnailsTemplate">
|
||||||
|
<adf-pdf-thumbnails [pdfViewer]="pdfViewer"></adf-pdf-thumbnails>
|
||||||
|
</ng-container>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
|
@@ -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 {
|
||||||
|
@@ -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();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -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 {
|
||||||
|
Reference in New Issue
Block a user