mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ACS-5991] ESLint fixes and code quality improvements (#8893)
* prefer-optional-chain: core * prefer-optional-chain: content, fix typings * prefer-optional-chain: process, fix typings * prefer-optional-chain: process-cloud, fix typings, fix ts configs and eslint * [ci: force] sonar errors fixes, insights lib * [ci:force] fix security issues * [ci:force] fix metadata e2e bug, js assignment bugs * [ci:force] fix lint issue * [ci:force] fix tests
This commit is contained in:
@@ -28,7 +28,8 @@ import {
|
||||
TemplateRef,
|
||||
ViewChild,
|
||||
ViewEncapsulation,
|
||||
OnDestroy
|
||||
OnDestroy,
|
||||
SimpleChanges
|
||||
} from '@angular/core';
|
||||
import { NodePaging, ResultSetPaging } from '@alfresco/js-api';
|
||||
import { Subject } from 'rxjs';
|
||||
@@ -45,7 +46,6 @@ import { SearchComponentInterface } from '@alfresco/adf-core';
|
||||
host: { class: 'adf-search' }
|
||||
})
|
||||
export class SearchComponent implements SearchComponentInterface, AfterContentInit, OnChanges, OnDestroy {
|
||||
|
||||
@ViewChild('panel', { static: true })
|
||||
panel: ElementRef;
|
||||
|
||||
@@ -74,8 +74,8 @@ export class SearchComponent implements SearchComponentInterface, AfterContentIn
|
||||
// eslint-disable-next-line @angular-eslint/no-input-rename
|
||||
@Input('class')
|
||||
set classList(classList: string) {
|
||||
if (classList && classList.length) {
|
||||
classList.split(' ').forEach((className) => this._classList[className.trim()] = true);
|
||||
if (classList?.length) {
|
||||
classList.split(' ').forEach((className) => (this._classList[className.trim()] = true));
|
||||
this._elementRef.nativeElement.className = '';
|
||||
}
|
||||
}
|
||||
@@ -104,31 +104,23 @@ export class SearchComponent implements SearchComponentInterface, AfterContentIn
|
||||
_classList: { [key: string]: boolean } = {};
|
||||
private onDestroy$ = new Subject<boolean>();
|
||||
|
||||
constructor(private searchService: SearchService,
|
||||
private _elementRef: ElementRef) {
|
||||
this.keyPressedStream
|
||||
.pipe(
|
||||
debounceTime(200),
|
||||
takeUntil(this.onDestroy$)
|
||||
)
|
||||
.subscribe(searchedWord => {
|
||||
this.loadSearchResults(searchedWord);
|
||||
});
|
||||
constructor(private searchService: SearchService, private _elementRef: ElementRef) {
|
||||
this.keyPressedStream.pipe(debounceTime(200), takeUntil(this.onDestroy$)).subscribe((searchedWord) => {
|
||||
this.loadSearchResults(searchedWord);
|
||||
});
|
||||
|
||||
searchService.dataLoaded
|
||||
.pipe(takeUntil(this.onDestroy$))
|
||||
.subscribe(
|
||||
nodePaging => this.onSearchDataLoaded(nodePaging),
|
||||
error => this.onSearchDataError(error)
|
||||
);
|
||||
searchService.dataLoaded.pipe(takeUntil(this.onDestroy$)).subscribe(
|
||||
(nodePaging) => this.onSearchDataLoaded(nodePaging),
|
||||
(error) => this.onSearchDataError(error)
|
||||
);
|
||||
}
|
||||
|
||||
ngAfterContentInit() {
|
||||
this.setVisibility();
|
||||
}
|
||||
|
||||
ngOnChanges(changes) {
|
||||
if (changes.searchTerm && changes.searchTerm.currentValue) {
|
||||
ngOnChanges(changes: SimpleChanges) {
|
||||
if (changes.searchTerm?.currentValue) {
|
||||
this.loadSearchResults(changes.searchTerm.currentValue);
|
||||
}
|
||||
}
|
||||
@@ -174,8 +166,8 @@ export class SearchComponent implements SearchComponentInterface, AfterContentIn
|
||||
}
|
||||
}
|
||||
|
||||
onSearchDataError(error) {
|
||||
if (error && error.status !== 400) {
|
||||
onSearchDataError(error: { status: number }) {
|
||||
if (error?.status !== 400) {
|
||||
this.results = null;
|
||||
this.error.emit(error);
|
||||
}
|
||||
|
Reference in New Issue
Block a user