3
0

Add ability to configure columns in metric and chart blocks

This commit is contained in:
Emmy Leke
2024-01-17 14:04:47 +01:00
committed by Jože Fortun
parent 9263f690b4
commit c30d07797d
9 changed files with 164 additions and 47 deletions

View File

@@ -1,11 +1,14 @@
import { PageBlock, PageBlockInput, Registry } from './base'
import { Apply, CortezaID, NoID } from '../../../cast'
import { Apply,NoID } from '../../../cast'
import { Options as PageBlockRecordListOptions } from './record-list'
import { cloneDeep, merge } from 'lodash'
const kind = 'Chart'
interface DrillDown {
enabled: boolean;
blockID?: string;
blockID: string;
recordListOptions: Partial<PageBlockRecordListOptions>;
}
interface Options {
@@ -24,7 +27,10 @@ const defaults: Readonly<Options> = Object.freeze({
drillDown: {
enabled: false,
blockID: '',
},
recordListOptions: {
fields: [],
},
}
})
export class PageBlockChart extends PageBlock {
@@ -47,9 +53,13 @@ export class PageBlockChart extends PageBlock {
Apply(this.options, o, Boolean, 'showRefresh')
if (o.drillDown) {
this.options.drillDown = o.drillDown
this.options.drillDown = merge({}, defaults.drillDown, o.drillDown)
}
}
resetDrillDown(): void {
this.options.drillDown = cloneDeep(defaults.drillDown)
}
}
Registry.set(kind, PageBlockChart)

View File

@@ -1,14 +1,15 @@
import { PageBlock, PageBlockInput, Registry } from './base'
import { merge } from 'lodash'
import { Apply } from '../../../cast'
import { Options as PageBlockRecordListOptions } from './record-list'
const kind = 'Metric'
type Reporter = (p: ReporterParams) => Promise<any>
interface DrillDown {
enabled: boolean;
blockID?: string;
blockID: string;
recordListOptions: Partial<PageBlockRecordListOptions>;
}
interface ReporterParams {
@@ -62,9 +63,13 @@ const defaultMetric: Readonly<Metric> = Object.freeze({
color: '#000000',
fontSize: undefined,
},
drillDown: {
enabled: false,
blockID: '',
recordListOptions: {
fields: [],
},
},
})

View File

@@ -12,7 +12,7 @@ interface FilterPreset {
roles: string[];
}
interface Options {
export interface Options {
moduleID: string;
prefilter: string;
presort: string;