From a2ad62b3104cbca843ab07cd151334af2d1a1887 Mon Sep 17 00:00:00 2001 From: jonaswinkler Date: Sun, 27 Dec 2020 13:10:43 +0100 Subject: [PATCH] typing --- .../filterable-dropdown.component.ts | 10 ++++------ .../toggleable-dropdown-button.component.ts | 6 ++---- .../filter-editor/filter-editor.component.ts | 5 ++--- 3 files changed, 8 insertions(+), 13 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 3f0b3c3ad..e66966486 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 @@ -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) } diff --git a/src-ui/src/app/components/common/filterable-dropdown/toggleable-dropdown-button/toggleable-dropdown-button.component.ts b/src-ui/src/app/components/common/filterable-dropdown/toggleable-dropdown-button/toggleable-dropdown-button.component.ts index 4d58023ad..adfea556a 100644 --- a/src-ui/src/app/components/common/filterable-dropdown/toggleable-dropdown-button/toggleable-dropdown-button.component.ts +++ b/src-ui/src/app/components/common/filterable-dropdown/toggleable-dropdown-button/toggleable-dropdown-button.component.ts @@ -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 } diff --git a/src-ui/src/app/components/document-list/filter-editor/filter-editor.component.ts b/src-ui/src/app/components/document-list/filter-editor/filter-editor.component.ts index 2d88579f9..dfc0e4e2c 100644 --- a/src-ui/src/app/components/document-list/filter-editor/filter-editor.component.ts +++ b/src-ui/src/app/components/document-list/filter-editor/filter-editor.component.ts @@ -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[] = []