mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-07 18:25:09 +00:00
[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:
parent
99e694ef98
commit
e8e2af7d6b
@ -68,7 +68,7 @@ jobs:
|
|||||||
before_install:
|
before_install:
|
||||||
- "export DISPLAY=:99.0"
|
- "export DISPLAY=:99.0"
|
||||||
- "sh -e /etc/init.d/xvfb start"
|
- "sh -e /etc/init.d/xvfb start"
|
||||||
script: ./scripts/test-dist.sh
|
script: travis_wait 30 ./scripts/test-dist.sh
|
||||||
- stage: Check 2.0.0 Project Update
|
- stage: Check 2.0.0 Project Update
|
||||||
script: ./scripts/test-e2e-bc.sh
|
script: ./scripts/test-e2e-bc.sh
|
||||||
- stage: Check ADF exports
|
- stage: Check ADF exports
|
||||||
|
@ -70,6 +70,7 @@
|
|||||||
},
|
},
|
||||||
"COLUMNS": {
|
"COLUMNS": {
|
||||||
"DISPLAY_NAME": "Display name",
|
"DISPLAY_NAME": "Display name",
|
||||||
|
"IS_LOCKED": "Lock",
|
||||||
"TAG": "Tag",
|
"TAG": "Tag",
|
||||||
"CREATED_BY": "Created by",
|
"CREATED_BY": "Created by",
|
||||||
"CREATED_ON": "Created on",
|
"CREATED_ON": "Created on",
|
||||||
|
@ -189,6 +189,7 @@
|
|||||||
[multiselect]="multiselect"
|
[multiselect]="multiselect"
|
||||||
[display]="displayMode"
|
[display]="displayMode"
|
||||||
[node]="nodeResult"
|
[node]="nodeResult"
|
||||||
|
[includeFields]="includeFields"
|
||||||
(error)="onNavigationError($event)"
|
(error)="onNavigationError($event)"
|
||||||
(success)="resetError()"
|
(success)="resetError()"
|
||||||
(ready)="emitReadyEvent($event)"
|
(ready)="emitReadyEvent($event)"
|
||||||
@ -240,6 +241,15 @@
|
|||||||
</ng-template>
|
</ng-template>
|
||||||
</data-column>
|
</data-column>
|
||||||
-->
|
-->
|
||||||
|
<data-column
|
||||||
|
class="desktop-only"
|
||||||
|
title="{{'DOCUMENT_LIST.COLUMNS.IS_LOCKED' | translate}}"
|
||||||
|
key="isLocked">
|
||||||
|
<ng-template let-entry="$implicit">
|
||||||
|
<mat-icon *ngIf="entry.data.getValue(entry.row, entry.col)">lock</mat-icon>
|
||||||
|
<mat-icon *ngIf="!entry.data.getValue(entry.row, entry.col)">lock_open</mat-icon>
|
||||||
|
</ng-template>
|
||||||
|
</data-column>
|
||||||
<data-column
|
<data-column
|
||||||
title="{{'DOCUMENT_LIST.COLUMNS.CREATED_BY' | translate}}"
|
title="{{'DOCUMENT_LIST.COLUMNS.CREATED_BY' | translate}}"
|
||||||
key="createdByUser.displayName"
|
key="createdByUser.displayName"
|
||||||
|
@ -58,6 +58,7 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
showViewer = false;
|
showViewer = false;
|
||||||
showVersions = false;
|
showVersions = false;
|
||||||
displayMode = DisplayMode.List;
|
displayMode = DisplayMode.List;
|
||||||
|
includeFields = ['isLocked'];
|
||||||
|
|
||||||
baseShareUrl = this.appConfig.get<string>('ecmHost') + '/preview/s/';
|
baseShareUrl = this.appConfig.get<string>('ecmHost') + '/preview/s/';
|
||||||
|
|
||||||
|
@ -82,6 +82,7 @@ Displays the documents from a repository.
|
|||||||
| maxItems | `number` | | Default value is stored into user preference settings |
|
| maxItems | `number` | | Default value is stored into user preference settings |
|
||||||
| skipCount | `number` | `0` | Number of elements to skip over for pagination purposes |
|
| skipCount | `number` | `0` | Number of elements to skip over for pagination purposes |
|
||||||
| enableInfiniteScrolling | `boolean` | `false` | Set document list to work in infinite scrolling mode |
|
| enableInfiniteScrolling | `boolean` | `false` | Set document list to work in infinite scrolling mode |
|
||||||
|
| includeFields | `string[]` | `[]` | Include additional information about the node in the server request.for example: association, isLink, isLocked and others. |
|
||||||
|
|
||||||
### Events
|
### Events
|
||||||
|
|
||||||
|
@ -124,7 +124,8 @@ describe('DocumentList', () => {
|
|||||||
it('should call action\'s handler with node', () => {
|
it('should call action\'s handler with node', () => {
|
||||||
let node = new FileNode();
|
let node = new FileNode();
|
||||||
let action = new ContentActionModel();
|
let action = new ContentActionModel();
|
||||||
action.handler = () => { };
|
action.handler = () => {
|
||||||
|
};
|
||||||
|
|
||||||
spyOn(action, 'handler').and.stub();
|
spyOn(action, 'handler').and.stub();
|
||||||
|
|
||||||
@ -136,7 +137,8 @@ describe('DocumentList', () => {
|
|||||||
it('should call action\'s handler with node and permission', () => {
|
it('should call action\'s handler with node and permission', () => {
|
||||||
let node = new FileNode();
|
let node = new FileNode();
|
||||||
let action = new ContentActionModel();
|
let action = new ContentActionModel();
|
||||||
action.handler = () => { };
|
action.handler = () => {
|
||||||
|
};
|
||||||
action.permission = 'fake-permission';
|
action.permission = 'fake-permission';
|
||||||
spyOn(action, 'handler').and.stub();
|
spyOn(action, 'handler').and.stub();
|
||||||
|
|
||||||
@ -148,7 +150,8 @@ describe('DocumentList', () => {
|
|||||||
it('should call action\'s execute with node if it is defined', () => {
|
it('should call action\'s execute with node if it is defined', () => {
|
||||||
let node = new FileNode();
|
let node = new FileNode();
|
||||||
let action = new ContentActionModel();
|
let action = new ContentActionModel();
|
||||||
action.execute = () => { };
|
action.execute = () => {
|
||||||
|
};
|
||||||
spyOn(action, 'execute').and.stub();
|
spyOn(action, 'execute').and.stub();
|
||||||
|
|
||||||
documentList.executeContentAction(node, action);
|
documentList.executeContentAction(node, action);
|
||||||
@ -161,7 +164,8 @@ describe('DocumentList', () => {
|
|||||||
let node = new FileNode();
|
let node = new FileNode();
|
||||||
let action = new ContentActionModel();
|
let action = new ContentActionModel();
|
||||||
action.handler = () => deleteObservable;
|
action.handler = () => deleteObservable;
|
||||||
action.execute = () => { };
|
action.execute = () => {
|
||||||
|
};
|
||||||
spyOn(action, 'execute').and.stub();
|
spyOn(action, 'execute').and.stub();
|
||||||
|
|
||||||
documentList.executeContentAction(node, action);
|
documentList.executeContentAction(node, action);
|
||||||
@ -1395,4 +1399,18 @@ describe('DocumentList', () => {
|
|||||||
documentList.loadFolderByNodeId('-favorites-');
|
documentList.loadFolderByNodeId('-favorites-');
|
||||||
expect(documentList.skipCount).toBe(0, 'skipCount is reset');
|
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']);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -27,7 +27,12 @@ import {
|
|||||||
PaginationQueryParams,
|
PaginationQueryParams,
|
||||||
PermissionsEnum
|
PermissionsEnum
|
||||||
} from '@alfresco/adf-core';
|
} from '@alfresco/adf-core';
|
||||||
import { AlfrescoApiService, AppConfigService, DataColumnListComponent, UserPreferencesService } from '@alfresco/adf-core';
|
import {
|
||||||
|
AlfrescoApiService,
|
||||||
|
AppConfigService,
|
||||||
|
DataColumnListComponent,
|
||||||
|
UserPreferencesService
|
||||||
|
} from '@alfresco/adf-core';
|
||||||
import {
|
import {
|
||||||
AfterContentInit, Component, ContentChild, ElementRef, EventEmitter, HostListener, Input, NgZone,
|
AfterContentInit, Component, ContentChild, ElementRef, EventEmitter, HostListener, Input, NgZone,
|
||||||
OnChanges, OnDestroy, OnInit, Output, SimpleChanges, TemplateRef, ViewChild, ViewEncapsulation
|
OnChanges, OnDestroy, OnInit, Output, SimpleChanges, TemplateRef, ViewChild, ViewEncapsulation
|
||||||
@ -73,6 +78,10 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
|||||||
|
|
||||||
@ContentChild(DataColumnListComponent) columnList: DataColumnListComponent;
|
@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". */
|
/** Change the display mode of the table. Can be "list" or "gallery". */
|
||||||
@Input()
|
@Input()
|
||||||
display: string = DisplayMode.List;
|
display: string = DisplayMode.List;
|
||||||
@ -539,7 +548,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
|||||||
this.loadRecent(merge);
|
this.loadRecent(merge);
|
||||||
} else {
|
} else {
|
||||||
this.documentListService
|
this.documentListService
|
||||||
.getFolderNode(nodeId)
|
.getFolderNode(nodeId, this.includeFields)
|
||||||
.then(node => {
|
.then(node => {
|
||||||
this.folderNode = node;
|
this.folderNode = node;
|
||||||
this.currentFolderId = node.id;
|
this.currentFolderId = node.id;
|
||||||
@ -566,7 +575,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
|||||||
maxItems: maxItems,
|
maxItems: maxItems,
|
||||||
skipCount: skipCount,
|
skipCount: skipCount,
|
||||||
rootFolderId: id
|
rootFolderId: id
|
||||||
})
|
}, this.includeFields)
|
||||||
.subscribe(
|
.subscribe(
|
||||||
val => {
|
val => {
|
||||||
this.data.loadPage(<NodePaging> val, merge);
|
this.data.loadPage(<NodePaging> val, merge);
|
||||||
@ -976,7 +985,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
|||||||
.then(result => result.list.entries.map(node => node.entry.id));
|
.then(result => result.list.entries.map(node => node.entry.id));
|
||||||
|
|
||||||
} else if (nodeId) {
|
} else if (nodeId) {
|
||||||
return this.documentListService.getFolderNode(nodeId)
|
return this.documentListService.getFolderNode(nodeId, this.includeFields)
|
||||||
.then(node => [node.id]);
|
.then(node => [node.id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ declare let jasmine: any;
|
|||||||
describe('DocumentListService', () => {
|
describe('DocumentListService', () => {
|
||||||
|
|
||||||
let service: DocumentListService;
|
let service: DocumentListService;
|
||||||
|
let alfrescoApiService: AlfrescoApiService;
|
||||||
|
|
||||||
let fakeEntryNode = {
|
let fakeEntryNode = {
|
||||||
'entry': {
|
'entry': {
|
||||||
@ -92,7 +93,7 @@ describe('DocumentListService', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
let contentService = new ContentService(null, null, null, null);
|
let contentService = new ContentService(null, null, null, null);
|
||||||
let alfrescoApiService = new AlfrescoApiService(new AppConfigService(null), new StorageService());
|
alfrescoApiService = new AlfrescoApiService(new AppConfigService(null), new StorageService());
|
||||||
service = new DocumentListService(null, contentService, alfrescoApiService, null, null);
|
service = new DocumentListService(null, contentService, alfrescoApiService, null, null);
|
||||||
jasmine.Ajax.install();
|
jasmine.Ajax.install();
|
||||||
});
|
});
|
||||||
@ -157,6 +158,53 @@ describe('DocumentListService', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should add the includeTypes in the request Node Children if required', () => {
|
||||||
|
let spyGetNodeInfo = spyOn(alfrescoApiService.getInstance().nodes, 'getNodeChildren');
|
||||||
|
|
||||||
|
service.getFolder('/fake-root/fake-name', {}, ['isLocked']);
|
||||||
|
|
||||||
|
expect(spyGetNodeInfo).toHaveBeenCalledWith('-root-', {
|
||||||
|
includeSource: true,
|
||||||
|
include: ['path', 'properties', 'allowableOperations', 'permissions', 'isLocked'],
|
||||||
|
relativePath: '/fake-root/fake-name'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not add the includeTypes in the request Node Children if is duplicated', () => {
|
||||||
|
let spyGetNodeInfo = spyOn(alfrescoApiService.getInstance().nodes, 'getNodeChildren');
|
||||||
|
|
||||||
|
service.getFolder('/fake-root/fake-name', {}, ['allowableOperations']);
|
||||||
|
|
||||||
|
expect(spyGetNodeInfo).toHaveBeenCalledWith('-root-', {
|
||||||
|
includeSource: true,
|
||||||
|
include: ['path', 'properties', 'allowableOperations', 'permissions'],
|
||||||
|
relativePath: '/fake-root/fake-name'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should add the includeTypes in the request getFolderNode if required', () => {
|
||||||
|
let spyGetNodeInfo = spyOn(alfrescoApiService.getInstance().nodes, 'getNodeInfo');
|
||||||
|
|
||||||
|
service.getFolderNode('test-id', ['isLocked']);
|
||||||
|
|
||||||
|
expect(spyGetNodeInfo).toHaveBeenCalledWith('test-id', {
|
||||||
|
includeSource: true,
|
||||||
|
include: ['path', 'properties', 'allowableOperations', 'permissions', 'isLocked']
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not add the includeTypes in the request getFolderNode if is duplicated', () => {
|
||||||
|
let spyGetNodeInfo = spyOn(alfrescoApiService.getInstance().nodes, 'getNodeInfo');
|
||||||
|
|
||||||
|
service.getFolderNode('test-id', ['allowableOperations']);
|
||||||
|
|
||||||
|
expect(spyGetNodeInfo).toHaveBeenCalledWith('test-id', {
|
||||||
|
includeSource: true,
|
||||||
|
include: ['path', 'properties', 'allowableOperations', 'permissions']
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it('should delete the folder', () => {
|
it('should delete the folder', () => {
|
||||||
service.deleteNode('fake-id').subscribe(
|
service.deleteNode('fake-id').subscribe(
|
||||||
res => {
|
res => {
|
||||||
@ -189,4 +237,4 @@ describe('DocumentListService', () => {
|
|||||||
|
|
||||||
jasmine.Ajax.requests.mostRecent().respondWith({ status: 200, contentType: 'json' });
|
jasmine.Ajax.requests.mostRecent().respondWith({ status: 200, contentType: 'json' });
|
||||||
});
|
});
|
||||||
});
|
})
|
||||||
|
@ -41,16 +41,19 @@ export class DocumentListService {
|
|||||||
private thumbnailService: ThumbnailService) {
|
private thumbnailService: ThumbnailService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
private getNodesPromise(folder: string, opts?: any): Promise<NodePaging> {
|
private getNodesPromise(folder: string, opts?: any, includeFields: string[] = []): Promise<NodePaging> {
|
||||||
|
|
||||||
let rootNodeId = DocumentListService.ROOT_ID;
|
let rootNodeId = DocumentListService.ROOT_ID;
|
||||||
if (opts && opts.rootFolderId) {
|
if (opts && opts.rootFolderId) {
|
||||||
rootNodeId = opts.rootFolderId;
|
rootNodeId = opts.rootFolderId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let includeFieldsRequest = ['path', 'properties', 'allowableOperations', 'permissions', ...includeFields]
|
||||||
|
.filter((element, index, array) => index === array.indexOf(element));
|
||||||
|
|
||||||
let params: any = {
|
let params: any = {
|
||||||
includeSource: true,
|
includeSource: true,
|
||||||
include: ['path', 'properties', 'allowableOperations', 'permissions']
|
include: includeFieldsRequest
|
||||||
};
|
};
|
||||||
|
|
||||||
if (folder) {
|
if (folder) {
|
||||||
@ -114,8 +117,8 @@ export class DocumentListService {
|
|||||||
* @param folder Path to folder.
|
* @param folder Path to folder.
|
||||||
* @param opts Options.
|
* @param opts Options.
|
||||||
*/
|
*/
|
||||||
getFolder(folder: string, opts?: any): Observable<NodePaging> {
|
getFolder(folder: string, opts?: any, includeFields: string[] = []): Observable<NodePaging> {
|
||||||
return Observable.fromPromise(this.getNodesPromise(folder, opts))
|
return Observable.fromPromise(this.getNodesPromise(folder, opts, includeFields))
|
||||||
.map(res => <NodePaging> res)
|
.map(res => <NodePaging> res)
|
||||||
.catch(err => this.handleError(err));
|
.catch(err => this.handleError(err));
|
||||||
}
|
}
|
||||||
@ -124,10 +127,14 @@ export class DocumentListService {
|
|||||||
* Gets a folder node via its node ID.
|
* Gets a folder node via its node ID.
|
||||||
* @param nodeId ID of the folder node
|
* @param nodeId ID of the folder node
|
||||||
*/
|
*/
|
||||||
getFolderNode(nodeId: string): Promise<MinimalNodeEntryEntity> {
|
getFolderNode(nodeId: string, includeFields: string[] = []): Promise<MinimalNodeEntryEntity> {
|
||||||
|
|
||||||
|
let includeFieldsRequest = ['path', 'properties', 'allowableOperations', 'permissions', ...includeFields]
|
||||||
|
.filter((element, index, array) => index === array.indexOf(element));
|
||||||
|
|
||||||
let opts: any = {
|
let opts: any = {
|
||||||
includeSource: true,
|
includeSource: true,
|
||||||
include: ['path', 'properties', 'allowableOperations', 'permissions']
|
include: includeFieldsRequest
|
||||||
};
|
};
|
||||||
|
|
||||||
let nodes: any = this.apiService.getInstance().nodes;
|
let nodes: any = this.apiService.getInstance().nodes;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user