Skip to content

Commit

Permalink
Disabling search textbox initially
Browse files Browse the repository at this point in the history
  • Loading branch information
polterguy committed Dec 14, 2023
1 parent b7ee339 commit a3104d8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,27 @@ export class SearchboxComponent implements OnInit {
@Input() buttonDisabled: boolean = false;
@Input() button2Disabled: boolean = false;
@Input() button3Disabled: boolean = false;
@Input() set disableSearchTextBox( condition : boolean ) {
this.disabledInitially = condition;
if (this.filterControl) {
if (condition) {
this.filterControl.disable();
} else {
this.filterControl.enable();
}
}
}

filterControl: FormControl;
checked: boolean = false;
disabledInitially: boolean = false;

ngOnInit() {

this.filterControl = new FormControl('');
if (this.disabledInitially) {
this.filterControl.disable();
}
this.filterControl.valueChanges
.pipe(debounceTime(400), distinctUntilChanged())
.subscribe(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ <h3 class="my-0 fw-bold">
<div class="col-12">
<app-searchbox
(filterList)="filterList($event)"
[disableSearchTextBox]="isLoading | async"
checkBoxText="System endpoints">
</app-searchbox>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class EndpointsComponent implements OnInit {
defaultListToShow: string = '';
searchKey: string = '';
itemToBeTried = new BehaviorSubject<any>({});
isLoading: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(true);
isLoading: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);

constructor(
private generalService: GeneralService,
Expand Down Expand Up @@ -64,6 +64,8 @@ export class EndpointsComponent implements OnInit {

private getEndpoints() {

this.isLoading.next(true);
this.generalService.showLoading();
this.endpointsService.endpoints().subscribe({

next: (endpoints: Endpoint[]) => {
Expand Down Expand Up @@ -105,11 +107,13 @@ export class EndpointsComponent implements OnInit {

this.isLoading.next(false);
}
this.generalService.hideLoading();
},

error: (error: any) => {

this.isLoading.next(false);
this.generalService.hideLoading();
this.generalService.showFeedback(error?.error?.message ?? error, 'errorMessage');
}
});
Expand Down

0 comments on commit a3104d8

Please sign in to comment.