[ADF-1949 ] Allow customization of the dropdown menu on document picker (#2660)

* [ADF-1949] Allow customization of the dropdown menu on document picker

- add as input properties the 'dropdownHideMyFiles' and the 'dropdownSiteList' to the destination picker, so the list of sites from the dropdown can be customized, if wanted
- add navigation on '-mysites-' entries on document-list
- use custom dropdown on the copy/move document picker

* [ADF-1949] do not use a custom dropdown on the copy/move document picker on ADF side, because this can be done only on ACA side

* [ADF-1949] handling the node-dblclick event on content-node-selector.component instead of doing it on the document-list component

- and update the sites-dropdown documentation file

* [ADF-1949] changes requested on code review

* [ADF-1949] fix failing tests
This commit is contained in:
suzanadirla
2017-11-20 14:10:38 +02:00
committed by Eugenio Romano
parent 141bc0f8b4
commit edaa442e18
7 changed files with 103 additions and 43 deletions

View File

@@ -287,7 +287,7 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
if (this.folderNode) {
this.loadFolder(merge);
} else if (this.currentFolderId) {
this.loadFolderByNodeId(this.currentFolderId);
this.loadFolderByNodeId(this.currentFolderId, merge);
} else if (this.node) {
this.data.loadPage(this.node);
this.ready.emit(this.node);
@@ -376,17 +376,29 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
performNavigation(node: MinimalNodeEntity): boolean {
if (this.canNavigateFolder(node)) {
this.currentFolderId = node.entry.id;
this.folderNode = node.entry;
this.skipCount = 0;
this.currentNodeAllowableOperations = node.entry['allowableOperations'] ? node.entry['allowableOperations'] : [];
this.loadFolder();
this.folderChange.emit(new NodeEntryEvent(node.entry));
this.updateFolderData(node);
return true;
}
return false;
}
performCustomSourceNavigation(node: MinimalNodeEntity): boolean {
if (this.isCustomSource(this.currentFolderId)) {
this.updateFolderData(node);
return true;
}
return false;
}
updateFolderData(node: MinimalNodeEntity): void {
this.currentFolderId = node.entry.id;
this.folderNode = node.entry;
this.skipCount = 0;
this.currentNodeAllowableOperations = node.entry['allowableOperations'] ? node.entry['allowableOperations'] : [];
this.loadFolder();
this.folderChange.emit(new NodeEntryEvent(node.entry));
}
/**
* Invoked when executing content action for a document or folder.
* @param node Node to be the context of the execution.
@@ -418,28 +430,32 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
}
let nodeId = this.folderNode ? this.folderNode.id : this.currentFolderId;
if (!this.hasCustomLayout) {
this.setupDefaultColumns(nodeId);
}
if (nodeId) {
this.loadFolderNodesByFolderNodeId(nodeId, this.maxItems, this.skipCount, merge).catch(err => this.error.emit(err));
}
}
// gets folder node and its content
loadFolderByNodeId(nodeId: string) {
loadFolderByNodeId(nodeId: string, merge: boolean = false) {
this.loading = true;
this.resetSelection();
if (nodeId === '-trashcan-') {
this.loadTrashcan();
this.loadTrashcan(merge);
} else if (nodeId === '-sharedlinks-') {
this.loadSharedLinks();
this.loadSharedLinks(merge);
} else if (nodeId === '-sites-') {
this.loadSites();
this.loadSites(merge);
} else if (nodeId === '-mysites-') {
this.loadMemberSites();
this.loadMemberSites(merge);
} else if (nodeId === '-favorites-') {
this.loadFavorites();
this.loadFavorites(merge);
} else if (nodeId === '-recent-') {
this.loadRecent();
this.loadRecent(merge);
} else {
this.documentListService
.getFolderNode(nodeId)
@@ -448,7 +464,7 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
this.currentFolderId = node.id;
this.skipCount = 0;
this.currentNodeAllowableOperations = node['allowableOperations'] ? node['allowableOperations'] : [];
return this.loadFolderNodesByFolderNodeId(node.id, this.maxItems, this.skipCount);
return this.loadFolderNodesByFolderNodeId(node.id, this.maxItems, this.skipCount, merge);
})
.catch(err => {
if (JSON.parse(err.message).error.statusCode === 403) {
@@ -502,29 +518,29 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
changePage.maxItems.currentValue !== changePage.maxItems.previousValue;
}
private loadTrashcan(): void {
private loadTrashcan(merge: boolean = false): void {
const options = {
include: ['path', 'properties'],
maxItems: this.maxItems,
skipCount: this.skipCount
};
this.apiService.nodesApi.getDeletedNodes(options)
.then((page: DeletedNodesPaging) => this.onPageLoaded(page))
.then((page: DeletedNodesPaging) => this.onPageLoaded(page, merge))
.catch(error => this.error.emit(error));
}
private loadSharedLinks(): void {
private loadSharedLinks(merge: boolean = false): void {
const options = {
include: ['properties', 'allowableOperations', 'path'],
maxItems: this.maxItems,
skipCount: this.skipCount
};
this.apiService.sharedLinksApi.findSharedLinks(options)
.then((page: NodePaging) => this.onPageLoaded(page))
.then((page: NodePaging) => this.onPageLoaded(page, merge))
.catch(error => this.error.emit(error));
}
private loadSites(): void {
private loadSites(merge: boolean = false): void {
const options = {
include: ['properties'],
maxItems: this.maxItems,
@@ -532,11 +548,11 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
};
this.apiService.sitesApi.getSites(options)
.then((page: NodePaging) => this.onPageLoaded(page))
.then((page: NodePaging) => this.onPageLoaded(page, merge))
.catch(error => this.error.emit(error));
}
private loadMemberSites(): void {
private loadMemberSites(merge: boolean = false): void {
const options = {
include: ['properties'],
maxItems: this.maxItems,
@@ -548,19 +564,22 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
let page: NodePaging = {
list: {
entries: result.list.entries
.map(({ entry: { site } }: any) => ({
entry: site
})),
.map(({entry: {site}}: any) => {
site.allowableOperations = site.allowableOperations ? site.allowableOperations : [this.CREATE_PERMISSION];
return {
entry: site
};
}),
pagination: result.list.pagination
}
};
this.onPageLoaded(page);
this.onPageLoaded(page, merge);
})
.catch(error => this.error.emit(error));
}
private loadFavorites(): void {
private loadFavorites(merge: boolean = false): void {
const options = {
maxItems: this.maxItems,
skipCount: this.skipCount,
@@ -586,12 +605,12 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
pagination: result.list.pagination
}
};
this.onPageLoaded(page);
this.onPageLoaded(page, merge);
})
.catch(error => this.error.emit(error));
}
private loadRecent(): void {
private loadRecent(merge: boolean = false): void {
this.apiService.peopleApi.getPerson('-me-')
.then((person: PersonEntry) => {
const username = person.entry.id;
@@ -619,13 +638,13 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
return this.apiService.searchApi.search(query);
})
.then((page: NodePaging) => this.onPageLoaded(page))
.then((page: NodePaging) => this.onPageLoaded(page, merge))
.catch(error => this.error.emit(error));
}
private onPageLoaded(page: NodePaging) {
private onPageLoaded(page: NodePaging, merge: boolean = false) {
if (page) {
this.data.loadPage(page);
this.data.loadPage(page, merge);
this.loading = false;
this.ready.emit(page);
}