mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
HXCS 3856 File rotation in ADF Viewer (#9873)
This commit is contained in:
committed by
GitHub
parent
f3a94bdfa4
commit
e457dd3a78
@@ -33,14 +33,14 @@
|
||||
<mat-icon>zoom_in</mat-icon>
|
||||
</button>
|
||||
|
||||
<button *ngIf="!readOnly" id="viewer-rotate-button"
|
||||
<button *ngIf="!readOnly && allowedEditActions.rotate" id="viewer-rotate-button"
|
||||
title="{{ 'ADF_VIEWER.ARIA.ROTATE' | translate }}"
|
||||
attr.aria-label="{{ 'ADF_VIEWER.ARIA.ROTATE' | translate }}"
|
||||
mat-icon-button
|
||||
(click)="rotateImage()">
|
||||
<mat-icon>rotate_left</mat-icon>
|
||||
</button>
|
||||
<button *ngIf="!readOnly" id="viewer-crop-button"
|
||||
<button *ngIf="!readOnly && allowedEditActions.crop" id="viewer-crop-button"
|
||||
title="{{ 'ADF_VIEWER.ARIA.CROP' | translate }}"
|
||||
attr.aria-label="{{ 'ADF_VIEWER.ARIA.CROP' | translate }}"
|
||||
mat-icon-button
|
||||
@@ -58,7 +58,7 @@
|
||||
|
||||
</adf-toolbar>
|
||||
|
||||
<adf-toolbar class="adf-secondary-toolbar" *ngIf="!readOnly && isEditing">
|
||||
<adf-toolbar class="adf-secondary-toolbar" *ngIf="isEditing && !readOnly">
|
||||
<button id="viewer-cancel-button"
|
||||
title="{{ 'ADF_VIEWER.ARIA.CANCEL' | translate }}"
|
||||
attr.aria-label="{{ 'ADF_VIEWER.ARIA.CANCEL' | translate }}"
|
||||
|
@@ -370,4 +370,36 @@ describe('Test Img viewer component ', () => {
|
||||
expect(component.reset).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('allowedEditActions', () => {
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ImgViewerComponent);
|
||||
element = fixture.nativeElement;
|
||||
component = fixture.componentInstance;
|
||||
});
|
||||
|
||||
it('should conditionally display rotate and crop buttons based on allowedEditActions', () => {
|
||||
component.readOnly = false;
|
||||
component.allowedEditActions = { rotate: true, crop: true };
|
||||
fixture.detectChanges();
|
||||
|
||||
let rotateButton = element.querySelector('#viewer-rotate-button');
|
||||
let cropButton = element.querySelector('#viewer-crop-button');
|
||||
|
||||
// Check both buttons are visible when allowed
|
||||
expect(rotateButton).not.toBeNull('Rotate button should be visible when allowed');
|
||||
expect(cropButton).not.toBeNull('Crop button should be visible when allowed');
|
||||
|
||||
// Change allowedEditActions to disallow both actions
|
||||
component.allowedEditActions = { rotate: false, crop: false };
|
||||
fixture.detectChanges();
|
||||
|
||||
rotateButton = element.querySelector('#viewer-rotate-button');
|
||||
cropButton = element.querySelector('#viewer-crop-button');
|
||||
|
||||
// Check both buttons are not visible when not allowed
|
||||
expect(rotateButton).toBeNull('Rotate button should not be visible when disallowed');
|
||||
expect(cropButton).toBeNull('Crop button should not be visible when disallowed');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -54,6 +54,12 @@ export class ImgViewerComponent implements AfterViewInit, OnChanges, OnDestroy {
|
||||
@Input()
|
||||
readOnly = true;
|
||||
|
||||
@Input()
|
||||
allowedEditActions: { [key: string]: boolean } = {
|
||||
rotate: true,
|
||||
crop: true
|
||||
};
|
||||
|
||||
@Input()
|
||||
urlFile: string;
|
||||
|
||||
|
@@ -44,6 +44,7 @@
|
||||
<adf-img-viewer [urlFile]="urlFile"
|
||||
[readOnly]="readOnly"
|
||||
[fileName]="internalFileName"
|
||||
[allowedEditActions]="allowedEditActions"
|
||||
[blobFile]="blobFile"
|
||||
(error)="onUnsupportedFile()"
|
||||
(submit)="onSubmitFile($event)"
|
||||
|
@@ -95,6 +95,17 @@ export class ViewerRenderComponent implements OnChanges, OnInit, OnDestroy {
|
||||
@Input()
|
||||
readOnly = true;
|
||||
|
||||
/**
|
||||
* Controls which actions are enabled in the viewer.
|
||||
* Example:
|
||||
* { rotate: true, crop: false } will enable rotation but disable cropping.
|
||||
*/
|
||||
@Input()
|
||||
allowedEditActions: { [key: string]: boolean } = {
|
||||
rotate: true,
|
||||
crop: true
|
||||
};
|
||||
|
||||
/** media subtitles for the media player*/
|
||||
@Input()
|
||||
tracks: Track[] = [];
|
||||
|
@@ -167,6 +167,7 @@
|
||||
[blobFile]="blobFile"
|
||||
[readOnly]="readOnly"
|
||||
(submitFile)="onSubmitFile($event)"
|
||||
[allowedEditActions]="allowedEditActions"
|
||||
[urlFile]="urlFile"
|
||||
(isSaving)="allowNavigate = !$event"
|
||||
[tracks]="tracks"
|
||||
|
@@ -189,6 +189,17 @@ export class ViewerComponent<T> implements OnDestroy, OnInit, OnChanges {
|
||||
@Input()
|
||||
readOnly = true;
|
||||
|
||||
/**
|
||||
* Controls which actions are enabled in the viewer.
|
||||
* Example:
|
||||
* { rotate: true, crop: false } will enable rotation but disable cropping.
|
||||
*/
|
||||
@Input()
|
||||
allowedEditActions: { [key: string]: boolean } = {
|
||||
rotate: true,
|
||||
crop: true
|
||||
};
|
||||
|
||||
/** media subtitles for the media player*/
|
||||
@Input()
|
||||
tracks: Track[] = [];
|
||||
|
Reference in New Issue
Block a user