Skip to content

Commit

Permalink
[ACS-4130] Resolved PR review comments - AutoCompleteOption is now bu…
Browse files Browse the repository at this point in the history
…ilt using a single common helper method
  • Loading branch information
swapnil-verma-gl committed Oct 9, 2023
1 parent 33f5f9b commit 27d70de
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}
}

&__autocomplete-loading-spinner {
&__auto-complete-loading-spinner {
display: flex;
flex-direction: row;
justify-content: center;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,7 @@ export class RuleSimpleConditionUiComponent implements OnInit, ControlValueAcces
.pipe(first())
.subscribe((category: CategoryEntry) => {
this.showLoadingSpinner = false;
const path = category.entry.path.split('/').splice(3).join('/');
const option: AutoCompleteOption = {
value: category.entry.id,
displayLabel: path ? `${path}/${category.entry.name}` : category.entry.name
};

const option = this.buildAutocompleteOptionFromCategory(category.entry.id, category.entry.path, category.entry.name);
this.autoCompleteOptions.push(option);
this.parameterControl.setValue(option.value);
});
Expand Down Expand Up @@ -225,14 +220,9 @@ export class RuleSimpleConditionUiComponent implements OnInit, ControlValueAcces
.pipe(first())
.subscribe((existingCategoriesResult) => {
this.showLoadingSpinner = false;
const options: AutoCompleteOption[] = existingCategoriesResult?.list?.entries?.map((rowEntry) => {
const path = rowEntry.entry.path.name.split('/').splice(3).join('/');
const option: AutoCompleteOption = {
value: rowEntry.entry.id,
displayLabel: path ? `${path}/${rowEntry.entry.name}` : rowEntry.entry.name
};
return option;
});
const options: AutoCompleteOption[] = existingCategoriesResult?.list?.entries?.map((rowEntry) =>
this.buildAutocompleteOptionFromCategory(rowEntry.entry.id, rowEntry.entry.path.name, rowEntry.entry.name)
);
if (options.length > 0) {
this.autoCompleteOptions = this.sortAutoCompleteOptions(options);
}
Expand All @@ -253,4 +243,12 @@ export class RuleSimpleConditionUiComponent implements OnInit, ControlValueAcces
this.parameterControl.setValue(this.autoCompleteOptions?.[0].value);
}
}

buildAutocompleteOptionFromCategory(categoryId: string, categoryPath: string, categoryName: string): AutoCompleteOption {
const path = categoryPath.split('/').splice(3).join('/');
return {
value: categoryId,
displayLabel: path ? `${path}/${categoryName}` : categoryName
};
}
}

0 comments on commit 27d70de

Please sign in to comment.