mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-1873] Remove all deprecated code from ADF (#4145)
* remove deprecated code part 1 * remove deprecation step 2 * fix spellcheck * fix * fix lint * fix not used import * remove deprecation * fix test first part after remove deprecation * fix test * fix sidebar demo shell
This commit is contained in:
@@ -32,8 +32,7 @@
|
||||
<adf-search #search
|
||||
#auto="searchAutocomplete"
|
||||
class="adf-search-result-autocomplete"
|
||||
[maxResults]="liveSearchMaxResults"
|
||||
[queryBody]="customQueryBody">
|
||||
[maxResults]="liveSearchMaxResults">
|
||||
<ng-template let-data>
|
||||
<mat-list *ngIf="isSearchBarActive()" id="autocomplete-search-result-list">
|
||||
<mat-list-item
|
||||
|
@@ -19,7 +19,7 @@ import { AuthenticationService, ThumbnailService } from '@alfresco/adf-core';
|
||||
import { animate, state, style, transition, trigger } from '@angular/animations';
|
||||
import { Component, EventEmitter, Input, OnDestroy, OnInit, Output,
|
||||
QueryList, ViewEncapsulation, ViewChild, ViewChildren, ElementRef, TemplateRef, ContentChild } from '@angular/core';
|
||||
import { NodeEntry, QueryBody } from '@alfresco/js-api';
|
||||
import { NodeEntry } from '@alfresco/js-api';
|
||||
import { Observable, Subject } from 'rxjs';
|
||||
import { SearchComponent } from './search.component';
|
||||
import { MatListItem } from '@angular/material';
|
||||
@@ -72,10 +72,6 @@ export class SearchControlComponent implements OnInit, OnDestroy {
|
||||
@Input()
|
||||
liveSearchMaxResults: number = 5;
|
||||
|
||||
/** @deprecated in 2.1.0 */
|
||||
@Input()
|
||||
customQueryBody: QueryBody;
|
||||
|
||||
/** Emitted when the search is submitted by pressing the ENTER key.
|
||||
* The search term is provided as the value of the event.
|
||||
*/
|
||||
|
@@ -17,22 +17,10 @@
|
||||
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { SearchService, setupTestBed, CoreModule } from '@alfresco/adf-core';
|
||||
import { QueryBody } from '@alfresco/js-api';
|
||||
import { differentResult, folderResult, result, SimpleSearchTestComponent } from '../../mock';
|
||||
import { Observable, of, throwError } from 'rxjs';
|
||||
import { differentResult, result, SimpleSearchTestComponent } from '../../mock';
|
||||
import { of, throwError } from 'rxjs';
|
||||
import { SearchModule } from '../search.module';
|
||||
|
||||
function fakeNodeResultSearch(searchNode: QueryBody): Observable<any> {
|
||||
if (searchNode && searchNode.query.query === 'FAKE_SEARCH_EXMPL') {
|
||||
return of(differentResult);
|
||||
}
|
||||
if (searchNode && searchNode.filterQueries.length === 1 &&
|
||||
searchNode.filterQueries[0].query === "TYPE:'cm:folder'") {
|
||||
return of(folderResult);
|
||||
}
|
||||
return of(result);
|
||||
}
|
||||
|
||||
describe('SearchComponent', () => {
|
||||
|
||||
let fixture: ComponentFixture<SimpleSearchTestComponent>, element: HTMLElement;
|
||||
@@ -131,30 +119,6 @@ describe('SearchComponent', () => {
|
||||
|
||||
describe('search node', () => {
|
||||
|
||||
it('should perform a search based on the query node given', (done) => {
|
||||
spyOn(searchService, 'searchByQueryBody')
|
||||
.and.callFake((searchObj) => fakeNodeResultSearch(searchObj));
|
||||
let fakeSearchNode: QueryBody = {
|
||||
query: {
|
||||
query: 'TEST-FAKE-NODE'
|
||||
},
|
||||
filterQueries: [
|
||||
{ 'query': "TYPE:'cm:folder'" }
|
||||
]
|
||||
};
|
||||
component.setSearchWordTo('searchTerm');
|
||||
component.setSearchNodeTo(fakeSearchNode);
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
let optionShowed = element.querySelectorAll('#autocomplete-search-result-list > li').length;
|
||||
expect(optionShowed).toBe(1);
|
||||
let folderOption: HTMLElement = <HTMLElement> element.querySelector('#result_option_0');
|
||||
expect(folderOption.textContent.trim()).toBe('MyFolder');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should perform a search with a defaultNode if no search node is given', (done) => {
|
||||
spyOn(searchService, 'search').and.returnValue(of(result));
|
||||
component.setSearchWordTo('searchTerm');
|
||||
@@ -168,29 +132,5 @@ describe('SearchComponent', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should perform a search with the searchNode given', (done) => {
|
||||
spyOn(searchService, 'searchByQueryBody')
|
||||
.and.callFake((searchObj) => fakeNodeResultSearch(searchObj));
|
||||
let fakeSearchNode: QueryBody = {
|
||||
query: {
|
||||
query: 'FAKE_SEARCH_EXMPL'
|
||||
},
|
||||
filterQueries: [
|
||||
{ 'query': "TYPE:'cm:folder'" }
|
||||
]
|
||||
};
|
||||
component.setSearchWordTo('searchTerm');
|
||||
component.setSearchNodeTo(fakeSearchNode);
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
let optionShowed = element.querySelectorAll('#autocomplete-search-result-list > li').length;
|
||||
expect(optionShowed).toBe(1);
|
||||
let folderOption: HTMLElement = <HTMLElement> element.querySelector('#result_option_0');
|
||||
expect(folderOption.textContent.trim()).toBe('TEST_DOC');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -29,7 +29,7 @@ import {
|
||||
ViewChild,
|
||||
ViewEncapsulation
|
||||
} from '@angular/core';
|
||||
import { NodePaging, QueryBody } from '@alfresco/js-api';
|
||||
import { NodePaging } from '@alfresco/js-api';
|
||||
import { Subject } from 'rxjs';
|
||||
import { debounceTime } from 'rxjs/operators';
|
||||
|
||||
@@ -64,10 +64,6 @@ export class SearchComponent implements AfterContentInit, OnChanges {
|
||||
@Input()
|
||||
skipResults: number = 0;
|
||||
|
||||
/** @deprecated in 2.1.0 */
|
||||
@Input()
|
||||
queryBody: QueryBody;
|
||||
|
||||
/** Search term to use when executing the search. Updating this value will
|
||||
* run a new search and update the results.
|
||||
*/
|
||||
@@ -129,10 +125,6 @@ export class SearchComponent implements AfterContentInit, OnChanges {
|
||||
}
|
||||
|
||||
ngOnChanges(changes) {
|
||||
if (changes.queryBody &&
|
||||
this.hasDifferentQueryBody(changes.queryBody.previousValue, changes.queryBody.currentValue)) {
|
||||
this.loadSearchResults();
|
||||
}
|
||||
if (changes.searchTerm && changes.searchTerm.currentValue) {
|
||||
this.loadSearchResults(changes.searchTerm.currentValue);
|
||||
}
|
||||
@@ -147,10 +139,6 @@ export class SearchComponent implements AfterContentInit, OnChanges {
|
||||
this.loadSearchResults(this.searchTerm);
|
||||
}
|
||||
|
||||
private hasDifferentQueryBody(previousQueryBody: QueryBody, currentQueryBody: QueryBody) {
|
||||
return JSON.stringify(previousQueryBody) !== JSON.stringify(currentQueryBody);
|
||||
}
|
||||
|
||||
private cleanResults() {
|
||||
if (this.results) {
|
||||
this.results = {};
|
||||
@@ -160,17 +148,10 @@ export class SearchComponent implements AfterContentInit, OnChanges {
|
||||
private loadSearchResults(searchTerm?: string) {
|
||||
this.resetResults();
|
||||
if (searchTerm) {
|
||||
if (this.queryBody) {
|
||||
this.searchService.searchByQueryBody(this.queryBody).subscribe(
|
||||
(result) => this.onSearchDataLoaded(result),
|
||||
(err) => this.onSearchDataError(err)
|
||||
);
|
||||
} else {
|
||||
this.searchService.search(searchTerm, this.maxResults, this.skipResults).subscribe(
|
||||
(result) => this.onSearchDataLoaded(result),
|
||||
(err) => this.onSearchDataError(err)
|
||||
);
|
||||
}
|
||||
this.searchService.search(searchTerm, this.maxResults, this.skipResults).subscribe(
|
||||
(result) => this.onSearchDataLoaded(result),
|
||||
(err) => this.onSearchDataError(err)
|
||||
);
|
||||
} else {
|
||||
this.cleanResults();
|
||||
}
|
||||
|
Reference in New Issue
Block a user