mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
Files and search component fix with routing support (#2191)
This commit is contained in:
committed by
Mario Romano
parent
5ad4fe171a
commit
e6ae21a0bc
@@ -88,6 +88,7 @@
|
|||||||
(error)="onNavigationError($event)"
|
(error)="onNavigationError($event)"
|
||||||
(success)="resetError()"
|
(success)="resetError()"
|
||||||
(preview)="showFile($event)"
|
(preview)="showFile($event)"
|
||||||
|
(folderChange)="onFolderChange($event)"
|
||||||
(permissionError)="handlePermissionError($event)">
|
(permissionError)="handlePermissionError($event)">
|
||||||
<data-columns>
|
<data-columns>
|
||||||
<data-column
|
<data-column
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
import { ChangeDetectorRef, Component, Input, OnInit, Optional, ViewChild } from '@angular/core';
|
import { ChangeDetectorRef, Component, Input, OnInit, Optional, ViewChild } from '@angular/core';
|
||||||
import { MdDialog } from '@angular/material';
|
import { MdDialog } from '@angular/material';
|
||||||
import { ActivatedRoute, Params } from '@angular/router';
|
import { ActivatedRoute, Params, Router } from '@angular/router';
|
||||||
import { MinimalNodeEntity } from 'alfresco-js-api';
|
import { MinimalNodeEntity } from 'alfresco-js-api';
|
||||||
import {
|
import {
|
||||||
AlfrescoApiService, AlfrescoContentService, AlfrescoTranslationService, FileUploadCompleteEvent,
|
AlfrescoApiService, AlfrescoContentService, AlfrescoTranslationService, FileUploadCompleteEvent,
|
||||||
@@ -90,6 +90,7 @@ export class FilesComponent implements OnInit {
|
|||||||
private contentService: AlfrescoContentService,
|
private contentService: AlfrescoContentService,
|
||||||
private dialog: MdDialog,
|
private dialog: MdDialog,
|
||||||
private translateService: AlfrescoTranslationService,
|
private translateService: AlfrescoTranslationService,
|
||||||
|
private router: Router,
|
||||||
@Optional() private route: ActivatedRoute) {
|
@Optional() private route: ActivatedRoute) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,6 +103,10 @@ export class FilesComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onFolderChange($event) {
|
||||||
|
this.router.navigate(['/files', $event.value.id]);
|
||||||
|
}
|
||||||
|
|
||||||
toggleFolder() {
|
toggleFolder() {
|
||||||
this.multipleFileUpload = false;
|
this.multipleFileUpload = false;
|
||||||
this.folderUpload = !this.folderUpload;
|
this.folderUpload = !this.folderUpload;
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
<div class="search-results-container">
|
<div class="search-results-container">
|
||||||
<h1>Search results</h1>
|
<h1>Search results</h1>
|
||||||
<alfresco-search (preview)="showFile($event)"></alfresco-search>
|
<alfresco-search
|
||||||
|
[navigate]="false"
|
||||||
|
(nodeDbClick)="nodeDbClick($event)"></alfresco-search>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div *ngIf="fileShowed">
|
<div *ngIf="fileShowed">
|
||||||
|
@@ -52,9 +52,17 @@ export class SearchComponent {
|
|||||||
constructor(public router: Router) {
|
constructor(public router: Router) {
|
||||||
}
|
}
|
||||||
|
|
||||||
showFile(event) {
|
nodeDbClick($event: any) {
|
||||||
if (event.value.entry.isFile) {
|
if ($event.value.entry.isFolder) {
|
||||||
this.fileNodeId = event.value.entry.id;
|
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;
|
this.fileShowed = true;
|
||||||
} else {
|
} else {
|
||||||
this.fileShowed = false;
|
this.fileShowed = false;
|
||||||
|
@@ -88,20 +88,22 @@ results page will be shown.
|
|||||||
|
|
||||||
### Properties
|
### 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 |
|
| 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. |
|
| 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. |
|
| 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" |
|
| 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
|
### Events
|
||||||
|
|
||||||
| Name | Description |
|
| Name | Description |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| preview | Emitted when user acts upon files with either single or double click (depends on `navigation-mode`), recommended for Viewer components integration |
|
| 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 |
|
| resultsLoad | Emitted when search results have fully loaded |
|
||||||
|
|
||||||
## Build from sources
|
## Build from sources
|
||||||
|
@@ -8,7 +8,9 @@
|
|||||||
[creationMenuActions]="false"
|
[creationMenuActions]="false"
|
||||||
[contentActions]="true"
|
[contentActions]="true"
|
||||||
[navigationMode]="navigationMode"
|
[navigationMode]="navigationMode"
|
||||||
|
[navigate]="navigate"
|
||||||
[enablePagination]="false"
|
[enablePagination]="false"
|
||||||
|
(nodeDblClick)="onDoubleClick($event)"
|
||||||
(preview)="onPreviewFile($event)">
|
(preview)="onPreviewFile($event)">
|
||||||
<empty-folder-content>
|
<empty-folder-content>
|
||||||
<ng-template>
|
<ng-template>
|
||||||
|
@@ -49,6 +49,9 @@ export class SearchComponent implements OnChanges, OnInit {
|
|||||||
@Input()
|
@Input()
|
||||||
navigationMode: string = SearchComponent.DOUBLE_CLICK_NAVIGATION; // click|dblclick
|
navigationMode: string = SearchComponent.DOUBLE_CLICK_NAVIGATION; // click|dblclick
|
||||||
|
|
||||||
|
@Input()
|
||||||
|
navigate: boolean = true;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
emptyFolderImageUrl: string = require('../assets/images/empty_doc_lib.svg');
|
emptyFolderImageUrl: string = require('../assets/images/empty_doc_lib.svg');
|
||||||
|
|
||||||
@@ -58,6 +61,9 @@ export class SearchComponent implements OnChanges, OnInit {
|
|||||||
@Output()
|
@Output()
|
||||||
preview: EventEmitter<any> = new EventEmitter<any>();
|
preview: EventEmitter<any> = new EventEmitter<any>();
|
||||||
|
|
||||||
|
@Output()
|
||||||
|
nodeDbClick: EventEmitter<any> = new EventEmitter<any>();
|
||||||
|
|
||||||
pagination: Pagination;
|
pagination: Pagination;
|
||||||
errorMessage;
|
errorMessage;
|
||||||
queryParamName = 'q';
|
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) {
|
onPreviewFile(event: any) {
|
||||||
if (event.value) {
|
if (event.value) {
|
||||||
this.preview.emit({
|
this.preview.emit({ value: event.value });
|
||||||
value: event.value
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user