[ADF-2010] Move/copy, when searching for folder multiple results are returned (#2727)

* adding debounce time in object picker
unify search api
fix multiples duplicate result
remove limit of 4 character to search

* remove three.min.js

* remove unused import

* tlsint fix and remove file

* rename sitesApiService to sitesService as all the other services

* fix test timeout async
This commit is contained in:
Eugenio Romano
2017-11-26 22:06:05 +00:00
committed by GitHub
parent 4549dbf1f5
commit 197fab4da8
23 changed files with 380 additions and 323 deletions

View File

@@ -15,16 +15,34 @@
* limitations under the License.
*/
import { Component, EventEmitter, Inject, Input, OnInit, Optional, Output, ViewChild, ViewEncapsulation } from '@angular/core';
import { AlfrescoApiService, ContentService, HighlightDirective, SiteModel, UserPreferencesService } from '@alfresco/adf-core';
import {
Component,
EventEmitter,
Inject,
Input,
OnInit,
Optional,
Output,
ViewChild,
ViewEncapsulation
} from '@angular/core';
import {
AlfrescoApiService,
ContentService,
HighlightDirective,
SiteModel,
UserPreferencesService
} from '@alfresco/adf-core';
import { FormControl } from '@angular/forms';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material';
import { MinimalNodeEntryEntity, NodePaging, Pagination, Site } from 'alfresco-js-api';
import { DocumentListComponent, PaginationStrategy } from '../document-list/components/document-list.component';
import { DocumentListComponent, PaginationStrategy } from '../document-list/components/document-list.component';
import { RowFilter } from '../document-list/data/row-filter.model';
import { ImageResolver } from '../document-list/data/image-resolver.model';
import { ContentNodeSelectorComponentData } from './content-node-selector.component-data.interface';
import { ContentNodeSelectorService } from './content-node-selector.service';
import { debounceTime } from 'rxjs/operators';
@Component({
selector: 'adf-content-node-selector',
@@ -81,6 +99,10 @@ export class ContentNodeSelectorComponent implements OnInit {
@ViewChild(HighlightDirective)
highlighter: HighlightDirective;
debounceSearch: number= 200;
searchInput: FormControl = new FormControl();
constructor(private contentNodeSelectorService: ContentNodeSelectorService,
private contentService: ContentService,
private apiService: AlfrescoApiService,
@@ -102,6 +124,15 @@ export class ContentNodeSelectorComponent implements OnInit {
if (this.containingDialog) {
this.inDialog = true;
}
this.searchInput.valueChanges
.pipe(
debounceTime(this.debounceSearch)
)
.subscribe((searchValue) => {
this.search(searchValue);
});
this.pageSize = this.preferences.paginationSize;
}
@@ -200,12 +231,10 @@ export class ContentNodeSelectorComponent implements OnInit {
* Perform the call to searchService with the proper parameters
*/
private querySearch(): void {
if (this.isSearchTermLongEnough()) {
this.loadingSearchResults = true;
this.loadingSearchResults = true;
this.contentNodeSelectorService.search(this.searchTerm, this.siteId, this.skipCount, this.pageSize)
.subscribe(this.showSearchResults.bind(this));
}
this.contentNodeSelectorService.search(this.searchTerm, this.siteId, this.skipCount, this.pageSize)
.subscribe(this.showSearchResults.bind(this));
}
/**
@@ -228,13 +257,6 @@ export class ContentNodeSelectorComponent implements OnInit {
this.highlight();
}
/**
* Predicate method to decide whether searchTerm fulfills the necessary criteria
*/
isSearchTermLongEnough(): boolean {
return this.searchTerm.length > 3;
}
/**
* Hightlight the actual searchterm in the next frame
*/