<context context-type="linenumber">23</context>
</context-group>
</trans-unit>
+ <trans-unit id="4460262093225954455" datatype="html">
+ <source>Search score</source>
+ <context-group purpose="location">
+ <context context-type="sourcefile">src/app/services/rest/document.service.ts</context>
+ <context context-type="linenumber">28</context>
+ </context-group>
+ <note priority="1" from="description">Score is a value returned by the full text search engine and specifies how well a result matches the given query</note>
+ </trans-unit>
<trans-unit id="4561076822163447092" datatype="html">
<source>Create new item</source>
<context-group purpose="location">
import { ActivatedRoute, Router } from '@angular/router';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { Subscription } from 'rxjs';
-import { FilterRule } from 'src/app/data/filter-rule';
+import { FilterRule, isFullTextFilterRule } from 'src/app/data/filter-rule';
import { FILTER_FULLTEXT_MORELIKE } from 'src/app/data/filter-rule-type';
import { PaperlessDocument } from 'src/app/data/paperless-document';
import { PaperlessSavedView } from 'src/app/data/paperless-saved-view';
import { SortableDirective, SortEvent } from 'src/app/directives/sortable.directive';
import { ConsumerStatusService } from 'src/app/services/consumer-status.service';
import { DocumentListViewService } from 'src/app/services/document-list-view.service';
-import { DOCUMENT_SORT_FIELDS } from 'src/app/services/rest/document.service';
+import { DOCUMENT_SORT_FIELDS, DOCUMENT_SORT_FIELDS_FULLTEXT } from 'src/app/services/rest/document.service';
import { SavedViewService } from 'src/app/services/rest/saved-view.service';
import { ToastService } from 'src/app/services/toast.service';
import { FilterEditorComponent } from './filter-editor/filter-editor.component';
}
getSortFields() {
- return DOCUMENT_SORT_FIELDS
+ return isFullTextFilterRule(this.list.filterRules) ? DOCUMENT_SORT_FIELDS_FULLTEXT : DOCUMENT_SORT_FIELDS
}
onSort(event: SortEvent) {
import { Injectable } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { Observable } from 'rxjs';
-import { cloneFilterRules, FilterRule } from '../data/filter-rule';
-import { FILTER_FULLTEXT_MORELIKE, FILTER_FULLTEXT_QUERY } from '../data/filter-rule-type';
+import { cloneFilterRules, FilterRule, isFullTextFilterRule } from '../data/filter-rule';
import { PaperlessDocument } from '../data/paperless-document';
import { PaperlessSavedView } from '../data/paperless-saved-view';
import { DOCUMENT_LIST_SERVICE } from '../data/storage-keys';
import { DocumentService } from './rest/document.service';
import { SettingsService, SETTINGS_KEYS } from './settings.service';
+/**
+ * Captures the current state of the list view.
+ */
interface ListViewState {
+ /**
+ * Title of the document list view. Either "Documents" (localized) or the name of a saved view.
+ */
title?: string
+ /**
+ * Current paginated list of documents displayed.
+ */
documents?: PaperlessDocument[]
currentPage: number
+
+ /**
+ * Total amount of documents with the current filter rules. Used to calculate the number of pages.
+ */
collectionSize: number
+ /**
+ * Currently selected sort field.
+ */
sortField: string
+
+ /**
+ * True if the list is sorted in reverse.
+ */
sortReverse: boolean
+ /**
+ * Filter rules for the current list view.
+ */
filterRules: FilterRule[]
+ /**
+ * Contains the IDs of all selected documents.
+ */
selected?: Set<number>
}
}
set filterRules(filterRules: FilterRule[]) {
- this.activeListViewState.filterRules = filterRules
- if (filterRules.find(r => (r.rule_type == FILTER_FULLTEXT_QUERY || r.rule_type == FILTER_FULLTEXT_MORELIKE))) {
- this.activeListViewState.currentPage = 1
+ if (!isFullTextFilterRule(filterRules) && this.activeListViewState.sortField == "score") {
+ this.activeListViewState.sortField = "created"
}
+ this.activeListViewState.filterRules = filterRules
this.reload()
this.reduceSelectionToFilter()
this.saveDocumentListView()
this._activeSavedViewId = null
this.activeListViewState.filterRules = filterRules
this.activeListViewState.currentPage = 1
+ if (isFullTextFilterRule(filterRules)) {
+ this.activeListViewState.sortField = "score"
+ this.activeListViewState.sortReverse = false
+ }
this.reduceSelectionToFilter()
this.saveDocumentListView()
if (this.router.url == "/documents") {