mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-3108] Search - facetQueries panel renders when not defined in configuration (#3417)
* show facetQueries based on configuration definition * tests * FacetQueries is defined
This commit is contained in:
committed by
Denys Vuika
parent
3f332997c6
commit
2f12f518ef
@@ -17,7 +17,7 @@
|
||||
</adf-search-widget-container>
|
||||
</mat-expansion-panel>
|
||||
|
||||
<mat-expansion-panel [expanded]="facetQueriesExpanded">
|
||||
<mat-expansion-panel *ngIf="isFacetQueriesDefined" [expanded]="facetQueriesExpanded">
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title>{{ facetQueriesLabel | translate }}</mat-panel-title>
|
||||
</mat-expansion-panel-header>
|
||||
|
@@ -162,6 +162,38 @@ describe('SearchSettingsComponent', () => {
|
||||
expect(queryBuilder.update).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should allow facetQueries when defined in configuration', () => {
|
||||
component.queryBuilder.config = {
|
||||
categories: [],
|
||||
facetQueries: {
|
||||
queries: [
|
||||
{ label: 'q1', query: 'query1' }
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
expect(component.isFacetQueriesDefined).toBe(true);
|
||||
});
|
||||
|
||||
it('should not allow facetQueries when not defined in configuration', () => {
|
||||
component.queryBuilder.config = {
|
||||
categories: []
|
||||
};
|
||||
|
||||
expect(component.isFacetQueriesDefined).toBe(false);
|
||||
});
|
||||
|
||||
it('should not allow facetQueries when queries are not defined in configuration', () => {
|
||||
component.queryBuilder.config = {
|
||||
categories: [],
|
||||
facetQueries: {
|
||||
queries: []
|
||||
}
|
||||
};
|
||||
|
||||
expect(component.isFacetQueriesDefined).toBe(false);
|
||||
});
|
||||
|
||||
it('should fetch facet queries from response payload', () => {
|
||||
component.responseFacetQueries = new ResponseFacetQueryList();
|
||||
const queries = [
|
||||
|
@@ -71,6 +71,10 @@ export class SearchFilterComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
get isFacetQueriesDefined() {
|
||||
return this.queryBuilder.hasFacetQueries;
|
||||
}
|
||||
|
||||
onCategoryExpanded(category: SearchCategory) {
|
||||
category.expanded = true;
|
||||
}
|
||||
|
@@ -159,6 +159,19 @@ export class SearchQueryBuilderService {
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if FacetQueries has been defined
|
||||
*/
|
||||
get hasFacetQueries(): boolean {
|
||||
if (this.config
|
||||
&& this.config.facetQueries
|
||||
&& this.config.facetQueries.queries
|
||||
&& this.config.facetQueries.queries.length > 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private get sort(): RequestSortDefinitionInner[] {
|
||||
return this.sorting.map(def => {
|
||||
return {
|
||||
@@ -217,14 +230,4 @@ export class SearchQueryBuilderService {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private get hasFacetQueries(): boolean {
|
||||
if (this.config
|
||||
&& this.config.facetQueries
|
||||
&& this.config.facetQueries.queries
|
||||
&& this.config.facetQueries.queries.length > 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user