[ACS-4985] Using widget-composite component now correctly updates the search query on submit. Added optional property to disable update on submit button click for widget-composite.

This commit is contained in:
swapnil.verma
2023-07-27 11:14:48 +05:30
committed by Jatin_Chugh
parent f8455a57cc
commit df1801dd44
4 changed files with 27 additions and 7 deletions
@@ -57,6 +57,7 @@ export class SearchDateRangeAdvancedComponent implements SearchWidget, OnInit, O
settings?: SearchWidgetSettings;
context?: SearchQueryBuilderService;
startValue: SearchDateRangeAdvanced;
disableUpdateOnSubmit: boolean;
maxDate: any;
dateRangeTypeValue: DateRangeType = DateRangeType.ANY;
inLastValue: string;
@@ -69,7 +70,6 @@ export class SearchDateRangeAdvancedComponent implements SearchWidget, OnInit, O
private enableChangeUpdate: boolean;
private datePickerFormat: string;
private disableUpdateOnSubmit = false;
private onDestroy$ = new Subject<void>();
@@ -234,5 +234,5 @@ export class SearchDateRangeAdvancedComponent implements SearchWidget, OnInit, O
}
}
}
//TODO: Format dates for Between date range type
@@ -57,6 +57,9 @@ export class SearchWidgetContainerComponent implements OnInit, OnDestroy, OnChan
@Input()
value: any;
@Input()
disableUpdateOnSubmit = false;
componentRef: ComponentRef<any>;
constructor(
@@ -89,6 +92,7 @@ export class SearchWidgetContainerComponent implements OnInit, OnDestroy, OnChan
ref.instance.id = this.id;
ref.instance.settings = {...this.settings};
ref.instance.context = this.queryBuilder;
ref.instance.disableUpdateOnSubmit = this.disableUpdateOnSubmit;
if (this.value) {
ref.instance.isActive = true;
ref.instance.startValue = this.value;
@@ -25,6 +25,7 @@ export interface SearchWidget {
settings?: SearchWidgetSettings;
context?: SearchQueryBuilderService;
isActive?: boolean;
disableUpdateOnSubmit?: boolean;
startValue: any;
/* stream emit value on changes */
displayValue$: Subject<string>;
@@ -487,12 +487,27 @@ export abstract class BaseQueryBuilderService {
let query = '';
this.categories.forEach((facet) => {
const customQuery = this.queryFragments[facet.id];
if (customQuery) {
if (query.length > 0) {
query += ' AND ';
let customQuery: string;
if (facet.component.selector === 'widget-composite') {
const widgetTabs: any[] = facet.component.settings.tabs;
widgetTabs.forEach(tab => {
customQuery = this.queryFragments[tab.id];
if (customQuery) {
if (query.length > 0) {
query += ' AND ';
}
query += `(${customQuery})`;
}
});
} else {
customQuery = this.queryFragments[facet.id];
if (customQuery) {
if (query.length > 0) {
query += ' AND ';
}
query += `(${customQuery})`;
}
query += `(${customQuery})`;
}
});