Warn on closing edited doc due to max open docs

This commit is contained in:
Michael Shamoon
2022-05-15 22:55:25 -07:00
parent c7412deb77
commit f5e740f2ec
9 changed files with 79 additions and 20 deletions

View File

@@ -6,7 +6,7 @@ import {
Output,
ViewChild,
} from '@angular/core'
import { map } from 'rxjs/operators'
import { first, map } from 'rxjs/operators'
import { PaperlessDocument } from 'src/app/data/paperless-document'
import { DocumentService } from 'src/app/services/rest/document.service'
import {
@@ -14,6 +14,8 @@ import {
SETTINGS_KEYS,
} 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',
@@ -26,7 +28,9 @@ import { NgbPopover } from '@ng-bootstrap/ng-bootstrap'
export class DocumentCardSmallComponent implements OnInit {
constructor(
private documentService: DocumentService,
private settingsService: SettingsService
private settingsService: SettingsService,
private openDocumentsService: OpenDocumentsService,
private router: Router
) {}
@Input()
@@ -109,4 +113,13 @@ 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])
})
}
}