Skip to content

Commit

Permalink
[MNT-23433] setting close button position
Browse files Browse the repository at this point in the history
  • Loading branch information
AnukritiGL committed Dec 12, 2023
1 parent b13b835 commit 4f2d8b5
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 39 deletions.
3 changes: 1 addition & 2 deletions demo-shell/src/app.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -1493,7 +1493,6 @@
"downloadPromptDelay": 50,
"downloadPromptReminderDelay": 30,
"enableFileAutoDownload": true,
"fileAutoDownloadSizeThresholdInMB": 15,
"isCloseButtonOnLeft": false
"fileAutoDownloadSizeThresholdInMB": 15
}
}
4 changes: 2 additions & 2 deletions docs/content-services/components/alfresco-viewer.component.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ See the [Custom layout](#custom-layout) section for full details of all availabl
| ---- | ---- | ------------- | ----------- |
| allowDownload | `boolean` | true | Toggles downloading. |
| allowFullScreen | `boolean` | true | Toggles the 'Full Screen' feature. |
| allowGoBack | `boolean` | true | Allows `back` navigation on left or right position. |
| showCloseButton | `boolean` | true | Show/hide close button. |
| allowGoBack | `boolean` | true | Allows `back` navigation. |
| closeButtonPosition | `string` | `right` | Set close button position right/left. |
| allowLeftSidebar | `boolean` | false | Allow the left the sidebar. |
| allowNavigate | `boolean` | false | Toggles before/next navigation. You can use the arrow buttons to navigate between documents in the collection. |
| allowPrint | `boolean` | false | Toggles printing. |
Expand Down
4 changes: 2 additions & 2 deletions docs/core/components/viewer.component.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ See the [Custom layout](#custom-layout) section for full details of all availabl
| Name | Type | Default value | Description |
| ---- | ---- | ------------- | ----------- |
| allowFullScreen | `boolean` | true | Toggles the 'Full Screen' feature. |
| allowGoBack | `boolean` | true | Allows `back` navigation on left or right position. |
| showCloseButton | `boolean` | true | Show/hide close button. |
| allowGoBack | `boolean` | true | Allows `back` navigation. |
| closeButtonPosition | `string` | `right` | Set close button position right/left. |
| allowLeftSidebar | `boolean` | false | Allow the left the sidebar. |
| allowNavigate | `boolean` | false | Toggles before/next navigation. You can use the arrow buttons to navigate between documents in the collection. |
| allowRightSidebar | `boolean` | false | Allow the right sidebar. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
[sidebarLeftTemplate]="sidebarLeftTemplate"
[sidebarRightTemplateContext]="sidebarRightTemplateContext"
[sidebarLeftTemplateContext]="sidebarLeftTemplateContext"
[showCloseButton]="showCloseButton"
[closeButtonPosition]="closeButtonPosition"
[fileName]="fileName"
[mimeType]="mimeType"
[originalMimeType]="originalMimeType"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import {
} from '@angular/core';
import {
AlfrescoApiService,
AppConfigService,
LogService,
Track,
ViewerComponent,
Expand Down Expand Up @@ -161,6 +160,10 @@ export class AlfrescoViewerComponent implements OnChanges, OnInit, OnDestroy {
@Input()
allowFullScreen = true;

/** Change the close button position Right/Left */
@Input()
closeButtonPosition = 'right';

/** The template for the right sidebar. The template context contains the loaded node data. */
@Input()
sidebarRightTemplate: TemplateRef<any> = null;
Expand Down Expand Up @@ -197,7 +200,6 @@ export class AlfrescoViewerComponent implements OnChanges, OnInit, OnDestroy {
nodeEntry: NodeEntry;
tracks: Track[] = [];
readOnly: boolean = true;
showCloseButton: boolean = true;

sidebarRightTemplateContext: { node: Node } = { node: null };
sidebarLeftTemplateContext: { node: Node } = { node: null };
Expand Down Expand Up @@ -236,11 +238,9 @@ export class AlfrescoViewerComponent implements OnChanges, OnInit, OnDestroy {
private uploadService: UploadService,
public dialog: MatDialog,
private cdr: ChangeDetectorRef,
private nodeActionsService: NodeActionsService,
private appConfig: AppConfigService
private nodeActionsService: NodeActionsService
) {
renditionService.maxRetries = this.maxRetries;
this.allowGoBack = this.appConfig.get('viewer.isCloseButtonOnLeft', false);
}

ngOnInit() {
Expand Down Expand Up @@ -270,7 +270,7 @@ export class AlfrescoViewerComponent implements OnChanges, OnInit, OnDestroy {
}

private async setupSharedLink() {
this.showCloseButton = false;
this.allowGoBack = false;

try {
const sharedLinkEntry = await this.sharedLinksApi.getSharedLink(this.sharedLinkId);
Expand Down
21 changes: 10 additions & 11 deletions lib/core/src/lib/viewer/components/viewer.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
cdkTrapFocusAutoCapture>
<ng-content select="adf-viewer-toolbar"></ng-content>
<ng-container *ngIf="showToolbar && !toolbar">
<adf-toolbar id="adf-viewer-toolbar" class="adf-viewer-toolbar">
<adf-toolbar id="adf-viewer-toolbar" class="adf-viewer-toolbar" >
<adf-toolbar-title>

<ng-container *ngIf="allowLeftSidebar">
Expand All @@ -23,8 +23,8 @@
</button>
</ng-container>

<button *ngIf="showCloseButton && allowGoBack"
class="adf-viewer-close-button"
<button *ngIf="allowGoBack && closeButtonPosition === 'left'"
class="adf-viewer-close-button adf-left-close-button"
data-automation-id="adf-toolbar-back"
[attr.aria-label]="'ADF_VIEWER.ACTIONS.CLOSE' | translate"
mat-icon-button
Expand Down Expand Up @@ -120,16 +120,15 @@
</mat-menu>
</ng-container>

<ng-container *ngIf="showCloseButton && !allowGoBack">
<ng-container *ngIf="allowGoBack && closeButtonPosition === 'right'">
<adf-toolbar-divider></adf-toolbar-divider>

<button
class="adf-viewer-close-button"
data-automation-id="adf-toolbar-back"
[attr.aria-label]="'ADF_VIEWER.ACTIONS.CLOSE' | translate"
mat-icon-button
title="{{ 'ADF_VIEWER.ACTIONS.CLOSE' | translate }}"
(click)="onClose()">
<button class="adf-viewer-close-button adf-right-close-button"
data-automation-id="adf-toolbar-back"
[attr.aria-label]="'ADF_VIEWER.ACTIONS.CLOSE' | translate"
mat-icon-button
title="{{ 'ADF_VIEWER.ACTIONS.CLOSE' | translate }}"
(click)="onClose()">
<mat-icon>close</mat-icon>
</button>
</ng-container>
Expand Down
23 changes: 11 additions & 12 deletions lib/core/src/lib/viewer/components/viewer.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -527,29 +527,28 @@ describe('ViewerComponent', () => {

describe('Close Button', () => {

it('should show close button on left side when showCloseButton is true and allowGoBack is true', () => {
component.showCloseButton = true;
it('should show close button on left side when closeButtonPosition is left and allowGoBack is true', () => {
component.allowGoBack = true;
component.closeButtonPosition = 'left';
fixture.detectChanges();

expect(element.querySelector('.adf-viewer-close-button')).not.toBeNull();

expect(element.querySelector('.adf-left-close-button')).not.toBeNull();
});

it('should show close button on right side when showCloseButton is true and allowGoBack is false', () => {
component.showCloseButton = true;
component.allowGoBack = false;
it('should show close button on right side when closeButtonPosition is right and allowGoBack is true', () => {
component.allowGoBack = true;
component.closeButtonPosition = 'right';
fixture.detectChanges();

expect(element.querySelector('.adf-viewer-close-button')).not.toBeNull();

expect(element.querySelector('.adf-right-close-button')).not.toBeNull();
});

it('should hide close button when showCloseButton is false', () => {
component.showCloseButton = false;
it('should hide close button allowGoBack is false', () => {
component.allowGoBack = false;
fixture.detectChanges();

expect(element.querySelector('.adf-viewer-close-button')).toBeNull();
expect(element.querySelector('.adf-right-close-button')).toBeNull();
expect(element.querySelector('.adf-left-close-button')).toBeNull();
});
});

Expand Down
6 changes: 3 additions & 3 deletions lib/core/src/lib/viewer/components/viewer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,11 @@ export class ViewerComponent<T> implements OnDestroy, OnInit, OnChanges {
@Input()
sidebarLeftTemplateContext: T = null;

/**
* show/hide close button on shareable link.
/**
* Change the close button position Right/Left.
*/
@Input()
showCloseButton = true;
closeButtonPosition = 'right';

/**
* Enable dialog box to allow user to download the previewed file, in case the preview is not responding for a set period of time.
Expand Down

0 comments on commit 4f2d8b5

Please sign in to comment.