mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-31 17:38:28 +00:00
[ACA-1968] Trigger search on Enter (#827)
* [ACA-1968] remove arrow from active input * [ACA-1968] remove route reuse * [ACA-1968] trigger search on Enter
This commit is contained in:
committed by
Denys Vuika
parent
647117b488
commit
e3cbb5f13d
@@ -18,7 +18,6 @@
|
||||
|
||||
<div matSuffix class="app-suffix-search-icon-wrapper">
|
||||
<mat-icon *ngIf="searchTerm.length" (click)="clear()" class="app-clear-icon">clear</mat-icon>
|
||||
<mat-icon *ngIf="!searchTerm.length">arrow_drop_down</mat-icon>
|
||||
</div>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
|
@@ -32,7 +32,7 @@
|
||||
id="{{ option.id }}"
|
||||
[(ngModel)]="option.value"
|
||||
[disabled]="option.shouldDisable()"
|
||||
(change)="onOptionChange()"
|
||||
(change)="searchByOption()"
|
||||
(click)="$event.stopPropagation()">
|
||||
{{ option.key | translate }}
|
||||
</mat-checkbox>
|
||||
|
@@ -47,6 +47,7 @@ import { filter, takeUntil } from 'rxjs/operators';
|
||||
import { SearchQueryBuilderService } from '@alfresco/adf-content-services';
|
||||
import { ContentManagementService } from '../../../services/content-management.service';
|
||||
import { Subject } from 'rxjs';
|
||||
import { SearchLibrariesQueryBuilderService } from '../search-libraries-results/search-libraries-query-builder.service';
|
||||
|
||||
export enum SearchOptionIds {
|
||||
Files = 'content',
|
||||
@@ -94,6 +95,7 @@ export class SearchInputComponent implements OnInit, OnDestroy {
|
||||
|
||||
constructor(
|
||||
private queryBuilder: SearchQueryBuilderService,
|
||||
private queryLibrariesBuilder: SearchLibrariesQueryBuilderService,
|
||||
private content: ContentManagementService,
|
||||
private router: Router,
|
||||
private store: Store<AppStore>
|
||||
@@ -156,9 +158,9 @@ export class SearchInputComponent implements OnInit, OnDestroy {
|
||||
this.has400LibraryError = false;
|
||||
const searchTerm = (event.target as HTMLInputElement).value;
|
||||
if (searchTerm) {
|
||||
this.store.dispatch(
|
||||
new SearchByTermAction(searchTerm, this.searchOptions)
|
||||
);
|
||||
this.searchedWord = searchTerm;
|
||||
|
||||
this.searchByOption();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,13 +189,15 @@ export class SearchInputComponent implements OnInit, OnDestroy {
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
onOptionChange() {
|
||||
searchByOption() {
|
||||
this.has400LibraryError = false;
|
||||
if (this.isLibrariesChecked()) {
|
||||
if (this.searchedWord && !this.onLibrariesSearchResults) {
|
||||
this.store.dispatch(
|
||||
new SearchByTermAction(this.searchedWord, this.searchOptions)
|
||||
);
|
||||
} else {
|
||||
this.queryLibrariesBuilder.update();
|
||||
}
|
||||
} else {
|
||||
if (this.isFoldersChecked() && !this.isFilesChecked()) {
|
||||
|
@@ -52,7 +52,9 @@ export class SearchLibrariesQueryBuilderService {
|
||||
|
||||
update(): void {
|
||||
const query = this.buildQuery();
|
||||
this.updated.next(query);
|
||||
if (query) {
|
||||
this.updated.next(query);
|
||||
}
|
||||
}
|
||||
|
||||
async execute() {
|
||||
@@ -65,7 +67,7 @@ export class SearchLibrariesQueryBuilderService {
|
||||
|
||||
buildQuery(): any {
|
||||
const query = this.userQuery;
|
||||
if (query) {
|
||||
if (query && query.length > 1) {
|
||||
const resultQuery = {
|
||||
term: query,
|
||||
opts: {
|
||||
|
@@ -38,8 +38,7 @@ import { BreakpointObserver, Breakpoints } from '@angular/cdk/layout';
|
||||
@Component({
|
||||
selector: 'aca-search-results',
|
||||
templateUrl: './search-libraries-results.component.html',
|
||||
styleUrls: ['./search-libraries-results.component.scss'],
|
||||
providers: [SearchLibrariesQueryBuilderService]
|
||||
styleUrls: ['./search-libraries-results.component.scss']
|
||||
})
|
||||
export class SearchLibrariesResultsComponent extends PageComponent
|
||||
implements OnInit {
|
||||
|
Reference in New Issue
Block a user