Skip to content

Commit

Permalink
[ACS-4130] Added safety checks and minor code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
swapnil-verma-gl committed Oct 5, 2023
1 parent 6e937e5 commit 2045232
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,9 @@ const AUTOCOMPLETE_OPTIONS_DEBOUNCE_TIME = 500;
MatFormFieldModule,
MatSelectModule,
MatInputModule,
TranslateModule,
MatAutocompleteModule,
AsyncPipe,
MatOptionModule,
MatProgressSpinnerModule,
MatProgressSpinnerModule
],
selector: 'aca-rule-simple-condition',
Expand Down Expand Up @@ -208,8 +206,7 @@ export class RuleSimpleConditionUiComponent implements OnInit, ControlValueAcces
if (field === 'category') {
this.autoCompleteOptionsSubscription = this.form
.get('parameter')
.valueChanges.pipe(distinctUntilChanged(), debounceTime(AUTOCOMPLETE_OPTIONS_DEBOUNCE_TIME))
.pipe(takeUntil(this.onDestroy$))
.valueChanges.pipe(distinctUntilChanged(), debounceTime(AUTOCOMPLETE_OPTIONS_DEBOUNCE_TIME), takeUntil(this.onDestroy$))
.subscribe((categoryName) => {
this.getCategories(categoryName);
});
Expand All @@ -227,7 +224,7 @@ export class RuleSimpleConditionUiComponent implements OnInit, ControlValueAcces
.pipe(first())
.subscribe((existingCategoriesResult) => {
this.showLoadingSpinner = false;
const options: AutoCompleteOption[] = existingCategoriesResult.list.entries.map((rowEntry) => {
const options: AutoCompleteOption[] = existingCategoriesResult?.list?.entries?.map((rowEntry) => {
const option = new AutoCompleteOption();
option.value = rowEntry.entry.id;
const path = rowEntry.entry.path.name.split('/').splice(3).join('/');
Expand All @@ -240,8 +237,8 @@ export class RuleSimpleConditionUiComponent implements OnInit, ControlValueAcces
});
}

private sortAutoCompleteOptions(typeAheadOptions: AutoCompleteOption[]): AutoCompleteOption[] {
return typeAheadOptions.sort((option1, option2) => option1.displayLabel.localeCompare(option2.displayLabel));
private sortAutoCompleteOptions(autoCompleteOptions: AutoCompleteOption[]): AutoCompleteOption[] {
return autoCompleteOptions.sort((option1, option2) => option1.displayLabel.localeCompare(option2.displayLabel));
}

autoCompleteDisplayFunction: (id: string) => string = (optionValue) =>
Expand Down

0 comments on commit 2045232

Please sign in to comment.