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
This commit is contained in:
parent
2a0c03eda0
commit
6897ffbd73
@ -19,8 +19,8 @@
|
||||
</div>
|
||||
</div>
|
||||
@if (query) {
|
||||
<button class="btn btn-sm btn-outline-secondary" type="button" (click)="runAdvanedSearch()">
|
||||
<ng-container i18n>Advanced search</ng-container>
|
||||
<button class="btn btn-sm btn-outline-secondary" type="button" (click)="runContentSearch()">
|
||||
<ng-container i18n>Search contents</ng-container>
|
||||
<i-bs width="1em" height="1em" name="arrow-right-short"></i-bs>
|
||||
</button>
|
||||
}
|
||||
|
@ -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' },
|
||||
])
|
||||
})
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user