diff --git a/.travis.yml b/.travis.yml
index 141a233b74..cc09e0a37e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -9,7 +9,7 @@ addons:
before_script:
- "sudo chown root /opt/google/chrome/chrome-sandbox"
- "sudo chmod 4755 /opt/google/chrome/chrome-sandbox"
-
+
before_install:
- export CHROME_BIN=chromium-browser
- export DISPLAY=:99.0
@@ -68,7 +68,7 @@ jobs:
before_install:
- "export DISPLAY=:99.0"
- "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
script: ./scripts/test-e2e-bc.sh
- stage: Check ADF exports
diff --git a/demo-shell/resources/i18n/en.json b/demo-shell/resources/i18n/en.json
index af2536eae6..7a780718f5 100644
--- a/demo-shell/resources/i18n/en.json
+++ b/demo-shell/resources/i18n/en.json
@@ -70,6 +70,7 @@
},
"COLUMNS": {
"DISPLAY_NAME": "Display name",
+ "IS_LOCKED": "Lock",
"TAG": "Tag",
"CREATED_BY": "Created by",
"CREATED_ON": "Created on",
diff --git a/demo-shell/src/app/components/files/files.component.html b/demo-shell/src/app/components/files/files.component.html
index 33e0dd15ef..486198b5ec 100644
--- a/demo-shell/src/app/components/files/files.component.html
+++ b/demo-shell/src/app/components/files/files.component.html
@@ -189,6 +189,7 @@
[multiselect]="multiselect"
[display]="displayMode"
[node]="nodeResult"
+ [includeFields]="includeFields"
(error)="onNavigationError($event)"
(success)="resetError()"
(ready)="emitReadyEvent($event)"
@@ -240,6 +241,15 @@
-->
+
+
+ lock
+ lock_open
+
+
('ecmHost') + '/preview/s/';
diff --git a/docs/content-services/document-list.component.md b/docs/content-services/document-list.component.md
index 893587fdb4..92b0ad3e5e 100644
--- a/docs/content-services/document-list.component.md
+++ b/docs/content-services/document-list.component.md
@@ -82,6 +82,7 @@ Displays the documents from a repository.
| maxItems | `number` | | Default value is stored into user preference settings |
| skipCount | `number` | `0` | Number of elements to skip over for pagination purposes |
| 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
diff --git a/lib/content-services/document-list/components/document-list.component.spec.ts b/lib/content-services/document-list/components/document-list.component.spec.ts
index 8bc27e01b1..70f22b5a6a 100644
--- a/lib/content-services/document-list/components/document-list.component.spec.ts
+++ b/lib/content-services/document-list/components/document-list.component.spec.ts
@@ -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, {}, true) });
+
+ expect(documentListService.getFolder).toHaveBeenCalledWith(null, {
+ maxItems: 25,
+ skipCount: 0,
+ rootFolderId: 'fake-id'
+ }, ['test-include']);
+ });
});
diff --git a/lib/content-services/document-list/components/document-list.component.ts b/lib/content-services/document-list/components/document-list.component.ts
index 03fb5a7a85..dd1f81f3ca 100644
--- a/lib/content-services/document-list/components/document-list.component.ts
+++ b/lib/content-services/document-list/components/document-list.component.ts
@@ -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( val, merge);
- this.loading = false;
- this.infiniteLoading = false;
- this.onDataReady(val);
- resolve(true);
- },
- error => {
- reject(error);
- });
+ val => {
+ this.data.loadPage( 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) => {
diff --git a/lib/content-services/document-list/services/document-list.service.spec.ts b/lib/content-services/document-list/services/document-list.service.spec.ts
index 990e7bc730..ca6f707496 100644
--- a/lib/content-services/document-list/services/document-list.service.spec.ts
+++ b/lib/content-services/document-list/services/document-list.service.spec.ts
@@ -28,6 +28,7 @@ declare let jasmine: any;
describe('DocumentListService', () => {
let service: DocumentListService;
+ let alfrescoApiService: AlfrescoApiService;
let fakeEntryNode = {
'entry': {
@@ -35,9 +36,9 @@ describe('DocumentListService', () => {
'createdAt': '2016-12-06T15:58:32.408+0000',
'isFolder': true,
'isFile': false,
- 'createdByUser': {'id': 'admin', 'displayName': 'Administrator'},
+ 'createdByUser': { 'id': 'admin', 'displayName': 'Administrator' },
'modifiedAt': '2016-12-06T15:58:32.408+0000',
- 'modifiedByUser': {'id': 'admin', 'displayName': 'Administrator'},
+ 'modifiedByUser': { 'id': 'admin', 'displayName': 'Administrator' },
'name': 'fake-name',
'id': '2214733d-a920-4dbe-af95-4230345fae82',
'nodeType': 'cm:folder',
@@ -58,7 +59,7 @@ describe('DocumentListService', () => {
let fakeFolder = {
'list': {
- 'pagination': {'count': 1, 'hasMoreItems': false, 'totalItems': 1, 'skipCount': 0, 'maxItems': 20},
+ 'pagination': { 'count': 1, 'hasMoreItems': false, 'totalItems': 1, 'skipCount': 0, 'maxItems': 20 },
'entries': [{
'entry': {
'createdAt': '2016-12-06T13:03:14.880+0000',
@@ -68,19 +69,19 @@ describe('DocumentListService', () => {
'elements': [{
'id': 'ed7ab80e-b398-4bed-b38d-139ae4cc592a',
'name': 'Company Home'
- }, {'id': '99e1368f-e816-47fc-a8bf-3b358feaf31e', 'name': 'Sites'}, {
+ }, { 'id': '99e1368f-e816-47fc-a8bf-3b358feaf31e', 'name': 'Sites' }, {
'id': 'b4cff62a-664d-4d45-9302-98723eac1319',
'name': 'swsdp'
}, {
'id': '8f2105b4-daaf-4874-9e8a-2152569d109b',
'name': 'documentLibrary'
- }, {'id': '17fa78d2-4d6b-4a46-876b-4b0ea07f7f32', 'name': 'empty'}]
+ }, { 'id': '17fa78d2-4d6b-4a46-876b-4b0ea07f7f32', 'name': 'empty' }]
},
'isFolder': true,
'isFile': false,
- 'createdByUser': {'id': 'admin', 'displayName': 'Administrator'},
+ 'createdByUser': { 'id': 'admin', 'displayName': 'Administrator' },
'modifiedAt': '2016-12-06T13:03:14.880+0000',
- 'modifiedByUser': {'id': 'admin', 'displayName': 'Administrator'},
+ 'modifiedByUser': { 'id': 'admin', 'displayName': 'Administrator' },
'name': 'fake-name',
'id': 'aac546f6-1525-46ff-bf6b-51cb85f3cda7',
'nodeType': 'cm:folder',
@@ -92,7 +93,7 @@ describe('DocumentListService', () => {
beforeEach(() => {
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);
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', () => {
service.deleteNode('fake-id').subscribe(
res => {
@@ -189,4 +237,4 @@ describe('DocumentListService', () => {
jasmine.Ajax.requests.mostRecent().respondWith({ status: 200, contentType: 'json' });
});
-});
+})
diff --git a/lib/content-services/document-list/services/document-list.service.ts b/lib/content-services/document-list/services/document-list.service.ts
index 45a6d4cf19..342eac5f89 100644
--- a/lib/content-services/document-list/services/document-list.service.ts
+++ b/lib/content-services/document-list/services/document-list.service.ts
@@ -41,16 +41,19 @@ export class DocumentListService {
private thumbnailService: ThumbnailService) {
}
- private getNodesPromise(folder: string, opts?: any): Promise {
+ private getNodesPromise(folder: string, opts?: any, includeFields: string[] = []): Promise {
let rootNodeId = DocumentListService.ROOT_ID;
if (opts && opts.rootFolderId) {
rootNodeId = opts.rootFolderId;
}
+ let includeFieldsRequest = ['path', 'properties', 'allowableOperations', 'permissions', ...includeFields]
+ .filter((element, index, array) => index === array.indexOf(element));
+
let params: any = {
includeSource: true,
- include: ['path', 'properties', 'allowableOperations', 'permissions']
+ include: includeFieldsRequest
};
if (folder) {
@@ -114,8 +117,8 @@ export class DocumentListService {
* @param folder Path to folder.
* @param opts Options.
*/
- getFolder(folder: string, opts?: any): Observable {
- return Observable.fromPromise(this.getNodesPromise(folder, opts))
+ getFolder(folder: string, opts?: any, includeFields: string[] = []): Observable {
+ return Observable.fromPromise(this.getNodesPromise(folder, opts, includeFields))
.map(res => res)
.catch(err => this.handleError(err));
}
@@ -124,10 +127,14 @@ export class DocumentListService {
* Gets a folder node via its node ID.
* @param nodeId ID of the folder node
*/
- getFolderNode(nodeId: string): Promise {
+ getFolderNode(nodeId: string, includeFields: string[] = []): Promise {
+
+ let includeFieldsRequest = ['path', 'properties', 'allowableOperations', 'permissions', ...includeFields]
+ .filter((element, index, array) => index === array.indexOf(element));
+
let opts: any = {
includeSource: true,
- include: ['path', 'properties', 'allowableOperations', 'permissions']
+ include: includeFieldsRequest
};
let nodes: any = this.apiService.getInstance().nodes;