mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-09-17 14:21:29 +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:
@@ -9,7 +9,7 @@ addons:
|
|||||||
before_script:
|
before_script:
|
||||||
- "sudo chown root /opt/google/chrome/chrome-sandbox"
|
- "sudo chown root /opt/google/chrome/chrome-sandbox"
|
||||||
- "sudo chmod 4755 /opt/google/chrome/chrome-sandbox"
|
- "sudo chmod 4755 /opt/google/chrome/chrome-sandbox"
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- export CHROME_BIN=chromium-browser
|
- export CHROME_BIN=chromium-browser
|
||||||
- export DISPLAY=:99.0
|
- export DISPLAY=:99.0
|
||||||
@@ -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);
|
||||||
@@ -985,7 +989,7 @@ describe('DocumentList', () => {
|
|||||||
documentList.noPermission = true;
|
documentList.noPermission = true;
|
||||||
fixture.detectChanges();
|
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.data.loadPage).toHaveBeenCalled();
|
||||||
expect(documentList.noPermission).toBeFalsy();
|
expect(documentList.noPermission).toBeFalsy();
|
||||||
@@ -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,18 +575,18 @@ 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);
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
this.infiniteLoading = false;
|
this.infiniteLoading = false;
|
||||||
this.onDataReady(val);
|
this.onDataReady(val);
|
||||||
resolve(true);
|
resolve(true);
|
||||||
},
|
},
|
||||||
error => {
|
error => {
|
||||||
reject(error);
|
reject(error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -640,13 +649,13 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
|||||||
this.apiService.sitesApi.getSites(options)
|
this.apiService.sitesApi.getSites(options)
|
||||||
.then((page: NodePaging) => {
|
.then((page: NodePaging) => {
|
||||||
page.list.entries.map(
|
page.list.entries.map(
|
||||||
({entry}: any) => {
|
({ entry }: any) => {
|
||||||
entry.name = entry.name || entry.title;
|
entry.name = entry.name || entry.title;
|
||||||
return {entry};
|
return { entry };
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
this.onPageLoaded(page, merge);
|
this.onPageLoaded(page, merge);
|
||||||
})
|
})
|
||||||
.catch(error => this.error.emit(error));
|
.catch(error => this.error.emit(error));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -664,7 +673,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
|||||||
let page: NodePaging = {
|
let page: NodePaging = {
|
||||||
list: {
|
list: {
|
||||||
entries: result.list.entries
|
entries: result.list.entries
|
||||||
.map(({entry: {site}}: any) => {
|
.map(({ entry: { site } }: any) => {
|
||||||
site.allowableOperations = site.allowableOperations ? site.allowableOperations : [this.CREATE_PERMISSION];
|
site.allowableOperations = site.allowableOperations ? site.allowableOperations : [this.CREATE_PERMISSION];
|
||||||
site.name = site.name || site.title;
|
site.name = site.name || site.title;
|
||||||
return {
|
return {
|
||||||
@@ -976,8 +985,8 @@ 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]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
|
@@ -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': {
|
||||||
@@ -35,9 +36,9 @@ describe('DocumentListService', () => {
|
|||||||
'createdAt': '2016-12-06T15:58:32.408+0000',
|
'createdAt': '2016-12-06T15:58:32.408+0000',
|
||||||
'isFolder': true,
|
'isFolder': true,
|
||||||
'isFile': false,
|
'isFile': false,
|
||||||
'createdByUser': {'id': 'admin', 'displayName': 'Administrator'},
|
'createdByUser': { 'id': 'admin', 'displayName': 'Administrator' },
|
||||||
'modifiedAt': '2016-12-06T15:58:32.408+0000',
|
'modifiedAt': '2016-12-06T15:58:32.408+0000',
|
||||||
'modifiedByUser': {'id': 'admin', 'displayName': 'Administrator'},
|
'modifiedByUser': { 'id': 'admin', 'displayName': 'Administrator' },
|
||||||
'name': 'fake-name',
|
'name': 'fake-name',
|
||||||
'id': '2214733d-a920-4dbe-af95-4230345fae82',
|
'id': '2214733d-a920-4dbe-af95-4230345fae82',
|
||||||
'nodeType': 'cm:folder',
|
'nodeType': 'cm:folder',
|
||||||
@@ -58,7 +59,7 @@ describe('DocumentListService', () => {
|
|||||||
|
|
||||||
let fakeFolder = {
|
let fakeFolder = {
|
||||||
'list': {
|
'list': {
|
||||||
'pagination': {'count': 1, 'hasMoreItems': false, 'totalItems': 1, 'skipCount': 0, 'maxItems': 20},
|
'pagination': { 'count': 1, 'hasMoreItems': false, 'totalItems': 1, 'skipCount': 0, 'maxItems': 20 },
|
||||||
'entries': [{
|
'entries': [{
|
||||||
'entry': {
|
'entry': {
|
||||||
'createdAt': '2016-12-06T13:03:14.880+0000',
|
'createdAt': '2016-12-06T13:03:14.880+0000',
|
||||||
@@ -68,19 +69,19 @@ describe('DocumentListService', () => {
|
|||||||
'elements': [{
|
'elements': [{
|
||||||
'id': 'ed7ab80e-b398-4bed-b38d-139ae4cc592a',
|
'id': 'ed7ab80e-b398-4bed-b38d-139ae4cc592a',
|
||||||
'name': 'Company Home'
|
'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',
|
'id': 'b4cff62a-664d-4d45-9302-98723eac1319',
|
||||||
'name': 'swsdp'
|
'name': 'swsdp'
|
||||||
}, {
|
}, {
|
||||||
'id': '8f2105b4-daaf-4874-9e8a-2152569d109b',
|
'id': '8f2105b4-daaf-4874-9e8a-2152569d109b',
|
||||||
'name': 'documentLibrary'
|
'name': 'documentLibrary'
|
||||||
}, {'id': '17fa78d2-4d6b-4a46-876b-4b0ea07f7f32', 'name': 'empty'}]
|
}, { 'id': '17fa78d2-4d6b-4a46-876b-4b0ea07f7f32', 'name': 'empty' }]
|
||||||
},
|
},
|
||||||
'isFolder': true,
|
'isFolder': true,
|
||||||
'isFile': false,
|
'isFile': false,
|
||||||
'createdByUser': {'id': 'admin', 'displayName': 'Administrator'},
|
'createdByUser': { 'id': 'admin', 'displayName': 'Administrator' },
|
||||||
'modifiedAt': '2016-12-06T13:03:14.880+0000',
|
'modifiedAt': '2016-12-06T13:03:14.880+0000',
|
||||||
'modifiedByUser': {'id': 'admin', 'displayName': 'Administrator'},
|
'modifiedByUser': { 'id': 'admin', 'displayName': 'Administrator' },
|
||||||
'name': 'fake-name',
|
'name': 'fake-name',
|
||||||
'id': 'aac546f6-1525-46ff-bf6b-51cb85f3cda7',
|
'id': 'aac546f6-1525-46ff-bf6b-51cb85f3cda7',
|
||||||
'nodeType': 'cm:folder',
|
'nodeType': 'cm:folder',
|
||||||
@@ -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;
|
||||||
|
Reference in New Issue
Block a user