Skip to content

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

Merge branch 'dev' into feature-bulk-edit

jonaswinklerbb9b438aa626
diff --cc src-ui/src/app/app.module.ts
index befd26639,5b92364d2..887dc7ffd
--- a/src-ui/src/app/app.module.ts
+++ b/src-ui/src/app/app.module.ts
@@@ -49,7 -49,7 +49,8 @@@ import { WelcomeWidgetComponent } from
import { YesNoPipe } from './pipes/yes-no.pipe';
import { FileSizePipe } from './pipes/file-size.pipe';
import { DocumentTitlePipe } from './pipes/document-title.pipe';
+ import { MetadataCollapseComponent } from './components/document-detail/metadata-collapse/metadata-collapse.component';
+import { SelectDialogComponent } from './components/common/select-dialog/select-dialog.component';
@NgModule({
declarations: [
@@@ -91,7 -91,7 +92,8 @@@
YesNoPipe,
FileSizePipe,
DocumentTitlePipe,
- MetadataCollapseComponent
++ MetadataCollapseComponent,
+ SelectDialogComponent
],
imports: [
BrowserModule,
diff --cc src-ui/src/app/components/common/confirm-dialog/confirm-dialog.component.html
index 52287fc69,53b613244..f4dffa7d1
--- a/src-ui/src/app/components/common/confirm-dialog/confirm-dialog.component.html
+++ b/src-ui/src/app/components/common/confirm-dialog/confirm-dialog.component.html
@@@ -10,5 -10,5 +10,8 @@@
</div>
<div class="modal-footer">
<button type="button" class="btn btn-outline-dark" (click)="cancelClicked()">Cancel</button>
- <button type="button" class="btn btn-danger" (click)="deleteClicked.emit()" [disabled]="!deleteButtonEnabled">Delete<span *ngIf="!deleteButtonEnabled"> ({{seconds}})</span></button>
- <button type="button" class="btn" [class]="btnClass" (click)="confirmClicked.emit()">{{btnCaption}}</button>
-- </div>
++ <button type="button" class="btn" [class]="btnClass" (click)="confirmClicked.emit()" [disabled]="!confirmButtonEnabled">
++ {{btnCaption}}
++ <span *ngIf="!confirmButtonEnabled"> ({{seconds}})</span>
++ </button>
++ </div>
diff --cc src-ui/src/app/components/common/confirm-dialog/confirm-dialog.component.ts
index 38ec93bae,e207f4598..4791d0e77
--- a/src-ui/src/app/components/common/confirm-dialog/confirm-dialog.component.ts
+++ b/src-ui/src/app/components/common/confirm-dialog/confirm-dialog.component.ts
@@@ -11,32 -11,23 +11,38 @@@ export class ConfirmDialogComponent imp
constructor(public activeModal: NgbActiveModal) { }
@Output()
- public deleteClicked = new EventEmitter()
+ public confirmClicked = new EventEmitter()
@Input()
- title = "Delete confirmation"
+ title = "Confirmation"
@Input()
- message = "Do you really want to delete this?"
+ messageBold
@Input()
- message2
+ message
- deleteButtonEnabled = true
+ @Input()
+ btnClass = "btn-primary"
+
+ @Input()
+ btnCaption = "Confirm"
+
++ confirmButtonEnabled = true
+ seconds = 0
+
+ delayConfirm(seconds: number) {
- this.deleteButtonEnabled = false
++ this.confirmButtonEnabled = false
+ this.seconds = seconds
+ setTimeout(() => {
+ if (this.seconds <= 1) {
- this.deleteButtonEnabled = true
++ this.confirmButtonEnabled = true
+ } else {
+ this.delayConfirm(seconds - 1)
+ }
+ }, 1000)
+ }
+
ngOnInit(): void {
}
diff --cc src-ui/src/app/components/document-list/document-list.component.ts
index 4d5597220,09e73dd96..36c70a00e
--- a/src-ui/src/app/components/document-list/document-list.component.ts
+++ b/src-ui/src/app/components/document-list/document-list.component.ts
@@@ -15,8 -10,6 +15,8 @@@ import { TagService } from 'src/app/ser
import { SavedViewConfigService } from 'src/app/services/saved-view-config.service';
import { Toast, ToastService } from 'src/app/services/toast.service';
import { environment } from 'src/environments/environment';
- import { DeleteDialogComponent } from '../common/delete-dialog/delete-dialog.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';
@Component({
@@@ -153,101 -142,4 +153,104 @@@ export class DocumentListComponent impl
this.applyFilterRules()
}
+ 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() {
+ this.executeBulkOperation('set_correspondent', {"correspondent": null}).subscribe(r => {})
+ }
+
+ 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() {
+ this.executeBulkOperation('set_document_type', {"document_type": null}).subscribe(r => {})
+ }
+
+ 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(DeleteDialogComponent, {backdrop: 'static'})
++ let modal = this.modalService.open(ConfirmDialogComponent, {backdrop: 'static'})
+ modal.componentInstance.delayConfirm(5)
- modal.componentInstance.message = `This operation will permanently delete all ${this.list.selected.size} selected document(s).`
- modal.componentInstance.message2 = `This operation cannot be undone.`
- modal.componentInstance.deleteClicked.subscribe(() => {
++ 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()
+ }
+ )
+ })
+ }
}