From 6897ffbd736d30a61cfbb47965c67928daf3fb02 Mon Sep 17 00:00:00 2001 From: Felix Eckhofer Date: Tue, 21 May 2024 10:22:11 +0200 Subject: [PATCH] Run "Title & content" search from global search instead of advanced - This is in line with the default for the "documents" view (such as after "Reset filters") - It's more intuitive for new users - It yields the most search results Ref. paperless-ngx/paperless-ngx#6632 --- .../global-search/global-search.component.html | 4 ++-- .../global-search/global-search.component.spec.ts | 12 ++++++------ .../global-search/global-search.component.ts | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src-ui/src/app/components/app-frame/global-search/global-search.component.html b/src-ui/src/app/components/app-frame/global-search/global-search.component.html index eeb118967..dfd27e6a8 100644 --- a/src-ui/src/app/components/app-frame/global-search/global-search.component.html +++ b/src-ui/src/app/components/app-frame/global-search/global-search.component.html @@ -19,8 +19,8 @@ @if (query) { - } diff --git a/src-ui/src/app/components/app-frame/global-search/global-search.component.spec.ts b/src-ui/src/app/components/app-frame/global-search/global-search.component.spec.ts index 076fa95d1..95b96ae77 100644 --- a/src-ui/src/app/components/app-frame/global-search/global-search.component.spec.ts +++ b/src-ui/src/app/components/app-frame/global-search/global-search.component.spec.ts @@ -20,11 +20,11 @@ import { DocumentListViewService } from 'src/app/services/document-list-view.ser import { HttpClientTestingModule } from '@angular/common/http/testing' import { FormsModule, ReactiveFormsModule } from '@angular/forms' import { - FILTER_FULLTEXT_QUERY, FILTER_HAS_CORRESPONDENT_ANY, FILTER_HAS_DOCUMENT_TYPE_ANY, FILTER_HAS_STORAGE_PATH_ANY, FILTER_HAS_TAGS_ALL, + FILTER_TITLE_CONTENT, } from 'src/app/data/filter-rule-type' import { NgxBootstrapIconsModule, allIcons } from 'ngx-bootstrap-icons' import { DocumentService } from 'src/app/services/rest/document.service' @@ -262,9 +262,9 @@ describe('GlobalSearchComponent', () => { component.searchResults = searchResults as any component.resultsDropdown.open() component.query = 'test' - const advancedSearchSpy = jest.spyOn(component, 'runAdvanedSearch') + const contentsSearchSpy = jest.spyOn(component, 'runContentSearch') component.searchInputKeyDown(new KeyboardEvent('keydown', { key: 'Enter' })) - expect(advancedSearchSpy).toHaveBeenCalled() + expect(contentsSearchSpy).toHaveBeenCalled() }) it('should search on query debounce', fakeAsync(() => { @@ -499,12 +499,12 @@ describe('GlobalSearchComponent', () => { expect(focusSpy).toHaveBeenCalled() }) - it('should support explicit advanced search', () => { + it('should support explicit contents search', () => { const qfSpy = jest.spyOn(documentListViewService, 'quickFilter') component.query = 'test' - component.runAdvanedSearch() + component.runContentSearch() expect(qfSpy).toHaveBeenCalledWith([ - { rule_type: FILTER_FULLTEXT_QUERY, value: 'test' }, + { rule_type: FILTER_TITLE_CONTENT, value: 'test' }, ]) }) diff --git a/src-ui/src/app/components/app-frame/global-search/global-search.component.ts b/src-ui/src/app/components/app-frame/global-search/global-search.component.ts index 2742ff59a..9b99618c1 100644 --- a/src-ui/src/app/components/app-frame/global-search/global-search.component.ts +++ b/src-ui/src/app/components/app-frame/global-search/global-search.component.ts @@ -10,7 +10,7 @@ import { Router } from '@angular/router' import { NgbDropdown, NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap' import { Subject, debounceTime, distinctUntilChanged, filter, map } from 'rxjs' import { - FILTER_FULLTEXT_QUERY, + FILTER_TITLE_CONTENT, FILTER_HAS_CORRESPONDENT_ANY, FILTER_HAS_DOCUMENT_TYPE_ANY, FILTER_HAS_STORAGE_PATH_ANY, @@ -282,7 +282,7 @@ export class GlobalSearchComponent implements OnInit { this.primaryButtons.first.nativeElement.click() this.searchInput.nativeElement.blur() } else if (this.query?.length) { - this.runAdvanedSearch() + this.runContentSearch() this.reset(true) } } else if (event.key === 'Escape' && !this.resultsDropdown.isOpen()) { @@ -378,9 +378,9 @@ export class GlobalSearchComponent implements OnInit { ) } - public runAdvanedSearch() { + public runContentSearch() { this.documentListViewService.quickFilter([ - { rule_type: FILTER_FULLTEXT_QUERY, value: this.query }, + { rule_type: FILTER_TITLE_CONTENT, value: this.query }, ]) this.reset(true) }