A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Fix: sort editing filterable dropdowns sooner (#11404)
shamoon7a50157164cf
diff --git a/src-ui/src/app/components/common/filterable-dropdown/filterable-dropdown.component.spec.ts b/src-ui/src/app/components/common/filterable-dropdown/filterable-dropdown.component.spec.tsindex 5b643dc9f..2ecf95f2b 100644--- a/src-ui/src/app/components/common/filterable-dropdown/filterable-dropdown.component.spec.ts+++ b/src-ui/src/app/components/common/filterable-dropdown/filterable-dropdown.component.spec.ts@@ -631,6 +631,47 @@ describe('FilterableDropdownComponent & FilterableDropdownSelectionModel', () =>])})+ it('resorts items immediately when document count sorting enabled', () => {+ const apple: Tag = { id: 55, name: 'Apple' }+ const zebra: Tag = { id: 56, name: 'Zebra' }++ selectionModel.documentCountSortingEnabled = true+ selectionModel.items = [apple, zebra]+ expect(selectionModel.items.map((item) => item?.id ?? null)).toEqual([+ null,+ apple.id,+ zebra.id,+ ])++ selectionModel.documentCounts = [+ { id: zebra.id, document_count: 5 },+ { id: apple.id, document_count: 0 },+ ]++ expect(selectionModel.items.map((item) => item?.id ?? null)).toEqual([+ null,+ zebra.id,+ apple.id,+ ])+ })++ it('does not resort items by default when document counts are set', () => {+ const first: Tag = { id: 57, name: 'First' }+ const second: Tag = { id: 58, name: 'Second' }++ selectionModel.items = [first, second]+ selectionModel.documentCounts = [+ { id: second.id, document_count: 10 },+ { id: first.id, document_count: 0 },+ ]++ expect(selectionModel.items.map((item) => item?.id ?? null)).toEqual([+ null,+ first.id,+ second.id,+ ])+ })+it('uses fallback document counts when selection data is missing', () => {const fallbackRoot: Tag = {id: 50,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.tsindex 1e15930d1..ec5425630 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@@ -61,8 +61,13 @@ export class FilterableDropdownSelectionModel {temporaryIntersection: Intersection = this._intersectionprivate _documentCounts: SelectionDataItem[] = []+ public documentCountSortingEnabled = false+public set documentCounts(counts: SelectionDataItem[]) {this._documentCounts = counts+ if (this.documentCountSortingEnabled) {+ this.sortItems()+ }}private _items: MatchingModel[] = []@@ -651,8 +656,9 @@ export class FilterableDropdownComponentthis.selectionModel.changed.complete()model.items = this.selectionModel.itemsmodel.manyToOne = this.selectionModel.manyToOne- model.singleSelect = this.editing && !this.selectionModel.manyToOne+ model.singleSelect = this._editing && !model.manyToOne}+ model.documentCountSortingEnabled = this._editingmodel.changed.subscribe((updatedModel) => {this.selectionModelChange.next(updatedModel)})@@ -682,8 +688,21 @@ export class FilterableDropdownComponent@Input()allowSelectNone: boolean = false+ private _editing = false+@Input()- editing = false+ set editing(value: boolean) {+ this._editing = value+ if (this.selectionModel) {+ this.selectionModel.singleSelect =+ this._editing && !this.selectionModel.manyToOne+ this.selectionModel.documentCountSortingEnabled = this._editing+ }+ }++ get editing() {+ return this._editing+ }@Input()applyOnClose = false