From 3561935e1b8d5906f2a477bbf08d2a47f1dffc48 Mon Sep 17 00:00:00 2001 From: Michael Shamoon <4887959+nikonratm@users.noreply.github.com> Date: Sun, 20 Dec 2020 00:12:40 -0800 Subject: [PATCH] Fix some TS syntax errors --- .../filterable-dropdown.component.ts | 20 +++++++++++-------- .../bulk-editor/bulk-editor.component.ts | 10 +++++----- 2 files changed, 17 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 9a2c3cfc0..10713cc00 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 @@ -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() + } } } diff --git a/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts b/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts index c8c05a327..66ad265de 100644 --- a/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts +++ b/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts @@ -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[] {