let OpenDocumentsService handle nav

This commit is contained in:
Michael Shamoon
2022-05-15 23:25:46 -07:00
parent d0f70c8f18
commit c1fb277f25
10 changed files with 38 additions and 65 deletions

View File

@@ -11,7 +11,7 @@
</tr>
</thead>
<tbody>
<tr *ngFor="let doc of documents" (click)="clickDoc(doc)">
<tr *ngFor="let doc of documents" (click)="openDocumentsService.openDocument(doc)">
<td>{{doc.created | customDate}}</td>
<td>{{doc.title | documentTitle}}<app-tag [tag]="t" *ngFor="let t of doc.tags$ | async" class="ms-1" (click)="clickTag(t); $event.stopPropagation();"></app-tag></td>
</tr>

View File

@@ -1,6 +1,6 @@
import { Component, Input, OnDestroy, OnInit } from '@angular/core'
import { Router } from '@angular/router'
import { first, Subscription } from 'rxjs'
import { Subscription } from 'rxjs'
import { PaperlessDocument } from 'src/app/data/paperless-document'
import { PaperlessSavedView } from 'src/app/data/paperless-saved-view'
import { ConsumerStatusService } from 'src/app/services/consumer-status.service'
@@ -23,7 +23,7 @@ export class SavedViewWidgetComponent implements OnInit, OnDestroy {
private router: Router,
private queryParamsService: QueryParamsService,
private consumerStatusService: ConsumerStatusService,
private openDocumentsService: OpenDocumentsService
public openDocumentsService: OpenDocumentsService
) {}
@Input()
@@ -72,15 +72,6 @@ export class SavedViewWidgetComponent implements OnInit, OnDestroy {
}
}
clickDoc(doc: PaperlessDocument) {
this.openDocumentsService
.openDocument(doc)
.pipe(first())
.subscribe((open) => {
if (open) this.router.navigate(['documents', doc.id])
})
}
clickTag(tag: PaperlessTag) {
this.queryParamsService.navigateWithFilterRules([
{ rule_type: FILTER_HAS_TAGS_ALL, value: tag.id.toString() },

View File

@@ -204,7 +204,7 @@ export class DocumentDetailComponent
this.openDocumentService.getOpenDocument(this.documentId)
)
} else {
this.openDocumentService.openDocument(doc)
this.openDocumentService.openDocument(doc, false)
this.updateComponent(doc)
}

View File

@@ -37,7 +37,7 @@
<use xlink:href="assets/bootstrap-icons.svg#diagram-3"/>
</svg>&nbsp;<span class="d-none d-md-inline" i18n>More like this</span>
</a>
<a (click)="clickEdit()" class="btn btn-sm btn-outline-secondary">
<a (click)="openDocumentsService.openDocument(document)" class="btn btn-sm btn-outline-secondary">
<svg class="sidebaricon" fill="currentColor" class="sidebaricon">
<use xlink:href="assets/bootstrap-icons.svg#pencil"/>
</svg>&nbsp;<span class="d-none d-md-inline" i18n>Edit</span>

View File

@@ -14,8 +14,6 @@ import {
} from 'src/app/services/settings.service'
import { NgbPopover } from '@ng-bootstrap/ng-bootstrap'
import { OpenDocumentsService } from 'src/app/services/open-documents.service'
import { Router } from '@angular/router'
import { first } from 'rxjs'
@Component({
selector: 'app-document-card-large',
@@ -29,8 +27,7 @@ export class DocumentCardLargeComponent implements OnInit {
constructor(
private documentService: DocumentService,
private settingsService: SettingsService,
private openDocumentsService: OpenDocumentsService,
private router: Router
public openDocumentsService: OpenDocumentsService
) {}
@Input()
@@ -121,13 +118,4 @@ export class DocumentCardLargeComponent implements OnInit {
get contentTrimmed() {
return this.document.content.substr(0, 500)
}
clickEdit() {
this.openDocumentsService
.openDocument(this.document)
.pipe(first())
.subscribe((open) => {
if (open) this.router.navigate(['documents', this.document.id])
})
}
}

View File

@@ -63,7 +63,7 @@
</div>
<div class="d-flex justify-content-between align-items-center">
<div class="btn-group w-100">
<a (click)="clickEdit()" class="btn btn-sm btn-outline-secondary" title="Edit" i18n-title>
<a (click)="openDocumentsService.openDocument(document)" class="btn btn-sm btn-outline-secondary" title="Edit" i18n-title>
<svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-pencil" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" d="M12.146.146a.5.5 0 0 1 .708 0l3 3a.5.5 0 0 1 0 .708l-10 10a.5.5 0 0 1-.168.11l-5 2a.5.5 0 0 1-.65-.65l2-5a.5.5 0 0 1 .11-.168l10-10zM11.207 2.5L13.5 4.793 14.793 3.5 12.5 1.207 11.207 2.5zm1.586 3L10.5 3.207 4 9.707V10h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.293l6.5-6.5zm-9.761 5.175l-.106.106-1.528 3.821 3.821-1.528.106-.106A.5.5 0 0 1 5 12.5V12h-.5a.5.5 0 0 1-.5-.5V11h-.5a.5.5 0 0 1-.468-.325z"/>
</svg>

View File

@@ -6,7 +6,7 @@ import {
Output,
ViewChild,
} from '@angular/core'
import { first, map } from 'rxjs/operators'
import { map } from 'rxjs/operators'
import { PaperlessDocument } from 'src/app/data/paperless-document'
import { DocumentService } from 'src/app/services/rest/document.service'
import {
@@ -15,7 +15,6 @@ import {
} from 'src/app/services/settings.service'
import { NgbPopover } from '@ng-bootstrap/ng-bootstrap'
import { OpenDocumentsService } from 'src/app/services/open-documents.service'
import { Router } from '@angular/router'
@Component({
selector: 'app-document-card-small',
@@ -29,8 +28,7 @@ export class DocumentCardSmallComponent implements OnInit {
constructor(
private documentService: DocumentService,
private settingsService: SettingsService,
private openDocumentsService: OpenDocumentsService,
private router: Router
public openDocumentsService: OpenDocumentsService
) {}
@Input()
@@ -113,13 +111,4 @@ export class DocumentCardSmallComponent implements OnInit {
mouseLeaveCard() {
this.popover.close()
}
clickEdit() {
this.openDocumentsService
.openDocument(this.document)
.pipe(first())
.subscribe((open) => {
if (open) this.router.navigate(['documents', this.document.id])
})
}
}

View File

@@ -168,7 +168,7 @@
</ng-container>
</td>
<td>
<a (click)="clickEdit(d.id)" title="Edit document" style="overflow-wrap: anywhere;">{{d.title | documentTitle}}</a>
<a (click)="openDocumentsService.openDocument(d)" title="Edit document" style="overflow-wrap: anywhere;">{{d.title | documentTitle}}</a>
<app-tag [tag]="t" *ngFor="let t of d.tags$ | async" class="ms-1" clickable="true" linkTitle="Filter by tag" (click)="clickTag(t.id);$event.stopPropagation()"></app-tag>
</td>
<td class="d-none d-xl-table-cell">

View File

@@ -21,10 +21,7 @@ import {
import { ConsumerStatusService } from 'src/app/services/consumer-status.service'
import { DocumentListViewService } from 'src/app/services/document-list-view.service'
import { OpenDocumentsService } from 'src/app/services/open-documents.service'
import {
filterRulesFromQueryParams,
QueryParamsService,
} from 'src/app/services/query-params.service'
import { QueryParamsService } from 'src/app/services/query-params.service'
import {
DOCUMENT_SORT_FIELDS,
DOCUMENT_SORT_FIELDS_FULLTEXT,
@@ -49,7 +46,7 @@ export class DocumentListComponent implements OnInit, OnDestroy, AfterViewInit {
private modalService: NgbModal,
private consumerStatusService: ConsumerStatusService,
private queryParamsService: QueryParamsService,
private openDocumentsService: OpenDocumentsService
public openDocumentsService: OpenDocumentsService
) {}
@ViewChild('filterEditor')
@@ -247,15 +244,6 @@ export class DocumentListComponent implements OnInit, OnDestroy, AfterViewInit {
else this.list.selectRangeTo(document)
}
clickEdit(doc: PaperlessDocument) {
this.openDocumentsService
.openDocument(doc)
.pipe(first())
.subscribe((open) => {
if (open) this.router.navigate(['documents', doc.id])
})
}
clickTag(tagID: number) {
this.list.selectNone()
setTimeout(() => {