mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
38 lines
982 B
TypeScript
38 lines
982 B
TypeScript
import { CanvasGroupOptions, CanvasElementOptions } from 'app/features/canvas';
|
|
import { GroupState } from './group';
|
|
|
|
export class RootElement extends GroupState {
|
|
constructor(public options: CanvasGroupOptions, private changeCallback: () => void) {
|
|
super(options);
|
|
}
|
|
|
|
isRoot() {
|
|
return true;
|
|
}
|
|
|
|
// The parent size is always fullsize
|
|
updateSize(width: number, height: number) {
|
|
super.updateSize(width, height);
|
|
this.width = width;
|
|
this.height = height;
|
|
this.sizeStyle.width = width;
|
|
this.sizeStyle.height = height;
|
|
}
|
|
|
|
// root type can not change
|
|
onChange(options: CanvasElementOptions) {
|
|
this.revId++;
|
|
this.options = { ...options } as CanvasGroupOptions;
|
|
this.changeCallback();
|
|
}
|
|
|
|
getSaveModel() {
|
|
const { placement, anchor, ...rest } = this.options;
|
|
|
|
return {
|
|
...rest, // everything except placement & anchor
|
|
elements: this.elements.map((v) => v.getSaveModel()),
|
|
} as CanvasGroupOptions;
|
|
}
|
|
}
|