diff --git a/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.html b/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.html index 84ee1aabe..32ca3859e 100644 --- a/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.html +++ b/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.html @@ -11,9 +11,9 @@ - - {{doc.created_date | customDate}} - {{doc.title | documentTitle}} + + {{doc.created_date | customDate}} + {{doc.title | documentTitle}} diff --git a/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.scss b/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.scss index 2edac1661..62bea686f 100644 --- a/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.scss +++ b/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.scss @@ -7,6 +7,6 @@ th:first-child { width: 25%; } -tbody tr { +tbody app-tag { cursor: pointer; } diff --git a/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.ts b/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.ts index 65ea4de0b..5e30ff8cd 100644 --- a/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.ts +++ b/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.ts @@ -72,7 +72,9 @@ export class SavedViewWidgetComponent implements OnInit, OnDestroy { } } - clickTag(tag: PaperlessTag) { + clickTag(tag: PaperlessTag, event: MouseEvent) { + event.preventDefault() + this.list.quickFilter([ { rule_type: FILTER_HAS_TAGS_ALL, value: tag.id.toString() }, ]) diff --git a/src-ui/src/app/components/document-detail/document-detail.component.ts b/src-ui/src/app/components/document-detail/document-detail.component.ts index 72f7b3613..557a0929f 100644 --- a/src-ui/src/app/components/document-detail/document-detail.component.ts +++ b/src-ui/src/app/components/document-detail/document-detail.component.ts @@ -184,7 +184,7 @@ export class DocumentDetailComponent this.openDocumentService.getOpenDocument(this.documentId) ) } else { - this.openDocumentService.openDocument(doc, false) + this.openDocumentService.openDocument(doc) this.updateComponent(doc) } diff --git a/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.html b/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.html index 1b859f39b..80aedb7f2 100644 --- a/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.html +++ b/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.html @@ -37,7 +37,7 @@  More like this - +  Edit diff --git a/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.ts b/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.ts index de6b94032..512cb51ae 100644 --- a/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.ts +++ b/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.ts @@ -10,9 +10,6 @@ import { PaperlessDocument } from 'src/app/data/paperless-document' import { DocumentService } from 'src/app/services/rest/document.service' import { SettingsService } from 'src/app/services/settings.service' import { NgbPopover } from '@ng-bootstrap/ng-bootstrap' -import { OpenDocumentsService } from 'src/app/services/open-documents.service' -import { DocumentListViewService } from 'src/app/services/document-list-view.service' -import { FILTER_FULLTEXT_MORELIKE } from 'src/app/data/filter-rule-type' import { SETTINGS_KEYS } from 'src/app/data/paperless-uisettings' @Component({ @@ -26,8 +23,7 @@ import { SETTINGS_KEYS } from 'src/app/data/paperless-uisettings' export class DocumentCardLargeComponent implements OnInit { constructor( private documentService: DocumentService, - private settingsService: SettingsService, - public openDocumentsService: OpenDocumentsService + private settingsService: SettingsService ) {} @Input() @@ -119,6 +115,9 @@ export class DocumentCardLargeComponent implements OnInit { } get contentTrimmed() { - return this.document.content.substr(0, 500) + return ( + this.document.content.substr(0, 500) + + (this.document.content.length > 500 ? '...' : '') + ) } } diff --git a/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.html b/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.html index aec8d76ae..5e46ed7b4 100644 --- a/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.html +++ b/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.html @@ -67,7 +67,7 @@
- + diff --git a/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.ts b/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.ts index 3f7fc7982..8e6ae33a6 100644 --- a/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.ts +++ b/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.ts @@ -11,7 +11,6 @@ import { PaperlessDocument } from 'src/app/data/paperless-document' import { DocumentService } from 'src/app/services/rest/document.service' import { SettingsService } from 'src/app/services/settings.service' import { NgbPopover } from '@ng-bootstrap/ng-bootstrap' -import { OpenDocumentsService } from 'src/app/services/open-documents.service' import { SETTINGS_KEYS } from 'src/app/data/paperless-uisettings' @Component({ @@ -25,8 +24,7 @@ import { SETTINGS_KEYS } from 'src/app/data/paperless-uisettings' export class DocumentCardSmallComponent implements OnInit { constructor( private documentService: DocumentService, - private settingsService: SettingsService, - public openDocumentsService: OpenDocumentsService + private settingsService: SettingsService ) {} @Input() diff --git a/src-ui/src/app/components/document-list/document-list.component.html b/src-ui/src/app/components/document-list/document-list.component.html index 9357813f6..892a0d3b2 100644 --- a/src-ui/src/app/components/document-list/document-list.component.html +++ b/src-ui/src/app/components/document-list/document-list.component.html @@ -179,7 +179,7 @@ - {{d.title | documentTitle}} + {{d.title | documentTitle}} diff --git a/src-ui/src/app/services/document-list-view.service.ts b/src-ui/src/app/services/document-list-view.service.ts index 3eb036710..3c5dbca21 100644 --- a/src-ui/src/app/services/document-list-view.service.ts +++ b/src-ui/src/app/services/document-list-view.service.ts @@ -213,7 +213,8 @@ export class DocumentListViewService { this.currentPageSize, activeListViewState.sortField, activeListViewState.sortReverse, - activeListViewState.filterRules + activeListViewState.filterRules, + { truncate_content: true } ) .subscribe({ next: (result) => { diff --git a/src-ui/src/app/services/open-documents.service.ts b/src-ui/src/app/services/open-documents.service.ts index 8533166c3..a21523458 100644 --- a/src-ui/src/app/services/open-documents.service.ts +++ b/src-ui/src/app/services/open-documents.service.ts @@ -6,7 +6,6 @@ import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { ConfirmDialogComponent } from 'src/app/components/common/confirm-dialog/confirm-dialog.component' import { Observable, Subject, of } from 'rxjs' import { first } from 'rxjs/operators' -import { Router } from '@angular/router' @Injectable({ providedIn: 'root', @@ -16,8 +15,7 @@ export class OpenDocumentsService { constructor( private documentService: DocumentService, - private modalService: NgbModal, - private router: Router + private modalService: NgbModal ) { if (sessionStorage.getItem(OPEN_DOCUMENT_SERVICE.DOCUMENTS)) { try { @@ -57,39 +55,28 @@ export class OpenDocumentsService { return this.openDocuments.find((d) => d.id == id) } - openDocument( - doc: PaperlessDocument, - navigate: boolean = true - ): Observable { + openDocument(doc: PaperlessDocument): Observable { if (this.openDocuments.find((d) => d.id == doc.id) == null) { if (this.openDocuments.length == this.MAX_OPEN_DOCUMENTS) { // at max, ensure changes arent lost const docToRemove = this.openDocuments[this.MAX_OPEN_DOCUMENTS - 1] const closeObservable = this.closeDocument(docToRemove) closeObservable.pipe(first()).subscribe((closed) => { - if (closed) this.finishOpenDocument(doc, navigate) + if (closed) this.finishOpenDocument(doc) }) return closeObservable } else { // not at max - this.finishOpenDocument(doc, navigate) - } - } else { - // doc is open, just maybe navigate - if (navigate) { - this.router.navigate(['documents', doc.id]) + this.finishOpenDocument(doc) } } return of(true) } - private finishOpenDocument(doc: PaperlessDocument, navigate: boolean) { + private finishOpenDocument(doc: PaperlessDocument) { this.openDocuments.unshift(doc) this.dirtyDocuments.delete(doc.id) this.save() - if (navigate) { - this.router.navigate(['documents', doc.id]) - } } setDirty(doc: PaperlessDocument, dirty: boolean) { diff --git a/src/documents/serialisers.py b/src/documents/serialisers.py index 3e6ec4390..a86e590ae 100644 --- a/src/documents/serialisers.py +++ b/src/documents/serialisers.py @@ -234,6 +234,12 @@ class DocumentSerializer(DynamicFieldsModelSerializer): else: return None + def to_representation(self, instance): + doc = super().to_representation(instance) + if self.truncate_content: + doc["content"] = doc.get("content")[0:550] + return doc + def update(self, instance, validated_data): if "created_date" in validated_data and "created" not in validated_data: new_datetime = datetime.datetime.combine( @@ -247,6 +253,11 @@ class DocumentSerializer(DynamicFieldsModelSerializer): super().update(instance, validated_data) return instance + def __init__(self, *args, **kwargs): + self.truncate_content = kwargs.pop("truncate_content", False) + + super().__init__(*args, **kwargs) + class Meta: model = Document depth = 1 diff --git a/src/documents/views.py b/src/documents/views.py index ce82cbfaa..7ff6e90d9 100644 --- a/src/documents/views.py +++ b/src/documents/views.py @@ -226,9 +226,11 @@ class DocumentViewSet( fields = fields_param.split(",") else: fields = None + truncate_content = self.request.query_params.get("truncate_content", "False") serializer_class = self.get_serializer_class() kwargs.setdefault("context", self.get_serializer_context()) kwargs.setdefault("fields", fields) + kwargs.setdefault("truncate_content", truncate_content.lower() in ["true", "1"]) return serializer_class(*args, **kwargs) def update(self, request, *args, **kwargs):