import * as i0 from '@angular/core'; import { InjectionToken, OnChanges, SimpleChanges, OnDestroy, ModuleWithProviders } from '@angular/core'; import { Router, ActivatedRoute } from '@angular/router'; import { Subject, Observable } from 'rxjs'; import { SearchService } from '@sinequa/components/search'; import { Query, AppService, FormatService } from '@sinequa/core/app-utils'; import { Results, CCColumn } from '@sinequa/core/web-services'; import * as i9 from '@sinequa/components/selection'; import { SelectionService } from '@sinequa/components/selection'; import * as i8 from '@sinequa/components/action'; import { Action } from '@sinequa/components/action'; import * as i3 from '@angular/common'; import * as i4 from '@sinequa/core/load-component'; import * as i5 from '@sinequa/core/intl'; import * as i6 from '@sinequa/core/validation'; import * as i7 from '@sinequa/components/utils'; /** * Configuration of a Results View */ interface ResultsView { /** Name of the results view */ name: string; /** Type of the results view (not used internally, but may be useful if multiple views share a common component) */ type: string; /** How the results view should be displayed (default to the name) */ display?: string; /** Icon class for the results view */ icon?: string; /** List of tab for which this tab can be displayed (defaults to all if undefined) */ includedTabs?: string[]; /** List of tab for which this tab is excluded (defaults to none if undefined) */ excludedTabs?: string[]; /** * Method called when selecting this results view. It can be used to modify the search query * when a view has specific data to display. If the method returns true, then selecting this view * triggers a search and the view selection becomes effective upon results. If the method results false, * (or if the method is undefined), then selecting this view does not trigger a new search * and the view selection is immediate. */ beforeSearch?: (query: Query, previousView: ResultsView) => boolean; } interface ResultsViewEvent { type: "before-select" | "after-select" | "select-cancelled"; } interface ResultsViewBeforeSelectEvent extends ResultsViewEvent { type: "before-select"; view: ResultsView; promises: Promise[]; } interface ResultsViewAfterSelectEvent extends ResultsViewEvent { type: "after-select"; view: ResultsView; } interface ResultsViewSelectCancelledEvent extends ResultsViewEvent { type: "select-cancelled"; view: ResultsView; } type ResultsViewEvents = ResultsViewBeforeSelectEvent | ResultsViewAfterSelectEvent | ResultsViewSelectCancelledEvent; declare const RESULTS_VIEWS: InjectionToken; declare const DEFAULT_VIEW: InjectionToken; declare class ResultsViewService { defaultView: ResultsView; protected router: Router; protected route: ActivatedRoute; protected searchService: SearchService; protected _resultsView: ResultsView; protected readonly _resultsViews: ResultsView[]; protected _resultsViewSelected: Subject; protected _events: Subject; protected pendingView: ResultsView | undefined; /** * Constructor: Expects the configuration for a list of views and * one default view. These views can be set when importing the module in the AppModule * with the ResultsViewModule.forRoot() method. */ constructor(defaultView: ResultsView, resultsViews: ResultsView[], router: Router, route: ActivatedRoute, searchService: SearchService); get resultsViewSelected(): Observable; get events(): Observable; get resultsView(): ResultsView; get views(): ResultsView[]; /** * Navigate to a new URL including the given results view's name * @param view */ protected navigate(view: ResultsView): void; /** * Responds to a change in the URL: Sets the results view if the URL * specifies a different results view name. */ protected handleNavigation(): void; /** * Sets the results view and emits an event * @param view */ protected setResultsView(view: ResultsView): void; /** * Selects the given results view. This method is asynchronous: * - The selected results view might modify the query before being displayed * - The view selection works with a navigation via the router (adding the view name to the URL) * @param view */ selectResultsView(view: ResultsView): void; /** * Selects the results view with the given name. This method is asynchronous: * - The selected results view might modify the query before being displayed * - The view selection works with a navigation via the router (adding the view name to the URL) * @param viewName */ selectResultsViewName(viewName: string): void; /** * Returns the results view with the given name * @param viewName */ getView(viewName: any): ResultsView | undefined; /** * Returns the list of results views compatible with a given tab * @param tab */ getIncludedViews(tab?: string): ResultsView[]; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } interface GridView extends ResultsView { columns: Column[]; } interface Column { active: boolean; title: string; field: string; sortable: boolean; renderAsHtml: boolean; } interface ColumnData { config: Column; column: CCColumn | undefined; sortIndex?: number; ascending?: boolean; sortIcon?: string; sortIndicator?: string; } declare class BsResultsGridView implements OnChanges { appService: AppService; searchService: SearchService; formatService: FormatService; private selectionService; results: Results; view: GridView; private orderBy; columnsData: ColumnData[] | undefined; constructor(appService: AppService, searchService: SearchService, formatService: FormatService, selectionService: SelectionService); observeQueryFields(): void; ngOnChanges(changes: SimpleChanges): void; toggleSelectedRecords(): void; get haveSelectedRecords(): boolean; getSortIndicator(columnData: ColumnData): string | undefined; ascendingFirst(column: Column): boolean; get maxSortIndex(): number; _setSort(columnData: ColumnData, ascending: boolean): void; _clearSort(columnData: ColumnData): void; clearSorts(): void; isSortable(columnData: ColumnData): boolean; initSorts(): void; setSort(columnData: ColumnData): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } declare class BsResultsViewSelector implements OnChanges, OnDestroy { resultsViewService: ResultsViewService; query: Query; results: Results; rightAligned: boolean; useDropdownMenu: boolean; size: string; private viewAction; items: Action[]; constructor(resultsViewService: ResultsViewService); private _subscription; ngOnDestroy(): void; private setCurrentViewAction; private buildViewAction; ngOnChanges(changes: SimpleChanges): void; selectView(view: ResultsView): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } declare class BsResultsViewModule { static forRoot(resultsViews: ResultsView[], defaultView: ResultsView): ModuleWithProviders; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵmod: i0.ɵɵNgModuleDeclaration; static ɵinj: i0.ɵɵInjectorDeclaration; } declare const enResultsView: any; declare const frResultsView: any; declare const deResultsView: any; export { BsResultsGridView, BsResultsViewModule, BsResultsViewSelector, DEFAULT_VIEW, RESULTS_VIEWS, ResultsViewService, deResultsView, enResultsView, frResultsView }; export type { Column, ColumnData, GridView, ResultsView, ResultsViewAfterSelectEvent, ResultsViewBeforeSelectEvent, ResultsViewEvent, ResultsViewEvents, ResultsViewSelectCancelledEvent };