Skip to content

Commit

Permalink
* Renamed method/property names
Browse files Browse the repository at this point in the history
  • Loading branch information
sivakumar414ram committed Aug 28, 2020
1 parent ac52563 commit 094b986
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,7 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
takeUntil(this.onDestroy$)
)
.subscribe((uploadedFiles: FileUploadCompleteEvent[]) => {

this.preSelectedNodes = uploadedFiles && uploadedFiles.length ? uploadedFiles.map((uploadedFile) => uploadedFile.data) : [];
this.preSelectedNodes = [...uploadedFiles.map((uploadedFile) => uploadedFile.data)];
this.onFileUploadEvent();
});

Expand Down Expand Up @@ -384,7 +383,7 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
this.searchTerm = '';
this.nodePaging = null;
this.pagination.maxItems = this.pageSize;
this.chosenNode = null;
this.resetChosenNode();
this.showingSearchResults = false;
}

Expand Down Expand Up @@ -455,6 +454,7 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
this.showingSearchResults = false;
this.infiniteScroll = false;
this.breadcrumbFolderTitle = null;
this.preSelectedNodes = [];
this.clearSearch();
this.navigationChange.emit($event);
}
Expand Down Expand Up @@ -497,8 +497,6 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
private attemptNodeSelection(entry: Node): void {
if (entry && this.isSelectionValid(entry)) {
this.chosenNode = [entry];
} else {
// this.resetChosenNode();
}
}

Expand Down Expand Up @@ -531,4 +529,8 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
this.breadcrumbFolderTitle = null;
}
}

hasPreSelectedNodes(): boolean {
return this.preSelectedNodes && this.preSelectedNodes.length > 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -458,11 +458,10 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte

if (changes['currentFolderId']?.currentValue !== changes['currentFolderId']?.previousValue) {
if (this.data) {
this.data.loadPage(null, false, null, this.preSelectedNodes);

if (this.hasPreSelectedNodes()) {
this.data.loadPage(null, false, false, this.preSelectedNodes);
this.onNodeSelect({ row: <ShareDataRow> this.data.getPreSelectedRows()[0], selection: <ShareDataRow[]> this.data.getPreSelectedRows() });
} else {
this.data.loadPage(null, false);
this.onNodeSelect({ row: undefined, selection: <ShareDataRow[]> this.data.getPreSelectedRows() });
}

this.resetNewFolderPagination();
Expand All @@ -478,12 +477,12 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
if (this.data) {
if (changes.node && changes.node.currentValue) {
const merge = this._pagination ? this._pagination.merge : false;
this.data.loadPage(changes.node.currentValue, merge, null, this.preSelectedNodes);

if (this.hasPreSelectedNodes()) {
this.data.loadPage(changes.node.currentValue, merge, null, this.preSelectedNodes);
this.onNodeSelect({ row: <ShareDataRow> this.data.getPreSelectedRows()[0], selection: <ShareDataRow[]> this.data.getPreSelectedRows() });
} else {
this.data.loadPage(changes.node.currentValue, merge, null);
this.onNodeSelect({ row: undefined, selection: <ShareDataRow[]> this.data.getPreSelectedRows() });
}

this.onDataReady(changes.node.currentValue);
} else if (changes.imageResolver) {
this.data.setImageResolver(changes.imageResolver.currentValue);
Expand All @@ -495,12 +494,12 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
this.ngZone.run(() => {
this.resetSelection();
if (this.node) {
this.data.loadPage(this.node, this._pagination.merge, null, this.preSelectedNodes);

if (this.hasPreSelectedNodes()) {
this.data.loadPage(this.node, this._pagination.merge, null, this.preSelectedNodes);
this.onNodeSelect({ row: <ShareDataRow> this.data.getPreSelectedRows()[0], selection: <ShareDataRow[]> this.data.getPreSelectedRows() });
} else {
this.data.loadPage(this.node, this._pagination.merge, null);
this.onNodeSelect({ row: undefined, selection: <ShareDataRow[]> this.data.getPreSelectedRows() });
}

this.onDataReady(this.node);
} else {
this.loadFolder();
Expand Down Expand Up @@ -690,12 +689,12 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte

onPageLoaded(nodePaging: NodePaging) {
if (nodePaging) {
this.data.loadPage(nodePaging, this._pagination.merge, this.allowDropFiles, this.preSelectedNodes);

if (this.hasPreSelectedNodes()) {
this.data.loadPage(nodePaging, this._pagination.merge, this.allowDropFiles, this.preSelectedNodes);
this.onNodeSelect({ row: <ShareDataRow> this.data.getPreSelectedRows()[0], selection: <ShareDataRow[]> this.data.getPreSelectedRows() });
} else {
this.data.loadPage(nodePaging, this._pagination.merge, this.allowDropFiles);
this.onNodeSelect({ row: undefined, selection: <ShareDataRow[]> this.data.getPreSelectedRows() });
}

this.setLoadingState(false);
this.onDataReady(nodePaging);
}
Expand Down Expand Up @@ -797,7 +796,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
this.selection = event.selection.map((entry) => entry.node);
const domEvent = new CustomEvent('node-select', {
detail: {
node: event.row.node,
node: event?.row?.node,
selection: this.selection
},
bubbles: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ export class ShareDataTableAdapter implements DataTableAdapter {
}
}

public loadPage(nodePaging: NodePaging, merge: boolean = false, allowDropFiles?: boolean, preSelectedRows: NodeEntry[] = []) {
public loadPage(nodePaging: NodePaging, merge: boolean = false, allowDropFiles?: boolean, preSelectedNodes: NodeEntry[] = []) {
let shareDataRows: ShareDataRow[] = [];
if (allowDropFiles !== undefined) {
this.allowDropFiles = allowDropFiles;
Expand Down Expand Up @@ -297,24 +297,22 @@ export class ShareDataTableAdapter implements DataTableAdapter {
} else {
this.rows = shareDataRows;
}
this.setPreSelectedRows(preSelectedRows);
this.selectRowsBasedOnGivenNodes(preSelectedNodes);
}

setPreSelectedRows(preSelectedRows: NodeEntry[]) {
const selectedRows: DataRow[] = [];
if (preSelectedRows) {
selectRowsBasedOnGivenNodes(preSelectedNodes: NodeEntry[]) {
if (preSelectedNodes && preSelectedNodes.length > 0) {
this.rows = this.rows.map((row) => {
preSelectedRows.map((res) => {
if (row.obj.entry.id === res.entry.id) {
preSelectedNodes.map((preSelectedNode) => {
if (row.obj.entry.id === preSelectedNode.entry.id) {
row.isSelected = true;
selectedRows.push(row);
}
});
return row;
});
}

this.preSelectedRows = [...selectedRows];
this.preSelectedRows = [...this.rows.filter((res) => res.isSelected)];
}

}

0 comments on commit 094b986

Please sign in to comment.