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
@@ -75,6 +75,7 @@ See the [Custom layout](#custom-layout) section for full details of all availabl
|
|||||||
| originalMimeType | `string` | | Overload originalMimeType |
|
| originalMimeType | `string` | | Overload originalMimeType |
|
||||||
| overlayMode | `boolean` | false | If `true` then show the Viewer as a full page over the current content. Otherwise fit inside the parent div. |
|
| overlayMode | `boolean` | false | If `true` then show the Viewer as a full page over the current content. Otherwise fit inside the parent div. |
|
||||||
| readOnly | `boolean` | true | Enable when where is possible the editing functionalities |
|
| readOnly | `boolean` | true | Enable when where is possible the editing functionalities |
|
||||||
|
| allowedEditActions | `{ [key: string]: boolean }` | `{ rotate: true, crop: true }` | Controls which editing actions are enabled when not in read-only mode. Allows granular control over actions like rotation and cropping. |
|
||||||
| showLeftSidebar | `boolean` | false | Toggles left sidebar visibility. Requires `allowLeftSidebar` to be set to `true`. |
|
| showLeftSidebar | `boolean` | false | Toggles left sidebar visibility. Requires `allowLeftSidebar` to be set to `true`. |
|
||||||
| showRightSidebar | `boolean` | false | Toggles right sidebar visibility. Requires `allowRightSidebar` to be set to `true`. |
|
| showRightSidebar | `boolean` | false | Toggles right sidebar visibility. Requires `allowRightSidebar` to be set to `true`. |
|
||||||
| showToolbar | `boolean` | true | Hide or show the toolbar |
|
| showToolbar | `boolean` | true | Hide or show the toolbar |
|
||||||
|
@@ -24,6 +24,7 @@
|
|||||||
[urlFile]="urlFileContent"
|
[urlFile]="urlFileContent"
|
||||||
[tracks]="tracks"
|
[tracks]="tracks"
|
||||||
[readOnly]="readOnly"
|
[readOnly]="readOnly"
|
||||||
|
[allowedEditActions]="allowedEditActions"
|
||||||
[viewerExtensions]="viewerExtensions"
|
[viewerExtensions]="viewerExtensions"
|
||||||
(downloadFile)="onDownloadFile()"
|
(downloadFile)="onDownloadFile()"
|
||||||
(navigateBefore)="onNavigateBeforeClick($event)"
|
(navigateBefore)="onNavigateBeforeClick($event)"
|
||||||
|
@@ -215,6 +215,10 @@ export class AlfrescoViewerComponent implements OnChanges, OnInit, OnDestroy {
|
|||||||
nodeEntry: NodeEntry;
|
nodeEntry: NodeEntry;
|
||||||
tracks: Track[] = [];
|
tracks: Track[] = [];
|
||||||
readOnly: boolean = true;
|
readOnly: boolean = true;
|
||||||
|
allowedEditActions: { [key: string]: boolean } = {
|
||||||
|
rotate: true,
|
||||||
|
crop: true
|
||||||
|
};
|
||||||
|
|
||||||
sidebarRightTemplateContext: { node: Node } = { node: null };
|
sidebarRightTemplateContext: { node: Node } = { node: null };
|
||||||
sidebarLeftTemplateContext: { node: Node } = { node: null };
|
sidebarLeftTemplateContext: { node: Node } = { node: null };
|
||||||
|
@@ -33,14 +33,14 @@
|
|||||||
<mat-icon>zoom_in</mat-icon>
|
<mat-icon>zoom_in</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button *ngIf="!readOnly" id="viewer-rotate-button"
|
<button *ngIf="!readOnly && allowedEditActions.rotate" id="viewer-rotate-button"
|
||||||
title="{{ 'ADF_VIEWER.ARIA.ROTATE' | translate }}"
|
title="{{ 'ADF_VIEWER.ARIA.ROTATE' | translate }}"
|
||||||
attr.aria-label="{{ 'ADF_VIEWER.ARIA.ROTATE' | translate }}"
|
attr.aria-label="{{ 'ADF_VIEWER.ARIA.ROTATE' | translate }}"
|
||||||
mat-icon-button
|
mat-icon-button
|
||||||
(click)="rotateImage()">
|
(click)="rotateImage()">
|
||||||
<mat-icon>rotate_left</mat-icon>
|
<mat-icon>rotate_left</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
<button *ngIf="!readOnly" id="viewer-crop-button"
|
<button *ngIf="!readOnly && allowedEditActions.crop" id="viewer-crop-button"
|
||||||
title="{{ 'ADF_VIEWER.ARIA.CROP' | translate }}"
|
title="{{ 'ADF_VIEWER.ARIA.CROP' | translate }}"
|
||||||
attr.aria-label="{{ 'ADF_VIEWER.ARIA.CROP' | translate }}"
|
attr.aria-label="{{ 'ADF_VIEWER.ARIA.CROP' | translate }}"
|
||||||
mat-icon-button
|
mat-icon-button
|
||||||
@@ -58,7 +58,7 @@
|
|||||||
|
|
||||||
</adf-toolbar>
|
</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"
|
<button id="viewer-cancel-button"
|
||||||
title="{{ 'ADF_VIEWER.ARIA.CANCEL' | translate }}"
|
title="{{ 'ADF_VIEWER.ARIA.CANCEL' | translate }}"
|
||||||
attr.aria-label="{{ '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();
|
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()
|
@Input()
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
|
|
||||||
|
@Input()
|
||||||
|
allowedEditActions: { [key: string]: boolean } = {
|
||||||
|
rotate: true,
|
||||||
|
crop: true
|
||||||
|
};
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
urlFile: string;
|
urlFile: string;
|
||||||
|
|
||||||
|
@@ -44,6 +44,7 @@
|
|||||||
<adf-img-viewer [urlFile]="urlFile"
|
<adf-img-viewer [urlFile]="urlFile"
|
||||||
[readOnly]="readOnly"
|
[readOnly]="readOnly"
|
||||||
[fileName]="internalFileName"
|
[fileName]="internalFileName"
|
||||||
|
[allowedEditActions]="allowedEditActions"
|
||||||
[blobFile]="blobFile"
|
[blobFile]="blobFile"
|
||||||
(error)="onUnsupportedFile()"
|
(error)="onUnsupportedFile()"
|
||||||
(submit)="onSubmitFile($event)"
|
(submit)="onSubmitFile($event)"
|
||||||
|
@@ -95,6 +95,17 @@ export class ViewerRenderComponent implements OnChanges, OnInit, OnDestroy {
|
|||||||
@Input()
|
@Input()
|
||||||
readOnly = true;
|
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*/
|
/** media subtitles for the media player*/
|
||||||
@Input()
|
@Input()
|
||||||
tracks: Track[] = [];
|
tracks: Track[] = [];
|
||||||
|
@@ -167,6 +167,7 @@
|
|||||||
[blobFile]="blobFile"
|
[blobFile]="blobFile"
|
||||||
[readOnly]="readOnly"
|
[readOnly]="readOnly"
|
||||||
(submitFile)="onSubmitFile($event)"
|
(submitFile)="onSubmitFile($event)"
|
||||||
|
[allowedEditActions]="allowedEditActions"
|
||||||
[urlFile]="urlFile"
|
[urlFile]="urlFile"
|
||||||
(isSaving)="allowNavigate = !$event"
|
(isSaving)="allowNavigate = !$event"
|
||||||
[tracks]="tracks"
|
[tracks]="tracks"
|
||||||
|
@@ -189,6 +189,17 @@ export class ViewerComponent<T> implements OnDestroy, OnInit, OnChanges {
|
|||||||
@Input()
|
@Input()
|
||||||
readOnly = true;
|
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*/
|
/** media subtitles for the media player*/
|
||||||
@Input()
|
@Input()
|
||||||
tracks: Track[] = [];
|
tracks: Track[] = [];
|
||||||
|
Reference in New Issue
Block a user