From e6ae21a0bc4cc9455c3ab6934fc68fd907a93c3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Popovics=20Andr=C3=A1s?= Date: Wed, 9 Aug 2017 18:32:23 +0100 Subject: [PATCH] Files and search component fix with routing support (#2191) --- .../app/components/files/files.component.html | 1 + .../app/components/files/files.component.ts | 7 ++++++- .../app/components/search/search.component.html | 4 +++- .../app/components/search/search.component.ts | 14 +++++++++++--- ng2-components/ng2-alfresco-search/README.md | 10 ++++++---- .../src/components/search.component.html | 2 ++ .../src/components/search.component.ts | 16 +++++++++++++--- 7 files changed, 42 insertions(+), 12 deletions(-) diff --git a/demo-shell-ng2/app/components/files/files.component.html b/demo-shell-ng2/app/components/files/files.component.html index 388a6b0ffc..e178531592 100644 --- a/demo-shell-ng2/app/components/files/files.component.html +++ b/demo-shell-ng2/app/components/files/files.component.html @@ -88,6 +88,7 @@ (error)="onNavigationError($event)" (success)="resetError()" (preview)="showFile($event)" + (folderChange)="onFolderChange($event)" (permissionError)="handlePermissionError($event)">

Search results

- +
diff --git a/demo-shell-ng2/app/components/search/search.component.ts b/demo-shell-ng2/app/components/search/search.component.ts index 971af0e758..7adfa19d01 100644 --- a/demo-shell-ng2/app/components/search/search.component.ts +++ b/demo-shell-ng2/app/components/search/search.component.ts @@ -52,9 +52,17 @@ export class SearchComponent { constructor(public router: Router) { } - showFile(event) { - if (event.value.entry.isFile) { - this.fileNodeId = event.value.entry.id; + nodeDbClick($event: any) { + if ($event.value.entry.isFolder) { + this.router.navigate(['/files', $event.value.entry.id]); + } else { + this.showFile($event); + } + } + + showFile($event) { + if ($event.value.entry.isFile) { + this.fileNodeId = $event.value.entry.id; this.fileShowed = true; } else { this.fileShowed = false; diff --git a/ng2-components/ng2-alfresco-search/README.md b/ng2-components/ng2-alfresco-search/README.md index 2adbe6c6d5..3070403dd4 100644 --- a/ng2-components/ng2-alfresco-search/README.md +++ b/ng2-components/ng2-alfresco-search/README.md @@ -88,20 +88,22 @@ results page will be shown. ### Properties -| Name | Type | Optional | Default | Description | -| --- | --- | --- | --- | --- | +| Name | Type | Default | Description | +| --- | --- | --- | --- | | searchTerm | string | | Search term to use when executing the search. Updating this value will run a new search and update the results | | rootNodeId | string | "-root-" | NodeRef or node name where the search should start. | | resultType | string | | Node type to filter search results by, e.g. 'cm:content', 'cm:folder' if you want only the files. | -| maxResults | number | 20 | Maximum number of results to show in the search. | +| maxResults | number | 20 | Maximum number of results to show in the search. | | resultSort | string | | Criteria to sort search results by, must be one of "name" , "modifiedAt" or "createdAt" | -| navigationMode | string | "dblclick" | Event used to initiate a navigation action to a specific result, one of "click" or "dblclick" | +| navigationMode | string | "dblclick" | Event used to initiate a navigation action to a specific result, one of "click" or "dblclick" | +| navigate | boolean | true | Allow documentlist to navigate or not. For more information see documentlist component's documentation | ### Events | Name | Description | | --- | --- | | preview | Emitted when user acts upon files with either single or double click (depends on `navigation-mode`), recommended for Viewer components integration | +| nodeDbClick | Emitted when user acts upon files or folders with double click **only when `navigation-mode` is set to false**, giving more freedom then just simply previewing the file | | resultsLoad | Emitted when search results have fully loaded | ## Build from sources diff --git a/ng2-components/ng2-alfresco-search/src/components/search.component.html b/ng2-components/ng2-alfresco-search/src/components/search.component.html index da814fe06f..57c2edd389 100644 --- a/ng2-components/ng2-alfresco-search/src/components/search.component.html +++ b/ng2-components/ng2-alfresco-search/src/components/search.component.html @@ -8,7 +8,9 @@ [creationMenuActions]="false" [contentActions]="true" [navigationMode]="navigationMode" + [navigate]="navigate" [enablePagination]="false" + (nodeDblClick)="onDoubleClick($event)" (preview)="onPreviewFile($event)"> diff --git a/ng2-components/ng2-alfresco-search/src/components/search.component.ts b/ng2-components/ng2-alfresco-search/src/components/search.component.ts index eada5d2298..29ffc76e61 100644 --- a/ng2-components/ng2-alfresco-search/src/components/search.component.ts +++ b/ng2-components/ng2-alfresco-search/src/components/search.component.ts @@ -49,6 +49,9 @@ export class SearchComponent implements OnChanges, OnInit { @Input() navigationMode: string = SearchComponent.DOUBLE_CLICK_NAVIGATION; // click|dblclick + @Input() + navigate: boolean = true; + @Input() emptyFolderImageUrl: string = require('../assets/images/empty_doc_lib.svg'); @@ -58,6 +61,9 @@ export class SearchComponent implements OnChanges, OnInit { @Output() preview: EventEmitter = new EventEmitter(); + @Output() + nodeDbClick: EventEmitter = new EventEmitter(); + pagination: Pagination; errorMessage; queryParamName = 'q'; @@ -93,11 +99,15 @@ export class SearchComponent implements OnChanges, OnInit { } } + onDoubleClick($event: any) { + if (!this.navigate && $event.value) { + this.nodeDbClick.emit({ value: $event.value }); + } + } + onPreviewFile(event: any) { if (event.value) { - this.preview.emit({ - value: event.value - }); + this.preview.emit({ value: event.value }); } }