This commit is contained in:
jonaswinkler 2020-12-27 13:10:43 +01:00
parent 4b9a8f3409
commit a2ad62b310
3 changed files with 8 additions and 13 deletions

View File

@ -1,10 +1,8 @@
import { Component, EventEmitter, Input, Output, ElementRef, ViewChild } from '@angular/core';
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 { FilterPipe } from 'src/app/pipes/filter.pipe';
import { NgbDropdown } from '@ng-bootstrap/ng-bootstrap'
import { ToggleableItem, ToggleableItemState } from './toggleable-dropdown-button/toggleable-dropdown-button.component';
import { MatchingModel } from 'src/app/data/matching-model';
export enum FilterableDropdownType {
Filtering = 'filtering',
@ -24,7 +22,7 @@ export class FilterableDropdownComponent {
filterText: string
@Input()
set items(items: (PaperlessTag | PaperlessCorrespondent | PaperlessDocumentType)[]) {
set items(items: MatchingModel[]) {
if (items) {
this._toggleableItems = items.map(i => {
return {item: i, state: ToggleableItemState.NotSelected, count: i.document_count}
@ -45,13 +43,13 @@ export class FilterableDropdownComponent {
}
@Input()
set itemsSelected(itemsSelected: (PaperlessTag | PaperlessCorrespondent | PaperlessDocumentType)[]) {
set itemsSelected(itemsSelected: MatchingModel[]) {
this.toggleableItems.forEach(i => {
i.state = (itemsSelected.find(is => is.id == i.item.id)) ? ToggleableItemState.Selected : ToggleableItemState.NotSelected
})
}
get itemsSelected() :(PaperlessTag | PaperlessCorrespondent | PaperlessDocumentType)[] {
get itemsSelected(): MatchingModel[] {
return this.toggleableItems.filter(ti => ti.state == ToggleableItemState.Selected).map(ti => ti.item)
}

View File

@ -1,10 +1,8 @@
import { Component, EventEmitter, Input, Output, OnInit } from '@angular/core';
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 { MatchingModel } from 'src/app/data/matching-model';
export interface ToggleableItem {
item: PaperlessTag | PaperlessDocumentType | PaperlessCorrespondent,
item: MatchingModel,
state: ToggleableItemState,
count: number
}

View File

@ -4,7 +4,7 @@ import { PaperlessCorrespondent } from 'src/app/data/paperless-correspondent';
import { PaperlessDocumentType } from 'src/app/data/paperless-document-type';
import { Subject, Subscription } from 'rxjs';
import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
import { NgbDateParserFormatter, NgbDateStruct } from '@ng-bootstrap/ng-bootstrap';
import { NgbDateParserFormatter } from '@ng-bootstrap/ng-bootstrap';
import { DocumentTypeService } from 'src/app/services/rest/document-type.service';
import { TagService } from 'src/app/services/rest/tag.service';
import { CorrespondentService } from 'src/app/services/rest/correspondent.service';
@ -42,8 +42,7 @@ export class FilterEditorComponent implements OnInit, OnDestroy {
constructor(
private documentTypeService: DocumentTypeService,
private tagService: TagService,
private correspondentService: CorrespondentService,
private dateParser: NgbDateParserFormatter
private correspondentService: CorrespondentService
) { }
tags: PaperlessTag[] = []