Fix some TS syntax errors

This commit is contained in:
Michael Shamoon 2020-12-20 00:12:40 -08:00
parent 7669679fb1
commit 3561935e1b
2 changed files with 17 additions and 13 deletions

View File

@ -52,7 +52,7 @@ export class FilterableDropdownComponent {
} }
get itemsSelected() :(PaperlessTag | PaperlessCorrespondent | PaperlessDocumentType)[] { get itemsSelected() :(PaperlessTag | PaperlessCorrespondent | PaperlessDocumentType)[] {
return this.toggleableItems.filter(si => si.state == ToggleableItemState.Selected).map(si => si.item) return this.toggleableItems.filter(ti => ti.state == ToggleableItemState.Selected).map(ti => ti.item)
} }
@Input() @Input()
@ -67,7 +67,7 @@ export class FilterableDropdownComponent {
types = FilterableDropdownType types = FilterableDropdownType
@Input() @Input()
singular: boolean = false tingular: boolean = false
@Output() @Output()
toggle = new EventEmitter() toggle = new EventEmitter()
@ -80,20 +80,20 @@ export class FilterableDropdownComponent {
_showCounts: boolean = true _showCounts: boolean = true
@Input @Input()
set showCounts(show: boolean) { set showCounts(show: boolean) {
this._showCounts = show this._showCounts = show
} }
get showCounts(): boolean { get showCounts(): boolean {
return this._showCounts && (this.type == FilterableDropdownType.Editing || (this.type == FilterableDropdownType.Filtering && this.itemsSelected == 0)) return this._showCounts && (this.type == FilterableDropdownType.Editing || (this.type == FilterableDropdownType.Filtering && this.itemsSelected.length == 0))
} }
constructor(private filterPipe: FilterPipe) { } constructor(private filterPipe: FilterPipe) { }
toggleItem(toggleableItem: ToggleableItem): void { toggleItem(toggleableItem: ToggleableItem): void {
if (this.singular && toggleableItem.state == ToggleableItemState.Selected) { if (this.tingular && toggleableItem.state == ToggleableItemState.Selected) {
this._toggleableItems.filter(si => si.item.id !== toggleableItem.item.id).forEach(si => si.state = ToggleableItemState.NotSelected) this._toggleableItems.filter(ti => ti.item.id !== toggleableItem.item.id).forEach(ti => ti.state = ToggleableItemState.NotSelected)
} }
this.toggle.emit(toggleableItem.item) this.toggle.emit(toggleableItem.item)
} }
@ -112,7 +112,11 @@ export class FilterableDropdownComponent {
listFilterEnter(): void { listFilterEnter(): void {
let filtered = this.filterPipe.transform(this.toggleableItems, this.filterText) let filtered = this.filterPipe.transform(this.toggleableItems, this.filterText)
if (filtered.length == 1) this.toggleItem(filtered.shift()) if (filtered.length == 1) {
this.dropdown.close() let toggleableItem = this.toggleableItems.find(ti => ti.item.id == filtered[0].item.id)
if (toggleableItem) toggleableItem.state = ToggleableItemState.Selected
this.toggleItem(filtered[0])
this.dropdown.close()
}
} }
} }

View File

@ -45,18 +45,18 @@ export class BulkEditorComponent {
@Output() @Output()
delete = new EventEmitter() delete = new EventEmitter()
private tags: PaperlessTag[] tags: PaperlessTag[]
private correspondents: PaperlessCorrespondent[] correspondents: PaperlessCorrespondent[]
private documentTypes: PaperlessDocumentType[] documentTypes: PaperlessDocumentType[]
private initiallySelectedTagsToggleableItems: ToggleableItem[] private initiallySelectedTagsToggleableItems: ToggleableItem[]
private initiallySelectedCorrespondentsToggleableItems: ToggleableItem[] private initiallySelectedCorrespondentsToggleableItems: ToggleableItem[]
private initiallySelectedDocumentTypesToggleableItems: ToggleableItem[] private initiallySelectedDocumentTypesToggleableItems: ToggleableItem[]
private dropdownTypes = FilterableDropdownType dropdownTypes = FilterableDropdownType
get selectionSpansPages(): boolean { get selectionSpansPages(): boolean {
return this.selectedDocuments.length > this.viewDocuments.length || !Array.from(this.selectedDocuments).every(sd => this.viewDocuments.find(d => d.id == sd)) return this.selectedDocuments.size > this.viewDocuments.length || !Array.from(this.selectedDocuments).every(sd => this.viewDocuments.find(d => d.id == sd))
} }
get tagsToggleableItems(): ToggleableItem[] { get tagsToggleableItems(): ToggleableItem[] {