diff --git a/src-ui/src/app/components/document-list/document-list.component.ts b/src-ui/src/app/components/document-list/document-list.component.ts
index 236bdeeaa..699e91cb4 100644
--- 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,23 +1,19 @@
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 { tap } from 'rxjs/operators';
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 { 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 { 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';
-import { ConfirmDialogComponent } from '../common/confirm-dialog/confirm-dialog.component';
import { SelectDialogComponent } from '../common/select-dialog/select-dialog.component';
import { SaveViewConfigDialogComponent } from './save-view-config-dialog/save-view-config-dialog.component';
import { ChangedItems } from './bulk-editor/bulk-editor.component';
-import { OpenDocumentsService } from 'src/app/services/open-documents.service';
@Component({
selector: 'app-document-list',
@@ -32,12 +28,10 @@ export class DocumentListComponent implements OnInit {
public route: ActivatedRoute,
private router: Router,
private toastService: ToastService,
- public modalService: NgbModal,
+ private modalService: NgbModal,
private correspondentService: CorrespondentService,
private documentTypeService: DocumentTypeService,
- private tagService: TagService,
- private documentService: DocumentService,
- private openDocumentService: OpenDocumentsService) { }
+ private tagService: TagService) { }
@ViewChild("filterEditor")
private filterEditor: FilterEditorComponent
@@ -143,118 +137,4 @@ export class DocumentListComponent implements OnInit {
trackByDocumentId(index, item: PaperlessDocument) {
return item.id
}
-
- private executeBulkOperation(method: string, args): Observable
{
- return this.documentService.bulkEdit(Array.from(this.list.selected), method, args).pipe(
- tap(() => {
- this.list.reload()
- this.list.selected.forEach(id => {
- this.openDocumentService.refreshDocument(id)
- })
- this.list.selectNone()
- })
- )
- }
-
- bulkSetTags(changedTags: ChangedItems) {
- let modal = this.modalService.open(ConfirmDialogComponent, {backdrop: 'static'})
- modal.componentInstance.title = "Confirm Tags Assignment"
- let action = 'set_tags'
- let tags
- let messageFragment = ''
- let both = changedTags && changedTags.itemsToAdd.length > 0 && changedTags.itemsToRemove.length > 0
- if (!changedTags) {
- messageFragment = `remove all tags from`
- } else {
- if (changedTags.itemsToAdd.length > 0) {
- tags = changedTags.itemsToAdd
- messageFragment = `assign the tag(s) ${changedTags.itemsToAdd.map(t => t.name).join(', ')} to`
- }
- if (changedTags.itemsToRemove.length > 0) {
- if (!both) {
- action = 'remove_tags'
- tags = changedTags.itemsToRemove
- } else {
- messageFragment += ' and '
- }
- messageFragment += `remove the tag(s) ${changedTags.itemsToRemove.map(t => t.name).join(', ')} from`
- }
- }
- modal.componentInstance.message = `This operation will ${messageFragment} all ${this.list.selected.size} selected document(s).`
- modal.componentInstance.btnClass = "btn-warning"
- modal.componentInstance.btnCaption = "Confirm"
- modal.componentInstance.confirmClicked.subscribe(() => {
- // TODO: API endpoints for add/remove multiple tags
- this.executeBulkOperation(action, {"tags": tags ? tags.map(t => t.id) : null}).subscribe(
- response => {
- if (!both) modal.close()
- else {
- this.executeBulkOperation('remove_tags', {"tags": changedTags.itemsToRemove.map(t => t.id)}).subscribe(
- response => {
- modal.close()
- })
- }
- }
- )
- })
- }
-
- bulkSetCorrespondents(changedCorrespondents: ChangedItems) {
- let modal = this.modalService.open(ConfirmDialogComponent, {backdrop: 'static'})
- modal.componentInstance.title = "Confirm Correspondent Assignment"
- let correspondent
- let messageFragment = 'remove all correspondents from'
- if (changedCorrespondents && changedCorrespondents.itemsToAdd.length > 0) {
- correspondent = changedCorrespondents.itemsToAdd[0]
- messageFragment = `assign the correspondent ${correspondent.name} to`
- }
- modal.componentInstance.message = `This operation will ${messageFragment} all ${this.list.selected.size} selected document(s).`
- modal.componentInstance.btnClass = "btn-warning"
- modal.componentInstance.btnCaption = "Confirm"
- modal.componentInstance.confirmClicked.subscribe(() => {
- this.executeBulkOperation('set_correspondent', {"correspondent": correspondent ? correspondent.id : null}).subscribe(
- response => {
- modal.close()
- }
- )
- })
- }
-
- bulkSetDocumentTypes(changedDocumentTypes: ChangedItems) {
- let modal = this.modalService.open(ConfirmDialogComponent, {backdrop: 'static'})
- modal.componentInstance.title = "Confirm Document Type Assignment"
- let documentType
- let messageFragment = 'remove all document types from'
- if (changedDocumentTypes && changedDocumentTypes.itemsToAdd.length > 0) {
- documentType = changedDocumentTypes.itemsToAdd[0]
- messageFragment = `assign the document type ${documentType.name} to`
- }
- modal.componentInstance.message = `This operation will ${messageFragment} all ${this.list.selected.size} selected document(s).`
- modal.componentInstance.btnClass = "btn-warning"
- modal.componentInstance.btnCaption = "Confirm"
- modal.componentInstance.confirmClicked.subscribe(() => {
- this.executeBulkOperation('set_document_type', {"document_type": documentType ? documentType.id : null}).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()
- }
- )
- })
- }
}
From 2ac6a02e31a1f4b49583fbbbe637b057db7ccf8b Mon Sep 17 00:00:00 2001
From: Michael Shamoon <4887959+nikonratm@users.noreply.github.com>
Date: Fri, 25 Dec 2020 01:14:56 -0800
Subject: [PATCH 53/92] More simplification
---
.../bulk-editor/bulk-editor.component.html | 24 ++++----
.../bulk-editor/bulk-editor.component.ts | 57 +++++++------------
2 files changed, 34 insertions(+), 47 deletions(-)
diff --git a/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.html b/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.html
index 11d3603b2..f27d6d201 100644
--- a/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.html
+++ b/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.html
@@ -32,29 +32,29 @@
+ (removeAll)="setTags(null)"
+ (editingComplete)="setTags($event)">
+ (removeAll)="setCorrespondents(null)"
+ (editingComplete)="setCorrespondents($event)">
+ (removeAll)="setDocumentTypes(null)"
+ (editingComplete)="setDocumentTypes($event)">