mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-10-20 06:48:16 +00:00
Enhancement (QoL): allow independently toggling child + parent tags in WF tag fields (#14400)
This commit is contained in:
1 parent
f6f420a491
commit
a4003df7e8
3 files changed
+25
-3
No files matched your search
+2
-1
@@ -209,6 +209,7 @@
|
||||
@if (isTagsFilter(filter.get('type').value)) {
|
||||
<pngx-input-tags
|
||||
[allowCreate]="false"
|
||||
[preserveHierarchy]="false"
|
||||
[title]="null"
|
||||
formControlName="values"
|
||||
></pngx-input-tags>
|
||||
@@ -320,7 +321,7 @@
|
||||
<h6 class="form-label" i18n>Remove tags</h6>
|
||||
<pngx-input-switch i18n-title title="Remove all" [horizontal]="true" formControlName="remove_all_tags"></pngx-input-switch>
|
||||
<div class="mt-n3">
|
||||
<pngx-input-tags [allowCreate]="false" title="" formControlName="remove_tags"></pngx-input-tags>
|
||||
<pngx-input-tags [allowCreate]="false" [preserveHierarchy]="false" title="" formControlName="remove_tags"></pngx-input-tags>
|
||||
</div>
|
||||
|
||||
<h6 class="form-label" i18n>Remove correspondents</h6>
|
||||
|
||||
@@ -222,6 +222,22 @@ describe('TagsComponent', () => {
|
||||
expect(propagated).toEqual([2, 1])
|
||||
})
|
||||
|
||||
it('should not add parents or remove children when not preserving hierarchy', () => {
|
||||
const parent: Tag = { id: 1, name: 'parent' }
|
||||
const child: Tag = { id: 2, name: 'child', parent: 1 }
|
||||
parent.children = [child]
|
||||
component.tags = [parent, child]
|
||||
component.preserveHierarchy = false
|
||||
|
||||
component.value = []
|
||||
component.addTag(2)
|
||||
expect(component.value).toEqual([2])
|
||||
|
||||
component.value = [1, 2]
|
||||
component.removeTag(1)
|
||||
expect(component.value).toEqual([2])
|
||||
})
|
||||
|
||||
it('should not duplicate parents when adding sibling nested tags', () => {
|
||||
const root: Tag = { id: 1, name: 'root' }
|
||||
const parent: Tag = { id: 2, name: 'parent', parent: 1 }
|
||||
|
||||
@@ -109,6 +109,9 @@ export class TagsComponent implements OnInit, ControlValueAccessor {
|
||||
@Input()
|
||||
multiple: boolean = true
|
||||
|
||||
@Input()
|
||||
preserveHierarchy: boolean = true
|
||||
|
||||
@Output()
|
||||
filterDocuments = new EventEmitter<Tag[]>()
|
||||
|
||||
@@ -148,7 +151,9 @@ export class TagsComponent implements OnInit, ControlValueAccessor {
|
||||
oldValue.splice(index, 1)
|
||||
|
||||
// remove children
|
||||
oldValue = this.removeChildren(oldValue, tag)
|
||||
if (this.preserveHierarchy) {
|
||||
oldValue = this.removeChildren(oldValue, tag)
|
||||
}
|
||||
|
||||
this.value = [...oldValue]
|
||||
this.onChange(this.value)
|
||||
@@ -167,7 +172,7 @@ export class TagsComponent implements OnInit, ControlValueAccessor {
|
||||
}
|
||||
|
||||
public onAdd(tag: Tag) {
|
||||
if (tag?.parent) {
|
||||
if (this.preserveHierarchy && tag?.parent) {
|
||||
// add all parents recursively
|
||||
const parent = this.getTag(tag.parent)
|
||||
if (parent && !this.value.includes(parent.id)) {
|
||||
|
||||
Reference in new issue
Block a user