mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
52 lines
1.5 KiB
TypeScript
52 lines
1.5 KiB
TypeScript
import { Component, OnInit } from '@angular/core'
|
|
import { ConfirmDialogComponent } from '../confirm-dialog.component'
|
|
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
|
|
import { DocumentService } from 'src/app/services/rest/document.service'
|
|
import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop'
|
|
import { Subject, takeUntil } from 'rxjs'
|
|
import { Document } from 'src/app/data/document'
|
|
|
|
@Component({
|
|
selector: 'pngx-merge-confirm-dialog',
|
|
templateUrl: './merge-confirm-dialog.component.html',
|
|
styleUrl: './merge-confirm-dialog.component.scss',
|
|
})
|
|
export class MergeConfirmDialogComponent
|
|
extends ConfirmDialogComponent
|
|
implements OnInit
|
|
{
|
|
public documentIDs: number[] = []
|
|
private _documents: Document[] = []
|
|
get documents(): Document[] {
|
|
return this._documents
|
|
}
|
|
|
|
public metadataDocumentID: number = -1
|
|
|
|
private unsubscribeNotifier: Subject<any> = new Subject()
|
|
|
|
constructor(
|
|
activeModal: NgbActiveModal,
|
|
private documentService: DocumentService
|
|
) {
|
|
super(activeModal)
|
|
}
|
|
|
|
ngOnInit() {
|
|
this.documentService
|
|
.getCachedMany(this.documentIDs)
|
|
.pipe(takeUntil(this.unsubscribeNotifier))
|
|
.subscribe((documents) => {
|
|
this._documents = documents
|
|
})
|
|
}
|
|
|
|
onDrop(event: CdkDragDrop<number[]>) {
|
|
moveItemInArray(this.documentIDs, event.previousIndex, event.currentIndex)
|
|
}
|
|
|
|
getDocument(documentID: number): Document {
|
|
return this.documents.find((d) => d.id === documentID)
|
|
}
|
|
}
|