UNPKG

fabric8-planner

Version:
56 lines (55 loc) 2.23 kB
import { UserService } from 'ngx-login-client'; import { BehaviorSubject, Observable } from 'rxjs'; import { AreaQuery } from '../models/area.model'; import { IterationQuery } from '../models/iteration.model'; import { LabelQuery } from '../models/label.model'; export declare class QuerySuggestionService { private areaQuery; private iterationQuery; private userService; private labelQuery; queryObservable: BehaviorSubject<string>; private valueToSuggest; private valueToSuggestObservable; constructor(areaQuery: AreaQuery, iterationQuery: IterationQuery, userService: UserService, labelQuery: LabelQuery); private fields; fetchUsersBySearchValue(): Observable<string[]>; /** * Takes the entire query written so far * split the query by keywords for the * ease of processing * @param query */ shouldSuggestField(query: string): { suggest: boolean; value: string; lastKey: string; }; /** * Takes a chunk of the query * extract the field and typed value * @param query */ suggestValue(query: string): { field: string; value: string; }; replaceSuggestion(query_before_cursor: string, query_after_cursor: string, suggestion: string): string; /** * This function takes the query and the suggested value to be replaced * the value is what is typed so far or before the cursor after the last key * for example, if the query before cursor is "area.name: area - 1 $AND iteration" * and after cursor is ".name: iteration - 1" * the value should be "iteration" and we'll have to remove that part from * query before cursor * For query after cursor section, we have to detect the first occurance of any key * and remove till that from initial of that part. * For our example the first key is ":" and we have to remove ".name" from that section * @param query_before_cursor * @param query_after_cursor * @param value * @param suggestion */ replaceSuggestedValue(query_before_cursor: string, query_after_cursor: string, value: string, suggestion: string): string; getSuggestions(): Observable<string[]>; }