A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Fix: use signal-backed queries input in CF dropdown to reflect changes immediately under zoneless (#13901)
shamoon38db6b51db88
diff --git a/src-ui/src/app/components/common/custom-fields-query-dropdown/custom-fields-query-dropdown.component.html b/src-ui/src/app/components/common/custom-fields-query-dropdown/custom-fields-query-dropdown.component.htmlindex 973d9f1a8..ceec0269e 100644--- a/src-ui/src/app/components/common/custom-fields-query-dropdown/custom-fields-query-dropdown.component.html+++ b/src-ui/src/app/components/common/custom-fields-query-dropdown/custom-fields-query-dropdown.component.html@@ -1,6 +1,6 @@@if (useDropdown) {<div class="btn-group w-100" role="group" ngbDropdown #dropdown="ngbDropdown" (openChange)="onOpenChange($event)" [popperOptions]="popperOptions">- <button class="btn btn-sm btn-outline-primary" id="dropdown_toggle" ngbDropdownToggle [disabled]="disabled" [aria-label]="title">+ <button class="btn btn-sm" [ngClass]="!editing && isActive ? 'btn-primary' : 'btn-outline-primary'" id="dropdown_toggle" ngbDropdownToggle [disabled]="disabled" [aria-label]="title"><i-bs name="{{icon}}"></i-bs><div class="d-none d-sm-inline ms-1">{{title}}</div>@if (isActive) {<pngx-clearable-badge [selected]="isActive" (cleared)="reset()"></pngx-clearable-badge>diff --git a/src-ui/src/app/components/common/custom-fields-query-dropdown/custom-fields-query-dropdown.component.ts b/src-ui/src/app/components/common/custom-fields-query-dropdown/custom-fields-query-dropdown.component.tsindex 7f17c0e3a..47f0955b9 100644--- a/src-ui/src/app/components/common/custom-fields-query-dropdown/custom-fields-query-dropdown.component.ts+++ b/src-ui/src/app/components/common/custom-fields-query-dropdown/custom-fields-query-dropdown.component.ts@@ -1,5 +1,6 @@import {getLocaleNumberSymbol,+ NgClass,NgTemplateOutlet,NumberSymbol,} from '@angular/common'@@ -48,25 +49,26 @@ import { ClearableBadgeComponent } from '../clearable-badge/clearable-badge.compimport { DocumentLinkComponent } from '../input/document-link/document-link.component'export class CustomFieldQueriesModel {- private _queries: CustomFieldQueryElement[] = []+ private readonly _queries = signal<CustomFieldQueryElement[]>([])private rootSubscriptions: Subscription[] = []public readonly changed = new Subject<CustomFieldQueriesModel>()public get queries(): CustomFieldQueryElement[] {- return this._queries+ return this._queries()}public set queries(value: CustomFieldQueryElement[]) {this.teardownRootSubscriptions()- this._queries = value ?? []- for (const element of this._queries) {+ const queries = value ?? []+ for (const element of queries) {this.rootSubscriptions.push(element.changed.subscribe(() => {this.changed.next(this)}))}+ this._queries.set(queries)}public clear(fireEvent = true) {@@ -209,6 +211,7 @@ export class CustomFieldQueriesModel {DocumentLinkComponent,ReactiveFormsModule,NgbDatepickerModule,+ NgClass,NgTemplateOutlet,NgSelectModule,NgxBootstrapIconsModule,diff --git a/src-ui/src/app/components/document-list/filter-editor/filter-editor.component.spec.ts b/src-ui/src/app/components/document-list/filter-editor/filter-editor.component.spec.tsindex 26e9bbeb3..af47edf5a 100644--- a/src-ui/src/app/components/document-list/filter-editor/filter-editor.component.spec.ts+++ b/src-ui/src/app/components/document-list/filter-editor/filter-editor.component.spec.ts@@ -1034,6 +1034,49 @@ describe('FilterEditorComponent', () => {).toEqual([42, CustomFieldQueryOperator.Exists, 'true'])})+ it('should reflect ingested custom field query rules in the dropdown toggle', () => {+ const dropdown = fixture.debugElement.query(+ By.css('pngx-custom-fields-query-dropdown')+ )+ expect(+ dropdown.nativeElement.querySelector('pngx-clearable-badge')+ ).toBeNull()++ // switching to a view with a custom field query+ component.filterRules = [+ {+ rule_type: FILTER_CUSTOM_FIELDS_QUERY,+ value: '["OR",[[42,"exists","true"]]]',+ },+ ]+ fixture.detectChanges()+ expect(+ dropdown.nativeElement.querySelector('pngx-clearable-badge')+ ).not.toBeNull()+ expect(+ dropdown.nativeElement+ .querySelector('#dropdown_toggle')+ .classList.contains('btn-primary')+ ).toBeTruthy()++ // and back to a view without one+ component.filterRules = [+ {+ rule_type: FILTER_HAS_TAGS_ALL,+ value: '19',+ },+ ]+ fixture.detectChanges()+ expect(+ dropdown.nativeElement.querySelector('pngx-clearable-badge')+ ).toBeNull()+ expect(+ dropdown.nativeElement+ .querySelector('#dropdown_toggle')+ .classList.contains('btn-primary')+ ).toBeFalsy()+ })+it('should ingest filter rules for owner', () => {expect(component.permissionsSelectionModel.ownerFilter).toEqual(OwnerFilterType.NONE