fix title viewer issues of priority between name display and real name

This commit is contained in:
Eugenio Romano
2018-08-09 15:01:20 +01:00
parent f69235df57
commit 35bcd80106
3 changed files with 9 additions and 8 deletions

View File

@@ -29,7 +29,7 @@
<mat-icon>navigate_before</mat-icon>
</button>
<img class="adf-viewer__mimeicon" [src]="mimeType | adfMimeTypeIcon" data-automation-id="adf-file-thumbnail">
<span class="adf-viewer__display-name" id="adf-viewer-display-name">{{ displayName }}</span>
<span class="adf-viewer__display-name" id="adf-viewer-display-name">{{ fileTitle }}</span>
<button
*ngIf="allowNavigate && canNavigateNext"
data-automation-id="adf-toolbar-next-file"

View File

@@ -175,14 +175,14 @@ describe('ViewerComponent', () => {
tick();
expect(alfrescoApiService.nodesApi.getNodeInfo).toHaveBeenCalledWith('id1', {include: [ 'allowableOperations' ]});
expect(component.displayName).toBe('file1');
expect(component.fileTitle).toBe('file1');
component.fileNodeId = 'id2';
component.ngOnChanges({});
tick();
expect(alfrescoApiService.nodesApi.getNodeInfo).toHaveBeenCalledWith('id2', {include: [ 'allowableOperations' ]});
expect(component.displayName).toBe('file2');
expect(component.fileTitle).toBe('file2');
}));
describe('Viewer Example Component Rendering', () => {

View File

@@ -219,6 +219,7 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
otherMenu: any;
extension: string;
sidebarTemplateContext: { node: MinimalNodeEntryEntity } = { node: null };
fileTitle: string;
private cacheBusterNumber;
@@ -312,7 +313,7 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
}
private setUpBlobData() {
this.displayName = this.getDisplayName('Unknown');
this.fileTitle = this.getDisplayName('Unknown');
this.mimeType = this.blobFile.type;
this.viewerType = this.getViewerTypeByMimeType(this.mimeType);
@@ -325,7 +326,7 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
private setUpUrlFile() {
let filenameFromUrl = this.getFilenameFromUrl(this.urlFile);
this.displayName = this.getDisplayName(filenameFromUrl);
this.fileTitle = this.getDisplayName(filenameFromUrl);
this.extension = this.getFileExtension(filenameFromUrl);
this.urlFileContent = this.urlFile;
@@ -348,7 +349,7 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
this.mimeType = data.content.mimeType;
}
this.displayName = this.getDisplayName(data.name);
this.fileTitle = this.getDisplayName(data.name);
this.urlFileContent = this.apiService.contentApi.getContentUrl(data.id);
this.urlFileContent = this.cacheBusterNumber ? this.urlFileContent + '&' + this.cacheBusterNumber : this.urlFileContent;
@@ -376,7 +377,7 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
private setUpSharedLinkFile(details: any) {
this.mimeType = details.entry.content.mimeType;
this.displayName = this.getDisplayName(details.entry.name);
this.fileTitle = this.getDisplayName(details.entry.name);
this.extension = this.getFileExtension(details.entry.name);
this.fileName = details.entry.name;
@@ -406,7 +407,7 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
}
private getDisplayName(name) {
return name || this.displayName ;
return this.displayName || name ;
}
scrollTop() {