Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

Merge branch 'dev' into feature-bulk-edit

jonaswinkler9ace1994225f
diff --cc src-ui/src/app/components/document-list/document-list.component.html
index 4b05d5e61,7c7541b4d..25bcb7468
--- a/src-ui/src/app/components/document-list/document-list.component.html
+++ b/src-ui/src/app/components/document-list/document-list.component.html
@@@ -97,7 -73,7 +97,7 @@@
</div>
<div *ngIf="displayMode == 'largeCards'">
- <app-document-card-large [selected]="list.isSelected(d)" (selectedChange)="list.setSelected(d, $event)" *ngFor="let d of list.documents" [document]="d" [details]="d.content" (clickTag)="clickTag($event)" (clickCorrespondent)="clickCorrespondent($event)">
- <app-document-card-large *ngFor="let d of list.documents; trackBy: trackByDocumentId" [document]="d" [details]="d.content" (clickTag)="clickTag($event)" (clickCorrespondent)="clickCorrespondent($event)">
++ <app-document-card-large [selected]="list.isSelected(d)" (selectedChange)="list.setSelected(d, $event)" *ngFor="let d of list.documents; trackBy: trackByDocumentId" [document]="d" [details]="d.content" (clickTag)="clickTag($event)" (clickCorrespondent)="clickCorrespondent($event)">
</app-document-card-large>
</div>
@@@ -112,13 -87,7 +112,13 @@@
<th class="d-none d-xl-table-cell">Added</th>
</thead>
<tbody>
- <tr *ngFor="let d of list.documents" [ngClass]="list.isSelected(d) ? 'table-row-selected' : ''">
- <tr *ngFor="let d of list.documents; trackBy: trackByDocumentId">
++ <tr *ngFor="let d of list.documents; trackBy: trackByDocumentId" [ngClass]="list.isSelected(d) ? 'table-row-selected' : ''">
+ <td>
+ <div class="custom-control custom-checkbox">
+ <input type="checkbox" class="custom-control-input" id="docCheck{{d.id}}" [checked]="list.isSelected(d)" (change)="list.setSelected(d, $event.target.checked)">
+ <label class="custom-control-label" for="docCheck{{d.id}}"></label>
+ </div>
+ </td>
<td class="d-none d-lg-table-cell">
{{d.archive_serial_number}}
</td>
@@@ -148,5 -117,5 +148,5 @@@
<div class="m-n2 row row-cols-paperless-cards" *ngIf="displayMode == 'smallCards'">
- <app-document-card-small [selected]="list.isSelected(d)" (selectedChange)="list.setSelected(d, $event)" [document]="d" *ngFor="let d of list.documents" (clickTag)="clickTag($event)" (clickCorrespondent)="clickCorrespondent($event)"></app-document-card-small>
- <app-document-card-small [document]="d" *ngFor="let d of list.documents; trackBy: trackByDocumentId" (clickTag)="clickTag($event)" (clickCorrespondent)="clickCorrespondent($event)"></app-document-card-small>
++ <app-document-card-small [selected]="list.isSelected(d)" (selectedChange)="list.setSelected(d, $event)" [document]="d" *ngFor="let d of list.documents; trackBy: trackByDocumentId" (clickTag)="clickTag($event)" (clickCorrespondent)="clickCorrespondent($event)"></app-document-card-small>
</div>
diff --cc src-ui/src/app/components/document-list/document-list.component.ts
index 5d9f2f102,2d5257804..5eb97b08d
--- a/src-ui/src/app/components/document-list/document-list.component.ts
+++ b/src-ui/src/app/components/document-list/document-list.component.ts
@@@ -1,15 -1,11 +1,16 @@@
import { Component, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
+import { Observable } from 'rxjs';
+import { map } from 'rxjs/operators';
import { FILTER_CORRESPONDENT } from 'src/app/data/filter-rule-type';
+ import { PaperlessDocument } from 'src/app/data/paperless-document';
import { PaperlessSavedView } from 'src/app/data/paperless-saved-view';
import { DocumentListViewService } from 'src/app/services/document-list-view.service';
-import { DOCUMENT_SORT_FIELDS } from 'src/app/services/rest/document.service';
+import { CorrespondentService } from 'src/app/services/rest/correspondent.service';
+import { DocumentTypeService } from 'src/app/services/rest/document-type.service';
+import { DocumentService, DOCUMENT_SORT_FIELDS } from 'src/app/services/rest/document.service';
+import { TagService } from 'src/app/services/rest/tag.service';
import { SavedViewService } from 'src/app/services/rest/saved-view.service';
import { Toast, ToastService } from 'src/app/services/toast.service';
import { FilterEditorComponent } from '../filter-editor/filter-editor.component';
@@@ -124,118 -114,7 +125,122 @@@ export class DocumentListComponent impl
this.filterEditor.toggleDocumentType(documentTypeID)
}
+ trackByDocumentId(index, item: PaperlessDocument) {
+ return item.id
+ }
++
+ private executeBulkOperation(method: string, args): Observable<any> {
+ return this.documentService.bulkEdit(Array.from(this.list.selected), method, args).pipe(
+ map(r => {
+
+ this.list.reload()
+ this.list.selectNone()
+
+ return r
+ })
+ )
+ }
+
+ bulkSetCorrespondent() {
+ let modal = this.modalService.open(SelectDialogComponent, {backdrop: 'static'})
+ modal.componentInstance.title = "Select correspondent"
+ modal.componentInstance.message = `Select the correspondent you wish to assign to ${this.list.selected.size} selected document(s):`
+ this.correspondentService.listAll().subscribe(response => {
+ modal.componentInstance.objects = response.results
+ })
+ modal.componentInstance.selectClicked.subscribe(selectedId => {
+ this.executeBulkOperation('set_correspondent', {"correspondent": selectedId}).subscribe(
+ response => {
+ modal.close()
+ }
+ )
+ })
+ }
+
+ bulkRemoveCorrespondent() {
+ let modal = this.modalService.open(ConfirmDialogComponent, {backdrop: 'static'})
+ modal.componentInstance.title = "Remove correspondent"
+ modal.componentInstance.message = `This operation will remove the correspondent from all ${this.list.selected.size} selected document(s).`
+ modal.componentInstance.confirmClicked.subscribe(() => {
+ this.executeBulkOperation('set_correspondent', {"correspondent": null}).subscribe(r => {
+ modal.close()
+ })
+ })
+ }
+
+ bulkSetDocumentType() {
+ let modal = this.modalService.open(SelectDialogComponent, {backdrop: 'static'})
+ modal.componentInstance.title = "Select document type"
+ modal.componentInstance.message = `Select the document type you wish to assign to ${this.list.selected.size} selected document(s):`
+ this.documentTypeService.listAll().subscribe(response => {
+ modal.componentInstance.objects = response.results
+ })
+ modal.componentInstance.selectClicked.subscribe(selectedId => {
+ this.executeBulkOperation('set_document_type', {"document_type": selectedId}).subscribe(
+ response => {
+ modal.close()
+ }
+ )
+ })
+ }
+
+ bulkRemoveDocumentType() {
+ let modal = this.modalService.open(ConfirmDialogComponent, {backdrop: 'static'})
+ modal.componentInstance.title = "Remove document type"
+ modal.componentInstance.message = `This operation will remove the document type from all ${this.list.selected.size} selected document(s).`
+ modal.componentInstance.confirmClicked.subscribe(() => {
+ this.executeBulkOperation('set_document_type', {"document_type": null}).subscribe(r => {
+ modal.close()
+ })
+ })
+ }
+
+ bulkAddTag() {
+ let modal = this.modalService.open(SelectDialogComponent, {backdrop: 'static'})
+ modal.componentInstance.title = "Select tag"
+ modal.componentInstance.message = `Select the tag you wish to assign to ${this.list.selected.size} selected document(s):`
+ this.tagService.listAll().subscribe(response => {
+ modal.componentInstance.objects = response.results
+ })
+ modal.componentInstance.selectClicked.subscribe(selectedId => {
+ this.executeBulkOperation('add_tag', {"tag": selectedId}).subscribe(
+ response => {
+ modal.close()
+ }
+ )
+ })
+ }
+
+ bulkRemoveTag() {
+ let modal = this.modalService.open(SelectDialogComponent, {backdrop: 'static'})
+ modal.componentInstance.title = "Select tag"
+ modal.componentInstance.message = `Select the tag you wish to remove from ${this.list.selected.size} selected document(s):`
+ this.tagService.listAll().subscribe(response => {
+ modal.componentInstance.objects = response.results
+ })
+ modal.componentInstance.selectClicked.subscribe(selectedId => {
+ this.executeBulkOperation('remove_tag', {"tag": selectedId}).subscribe(
+ response => {
+ modal.close()
+ }
+ )
+ })
+ }
+
+ bulkDelete() {
+ let modal = this.modalService.open(ConfirmDialogComponent, {backdrop: 'static'})
+ modal.componentInstance.delayConfirm(5)
+ modal.componentInstance.title = "Delete confirm"
+ modal.componentInstance.messageBold = `This operation will permanently delete all ${this.list.selected.size} selected document(s).`
+ modal.componentInstance.message = `This operation cannot be undone.`
+ modal.componentInstance.btnClass = "btn-danger"
+ modal.componentInstance.btnCaption = "Delete document(s)"
+ modal.componentInstance.confirmClicked.subscribe(() => {
+ this.executeBulkOperation("delete", {}).subscribe(
+ response => {
+ modal.close()
+ }
+ )
+ })
+ }
}