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)[] {
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()
@ -67,7 +67,7 @@ export class FilterableDropdownComponent {
types = FilterableDropdownType
@Input()
singular: boolean = false
tingular: boolean = false
@Output()
toggle = new EventEmitter()
@ -80,20 +80,20 @@ export class FilterableDropdownComponent {
_showCounts: boolean = true
@Input
@Input()
set showCounts(show: boolean) {
this._showCounts = show
}
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) { }
toggleItem(toggleableItem: ToggleableItem): void {
if (this.singular && toggleableItem.state == ToggleableItemState.Selected) {
this._toggleableItems.filter(si => si.item.id !== toggleableItem.item.id).forEach(si => si.state = ToggleableItemState.NotSelected)
if (this.tingular && toggleableItem.state == ToggleableItemState.Selected) {
this._toggleableItems.filter(ti => ti.item.id !== toggleableItem.item.id).forEach(ti => ti.state = ToggleableItemState.NotSelected)
}
this.toggle.emit(toggleableItem.item)
}
@ -112,7 +112,11 @@ export class FilterableDropdownComponent {
listFilterEnter(): void {
let filtered = this.filterPipe.transform(this.toggleableItems, this.filterText)
if (filtered.length == 1) this.toggleItem(filtered.shift())
this.dropdown.close()
if (filtered.length == 1) {
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()
delete = new EventEmitter()
private tags: PaperlessTag[]
private correspondents: PaperlessCorrespondent[]
private documentTypes: PaperlessDocumentType[]
tags: PaperlessTag[]
correspondents: PaperlessCorrespondent[]
documentTypes: PaperlessDocumentType[]
private initiallySelectedTagsToggleableItems: ToggleableItem[]
private initiallySelectedCorrespondentsToggleableItems: ToggleableItem[]
private initiallySelectedDocumentTypesToggleableItems: ToggleableItem[]
private dropdownTypes = FilterableDropdownType
dropdownTypes = FilterableDropdownType
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[] {