mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
typing
This commit is contained in:
parent
4b9a8f3409
commit
a2ad62b310
@ -1,10 +1,8 @@
|
|||||||
import { Component, EventEmitter, Input, Output, ElementRef, ViewChild } from '@angular/core';
|
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 { FilterPipe } from 'src/app/pipes/filter.pipe';
|
||||||
import { NgbDropdown } from '@ng-bootstrap/ng-bootstrap'
|
import { NgbDropdown } from '@ng-bootstrap/ng-bootstrap'
|
||||||
import { ToggleableItem, ToggleableItemState } from './toggleable-dropdown-button/toggleable-dropdown-button.component';
|
import { ToggleableItem, ToggleableItemState } from './toggleable-dropdown-button/toggleable-dropdown-button.component';
|
||||||
|
import { MatchingModel } from 'src/app/data/matching-model';
|
||||||
|
|
||||||
export enum FilterableDropdownType {
|
export enum FilterableDropdownType {
|
||||||
Filtering = 'filtering',
|
Filtering = 'filtering',
|
||||||
@ -24,7 +22,7 @@ export class FilterableDropdownComponent {
|
|||||||
filterText: string
|
filterText: string
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
set items(items: (PaperlessTag | PaperlessCorrespondent | PaperlessDocumentType)[]) {
|
set items(items: MatchingModel[]) {
|
||||||
if (items) {
|
if (items) {
|
||||||
this._toggleableItems = items.map(i => {
|
this._toggleableItems = items.map(i => {
|
||||||
return {item: i, state: ToggleableItemState.NotSelected, count: i.document_count}
|
return {item: i, state: ToggleableItemState.NotSelected, count: i.document_count}
|
||||||
@ -45,13 +43,13 @@ export class FilterableDropdownComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
set itemsSelected(itemsSelected: (PaperlessTag | PaperlessCorrespondent | PaperlessDocumentType)[]) {
|
set itemsSelected(itemsSelected: MatchingModel[]) {
|
||||||
this.toggleableItems.forEach(i => {
|
this.toggleableItems.forEach(i => {
|
||||||
i.state = (itemsSelected.find(is => is.id == i.item.id)) ? ToggleableItemState.Selected : ToggleableItemState.NotSelected
|
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)
|
return this.toggleableItems.filter(ti => ti.state == ToggleableItemState.Selected).map(ti => ti.item)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
import { Component, EventEmitter, Input, Output, OnInit } from '@angular/core';
|
import { Component, EventEmitter, Input, Output, OnInit } from '@angular/core';
|
||||||
import { PaperlessTag } from 'src/app/data/paperless-tag';
|
import { MatchingModel } from 'src/app/data/matching-model';
|
||||||
import { PaperlessCorrespondent } from 'src/app/data/paperless-correspondent';
|
|
||||||
import { PaperlessDocumentType } from 'src/app/data/paperless-document-type';
|
|
||||||
|
|
||||||
export interface ToggleableItem {
|
export interface ToggleableItem {
|
||||||
item: PaperlessTag | PaperlessDocumentType | PaperlessCorrespondent,
|
item: MatchingModel,
|
||||||
state: ToggleableItemState,
|
state: ToggleableItemState,
|
||||||
count: number
|
count: number
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import { PaperlessCorrespondent } from 'src/app/data/paperless-correspondent';
|
|||||||
import { PaperlessDocumentType } from 'src/app/data/paperless-document-type';
|
import { PaperlessDocumentType } from 'src/app/data/paperless-document-type';
|
||||||
import { Subject, Subscription } from 'rxjs';
|
import { Subject, Subscription } from 'rxjs';
|
||||||
import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
|
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 { DocumentTypeService } from 'src/app/services/rest/document-type.service';
|
||||||
import { TagService } from 'src/app/services/rest/tag.service';
|
import { TagService } from 'src/app/services/rest/tag.service';
|
||||||
import { CorrespondentService } from 'src/app/services/rest/correspondent.service';
|
import { CorrespondentService } from 'src/app/services/rest/correspondent.service';
|
||||||
@ -42,8 +42,7 @@ export class FilterEditorComponent implements OnInit, OnDestroy {
|
|||||||
constructor(
|
constructor(
|
||||||
private documentTypeService: DocumentTypeService,
|
private documentTypeService: DocumentTypeService,
|
||||||
private tagService: TagService,
|
private tagService: TagService,
|
||||||
private correspondentService: CorrespondentService,
|
private correspondentService: CorrespondentService
|
||||||
private dateParser: NgbDateParserFormatter
|
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
tags: PaperlessTag[] = []
|
tags: PaperlessTag[] = []
|
||||||
|
Loading…
x
Reference in New Issue
Block a user