From 01d448ecde9dffba833d89bb4c50f59593c8027b Mon Sep 17 00:00:00 2001 From: Michael Shamoon <4887959+nikonratm@users.noreply.github.com> Date: Fri, 18 Dec 2020 21:19:49 -0800 Subject: [PATCH] Bulk editor component skeleton --- .../filterable-dropdown.component.ts | 4 + .../bulk-editor/bulk-editor.component.html | 95 ++++--------------- .../bulk-editor/bulk-editor.component.scss | 10 -- .../bulk-editor/bulk-editor.component.ts | 75 ++++++++++++++- .../document-list.component.html | 22 ++--- 5 files changed, 107 insertions(+), 99 deletions(-) diff --git a/src-ui/src/app/components/common/filterable-dropdown/filterable-dropdown.component.ts b/src-ui/src/app/components/common/filterable-dropdown/filterable-dropdown.component.ts index 0f7f937aa..cecbdf9fa 100644 --- a/src-ui/src/app/components/common/filterable-dropdown/filterable-dropdown.component.ts +++ b/src-ui/src/app/components/common/filterable-dropdown/filterable-dropdown.component.ts @@ -27,6 +27,9 @@ export class FilterableDropdownComponent { @Output() toggle = new EventEmitter() + @Output() + close = new EventEmitter() + @ViewChild('listFilterTextInput') listFilterTextInput: ElementRef @ViewChild('dropdown') dropdown: NgbDropdown @@ -47,6 +50,7 @@ export class FilterableDropdownComponent { }, 0); } else { this.filterText = '' + this.close.emit(this.itemsSelected) } } 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 d330ba228..bf8f7b732 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 @@ -1,89 +1,34 @@ -
-
-
- -
- - -
-
- -
- - +
+
+
+ + + +
-
- -
- - -
-
-
- -
- - -
-
-
- -
-
- - - - - - Add - - - - - - - Edit - - - - - - - Remove - diff --git a/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.scss b/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.scss index 5afd86545..e69de29bb 100644 --- a/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.scss +++ b/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.scss @@ -1,10 +0,0 @@ -.btn svg { - width: 0.9em; - height: 0.9em; - margin-right: 3px; - margin-top: -1px; -} - -.btn-sm { - line-height: 1; -} diff --git a/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts b/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts index 5c1ad01ae..e5f722dc7 100644 --- a/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts +++ b/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts @@ -1,5 +1,12 @@ import { Component, EventEmitter, Input, Output } from '@angular/core'; -import { DocumentListViewService } from 'src/app/services/document-list-view.service'; +import { PaperlessTag } from 'src/app/data/paperless-tag'; +import { PaperlessCorrespondent } from 'src/app/data/paperless-correspondent'; +import { PaperlessDocumentType } from 'src/app/data/paperless-document-type'; +import { PaperlessDocument } from 'src/app/data/paperless-document'; +import { TagService } from 'src/app/services/rest/tag.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'; @Component({ selector: 'app-bulk-editor', @@ -9,7 +16,10 @@ import { DocumentListViewService } from 'src/app/services/document-list-view.ser export class BulkEditorComponent { @Input() - list: DocumentListViewService + documentsSelected: Set + + @Input() + allDocuments: PaperlessDocument[] @Output() selectPage = new EventEmitter() @@ -41,6 +51,65 @@ export class BulkEditorComponent { @Output() delete = new EventEmitter() - constructor( ) { } + tags: PaperlessTag[] + correspondents: PaperlessCorrespondent[] + documentTypes: PaperlessDocumentType[] + get selectedTags(): PaperlessTag[] { + let selectedTags = [] + this.allDocuments.forEach(d => { + if (this.documentsSelected.has(d.id)) { + if (d.tags && !d.tags.every(t => selectedTags.find(st => st.id == t) !== undefined)) d.tags$.subscribe(t => selectedTags = selectedTags.concat(t)) + } + }) + return selectedTags + } + + get selectedCorrespondents(): PaperlessCorrespondent[] { + let selectedCorrespondents = [] + this.allDocuments.forEach(d => { + if (this.documentsSelected.has(d.id)) { + if (d.correspondent && selectedCorrespondents.find(sc => sc.id == d.correspondent) == undefined) d.correspondent$.subscribe(c => selectedCorrespondents.push(c)) + } + }) + return selectedCorrespondents + } + + get selectedDocumentTypes(): PaperlessDocumentType[] { + let selectedDocumentTypes = [] + this.allDocuments.forEach(d => { + if (this.documentsSelected.has(d.id)) { + if (d.document_type && selectedDocumentTypes.find(sdt => sdt.id == d.document_type) == undefined) d.document_type$.subscribe(dt => selectedDocumentTypes.push(dt)) + } + }) + return selectedDocumentTypes + } + + constructor( + private documentTypeService: DocumentTypeService, + private tagService: TagService, + private correspondentService: CorrespondentService, + private documentService: DocumentService + ) { } + + ngOnInit() { + this.tagService.listAll().subscribe(result => this.tags = result.results) + this.correspondentService.listAll().subscribe(result => this.correspondents = result.results) + this.documentTypeService.listAll().subscribe(result => this.documentTypes = result.results) + } + + applyTags(tags) { + console.log(tags); + + } + + applyCorrespondent(correspondent) { + console.log(correspondent); + + } + + applyDocumentType(documentType) { + console.log(documentType); + + } } diff --git a/src-ui/src/app/components/document-list/document-list.component.html b/src-ui/src/app/components/document-list/document-list.component.html index 5b4511866..beb779636 100644 --- a/src-ui/src/app/components/document-list/document-list.component.html +++ b/src-ui/src/app/components/document-list/document-list.component.html @@ -78,17 +78,11 @@
- -
+ -
-

Selected {{list.selected.size}} of {{list.collectionSize || 0}} document(s) (filtered)

- -
- -
- - + +
+ +
+

Selected {{list.selected.size}} of {{list.collectionSize || 0}} document(s) (filtered)

+