@crnk/angular-ngrx
Version:
Angular helper library for ngrx-json-api and crnk:
97 lines (96 loc) • 3.65 kB
TypeScript
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/zip';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/debounceTime';
import 'rxjs/add/operator/distinct';
import 'rxjs/add/operator/switch';
import { ManyQueryResult, NgrxJsonApiService, Query, NgrxJsonApiZoneService, QueryParams } from 'ngrx-json-api';
import { CrnkBindingUtils } from './crnk.binding.utils';
import { LazyLoadEvent } from 'primeng/primeng';
import { Store } from '@ngrx/store';
export interface DataTableImplementationContext {
/**
* applies the given query parameters
*
* @param {QueryParams} param
*/
applyQueryParams(param: QueryParams): any;
}
export interface DataTableImplementationAdapter {
/**
* Called on startup and provides access to interface with binding implementation.
*
* @param {DataTableImplementationContext} context
*/
init(context: DataTableImplementationContext): any;
/**
* @param event called by table implementation to update the query
*/
onLazyLoad(event: any): any;
}
export interface DataTableBindingConfig {
/**
* Query to use from the store to specify sort, filter, page parameters and get results.
*/
queryId: string;
/**
* Query to use as base query. Table filter will be applied on top of this query.
* If not specified, the query from the store will be taken based on the specified
* queryId.
*/
baseQuery?: Query;
fromServer?: boolean;
/**
* Zone to use within ngrx-json-api.
*/
zoneId?: string;
/**
* Table implementation to use, currently the PrimeNG DataTable is supported out-of-the-box.
*/
implementationAdapter?: DataTableImplementationAdapter;
/**
* Additional query parameters (sorting, filtering, etc.) that will be applied to the query.
* As long as the observable emits no value, it is ignored. No waiting takes place.
*/
customQueryParams?: Observable<QueryParams>;
}
export declare class DataTableBinding {
private config;
private utils;
private store;
result$: Observable<ManyQueryResult>;
private baseQuery;
private latestQuery;
private latestImplementationQueryParams;
private latestExternalQueryParams;
implementationAdapter: DataTableImplementationAdapter;
private customQueryParamsSubscription;
private zoneId;
readonly zone: NgrxJsonApiZoneService;
constructor(ngrxJsonApiService: NgrxJsonApiService, config: DataTableBindingConfig, utils: CrnkBindingUtils, store: Store<any>);
private checkSubscriptions();
private cancelSubscriptions();
private initBaseQuery();
private setBaseQueryIfNecessary(result);
private guardAgainstEmptyQuery(result);
refresh(): void;
private setImplementationQueryParams(implementationParams);
private updateQueryParams();
onLazyLoad(event: any): void;
}
/**
* Maps an filter input value to a JSON API filter value.
*/
export interface DataFilterValueMapper {
mapFilterValue(attributePath: string, operator: string, value: any): any;
}
export declare class DefaultDataFilterValueMapper implements DataFilterValueMapper {
mapFilterValue(attributePath: string, operator: string, value: any): any;
}
export declare class DataTablePrimengAdapter implements DataTableImplementationAdapter {
private context;
defaultMatchMode: string;
filterValueMapper: DataFilterValueMapper;
init(context: DataTableImplementationContext): void;
onLazyLoad(event: LazyLoadEvent): void;
}