mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-11-04 03:27:12 -05:00 
			
		
		
		
	Fix: show children in tag list when filtering (#10899)
This commit is contained in:
		
							parent
							
								
									6b868a5ecb
								
							
						
					
					
						commit
						19ff339804
					
				@ -71,4 +71,20 @@ describe('TagListComponent', () => {
 | 
				
			|||||||
      'Do you really want to delete the tag "Tag1"?'
 | 
					      'Do you really want to delete the tag "Tag1"?'
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
  })
 | 
					  })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  it('should filter out child tags if name filter is empty, otherwise show all', () => {
 | 
				
			||||||
 | 
					    const tags = [
 | 
				
			||||||
 | 
					      { id: 1, name: 'Tag1', parent: null },
 | 
				
			||||||
 | 
					      { id: 2, name: 'Tag2', parent: 1 },
 | 
				
			||||||
 | 
					      { id: 3, name: 'Tag3', parent: null },
 | 
				
			||||||
 | 
					    ]
 | 
				
			||||||
 | 
					    component['_nameFilter'] = null // Simulate empty name filter
 | 
				
			||||||
 | 
					    const filtered = component.filterData(tags as any)
 | 
				
			||||||
 | 
					    expect(filtered.length).toBe(2)
 | 
				
			||||||
 | 
					    expect(filtered.find((t) => t.id === 2)).toBeUndefined()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    component['_nameFilter'] = 'Tag2' // Simulate non-empty name filter
 | 
				
			||||||
 | 
					    const filteredWithName = component.filterData(tags as any)
 | 
				
			||||||
 | 
					    expect(filteredWithName.length).toBe(3)
 | 
				
			||||||
 | 
					  })
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
				
			|||||||
@ -62,6 +62,8 @@ export class TagListComponent extends ManagementListComponent<Tag> {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  filterData(data: Tag[]) {
 | 
					  filterData(data: Tag[]) {
 | 
				
			||||||
    return data.filter((tag) => !tag.parent)
 | 
					    return this.nameFilter?.length
 | 
				
			||||||
 | 
					      ? [...data]
 | 
				
			||||||
 | 
					      : data.filter((tag) => !tag.parent)
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user