Skip to content

Commit

Permalink
Fix selection not working after uploading files, simplify if else con…
Browse files Browse the repository at this point in the history
…ditions
  • Loading branch information
adomi committed Jan 7, 2021
1 parent b54f148 commit 32d7a8b
Showing 1 changed file with 9 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ import {
RequestPaginationModel,
AlfrescoApiService,
UserPreferenceValues,
LockService,
DataRow
LockService
} from '@alfresco/adf-core';

import { Node, NodeEntry, NodePaging, Pagination } from '@alfresco/js-api';
Expand Down Expand Up @@ -634,13 +633,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
*/
executeContentAction(node: NodeEntry, action: ContentActionModel) {
if (node && node.entry && action) {
let handlerSub;

if (typeof action.handler === 'function') {
handlerSub = action.handler(node, this, action.permission);
} else {
handlerSub = of(true);
}
const handlerSub = (typeof action.handler === 'function') ? action.handler(node, this, action.permission) : of(true);

if (typeof action.execute === 'function' && handlerSub) {
handlerSub
Expand Down Expand Up @@ -879,12 +872,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte

private loadLayoutPresets(): void {
const externalSettings = this.appConfig.get('document-list.presets', null);

if (externalSettings) {
this.layoutPresets = Object.assign({}, presetsDefaultModel, externalSettings);
} else {
this.layoutPresets = presetsDefaultModel;
}
this.layoutPresets = externalSettings ? Object.assign({}, presetsDefaultModel, externalSettings) : presetsDefaultModel;
}

private onDataReady(nodePaging: NodePaging) {
Expand Down Expand Up @@ -932,29 +920,17 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
}

getPreselectNodesBasedOnSelectionMode(): NodeEntry[] {
let selectedNodes: NodeEntry[] = [];

if (this.hasPreselectNodes()) {
if (this.isSingleSelectionMode()) {
selectedNodes = [this.preselectNodes[0]];
} else {
selectedNodes = this.preselectNodes;
}
}

return selectedNodes;
return this.hasPreselectNodes() ? (this.isSingleSelectionMode() ? [this.preselectNodes[0]] : this.preselectNodes) : [];
}

private onPreselectNodes() {
if (this.hasPreselectNodes()) {
let selectedNodes: DataRow[] = [];

if (this.isSingleSelectionMode()) {
selectedNodes = [this.data.getPreselectRows()[0]];
} else {
selectedNodes = this.data.getPreselectRows();
}
const preselectedNodes = [...this.isSingleSelectionMode() ? [this.data.getPreselectRows()[0]] : this.data.getPreselectRows()];
const selectedNodes = [...this.selection, ...preselectedNodes];

preselectedNodes.forEach(node => {
this.dataTable.selectRow(node, true);
});
this.onNodeSelect({ row: undefined, selection: <ShareDataRow[]> selectedNodes });
}
}
Expand Down

0 comments on commit 32d7a8b

Please sign in to comment.