A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Fix: dont tie suggestions button to ai enabled any more (#14478)
shamoonde94657e170c
diff --git a/src-ui/src/app/components/common/suggestions-dropdown/suggestions-dropdown.component.html b/src-ui/src/app/components/common/suggestions-dropdown/suggestions-dropdown.component.htmlindex aca9fd72e..87411b8c5 100644--- a/src-ui/src/app/components/common/suggestions-dropdown/suggestions-dropdown.component.html+++ b/src-ui/src/app/components/common/suggestions-dropdown/suggestions-dropdown.component.html@@ -1,6 +1,6 @@<div class="d-flex align-items-center"><div class="btn-group">- <button type="button" class="btn btn-sm btn-outline-primary" (click)="clickSuggest()" [disabled]="disabled() || loading() || (suggestions() && !aiEnabled())" [aria-label]="noSuggestions ? 'No suggestions' : 'Suggest'" i18n-aria-label>+ <button type="button" class="btn btn-sm btn-outline-primary" (click)="clickSuggest()" [disabled]="disabled() || loading()" [aria-label]="noSuggestions ? 'No suggestions' : 'Suggest'" i18n-aria-label>@if (loading()) {<div class="spinner-border spinner-border-sm" role="status"></div>} @else if (noSuggestions) {@@ -18,46 +18,44 @@}</button>- @if (aiEnabled()) {- <div class="btn-group" ngbDropdown #dropdown="ngbDropdown" [popperOptions]="popperOptions">- <button type="button" class="btn btn-sm btn-outline-primary" ngbDropdownToggle [disabled]="disabled() || loading() || !suggestions()" aria-expanded="false" aria-controls="suggestionsDropdown" aria-label="Suggestions dropdown">- <span class="visually-hidden" i18n>Show suggestions</span>- </button>+ <div class="btn-group" ngbDropdown #dropdown="ngbDropdown" [popperOptions]="popperOptions">+ <button type="button" class="btn btn-sm btn-outline-primary" ngbDropdownToggle [disabled]="disabled() || loading() || !suggestions()" aria-expanded="false" aria-controls="suggestionsDropdown" aria-label="Suggestions dropdown">+ <span class="visually-hidden" i18n>Show suggestions</span>+ </button>- <div ngbDropdownMenu aria-labelledby="suggestionsDropdown" class="shadow suggestions-dropdown">- <div class="list-group list-group-flush small pb-0">- @if (novelSuggestions === 0 && fieldSuggestions === 0) {- <div class="list-group-item text-muted fst-italic">- <small class="text-muted small fst-italic" i18n>No novel suggestions</small>- </div>- }- @if (suggestions()?.suggested_tags?.length > 0) {- <small class="list-group-item text-uppercase text-muted small"><i-bs class="me-2" name="tags"></i-bs><ng-container i18n>Tags</ng-container></small>- @for (tag of suggestions().suggested_tags; track tag) {- <button type="button" class="list-group-item list-group-item-action bg-light" (click)="addTag.emit(tag)">{{ tag }}</button>- }+ <div ngbDropdownMenu aria-labelledby="suggestionsDropdown" class="shadow suggestions-dropdown">+ <div class="list-group list-group-flush small pb-0">+ @if (novelSuggestions === 0 && fieldSuggestions === 0) {+ <div class="list-group-item text-muted fst-italic">+ <small class="text-muted small fst-italic" i18n>No novel suggestions</small>+ </div>+ }+ @if (suggestions()?.suggested_tags?.length > 0) {+ <small class="list-group-item text-uppercase text-muted small"><i-bs class="me-2" name="tags"></i-bs><ng-container i18n>Tags</ng-container></small>+ @for (tag of suggestions().suggested_tags; track tag) {+ <button type="button" class="list-group-item list-group-item-action bg-light" (click)="addTag.emit(tag)">{{ tag }}</button>}- @if (suggestions()?.suggested_document_types?.length > 0) {- <div class="list-group-item text-uppercase text-muted small"><i-bs class="me-2" name="hash"></i-bs><ng-container i18n>Document Types</ng-container></div>- @for (type of suggestions().suggested_document_types; track type) {- <button type="button" class="list-group-item list-group-item-action bg-light" (click)="addDocumentType.emit(type)">{{ type }}</button>- }+ }+ @if (suggestions()?.suggested_document_types?.length > 0) {+ <div class="list-group-item text-uppercase text-muted small"><i-bs class="me-2" name="hash"></i-bs><ng-container i18n>Document Types</ng-container></div>+ @for (type of suggestions().suggested_document_types; track type) {+ <button type="button" class="list-group-item list-group-item-action bg-light" (click)="addDocumentType.emit(type)">{{ type }}</button>}- @if (suggestions()?.suggested_correspondents?.length > 0) {- <div class="list-group-item text-uppercase text-muted small"><i-bs class="me-2" name="person"></i-bs><ng-container i18n>Correspondents</ng-container></div>- @for (correspondent of suggestions().suggested_correspondents; track correspondent) {- <button type="button" class="list-group-item list-group-item-action bg-light" (click)="addCorrespondent.emit(correspondent)">{{ correspondent }}</button>- }+ }+ @if (suggestions()?.suggested_correspondents?.length > 0) {+ <div class="list-group-item text-uppercase text-muted small"><i-bs class="me-2" name="person"></i-bs><ng-container i18n>Correspondents</ng-container></div>+ @for (correspondent of suggestions().suggested_correspondents; track correspondent) {+ <button type="button" class="list-group-item list-group-item-action bg-light" (click)="addCorrespondent.emit(correspondent)">{{ correspondent }}</button>}- @if (fieldSuggestions > 0) {- <div class="list-group-item text-muted fst-italic">- <small class="text-muted small fst-italic" i18n>{fieldSuggestions, plural, =1 {1 suggestion available below} other {{{fieldSuggestions}} suggestions available below}}</small>- </div>- }- </div>+ }+ @if (fieldSuggestions > 0) {+ <div class="list-group-item text-muted fst-italic">+ <small class="text-muted small fst-italic" i18n>{fieldSuggestions, plural, =1 {1 suggestion available below} other {{{fieldSuggestions}} suggestions available below}}</small>+ </div>+ }</div></div>- }+ </div></div>@if (aiEnabled()) {diff --git a/src-ui/src/app/components/common/suggestions-dropdown/suggestions-dropdown.component.spec.ts b/src-ui/src/app/components/common/suggestions-dropdown/suggestions-dropdown.component.spec.tsindex 4395c6038..6cc7cb173 100644--- a/src-ui/src/app/components/common/suggestions-dropdown/suggestions-dropdown.component.spec.ts+++ b/src-ui/src/app/components/common/suggestions-dropdown/suggestions-dropdown.component.spec.ts@@ -251,6 +251,37 @@ describe('SuggestionsDropdownComponent', () => {expect(fixture.nativeElement.textContent).toContain('No novel suggestions')})+ it('should open ML date suggestions with AI disabled', () => {+ const getSuggestions = jest.spyOn(component.getSuggestions, 'emit')+ fixture.componentRef.setInput('aiEnabled', false)+ fixture.componentRef.setInput('fetchedSources', [SuggestionSource.ML])+ fixture.componentRef.setInput('suggestions', {+ dates: ['2026-01-04', '2026-02-01'],+ })+ fixture.componentRef.setInput('appliedCreated', '2026-01-04')+ fixture.detectChanges()++ const button = fixture.nativeElement.querySelector('button')+ expect(button.disabled).toBeFalsy()+ expect(button.querySelector('.badge').textContent.trim()).toBe('1')++ button.click()+ fixture.detectChanges()++ expect(component.dropdown.isOpen()).toBeTruthy()+ expect(fixture.nativeElement.textContent).toContain(+ '1 suggestion available below'+ )+ expect(getSuggestions).not.toHaveBeenCalled()+ expect(+ fixture.nativeElement.querySelector('button[title="Suggestion options"]')+ ).toBeNull()++ button.click()+ fixture.detectChanges()+ expect(component.dropdown.isOpen()).toBeFalsy()+ })+it('should fetch unfetched sources and show existing suggestions', () => {jest.spyOn(component.getSuggestions, 'emit')fixture.componentRef.setInput('aiEnabled', true)diff --git a/src-ui/src/app/components/common/suggestions-dropdown/suggestions-dropdown.component.ts b/src-ui/src/app/components/common/suggestions-dropdown/suggestions-dropdown.component.tsindex 2c04f6ecc..73086ab12 100644--- a/src-ui/src/app/components/common/suggestions-dropdown/suggestions-dropdown.component.ts+++ b/src-ui/src/app/components/common/suggestions-dropdown/suggestions-dropdown.component.ts@@ -53,11 +53,7 @@ export class SuggestionsDropdownComponent {addCorrespondent: EventEmitter<string> = new EventEmitter()public clickSuggest(): void {- if (- this.disabled() ||- this.loading() ||- (this.suggestions() && !this.aiEnabled())- ) {+ if (this.disabled() || this.loading()) {return}