mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-28 18:24:38 -05:00
Warn on closing edited doc due to max open docs
This commit is contained in:
@@ -55,14 +55,24 @@ export class OpenDocumentsService {
|
||||
return this.openDocuments.find((d) => d.id == id)
|
||||
}
|
||||
|
||||
openDocument(doc: PaperlessDocument) {
|
||||
openDocument(doc: PaperlessDocument): Observable<boolean> {
|
||||
if (this.openDocuments.find((d) => d.id == doc.id) == null) {
|
||||
this.openDocuments.unshift(doc)
|
||||
if (this.openDocuments.length > this.MAX_OPEN_DOCUMENTS) {
|
||||
this.openDocuments.pop()
|
||||
if (this.openDocuments.length == this.MAX_OPEN_DOCUMENTS) {
|
||||
const docToRemove = this.openDocuments[this.MAX_OPEN_DOCUMENTS - 1]
|
||||
const closeObservable = this.closeDocument(docToRemove)
|
||||
closeObservable.pipe(first()).subscribe((closed) => {
|
||||
if (closed) {
|
||||
this.openDocuments.unshift(doc)
|
||||
this.save()
|
||||
}
|
||||
})
|
||||
return closeObservable
|
||||
} else {
|
||||
this.openDocuments.unshift(doc)
|
||||
this.save()
|
||||
}
|
||||
this.save()
|
||||
}
|
||||
return of(true)
|
||||
}
|
||||
|
||||
setDirty(documentId: number, dirty: boolean) {
|
||||
@@ -82,7 +92,11 @@ export class OpenDocumentsService {
|
||||
backdrop: 'static',
|
||||
})
|
||||
modal.componentInstance.title = $localize`Unsaved Changes`
|
||||
modal.componentInstance.messageBold = $localize`You have unsaved changes.`
|
||||
modal.componentInstance.messageBold =
|
||||
$localize`You have unsaved changes to the document` +
|
||||
' "' +
|
||||
doc.title +
|
||||
'"'
|
||||
modal.componentInstance.message = $localize`Are you sure you want to close this document?`
|
||||
modal.componentInstance.btnClass = 'btn-warning'
|
||||
modal.componentInstance.btnCaption = $localize`Close document`
|
||||
|
Reference in New Issue
Block a user