mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-10-07 00:27:12 +00:00
Fix create after ML-only
This commit is contained in:
2 files changed
+52
-9
No files matched your search
@@ -662,6 +662,45 @@ describe('DocumentDetailComponent', () => {
|
||||
)
|
||||
})
|
||||
|
||||
it.each([
|
||||
['tag', 'createTag', 'tags', 'suggested_tags'],
|
||||
[
|
||||
'document type',
|
||||
'createDocumentType',
|
||||
'document_type',
|
||||
'suggested_document_types',
|
||||
],
|
||||
[
|
||||
'correspondent',
|
||||
'createCorrespondent',
|
||||
'correspondent',
|
||||
'suggested_correspondents',
|
||||
],
|
||||
])(
|
||||
'should create a %s after ML-only suggestions',
|
||||
(_, method, field, suggestedField) => {
|
||||
initNormally()
|
||||
component.suggestions.set({ tags: [1] })
|
||||
let openModal: NgbModalRef
|
||||
modalService.activeInstances.subscribe((modal) => (openModal = modal[0]))
|
||||
component[method]('New value')
|
||||
openModal.componentInstance.succeeded.next({
|
||||
id: 12,
|
||||
name: 'New value',
|
||||
is_inbox_tag: false,
|
||||
color: '#ff0000',
|
||||
text_color: '#000000',
|
||||
})
|
||||
|
||||
if (field === 'tags') {
|
||||
expect(component.tagsInput.value).toContain(12)
|
||||
} else {
|
||||
expect(component.documentForm.get(field).value).toBe(12)
|
||||
}
|
||||
expect(component.suggestions()[suggestedField]).toEqual([])
|
||||
}
|
||||
)
|
||||
|
||||
it('should support creating storage path', () => {
|
||||
initNormally()
|
||||
let openModal: NgbModalRef
|
||||
|
||||
@@ -1154,7 +1154,7 @@ export class DocumentDetailComponent
|
||||
if (this.suggestions()) {
|
||||
this.suggestions.set({
|
||||
...this.suggestions(),
|
||||
suggested_tags: this.suggestions().suggested_tags.filter(
|
||||
suggested_tags: (this.suggestions().suggested_tags ?? []).filter(
|
||||
(tag) => tag !== newTag.name
|
||||
),
|
||||
})
|
||||
@@ -1193,10 +1193,12 @@ export class DocumentDetailComponent
|
||||
this.documentForm.get('document_type').setValue(newDocumentType.id)
|
||||
this.documentForm.get('document_type').markAsDirty()
|
||||
if (this.suggestions()) {
|
||||
this.suggestions().suggested_document_types =
|
||||
this.suggestions().suggested_document_types.filter(
|
||||
(dt) => dt !== newName
|
||||
)
|
||||
this.suggestions.set({
|
||||
...this.suggestions(),
|
||||
suggested_document_types: (
|
||||
this.suggestions().suggested_document_types ?? []
|
||||
).filter((dt) => dt !== newName),
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -1223,10 +1225,12 @@ export class DocumentDetailComponent
|
||||
this.documentForm.get('correspondent').setValue(newCorrespondent.id)
|
||||
this.documentForm.get('correspondent').markAsDirty()
|
||||
if (this.suggestions()) {
|
||||
this.suggestions().suggested_correspondents =
|
||||
this.suggestions().suggested_correspondents.filter(
|
||||
(c) => c !== newName
|
||||
)
|
||||
this.suggestions.set({
|
||||
...this.suggestions(),
|
||||
suggested_correspondents: (
|
||||
this.suggestions().suggested_correspondents ?? []
|
||||
).filter((c) => c !== newName),
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user