[ADF-2306] DocumentList should let configure the includeFields request to the se… (#3109)

* DocumentList should let configure the includeFields request to the server

* fix test

* fix test after rebase

* fix permissions

* travis_wait dist
This commit is contained in:
Eugenio Romano
2018-03-22 09:27:12 +00:00
committed by GitHub
parent 99e694ef98
commit e8e2af7d6b
9 changed files with 136 additions and 41 deletions

View File

@@ -124,7 +124,8 @@ describe('DocumentList', () => {
it('should call action\'s handler with node', () => {
let node = new FileNode();
let action = new ContentActionModel();
action.handler = () => { };
action.handler = () => {
};
spyOn(action, 'handler').and.stub();
@@ -136,7 +137,8 @@ describe('DocumentList', () => {
it('should call action\'s handler with node and permission', () => {
let node = new FileNode();
let action = new ContentActionModel();
action.handler = () => { };
action.handler = () => {
};
action.permission = 'fake-permission';
spyOn(action, 'handler').and.stub();
@@ -148,7 +150,8 @@ describe('DocumentList', () => {
it('should call action\'s execute with node if it is defined', () => {
let node = new FileNode();
let action = new ContentActionModel();
action.execute = () => { };
action.execute = () => {
};
spyOn(action, 'execute').and.stub();
documentList.executeContentAction(node, action);
@@ -161,7 +164,8 @@ describe('DocumentList', () => {
let node = new FileNode();
let action = new ContentActionModel();
action.handler = () => deleteObservable;
action.execute = () => { };
action.execute = () => {
};
spyOn(action, 'execute').and.stub();
documentList.executeContentAction(node, action);
@@ -985,7 +989,7 @@ describe('DocumentList', () => {
documentList.noPermission = true;
fixture.detectChanges();
documentList.ngOnChanges({ node: new SimpleChange(null, {list: {entities: {}}}, true) });
documentList.ngOnChanges({ node: new SimpleChange(null, { list: { entities: {} } }, true) });
expect(documentList.data.loadPage).toHaveBeenCalled();
expect(documentList.noPermission).toBeFalsy();
@@ -1395,4 +1399,18 @@ describe('DocumentList', () => {
documentList.loadFolderByNodeId('-favorites-');
expect(documentList.skipCount).toBe(0, 'skipCount is reset');
});
it('should add includeFields in the server request when present', () => {
documentList.currentFolderId = 'fake-id';
documentList.includeFields = ['test-include'];
spyOn(documentListService, 'getFolder');
documentList.ngOnChanges({ rowFilter: new SimpleChange(null, <RowFilter> {}, true) });
expect(documentListService.getFolder).toHaveBeenCalledWith(null, {
maxItems: 25,
skipCount: 0,
rootFolderId: 'fake-id'
}, ['test-include']);
});
});

View File

@@ -27,7 +27,12 @@ import {
PaginationQueryParams,
PermissionsEnum
} from '@alfresco/adf-core';
import { AlfrescoApiService, AppConfigService, DataColumnListComponent, UserPreferencesService } from '@alfresco/adf-core';
import {
AlfrescoApiService,
AppConfigService,
DataColumnListComponent,
UserPreferencesService
} from '@alfresco/adf-core';
import {
AfterContentInit, Component, ContentChild, ElementRef, EventEmitter, HostListener, Input, NgZone,
OnChanges, OnDestroy, OnInit, Output, SimpleChanges, TemplateRef, ViewChild, ViewEncapsulation
@@ -73,6 +78,10 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
@ContentChild(DataColumnListComponent) columnList: DataColumnListComponent;
/** Include additional information about the node in the server request.for example: association, isLink, isLocked and others. */
@Input()
includeFields: string[];
/** Change the display mode of the table. Can be "list" or "gallery". */
@Input()
display: string = DisplayMode.List;
@@ -539,7 +548,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
this.loadRecent(merge);
} else {
this.documentListService
.getFolderNode(nodeId)
.getFolderNode(nodeId, this.includeFields)
.then(node => {
this.folderNode = node;
this.currentFolderId = node.id;
@@ -566,18 +575,18 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
maxItems: maxItems,
skipCount: skipCount,
rootFolderId: id
})
}, this.includeFields)
.subscribe(
val => {
this.data.loadPage(<NodePaging> val, merge);
this.loading = false;
this.infiniteLoading = false;
this.onDataReady(val);
resolve(true);
},
error => {
reject(error);
});
val => {
this.data.loadPage(<NodePaging> val, merge);
this.loading = false;
this.infiniteLoading = false;
this.onDataReady(val);
resolve(true);
},
error => {
reject(error);
});
});
}
@@ -640,13 +649,13 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
this.apiService.sitesApi.getSites(options)
.then((page: NodePaging) => {
page.list.entries.map(
({entry}: any) => {
({ entry }: any) => {
entry.name = entry.name || entry.title;
return {entry};
return { entry };
}
);
this.onPageLoaded(page, merge);
})
})
.catch(error => this.error.emit(error));
}
@@ -664,7 +673,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
let page: NodePaging = {
list: {
entries: result.list.entries
.map(({entry: {site}}: any) => {
.map(({ entry: { site } }: any) => {
site.allowableOperations = site.allowableOperations ? site.allowableOperations : [this.CREATE_PERMISSION];
site.name = site.name || site.title;
return {
@@ -976,8 +985,8 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
.then(result => result.list.entries.map(node => node.entry.id));
} else if (nodeId) {
return this.documentListService.getFolderNode(nodeId)
.then(node => [ node.id ]);
return this.documentListService.getFolderNode(nodeId, this.includeFields)
.then(node => [node.id]);
}
return new Promise((resolve) => {