2022-03-29 10:35:42 -07:00
import { Component , OnInit , OnDestroy , ViewChild } from '@angular/core'
2022-03-11 10:53:32 -08:00
import { FormControl , FormGroup } from '@angular/forms'
import { ActivatedRoute , Router } from '@angular/router'
import { NgbModal , NgbNav } from '@ng-bootstrap/ng-bootstrap'
import { PaperlessCorrespondent } from 'src/app/data/paperless-correspondent'
import { PaperlessDocument } from 'src/app/data/paperless-document'
import { PaperlessDocumentMetadata } from 'src/app/data/paperless-document-metadata'
import { PaperlessDocumentType } from 'src/app/data/paperless-document-type'
import { DocumentTitlePipe } from 'src/app/pipes/document-title.pipe'
import { DocumentListViewService } from 'src/app/services/document-list-view.service'
import { OpenDocumentsService } from 'src/app/services/open-documents.service'
import { CorrespondentService } from 'src/app/services/rest/correspondent.service'
import { DocumentTypeService } from 'src/app/services/rest/document-type.service'
import { DocumentService } from 'src/app/services/rest/document.service'
import { ConfirmDialogComponent } from '../common/confirm-dialog/confirm-dialog.component'
2022-03-22 22:01:46 -07:00
import { CorrespondentEditDialogComponent } from '../common/edit-dialog/correspondent-edit-dialog/correspondent-edit-dialog.component'
import { DocumentTypeEditDialogComponent } from '../common/edit-dialog/document-type-edit-dialog/document-type-edit-dialog.component'
2022-03-11 10:53:32 -08:00
import { PDFDocumentProxy } from 'ng2-pdf-viewer'
import { ToastService } from 'src/app/services/toast.service'
import { TextComponent } from '../common/input/text/text.component'
2022-05-09 11:01:45 -07:00
import { SettingsService } from 'src/app/services/settings.service'
2022-03-11 10:53:32 -08:00
import { dirtyCheck , DirtyComponent } from '@ngneat/dirty-check-forms'
import { Observable , Subject , BehaviorSubject } from 'rxjs'
import {
first ,
takeUntil ,
switchMap ,
map ,
debounceTime ,
distinctUntilChanged ,
} from 'rxjs/operators'
import { PaperlessDocumentSuggestions } from 'src/app/data/paperless-document-suggestions'
import { FILTER_FULLTEXT_MORELIKE } from 'src/app/data/filter-rule-type'
2022-05-19 23:42:25 +02:00
import { StoragePathService } from 'src/app/services/rest/storage-path.service'
import { PaperlessStoragePath } from 'src/app/data/paperless-storage-path'
import { StoragePathEditDialogComponent } from '../common/edit-dialog/storage-path-edit-dialog/storage-path-edit-dialog.component'
2022-05-09 11:01:45 -07:00
import { SETTINGS_KEYS } from 'src/app/data/paperless-uisettings'
2020-10-30 22:46:43 +01:00
2020-10-27 01:10:18 +01:00
@Component ( {
selector : 'app-document-detail' ,
templateUrl : './document-detail.component.html' ,
2022-03-11 10:53:32 -08:00
styleUrls : [ './document-detail.component.scss' ] ,
2020-10-27 01:10:18 +01:00
} )
2022-03-11 10:53:32 -08:00
export class DocumentDetailComponent
implements OnInit , OnDestroy , DirtyComponent
{
@ViewChild ( 'inputTitle' )
2021-01-05 22:11:42 +01:00
titleInput : TextComponent
2021-01-03 13:09:16 +01:00
expandOriginalMetadata = false
expandArchivedMetadata = false
error : any
networkActive = false
2020-12-08 15:28:09 +01:00
2020-10-27 01:10:18 +01:00
documentId : number
document : PaperlessDocument
2020-11-25 18:01:43 +01:00
metadata : PaperlessDocumentMetadata
2021-01-29 16:48:51 +01:00
suggestions : PaperlessDocumentSuggestions
2020-10-27 01:10:18 +01:00
title : string
2022-02-16 14:34:19 -08:00
titleSubject : Subject < string > = new Subject ( )
2020-10-27 01:10:18 +01:00
previewUrl : string
downloadUrl : string
2020-11-25 18:01:43 +01:00
downloadOriginalUrl : string
2020-10-27 01:10:18 +01:00
correspondents : PaperlessCorrespondent [ ]
documentTypes : PaperlessDocumentType [ ]
2022-05-19 23:42:25 +02:00
storagePaths : PaperlessStoragePath [ ]
2020-10-27 01:10:18 +01:00
documentForm : FormGroup = new FormGroup ( {
title : new FormControl ( '' ) ,
content : new FormControl ( '' ) ,
2022-05-15 21:09:42 -07:00
created_date : new FormControl ( ) ,
2020-12-03 20:28:17 +01:00
correspondent : new FormControl ( ) ,
document_type : new FormControl ( ) ,
2022-05-19 23:42:25 +02:00
storage_path : new FormControl ( ) ,
2020-10-27 01:10:18 +01:00
archive_serial_number : new FormControl ( ) ,
2022-03-11 10:53:32 -08:00
tags : new FormControl ( [ ] ) ,
2020-10-27 01:10:18 +01:00
} )
2020-12-18 14:47:06 -08:00
previewCurrentPage : number = 1
2020-12-19 01:15:40 +01:00
previewNumPages : number = 1
2020-12-18 14:31:09 -08:00
2021-01-25 23:00:57 -08:00
store : BehaviorSubject < any >
isDirty$ : Observable < boolean >
2022-02-15 23:43:54 -08:00
unsubscribeNotifier : Subject < any > = new Subject ( )
2022-05-17 09:59:14 -07:00
docChangeNotifier : Subject < any > = new Subject ( )
2021-01-25 23:00:57 -08:00
2022-03-29 10:35:42 -07:00
requiresPassword : boolean = false
password : string
2022-04-05 22:11:09 -07:00
ogDate : Date
2020-12-17 00:50:59 -08:00
@ViewChild ( 'nav' ) nav : NgbNav
2020-12-17 07:33:20 -08:00
@ViewChild ( 'pdfPreview' ) set pdfPreview ( element ) {
2020-12-17 00:50:59 -08:00
// this gets called when compontent added or removed from DOM
2022-03-11 10:53:32 -08:00
if (
element &&
element . nativeElement . offsetParent !== null &&
this . nav ? . activeId == 4
) {
// its visible
setTimeout ( ( ) = > this . nav ? . select ( 1 ) )
2020-12-17 00:50:59 -08:00
}
}
2020-10-27 01:10:18 +01:00
constructor (
2020-12-18 14:31:09 -08:00
private documentsService : DocumentService ,
2020-10-27 01:10:18 +01:00
private route : ActivatedRoute ,
private correspondentService : CorrespondentService ,
private documentTypeService : DocumentTypeService ,
private router : Router ,
private modalService : NgbModal ,
private openDocumentService : OpenDocumentsService ,
2020-12-16 16:44:54 +01:00
private documentListViewService : DocumentListViewService ,
2021-01-03 21:44:53 +01:00
private documentTitlePipe : DocumentTitlePipe ,
2021-01-14 13:35:21 +01:00
private toastService : ToastService ,
2022-05-05 00:23:06 -07:00
private settings : SettingsService ,
2022-08-07 15:05:58 -07:00
private storagePathService : StoragePathService
2022-05-17 09:59:14 -07:00
) { }
2022-02-16 14:34:19 -08:00
titleKeyUp ( event ) {
this . titleSubject . next ( event . target ? . value )
}
2021-01-14 13:35:21 +01:00
get useNativePdfViewer ( ) : boolean {
return this . settings . get ( SETTINGS_KEYS . USE_NATIVE_PDF_VIEWER )
}
2020-10-27 01:10:18 +01:00
2020-12-12 22:56:44 +01:00
getContentType() {
2022-03-11 10:53:32 -08:00
return this . metadata ? . has_archive_version
? 'application/pdf'
: this . metadata ? . original_mime_type
2020-12-12 22:56:44 +01:00
}
2020-10-27 01:10:18 +01:00
ngOnInit ( ) : void {
2022-03-11 10:53:32 -08:00
this . documentForm . valueChanges
. pipe ( takeUntil ( this . unsubscribeNotifier ) )
2022-05-15 21:09:42 -07:00
. subscribe ( ( ) = > {
2022-05-01 14:03:40 -07:00
this . error = null
2022-03-11 10:53:32 -08:00
Object . assign ( this . document , this . documentForm . value )
2022-02-16 02:27:17 -08:00
} )
2022-03-11 10:53:32 -08:00
this . correspondentService
. listAll ( )
. pipe ( first ( ) )
. subscribe ( ( result ) = > ( this . correspondents = result . results ) )
2022-05-19 23:42:25 +02:00
2022-03-11 10:53:32 -08:00
this . documentTypeService
. listAll ( )
. pipe ( first ( ) )
. subscribe ( ( result ) = > ( this . documentTypes = result . results ) )
2022-05-19 23:42:25 +02:00
this . storagePathService
. listAll ( )
. pipe ( first ( ) )
. subscribe ( ( result ) = > ( this . storagePaths = result . results ) )
2022-03-11 10:53:32 -08:00
this . route . paramMap
. pipe (
2022-05-17 10:36:43 -07:00
takeUntil ( this . unsubscribeNotifier ) ,
2022-03-11 10:53:32 -08:00
switchMap ( ( paramMap ) = > {
const documentId = + paramMap . get ( 'id' )
2022-05-17 09:59:14 -07:00
this . docChangeNotifier . next ( documentId )
2022-03-11 10:53:32 -08:00
return this . documentsService . get ( documentId )
} )
)
. pipe (
switchMap ( ( doc ) = > {
this . documentId = doc . id
this . previewUrl = this . documentsService . getPreviewUrl ( this . documentId )
this . downloadUrl = this . documentsService . getDownloadUrl (
this . documentId
)
this . downloadOriginalUrl = this . documentsService . getDownloadUrl (
this . documentId ,
true
)
this . suggestions = null
if ( this . openDocumentService . getOpenDocument ( this . documentId ) ) {
this . updateComponent (
this . openDocumentService . getOpenDocument ( this . documentId )
)
} else {
2022-11-22 15:25:27 -08:00
this . openDocumentService . openDocument ( doc )
2022-03-11 10:53:32 -08:00
this . updateComponent ( doc )
}
2022-05-17 09:59:14 -07:00
this . titleSubject
. pipe (
debounceTime ( 1000 ) ,
distinctUntilChanged ( ) ,
takeUntil ( this . docChangeNotifier ) ,
takeUntil ( this . unsubscribeNotifier )
)
2022-05-17 10:36:43 -07:00
. subscribe ( {
next : ( titleValue ) = > {
this . title = titleValue
this . documentForm . patchValue ( { title : titleValue } )
} ,
complete : ( ) = > {
// doc changed so we manually check dirty in case title was changed
if (
this . store . getValue ( ) . title !==
this . documentForm . get ( 'title' ) . value
) {
2022-08-06 19:30:39 -07:00
this . openDocumentService . setDirty ( doc , true )
2022-05-17 10:36:43 -07:00
}
} ,
2022-05-17 09:59:14 -07:00
} )
2022-03-11 10:53:32 -08:00
// Initialize dirtyCheck
this . store = new BehaviorSubject ( {
title : doc.title ,
content : doc.content ,
2022-05-15 21:09:42 -07:00
created_date : doc.created_date ,
2022-03-11 10:53:32 -08:00
correspondent : doc.correspondent ,
document_type : doc.document_type ,
2022-05-19 23:42:25 +02:00
storage_path : doc.storage_path ,
2022-03-11 10:53:32 -08:00
archive_serial_number : doc.archive_serial_number ,
tags : [ . . . doc . tags ] ,
} )
this . isDirty $ = dirtyCheck (
this . documentForm ,
this . store . asObservable ( )
)
2022-08-06 19:30:39 -07:00
return this . isDirty $ . pipe (
takeUntil ( this . unsubscribeNotifier ) ,
map ( ( dirty ) = > ( { doc , dirty } ) )
)
2022-03-11 10:53:32 -08:00
} )
)
2022-03-14 16:23:14 -07:00
. subscribe ( {
next : ( { doc , dirty } ) = > {
2022-08-06 19:30:39 -07:00
this . openDocumentService . setDirty ( doc , dirty )
2022-03-11 10:53:32 -08:00
} ,
2022-03-14 16:23:14 -07:00
error : ( error ) = > {
2022-03-11 10:53:32 -08:00
this . router . navigate ( [ '404' ] )
2022-03-14 16:23:14 -07:00
} ,
} )
2020-10-27 01:10:18 +01:00
}
2022-03-11 10:53:32 -08:00
ngOnDestroy ( ) : void {
2022-03-14 16:23:14 -07:00
this . unsubscribeNotifier . next ( this )
2022-03-11 10:53:32 -08:00
this . unsubscribeNotifier . complete ( )
2022-02-15 23:43:54 -08:00
}
2020-11-04 13:10:23 +01:00
updateComponent ( doc : PaperlessDocument ) {
this . document = doc
2022-04-28 21:07:25 -07:00
this . requiresPassword = false
2022-03-11 10:53:32 -08:00
this . documentsService
. getMetadata ( doc . id )
. pipe ( first ( ) )
2022-03-14 16:23:14 -07:00
. subscribe ( {
next : ( result ) = > {
2022-03-11 10:53:32 -08:00
this . metadata = result
} ,
2022-03-14 16:23:14 -07:00
error : ( error ) = > {
2022-03-11 10:53:32 -08:00
this . metadata = null
2022-03-14 16:23:14 -07:00
} ,
} )
2022-03-11 10:53:32 -08:00
this . documentsService
. getSuggestions ( doc . id )
. pipe ( first ( ) )
2022-03-14 16:23:14 -07:00
. subscribe ( {
next : ( result ) = > {
2022-03-11 10:53:32 -08:00
this . suggestions = result
} ,
2022-03-14 16:23:14 -07:00
error : ( error ) = > {
2022-03-11 10:53:32 -08:00
this . suggestions = null
2022-03-14 16:23:14 -07:00
} ,
} )
2020-12-16 16:44:54 +01:00
this . title = this . documentTitlePipe . transform ( doc . title )
2021-01-26 22:43:46 -08:00
this . documentForm . patchValue ( doc )
2020-11-04 13:10:23 +01:00
}
2021-03-24 12:21:13 -07:00
createDocumentType ( newName : string ) {
2022-03-11 10:53:32 -08:00
var modal = this . modalService . open ( DocumentTypeEditDialogComponent , {
backdrop : 'static' ,
} )
2020-10-27 01:10:18 +01:00
modal . componentInstance . dialogMode = 'create'
2021-03-24 12:21:13 -07:00
if ( newName ) modal . componentInstance . object = { name : newName }
2022-12-30 07:33:45 -08:00
modal . componentInstance . succeeded
2022-03-11 10:53:32 -08:00
. pipe (
switchMap ( ( newDocumentType ) = > {
return this . documentTypeService
. listAll ( )
. pipe ( map ( ( documentTypes ) = > ( { newDocumentType , documentTypes } ) ) )
} )
)
. pipe ( takeUntil ( this . unsubscribeNotifier ) )
. subscribe ( ( { newDocumentType , documentTypes } ) = > {
this . documentTypes = documentTypes . results
this . documentForm . get ( 'document_type' ) . setValue ( newDocumentType . id )
} )
2020-10-27 01:10:18 +01:00
}
2021-03-24 12:21:13 -07:00
createCorrespondent ( newName : string ) {
2022-03-11 10:53:32 -08:00
var modal = this . modalService . open ( CorrespondentEditDialogComponent , {
backdrop : 'static' ,
} )
2020-10-27 01:10:18 +01:00
modal . componentInstance . dialogMode = 'create'
2021-03-24 12:21:13 -07:00
if ( newName ) modal . componentInstance . object = { name : newName }
2022-12-30 07:33:45 -08:00
modal . componentInstance . succeeded
2022-03-11 10:53:32 -08:00
. pipe (
switchMap ( ( newCorrespondent ) = > {
return this . correspondentService
. listAll ( )
. pipe (
map ( ( correspondents ) = > ( { newCorrespondent , correspondents } ) )
)
} )
)
. pipe ( takeUntil ( this . unsubscribeNotifier ) )
. subscribe ( ( { newCorrespondent , correspondents } ) = > {
this . correspondents = correspondents . results
this . documentForm . get ( 'correspondent' ) . setValue ( newCorrespondent . id )
} )
2020-10-27 01:10:18 +01:00
}
2022-05-19 23:42:25 +02:00
createStoragePath ( newName : string ) {
var modal = this . modalService . open ( StoragePathEditDialogComponent , {
backdrop : 'static' ,
} )
modal . componentInstance . dialogMode = 'create'
if ( newName ) modal . componentInstance . object = { name : newName }
2022-12-30 07:33:45 -08:00
modal . componentInstance . succeeded
2022-05-19 23:42:25 +02:00
. pipe (
switchMap ( ( newStoragePath ) = > {
return this . storagePathService
. listAll ( )
. pipe ( map ( ( storagePaths ) = > ( { newStoragePath , storagePaths } ) ) )
} )
)
. pipe ( takeUntil ( this . unsubscribeNotifier ) )
2022-10-11 12:23:15 -07:00
. subscribe ( ( { newStoragePath , storagePaths } ) = > {
2022-05-19 23:42:25 +02:00
this . storagePaths = storagePaths . results
this . documentForm . get ( 'storage_path' ) . setValue ( newStoragePath . id )
} )
}
2020-11-04 17:23:36 +01:00
discard() {
2022-03-11 10:53:32 -08:00
this . documentsService
. get ( this . documentId )
. pipe ( first ( ) )
2022-05-01 14:03:40 -07:00
. subscribe ( {
next : ( doc ) = > {
2022-03-11 10:53:32 -08:00
Object . assign ( this . document , doc )
this . title = doc . title
this . documentForm . patchValue ( doc )
2022-08-06 19:30:39 -07:00
this . openDocumentService . setDirty ( doc , false )
2022-03-11 10:53:32 -08:00
} ,
2022-05-01 14:03:40 -07:00
error : ( ) = > {
2022-03-11 10:53:32 -08:00
this . router . navigate ( [ '404' ] )
2022-05-01 14:03:40 -07:00
} ,
} )
2020-10-27 01:10:18 +01:00
}
2020-12-18 14:31:09 -08:00
save() {
2021-01-03 13:09:16 +01:00
this . networkActive = true
2021-01-25 23:06:25 -08:00
this . store . next ( this . documentForm . value )
2022-03-11 10:53:32 -08:00
this . documentsService
. update ( this . document )
. pipe ( first ( ) )
2022-03-14 16:23:14 -07:00
. subscribe ( {
next : ( result ) = > {
2022-03-11 10:53:32 -08:00
this . close ( )
this . networkActive = false
this . error = null
} ,
2022-03-14 16:23:14 -07:00
error : ( error ) = > {
2022-03-11 10:53:32 -08:00
this . networkActive = false
this . error = error . error
2022-03-14 16:23:14 -07:00
} ,
} )
2020-10-27 01:10:18 +01:00
}
saveEditNext() {
2021-01-03 13:09:16 +01:00
this . networkActive = true
2021-01-25 23:06:25 -08:00
this . store . next ( this . documentForm . value )
2022-03-11 10:53:32 -08:00
this . documentsService
. update ( this . document )
. pipe (
switchMap ( ( updateResult ) = > {
return this . documentListViewService
. getNext ( this . documentId )
. pipe ( map ( ( nextDocId ) = > ( { nextDocId , updateResult } ) ) )
} )
)
. pipe (
switchMap ( ( { nextDocId , updateResult } ) = > {
if ( nextDocId && updateResult )
return this . openDocumentService
. closeDocument ( this . document )
. pipe (
map ( ( closeResult ) = > ( { updateResult , nextDocId , closeResult } ) )
)
} )
)
. pipe ( first ( ) )
2022-03-14 16:23:14 -07:00
. subscribe ( {
next : ( { updateResult , nextDocId , closeResult } ) = > {
2022-03-11 10:53:32 -08:00
this . error = null
this . networkActive = false
if ( closeResult && updateResult && nextDocId ) {
this . router . navigate ( [ 'documents' , nextDocId ] )
this . titleInput ? . focus ( )
}
} ,
2022-03-14 16:23:14 -07:00
error : ( error ) = > {
2022-03-11 10:53:32 -08:00
this . networkActive = false
this . error = error . error
2022-03-14 16:23:14 -07:00
} ,
} )
2020-10-27 01:10:18 +01:00
}
2022-02-16 01:06:22 -08:00
close() {
2022-03-11 10:53:32 -08:00
this . openDocumentService
. closeDocument ( this . document )
. pipe ( first ( ) )
. subscribe ( ( closed ) = > {
if ( ! closed ) return
if ( this . documentListViewService . activeSavedViewId ) {
this . router . navigate ( [
'view' ,
this . documentListViewService . activeSavedViewId ,
] )
} else {
this . router . navigate ( [ 'documents' ] )
}
} )
2021-01-26 20:46:28 -08:00
}
2020-10-27 01:10:18 +01:00
delete ( ) {
2022-03-11 10:53:32 -08:00
let modal = this . modalService . open ( ConfirmDialogComponent , {
backdrop : 'static' ,
} )
2020-12-23 15:09:39 +01:00
modal . componentInstance . title = $localize ` Confirm delete `
2020-12-30 16:29:22 +01:00
modal . componentInstance . messageBold = $localize ` Do you really want to delete document " ${ this . document . title } "? `
2020-12-23 15:09:39 +01:00
modal . componentInstance . message = $localize ` The files for this document will be deleted permanently. This operation cannot be undone. `
2022-03-11 10:53:32 -08:00
modal . componentInstance . btnClass = 'btn-danger'
2020-12-23 15:09:39 +01:00
modal . componentInstance . btnCaption = $localize ` Delete document `
2022-03-11 10:53:32 -08:00
modal . componentInstance . confirmClicked
. pipe (
switchMap ( ( ) = > {
modal . componentInstance . buttonsEnabled = false
return this . documentsService . delete ( this . document )
} )
)
. pipe ( takeUntil ( this . unsubscribeNotifier ) )
. subscribe (
( ) = > {
modal . close ( )
this . close ( )
} ,
( error ) = > {
this . toastService . showError (
$localize ` Error deleting document: ${ JSON . stringify ( error ) } `
)
modal . componentInstance . buttonsEnabled = true
}
)
2020-10-27 01:10:18 +01:00
}
2020-12-17 21:36:21 +01:00
moreLike() {
2022-05-20 15:16:17 -07:00
this . documentListViewService . quickFilter ( [
2022-03-11 10:53:32 -08:00
{
rule_type : FILTER_FULLTEXT_MORELIKE ,
value : this.documentId.toString ( ) ,
} ,
] )
2020-12-17 21:36:21 +01:00
}
2022-07-28 15:36:24 -07:00
redoOcr() {
let modal = this . modalService . open ( ConfirmDialogComponent , {
backdrop : 'static' ,
} )
modal . componentInstance . title = $localize ` Redo OCR confirm `
modal . componentInstance . messageBold = $localize ` This operation will permanently redo OCR for this document. `
modal . componentInstance . message = $localize ` This operation cannot be undone. `
modal . componentInstance . btnClass = 'btn-danger'
modal . componentInstance . btnCaption = $localize ` Proceed `
modal . componentInstance . confirmClicked . subscribe ( ( ) = > {
modal . componentInstance . buttonsEnabled = false
this . documentsService
. bulkEdit ( [ this . document . id ] , 'redo_ocr' , { } )
. subscribe ( {
next : ( ) = > {
this . toastService . showInfo (
2022-11-22 14:16:04 -08:00
$localize ` Redo OCR operation will begin in the background. Close and re-open or reload this document after the operation has completed to see new content. `
2022-07-28 15:36:24 -07:00
)
if ( modal ) {
modal . close ( )
}
} ,
error : ( error ) = > {
if ( modal ) {
modal . componentInstance . buttonsEnabled = true
}
this . toastService . showError (
$localize ` Error executing operation: ${ JSON . stringify (
error . error
) } `
)
} ,
} )
} )
}
2020-10-27 01:10:18 +01:00
hasNext() {
return this . documentListViewService . hasNext ( this . documentId )
}
2020-12-18 14:31:09 -08:00
2022-03-11 17:35:38 +01:00
hasPrevious() {
return this . documentListViewService . hasPrevious ( this . documentId )
}
nextDoc() {
2022-03-11 12:00:31 -08:00
this . documentListViewService
. getNext ( this . document . id )
. subscribe ( ( nextDocId : number ) = > {
this . router . navigate ( [ 'documents' , nextDocId ] )
} )
2022-03-11 17:35:38 +01:00
}
2022-03-11 12:00:31 -08:00
previousDoc() {
this . documentListViewService
. getPrevious ( this . document . id )
. subscribe ( ( prevDocId : number ) = > {
this . router . navigate ( [ 'documents' , prevDocId ] )
} )
2022-03-11 17:35:38 +01:00
}
2020-12-18 14:31:09 -08:00
pdfPreviewLoaded ( pdf : PDFDocumentProxy ) {
this . previewNumPages = pdf . numPages
2022-03-29 10:35:42 -07:00
if ( this . password ) this . requiresPassword = false
}
onError ( event ) {
if ( event . name == 'PasswordException' ) {
this . requiresPassword = true
}
}
onPasswordKeyUp ( event : KeyboardEvent ) {
if ( 'Enter' == event . key ) {
this . password = ( event . target as HTMLInputElement ) . value
}
2020-12-18 14:31:09 -08:00
}
2022-08-07 15:05:58 -07:00
get commentsEnabled ( ) : boolean {
return this . settings . get ( SETTINGS_KEYS . COMMENTS_ENABLED )
}
2020-10-27 01:10:18 +01:00
}