Skip to content

Commit

Permalink
CB-3753 adds base hints
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeyteleshev committed Dec 26, 2024
1 parent 47fe4b3 commit 4a6736d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,12 @@ export const useInputAutocomplete = (
return '';
}

return substring.split(' ').at(-1);
return (
substring
.split(' ')
.at(-1)
?.replace(/[^\w\s]|_/g, '') ?? ''
);
},
get filteredSuggestions() {
if (!this.currentWord) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,39 @@ interface IState {
apply: () => Promise<void>;
}

const BASE_HINTS: InputAutocompleteProposal[] = [
{
displayString: 'AND',
replacementString: 'AND',
score: 0,
},
{
displayString: 'OR',
replacementString: 'OR',
score: 0,
},
{
displayString: 'ILIKE',
replacementString: 'ILIKE',
score: 0,
},
{
displayString: 'LIKE',
replacementString: 'LIKE',
score: 0,
},
{
displayString: 'IN',
replacementString: 'IN',
score: 0,
},
{
displayString: 'BETWEEN',
replacementString: 'BETWEEN',
score: 0,
},
];

export function useWhereFilter(model: IDatabaseDataModel, resultIndex: number): Readonly<IState> {
return useObservableRef(
() => ({
Expand Down Expand Up @@ -65,12 +98,15 @@ export function useWhereFilter(model: IDatabaseDataModel, resultIndex: number):
return view?.columns ?? [];
},
get hintProposals() {
return this.columns.map(column => ({
title: column.label || '',
displayString: column.label || '',
replacementString: column.label || '',
icon: column.icon || '',
}));
return [...BASE_HINTS].concat(
this.columns.map(column => ({
title: column.label || '',
displayString: column.label || '',
replacementString: column.label || '',
icon: column.icon || '',
score: 1,
})),
);
},
get constraints() {
const model = this.model as any;
Expand Down

0 comments on commit 4a6736d

Please sign in to comment.