1 import {Injectable, EventEmitter, TemplateRef} from '@angular/core';
2 import {Observable, empty, throwError} from 'rxjs';
3 import {tap} from 'rxjs/operators';
4 import {StoreService} from '@eg/core/store.service';
5 import {LocaleService} from '@eg/core/locale.service';
6 import {AuthService} from '@eg/core/auth.service';
7 import {NetService} from '@eg/core/net.service';
8 import {GridContext, GridColumnSort} from './grid';
9 import {Pager} from '@eg/share/util/pager';
11 interface FlatQueryFields {
12 [name: string]: string;
17 export class GridFlatDataService {
20 private net: NetService,
21 private auth: AuthService
25 getRows(gridContext: GridContext,
26 query: any, pager: Pager, sort: GridColumnSort[]): Observable<any> {
28 if (!gridContext.idlClass) {
29 return throwError('GridFlatDataService requires an idlClass');
32 const fields = this.compileFields(gridContext);
33 const flatSort = sort.map(s => {
39 return this.net.request(
41 'open-ils.fielder.flattened_search',
42 this.auth.token(), gridContext.idlClass,
51 compileFields(gridContext: GridContext): FlatQueryFields {
52 const fields: FlatQueryFields = {};
54 gridContext.columnSet.requiredColumns().forEach(col => {
55 // Verify the column describes a proper IDL field
56 const path = col.path || col.name;
57 const info = gridContext.columnSet.idlInfoFromDotpath(path);
58 if (info) { fields[col.name] = path; }