[ACS-4985] Removed disableUpdateOnSubmit flag from search widgets

This commit is contained in:
swapnil.verma
2023-07-27 11:14:48 +05:30
committed by Jatin_Chugh
parent 0b8a4d9f0f
commit 5574aef240
9 changed files with 15 additions and 54 deletions
@@ -48,7 +48,6 @@ export class SearchCheckListComponent implements SearchWidget, OnInit {
pageSize = 5; pageSize = 5;
isActive = false; isActive = false;
enableChangeUpdate = true; enableChangeUpdate = true;
disableUpdateOnSubmit: boolean;
displayValue$: Subject<string> = new Subject<string>(); displayValue$: Subject<string> = new Subject<string>();
constructor(private translationService: TranslationService) { constructor(private translationService: TranslationService) {
@@ -95,11 +94,9 @@ export class SearchCheckListComponent implements SearchWidget, OnInit {
this.clearOptions(); this.clearOptions();
if (this.id && this.context) { if (this.id && this.context) {
this.updateDisplayValue(); this.updateDisplayValue();
if (!this.disableUpdateOnSubmit) {
this.context.update(); this.context.update();
} }
} }
}
updateDisplayValue(): void { updateDisplayValue(): void {
const displayValue = this.options.items const displayValue = this.options.items
@@ -145,9 +142,7 @@ export class SearchCheckListComponent implements SearchWidget, OnInit {
if (this.id && this.context) { if (this.id && this.context) {
this.context.queryFragments[this.id] = query; this.context.queryFragments[this.id] = query;
this.updateDisplayValue(); this.updateDisplayValue();
if(!this.disableUpdateOnSubmit) {
this.context.update(); this.context.update();
} }
} }
} }
}
@@ -70,7 +70,6 @@ export class SearchDateRangeComponent implements SearchWidget, OnInit, OnDestroy
isActive = false; isActive = false;
startValue: any; startValue: any;
enableChangeUpdate: boolean; enableChangeUpdate: boolean;
disableUpdateOnSubmit: boolean;
displayValue$: Subject<string> = new Subject<string>(); displayValue$: Subject<string> = new Subject<string>();
private onDestroy$ = new Subject<boolean>(); private onDestroy$ = new Subject<boolean>();
@@ -152,11 +151,9 @@ export class SearchDateRangeComponent implements SearchWidget, OnInit, OnDestroy
this.context.queryFragments[this.id] = `${this.settings.field}:['${start}' TO '${end}']`; this.context.queryFragments[this.id] = `${this.settings.field}:['${start}' TO '${end}']`;
this.updateDisplayValue(); this.updateDisplayValue();
if(!this.disableUpdateOnSubmit) {
this.context.update(); this.context.update();
} }
} }
}
submitValues() { submitValues() {
this.apply(this.form.value, this.form.valid); this.apply(this.form.value, this.form.valid);
@@ -217,11 +214,9 @@ export class SearchDateRangeComponent implements SearchWidget, OnInit, OnDestroy
private updateQuery() { private updateQuery() {
if (this.id && this.context) { if (this.id && this.context) {
this.updateDisplayValue(); this.updateDisplayValue();
if (!this.disableUpdateOnSubmit) {
this.context.update(); this.context.update();
} }
} }
}
onChangedHandler(event: any, formControl: UntypedFormControl) { onChangedHandler(event: any, formControl: UntypedFormControl) {
@@ -65,7 +65,6 @@ export class SearchDatetimeRangeComponent implements SearchWidget, OnInit, OnDes
isActive = false; isActive = false;
startValue: any; startValue: any;
enableChangeUpdate: boolean; enableChangeUpdate: boolean;
disableUpdateOnSubmit: boolean;
displayValue$: Subject<string> = new Subject<string>(); displayValue$: Subject<string> = new Subject<string>();
private onDestroy$ = new Subject<boolean>(); private onDestroy$ = new Subject<boolean>();
@@ -139,11 +138,9 @@ export class SearchDatetimeRangeComponent implements SearchWidget, OnInit, OnDes
this.context.queryFragments[this.id] = `${this.settings.field}:['${start}' TO '${end}']`; this.context.queryFragments[this.id] = `${this.settings.field}:['${start}' TO '${end}']`;
this.updateDisplayValue(); this.updateDisplayValue();
if(!this.disableUpdateOnSubmit) {
this.context.update(); this.context.update();
} }
} }
}
submitValues() { submitValues() {
this.apply(this.form.value, this.form.valid); this.apply(this.form.value, this.form.valid);
@@ -205,11 +202,9 @@ export class SearchDatetimeRangeComponent implements SearchWidget, OnInit, OnDes
private updateQuery() { private updateQuery() {
if (this.id && this.context) { if (this.id && this.context) {
this.updateDisplayValue(); this.updateDisplayValue();
if (!this.disableUpdateOnSubmit) {
this.context.update(); this.context.update();
} }
} }
}
onChangedHandler(event: any, formControl: UntypedFormControl) { onChangedHandler(event: any, formControl: UntypedFormControl) {
@@ -41,7 +41,6 @@ export class SearchNumberRangeComponent implements SearchWidget, OnInit {
id: string; id: string;
settings?: SearchWidgetSettings; settings?: SearchWidgetSettings;
context?: SearchQueryBuilderService; context?: SearchQueryBuilderService;
disableUpdateOnSubmit: boolean;
field: string; field: string;
format = '[{FROM} TO {TO}]'; format = '[{FROM} TO {TO}]';
@@ -99,11 +98,9 @@ export class SearchNumberRangeComponent implements SearchWidget, OnInit {
const value = this.formatString(this.format, map); const value = this.formatString(this.format, map);
this.context.queryFragments[this.id] = `${this.field}:${value}`; this.context.queryFragments[this.id] = `${this.field}:${value}`;
if (!this.disableUpdateOnSubmit) {
this.context.update(); this.context.update();
} }
} }
}
private formatString(str: string, map: Map<string, string>): string { private formatString(str: string, map: Map<string, string>): string {
let result = str; let result = str;
@@ -161,10 +158,8 @@ export class SearchNumberRangeComponent implements SearchWidget, OnInit {
reset() { reset() {
this.clear(); this.clear();
if (!this.disableUpdateOnSubmit) {
if (this.id && this.context) { if (this.id && this.context) {
this.context.update(); this.context.update();
} }
} }
} }
}
@@ -50,7 +50,6 @@ export class SearchRadioComponent implements SearchWidget, OnInit {
isActive = false; isActive = false;
startValue: any; startValue: any;
enableChangeUpdate: boolean; enableChangeUpdate: boolean;
disableUpdateOnSubmit: boolean;
displayValue$: Subject<string> = new Subject<string>(); displayValue$: Subject<string> = new Subject<string>();
constructor() { constructor() {
@@ -98,10 +97,8 @@ export class SearchRadioComponent implements SearchWidget, OnInit {
submitValues() { submitValues() {
this.setValue(this.value); this.setValue(this.value);
this.updateDisplayValue(); this.updateDisplayValue();
if(!this.disableUpdateOnSubmit) {
this.context.update(); this.context.update();
} }
}
hasValidValue() { hasValidValue() {
const currentValue = this.getSelectedValue(); const currentValue = this.getSelectedValue();
@@ -147,9 +144,7 @@ export class SearchRadioComponent implements SearchWidget, OnInit {
if (initialValue !== null) { if (initialValue !== null) {
this.setValue(initialValue); this.setValue(initialValue);
this.updateDisplayValue(); this.updateDisplayValue();
if (!this.disableUpdateOnSubmit) {
this.context.update(); this.context.update();
} }
} }
} }
}
@@ -41,7 +41,6 @@ export class SearchSliderComponent implements SearchWidget, OnInit {
max: number; max: number;
thumbLabel = false; thumbLabel = false;
enableChangeUpdate: boolean; enableChangeUpdate: boolean;
disableUpdateOnSubmit: boolean;
displayValue$: Subject<string> = new Subject<string>(); displayValue$: Subject<string> = new Subject<string>();
/** The numeric value represented by the slider. */ /** The numeric value represented by the slider. */
@@ -91,10 +90,8 @@ export class SearchSliderComponent implements SearchWidget, OnInit {
} }
submitValues() { submitValues() {
if(!this.disableUpdateOnSubmit) {
this.updateQuery(this.value); this.updateQuery(this.value);
} }
}
hasValidValue() { hasValidValue() {
return !!this.value; return !!this.value;
@@ -117,10 +114,8 @@ export class SearchSliderComponent implements SearchWidget, OnInit {
} else { } else {
this.context.queryFragments[this.id] = `${this.settings.field}:[0 TO ${value}]`; this.context.queryFragments[this.id] = `${this.settings.field}:[0 TO ${value}]`;
} }
if (!this.disableUpdateOnSubmit) {
this.context.update(); this.context.update();
} }
} }
}
} }
@@ -40,7 +40,6 @@ export class SearchTextComponent implements SearchWidget, OnInit {
startValue: string; startValue: string;
isActive = false; isActive = false;
enableChangeUpdate = true; enableChangeUpdate = true;
disableUpdateOnSubmit: boolean;
displayValue$: Subject<string> = new Subject<string>(); displayValue$: Subject<string> = new Subject<string>();
ngOnInit() { ngOnInit() {
@@ -87,17 +86,13 @@ export class SearchTextComponent implements SearchWidget, OnInit {
this.displayValue$.next(value); this.displayValue$.next(value);
if (this.context && this.settings && this.settings.field) { if (this.context && this.settings && this.settings.field) {
this.context.queryFragments[this.id] = value ? `${this.settings.field}:'${this.getSearchPrefix()}${value}${this.getSearchSuffix()}'` : ''; this.context.queryFragments[this.id] = value ? `${this.settings.field}:'${this.getSearchPrefix()}${value}${this.getSearchSuffix()}'` : '';
if (!this.disableUpdateOnSubmit) {
this.context.update(); this.context.update();
} }
} }
}
submitValues() { submitValues() {
if(!this.disableUpdateOnSubmit) {
this.updateQuery(this.value); this.updateQuery(this.value);
} }
}
hasValidValue() { hasValidValue() {
return !!this.value; return !!this.value;
@@ -57,8 +57,6 @@ export class SearchWidgetContainerComponent implements OnInit, OnDestroy, OnChan
@Input() @Input()
value: any; value: any;
@Input()
disableUpdateOnSubmit = false;
componentRef: ComponentRef<any>; componentRef: ComponentRef<any>;
@@ -92,7 +90,6 @@ export class SearchWidgetContainerComponent implements OnInit, OnDestroy, OnChan
ref.instance.id = this.id; ref.instance.id = this.id;
ref.instance.settings = {...this.settings}; ref.instance.settings = {...this.settings};
ref.instance.context = this.queryBuilder; ref.instance.context = this.queryBuilder;
ref.instance.disableUpdateOnSubmit = this.disableUpdateOnSubmit;
if (this.value) { if (this.value) {
ref.instance.isActive = true; ref.instance.isActive = true;
ref.instance.startValue = this.value; ref.instance.startValue = this.value;
@@ -25,7 +25,6 @@ export interface SearchWidget {
settings?: SearchWidgetSettings; settings?: SearchWidgetSettings;
context?: SearchQueryBuilderService; context?: SearchQueryBuilderService;
isActive?: boolean; isActive?: boolean;
disableUpdateOnSubmit?: boolean;
startValue: any; startValue: any;
/* stream emit value on changes */ /* stream emit value on changes */
displayValue$: Subject<string>; displayValue$: Subject<string>;