[ACA-1574] DocumentList - single click navigation (#513)

* single click navigation

* fix tests

* allow action on row

* use adf link class

* update tests
This commit is contained in:
Cilibiu Bogdan
2018-07-18 18:25:30 +03:00
committed by Denys Vuika
parent 36629adf99
commit af4089ae74
7 changed files with 36 additions and 34 deletions

View File

@@ -147,7 +147,7 @@
[allowDropFiles]="true"
[navigate]="false"
[imageResolver]="imageResolver"
(node-dblclick)="onNodeDoubleClick($event.detail?.node)">
(node-dblclick)="navigateTo($event.detail?.node)">
<data-columns>
<data-column
@@ -158,11 +158,15 @@
</data-column>
<data-column
class="adf-data-table-cell--ellipsis__name"
class="adf-data-table-cell--ellipsis__name adf-location-cell"
key="name"
title="APP.DOCUMENT_LIST.COLUMNS.NAME">
<ng-template let-value="value" let-context>
<span class="adf-datatable-cell" title="{{ context?.row?.obj | adfNodeNameTooltip }}">{{ value }}</span>
<a
title="{{ context?.row?.obj | adfNodeNameTooltip }}"
(click)="navigateTo(context?.row?.obj)">
{{ value }}
</a>
</ng-template>
</data-column>

View File

@@ -118,7 +118,7 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
});
}
onNodeDoubleClick(node: MinimalNodeEntity) {
navigateTo(node: MinimalNodeEntity) {
if (node && node.entry) {
const { id, isFolder } = node.entry;

View File

@@ -49,7 +49,7 @@
selectionMode="single"
[navigate]="false"
[sorting]="[ 'title', 'asc' ]"
(node-dblclick)="onNodeDoubleClick($event)">
(node-dblclick)="navigateTo($event.detail?.node)">
<empty-folder-content>
<ng-template>
@@ -70,13 +70,15 @@
</data-column>
<data-column
class="adf-data-table-cell--ellipsis__name"
class="adf-data-table-cell--ellipsis__name adf-location-cell"
key="title"
title="APP.DOCUMENT_LIST.COLUMNS.TITLE">
<ng-template let-context>
<span class="adf-datatable-cell" title="{{ makeLibraryTooltip(context.row.obj.entry) }}">
<a
title="{{ makeLibraryTooltip(context.row.obj.entry) }}"
(click)="navigateTo(context?.row?.obj)">
{{ makeLibraryTitle(context.row.obj.entry) }}
</span>
</a>
</ng-template>
</data-column>

View File

@@ -163,35 +163,23 @@ describe('LibrariesComponent', () => {
});
});
describe('onNodeDoubleClick', () => {
it('navigates to document', () => {
describe('navigateTo', () => {
it('navigates into library folder', () => {
spyOn(component, 'navigate');
const event: any = {
detail: {
node: {
entry: { guid: 'node-guid' }
}
}
const site: any = {
entry: { guid: 'node-guid' }
};
component.onNodeDoubleClick(event);
component.navigateTo(site);
expect(component.navigate).toHaveBeenCalledWith('node-guid');
});
it(' does not navigate when document is not provided', () => {
it(' does not navigate when library is not provided', () => {
spyOn(component, 'navigate');
const event: any = {
detail: {
node: {
entry: null
}
}
};
component.onNodeDoubleClick(event);
component.navigateTo(null);
expect(component.navigate).not.toHaveBeenCalled();
});

View File

@@ -84,11 +84,9 @@ export class LibrariesComponent extends PageComponent implements OnInit {
return isDuplicate ? `${title} (${id})` : `${title}`;
}
onNodeDoubleClick(e: CustomEvent) {
const node: any = e.detail.node.entry;
if (node && node.guid) {
this.navigate(node.guid);
navigateTo(node: SiteEntry) {
if (node && node.entry.guid) {
this.navigate(node.entry.guid);
}
}