mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ACS-9250] Adjust viewer to display properly under parent without overlay mode (#10950)
This commit is contained in:
@@ -116,7 +116,8 @@ export class CustomResourcesService {
|
||||
'-TYPE:"fm:topic"',
|
||||
'-TYPE:"fm:post"',
|
||||
'-TYPE:"ia:calendarEvent"',
|
||||
'-TYPE:"lnk:link"'
|
||||
'-TYPE:"lnk:link"',
|
||||
'-ASPECT:"app:linked"'
|
||||
];
|
||||
|
||||
return new Observable((observer) => {
|
||||
|
@@ -51,7 +51,7 @@ export abstract class InfiniteScrollDatasource<T> extends DataSource<T> {
|
||||
if (this.batchesFetched * this.batchSize <= range.end) {
|
||||
forkJoin([
|
||||
this.dataStream.asObservable().pipe(take(1)),
|
||||
this.getNextBatch({ skipCount: this.batchSize * this.batchesFetched, maxItems: this.batchSize }).pipe(
|
||||
this.getNextBatch({ skipCount: this._itemsCount, maxItems: this.batchSize }).pipe(
|
||||
take(1),
|
||||
tap((nextBatch) => (this._itemsCount += nextBatch.length))
|
||||
)
|
||||
|
@@ -23,7 +23,8 @@
|
||||
[nodeMimeType]="nodeMimeType"
|
||||
[urlFile]="urlFileContent"
|
||||
[tracks]="tracks"
|
||||
[readOnly]="readOnly"
|
||||
[readOnly]="readOnly || !canEditNode"
|
||||
[showToolbarDividers]="showToolbarDividers"
|
||||
[allowedEditActions]="allowedEditActions"
|
||||
[viewerExtensions]="viewerExtensions"
|
||||
[nodeId]="nodeId"
|
||||
@@ -53,7 +54,7 @@
|
||||
<ng-content select="adf-viewer-sidebar" />
|
||||
</adf-viewer-sidebar>
|
||||
|
||||
<adf-viewer-toolbar-custom-actions>
|
||||
<adf-viewer-toolbar-custom-actions *ngIf="allowDownload || allowPrint">
|
||||
<button id="adf-alfresco-viewer-download"
|
||||
*ngIf="allowDownload"
|
||||
mat-icon-button
|
||||
|
@@ -874,10 +874,11 @@ describe('AlfrescoViewerComponent', () => {
|
||||
});
|
||||
|
||||
describe('Events', () => {
|
||||
it('should update version when emitted by image-viewer and user has update permissions', () => {
|
||||
it('should update version when emitted by image-viewer when user has update permissions and read only is set to false', () => {
|
||||
spyOn(uploadService, 'uploadFilesInTheQueue').and.callFake(() => {});
|
||||
spyOn(uploadService, 'addToQueue');
|
||||
component.readOnly = false;
|
||||
component.canEditNode = true;
|
||||
component.nodeEntry = new NodeEntry({
|
||||
entry: new Node({ name: 'fakeImage.png', id: '12', content: new ContentInfo({ mimeType: 'img/png' }) })
|
||||
});
|
||||
@@ -899,13 +900,31 @@ describe('AlfrescoViewerComponent', () => {
|
||||
component.onSubmitFile(fakeBlob);
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(component.canEditNode).toBe(true);
|
||||
expect(uploadService.addToQueue).toHaveBeenCalledWith(...[newFile]);
|
||||
expect(uploadService.uploadFilesInTheQueue).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should not update version when emitted by image-viewer and user doesn`t have update permissions', () => {
|
||||
it('should not update version when emitted by image-viewer when user doesn`t have update permissions', () => {
|
||||
spyOn(uploadService, 'uploadFilesInTheQueue').and.callFake(() => {});
|
||||
component.readOnly = false;
|
||||
component.canEditNode = false;
|
||||
component.nodeEntry = new NodeEntry({
|
||||
entry: new Node({ name: 'fakeImage.png', id: '12', content: new ContentInfo({ mimeType: 'img/png' }) })
|
||||
});
|
||||
const data = atob('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==');
|
||||
const fakeBlob = new Blob([data], { type: 'image/png' });
|
||||
|
||||
component.onSubmitFile(fakeBlob);
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(uploadService.uploadFilesInTheQueue).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should not update version when emitted by image-viewer when user has update permissions and viewer is in read only mode', () => {
|
||||
spyOn(uploadService, 'uploadFilesInTheQueue').and.callFake(() => {});
|
||||
component.readOnly = true;
|
||||
component.canEditNode = true;
|
||||
component.nodeEntry = new NodeEntry({
|
||||
entry: new Node({ name: 'fakeImage.png', id: '12', content: new ContentInfo({ mimeType: 'img/png' }) })
|
||||
});
|
||||
|
@@ -189,6 +189,14 @@ export class AlfrescoViewerComponent implements OnChanges, OnInit {
|
||||
@Input()
|
||||
sidebarLeftTemplate: TemplateRef<any> = null;
|
||||
|
||||
/** Should viewer work in read only mode */
|
||||
@Input()
|
||||
readOnly = false;
|
||||
|
||||
/** Toggles dividers visibility */
|
||||
@Input()
|
||||
showToolbarDividers = true;
|
||||
|
||||
/** Emitted when the shared link used is not valid. */
|
||||
@Output()
|
||||
invalidSharedLink = new EventEmitter<void>();
|
||||
@@ -214,7 +222,7 @@ export class AlfrescoViewerComponent implements OnChanges, OnInit {
|
||||
nodeMimeType: string;
|
||||
nodeEntry: NodeEntry;
|
||||
tracks: Track[] = [];
|
||||
readOnly: boolean = true;
|
||||
canEditNode: boolean = false;
|
||||
allowedEditActions: { [key: string]: boolean } = {
|
||||
rotate: true,
|
||||
crop: true
|
||||
@@ -316,7 +324,7 @@ export class AlfrescoViewerComponent implements OnChanges, OnInit {
|
||||
}
|
||||
|
||||
private async setUpNodeFile(nodeData: Node, versionData?: Version): Promise<void> {
|
||||
this.readOnly = !this.contentService.hasAllowableOperations(nodeData, 'update');
|
||||
this.canEditNode = this.contentService.hasAllowableOperations(nodeData, 'update');
|
||||
let mimeType: string;
|
||||
let nodeMimeType: string;
|
||||
let urlFileContent: string;
|
||||
@@ -420,7 +428,7 @@ export class AlfrescoViewerComponent implements OnChanges, OnInit {
|
||||
}
|
||||
|
||||
onSubmitFile(newImageBlob: Blob) {
|
||||
if (this?.nodeEntry?.entry?.id && !this.readOnly) {
|
||||
if (this?.nodeEntry?.entry?.id && !this.readOnly && this.canEditNode) {
|
||||
const newImageFile: File = new File([newImageBlob], this?.nodeEntry?.entry?.name, { type: this?.nodeEntry?.entry?.content?.mimeType });
|
||||
const newFile = new FileModel(
|
||||
newImageFile,
|
||||
|
Reference in New Issue
Block a user