src/app/core/export/data-transformation-service/export-column-config.ts
Basic definition of a field / column to be included in an export through the ExportService.
Properties |
|
| groupBy |
groupBy:
|
Type : { label: TranslatableText; property: string }
|
|
Properties :
|
| Optional |
|
Group the results of the query based on unique values at |
| label |
label:
|
Type : TranslatableText
|
| Optional |
|
label shown in the header row. If not specified, query is used. May be configured per language, so resolve it before using it as a column key. |
| query |
query:
|
Type : string
|
|
The query to access the value for this column from the object to be exported |
| subQueries |
subQueries:
|
Type : ExportColumnConfig[]
|
| Optional |
|
One or more sub queries to expand one column into multiple columns and/or rows. The queries in the subQueries are executed based on the result(s) from the parent query where: each object in the parent query result will lead to its own row in the final export (extending one object into multiple export rows); each query in the subQueries will lead to one (or recursively more) columns in the export rows. e.g. |
import { TranslatableText } from "../../config/multi-lingual-config";
/**
* Basic definition of a field / column to be included in an export through the ExportService.
*/
export interface ExportColumnConfig {
/**
* label shown in the header row.
*
* If not specified, query is used.
* May be configured per language, so resolve it before using it as a column key.
*/
label?: TranslatableText;
/** The query to access the value for this column from the object to be exported */
query: string;
/**
* One or more sub queries to expand one column into multiple columns and/or rows.
*
* The queries in the subQueries are executed based on the result(s) from the parent query where:
* each object in the parent query result will lead to its own row in the final export (extending one object into multiple export rows);
* each query in the subQueries will lead to one (or recursively more) columns in the export rows.
*
* e.g. `{ query: ".participants:toEntities(Child), subQueries: [ {query: "name"}, {query: "phone"} ] }`
* => parent query (not output in export): [{..child1}, {..child2}]
* => overall result: two export rows: [{ name: "child1", phone: "123"}, {name: "child2", phone: "567"}]
*/
subQueries?: ExportColumnConfig[];
/**
* Group the results of the query based on unique values at `property`.
* This will also add another column to the list with the title `label` and the distinct values in the rows.
*/
groupBy?: { label: TranslatableText; property: string };
}
/**
* Normalize a query key used in export column configs.
* Strips a leading dot if present so callers can compare logical field keys.
*/
export function normalizeQueryKey(query: string): string {
return query.startsWith(".") ? query.slice(1) : query;
}