mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-26 17:24:56 +00:00
[ACS-8666] Fixed issue where header filters were not getting reset when navigating between folders (#10150)
This commit is contained in:
parent
3458546c92
commit
eb954c0ecd
@ -204,4 +204,40 @@ describe('SearchCheckListComponent', () => {
|
||||
const checkedElements = await loader.getAllHarnesses(MatCheckboxHarness.with({ checked: true }));
|
||||
expect(checkedElements.length).toBe(0);
|
||||
});
|
||||
|
||||
it('should update query with startValue on init, if provided', () => {
|
||||
component.id = 'checkList';
|
||||
component.options = new SearchFilterList<SearchListOption>([
|
||||
{ name: 'Folder', value: `TYPE:'cm:folder'`, checked: false },
|
||||
{ name: 'Document', value: `TYPE:'cm:content'`, checked: false }
|
||||
]);
|
||||
component.startValue = `TYPE:'cm:folder'`;
|
||||
component.context = {
|
||||
queryFragments: {},
|
||||
update: jasmine.createSpy()
|
||||
} as any;
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(component.context.queryFragments[component.id]).toBe(`TYPE:'cm:folder'`);
|
||||
expect(component.context.update).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should set query context as blank and not call query update, if no start value was provided', () => {
|
||||
component.id = 'checkList';
|
||||
component.options = new SearchFilterList<SearchListOption>([
|
||||
{ name: 'Folder', value: `TYPE:'cm:folder'`, checked: true },
|
||||
{ name: 'Document', value: `TYPE:'cm:content'`, checked: false }
|
||||
]);
|
||||
component.startValue = undefined;
|
||||
component.context = {
|
||||
queryFragments: {
|
||||
checkList: `TYPE:'cm:folder'`
|
||||
},
|
||||
update: jasmine.createSpy()
|
||||
} as any;
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(component.context.queryFragments[component.id]).toBe('');
|
||||
expect(component.context.update).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
@ -49,7 +49,7 @@ export class SearchCheckListComponent implements SearchWidget, OnInit {
|
||||
context?: SearchQueryBuilderService;
|
||||
options: SearchFilterList<SearchListOption>;
|
||||
operator: string = 'OR';
|
||||
startValue: SearchListOption = null;
|
||||
startValue: string;
|
||||
pageSize = 5;
|
||||
isActive = false;
|
||||
enableChangeUpdate = true;
|
||||
@ -72,6 +72,10 @@ export class SearchCheckListComponent implements SearchWidget, OnInit {
|
||||
|
||||
if (this.startValue) {
|
||||
this.setValue(this.startValue);
|
||||
} else {
|
||||
if (this.id && this.context) {
|
||||
this.context.queryFragments[this.id] = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,4 +119,25 @@ describe('SearchTextComponent', () => {
|
||||
expect(component.value).toBe('');
|
||||
expect(component.context.queryFragments[component.id]).toBe('');
|
||||
});
|
||||
|
||||
it('should update query with startValue on init, if provided', () => {
|
||||
spyOn(component.context, 'update');
|
||||
component.startValue = 'mock-start-value';
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(component.context.queryFragments[component.id]).toBe(`cm:name:'mock-start-value'`);
|
||||
expect(component.value).toBe('mock-start-value');
|
||||
expect(component.context.update).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should parse value and set query context as blank, and not call query update, if no start value was provided', () => {
|
||||
component.context.queryFragments[component.id] = `cm:name:'secret.pdf'`;
|
||||
spyOn(component.context, 'update');
|
||||
component.startValue = undefined;
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(component.context.queryFragments[component.id]).toBe('');
|
||||
expect(component.value).toBe('secret.pdf');
|
||||
expect(component.context.update).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
@ -64,6 +64,10 @@ export class SearchTextComponent implements SearchWidget, OnInit {
|
||||
|
||||
if (this.startValue) {
|
||||
this.setValue(this.startValue);
|
||||
} else {
|
||||
if (this.context?.queryFragments) {
|
||||
this.context.queryFragments[this.id] = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user