mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
Fix: retain sort field from global search filtering, use FILTER_HAS_TAGS_ALL
(#6737)
This commit is contained in:
parent
45138a1881
commit
97eec44647
@ -24,7 +24,7 @@ import {
|
|||||||
FILTER_HAS_CORRESPONDENT_ANY,
|
FILTER_HAS_CORRESPONDENT_ANY,
|
||||||
FILTER_HAS_DOCUMENT_TYPE_ANY,
|
FILTER_HAS_DOCUMENT_TYPE_ANY,
|
||||||
FILTER_HAS_STORAGE_PATH_ANY,
|
FILTER_HAS_STORAGE_PATH_ANY,
|
||||||
FILTER_HAS_TAGS_ANY,
|
FILTER_HAS_TAGS_ALL,
|
||||||
} from 'src/app/data/filter-rule-type'
|
} from 'src/app/data/filter-rule-type'
|
||||||
import { NgxBootstrapIconsModule, allIcons } from 'ngx-bootstrap-icons'
|
import { NgxBootstrapIconsModule, allIcons } from 'ngx-bootstrap-icons'
|
||||||
import { DocumentService } from 'src/app/services/rest/document.service'
|
import { DocumentService } from 'src/app/services/rest/document.service'
|
||||||
@ -294,36 +294,67 @@ describe('GlobalSearchComponent', () => {
|
|||||||
|
|
||||||
component.primaryAction(DataType.Correspondent, object)
|
component.primaryAction(DataType.Correspondent, object)
|
||||||
expect(routerSpy).toHaveBeenCalledWith(['/documents'], {
|
expect(routerSpy).toHaveBeenCalledWith(['/documents'], {
|
||||||
queryParams: queryParamsFromFilterRules([
|
queryParams: Object.assign(
|
||||||
{
|
{
|
||||||
rule_type: FILTER_HAS_CORRESPONDENT_ANY,
|
page: 1,
|
||||||
value: object.id.toString(),
|
reverse: 1,
|
||||||
|
sort: 'created',
|
||||||
},
|
},
|
||||||
]),
|
queryParamsFromFilterRules([
|
||||||
|
{
|
||||||
|
rule_type: FILTER_HAS_CORRESPONDENT_ANY,
|
||||||
|
value: object.id.toString(),
|
||||||
|
},
|
||||||
|
])
|
||||||
|
),
|
||||||
})
|
})
|
||||||
|
|
||||||
component.primaryAction(DataType.DocumentType, object)
|
component.primaryAction(DataType.DocumentType, object)
|
||||||
expect(routerSpy).toHaveBeenCalledWith(['/documents'], {
|
expect(routerSpy).toHaveBeenCalledWith(['/documents'], {
|
||||||
queryParams: queryParamsFromFilterRules([
|
queryParams: Object.assign(
|
||||||
{
|
{
|
||||||
rule_type: FILTER_HAS_DOCUMENT_TYPE_ANY,
|
page: 1,
|
||||||
value: object.id.toString(),
|
reverse: 1,
|
||||||
|
sort: 'created',
|
||||||
},
|
},
|
||||||
]),
|
queryParamsFromFilterRules([
|
||||||
|
{
|
||||||
|
rule_type: FILTER_HAS_DOCUMENT_TYPE_ANY,
|
||||||
|
value: object.id.toString(),
|
||||||
|
},
|
||||||
|
])
|
||||||
|
),
|
||||||
})
|
})
|
||||||
|
|
||||||
component.primaryAction(DataType.StoragePath, object)
|
component.primaryAction(DataType.StoragePath, object)
|
||||||
expect(routerSpy).toHaveBeenCalledWith(['/documents'], {
|
expect(routerSpy).toHaveBeenCalledWith(['/documents'], {
|
||||||
queryParams: queryParamsFromFilterRules([
|
queryParams: Object.assign(
|
||||||
{ rule_type: FILTER_HAS_STORAGE_PATH_ANY, value: object.id.toString() },
|
{
|
||||||
]),
|
page: 1,
|
||||||
|
reverse: 1,
|
||||||
|
sort: 'created',
|
||||||
|
},
|
||||||
|
queryParamsFromFilterRules([
|
||||||
|
{
|
||||||
|
rule_type: FILTER_HAS_STORAGE_PATH_ANY,
|
||||||
|
value: object.id.toString(),
|
||||||
|
},
|
||||||
|
])
|
||||||
|
),
|
||||||
})
|
})
|
||||||
|
|
||||||
component.primaryAction(DataType.Tag, object)
|
component.primaryAction(DataType.Tag, object)
|
||||||
expect(routerSpy).toHaveBeenCalledWith(['/documents'], {
|
expect(routerSpy).toHaveBeenCalledWith(['/documents'], {
|
||||||
queryParams: queryParamsFromFilterRules([
|
queryParams: Object.assign(
|
||||||
{ rule_type: FILTER_HAS_TAGS_ANY, value: object.id.toString() },
|
{
|
||||||
]),
|
page: 1,
|
||||||
|
reverse: 1,
|
||||||
|
sort: 'created',
|
||||||
|
},
|
||||||
|
queryParamsFromFilterRules([
|
||||||
|
{ rule_type: FILTER_HAS_TAGS_ALL, value: object.id.toString() },
|
||||||
|
])
|
||||||
|
),
|
||||||
})
|
})
|
||||||
|
|
||||||
component.primaryAction(DataType.User, object)
|
component.primaryAction(DataType.User, object)
|
||||||
|
@ -14,7 +14,7 @@ import {
|
|||||||
FILTER_HAS_CORRESPONDENT_ANY,
|
FILTER_HAS_CORRESPONDENT_ANY,
|
||||||
FILTER_HAS_DOCUMENT_TYPE_ANY,
|
FILTER_HAS_DOCUMENT_TYPE_ANY,
|
||||||
FILTER_HAS_STORAGE_PATH_ANY,
|
FILTER_HAS_STORAGE_PATH_ANY,
|
||||||
FILTER_HAS_TAGS_ANY,
|
FILTER_HAS_TAGS_ALL,
|
||||||
} from 'src/app/data/filter-rule-type'
|
} from 'src/app/data/filter-rule-type'
|
||||||
import { DataType } from 'src/app/data/datatype'
|
import { DataType } from 'src/app/data/datatype'
|
||||||
import { ObjectWithId } from 'src/app/data/object-with-id'
|
import { ObjectWithId } from 'src/app/data/object-with-id'
|
||||||
@ -41,7 +41,7 @@ import { TagEditDialogComponent } from '../../common/edit-dialog/tag-edit-dialog
|
|||||||
import { UserEditDialogComponent } from '../../common/edit-dialog/user-edit-dialog/user-edit-dialog.component'
|
import { UserEditDialogComponent } from '../../common/edit-dialog/user-edit-dialog/user-edit-dialog.component'
|
||||||
import { WorkflowEditDialogComponent } from '../../common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component'
|
import { WorkflowEditDialogComponent } from '../../common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component'
|
||||||
import { HotKeyService } from 'src/app/services/hot-key.service'
|
import { HotKeyService } from 'src/app/services/hot-key.service'
|
||||||
import { queryParamsFromFilterRules } from 'src/app/utils/query-params'
|
import { paramsFromViewState } from 'src/app/utils/query-params'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'pngx-global-search',
|
selector: 'pngx-global-search',
|
||||||
@ -132,7 +132,7 @@ export class GlobalSearchComponent implements OnInit {
|
|||||||
filterRuleType = FILTER_HAS_STORAGE_PATH_ANY
|
filterRuleType = FILTER_HAS_STORAGE_PATH_ANY
|
||||||
break
|
break
|
||||||
case DataType.Tag:
|
case DataType.Tag:
|
||||||
filterRuleType = FILTER_HAS_TAGS_ANY
|
filterRuleType = FILTER_HAS_TAGS_ALL
|
||||||
break
|
break
|
||||||
case DataType.User:
|
case DataType.User:
|
||||||
editDialogComponent = UserEditDialogComponent
|
editDialogComponent = UserEditDialogComponent
|
||||||
@ -160,9 +160,14 @@ export class GlobalSearchComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (filterRuleType) {
|
if (filterRuleType) {
|
||||||
let params = queryParamsFromFilterRules([
|
let params = paramsFromViewState({
|
||||||
{ rule_type: filterRuleType, value: object.id.toString() },
|
filterRules: [
|
||||||
])
|
{ rule_type: filterRuleType, value: object.id.toString() },
|
||||||
|
],
|
||||||
|
currentPage: 1,
|
||||||
|
sortField: this.documentListViewService.sortField ?? 'created',
|
||||||
|
sortReverse: this.documentListViewService.sortReverse,
|
||||||
|
})
|
||||||
this.navigateOrOpenInNewWindow(['/documents'], newWindow, {
|
this.navigateOrOpenInNewWindow(['/documents'], newWindow, {
|
||||||
queryParams: params,
|
queryParams: params,
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user