Skip to content

Commit

Permalink
added copy/paste methods
Browse files Browse the repository at this point in the history
  • Loading branch information
brianlagunas committed Dec 12, 2024
1 parent da85cc2 commit 584289d
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,12 @@ export class RevealViewComponent {
public getRVDashboard(): any {
return this.revealView.nativeElement.getRVDashboard();
}

public copy(input: string | number): void {
this.revealView.nativeElement.copy(input);
}

public paste(target?: RvRevealView): void {
this.revealView.nativeElement.paste(target);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -362,14 +362,6 @@ export class RvRevealView extends LitElement {
}
}

/**
* Adds a visualization to the dashboard.
* @returns {void}
*/
addVisualization(): void {
this._revealView._dashboardView._delegate.addWidgetTriggered();
}

/**
* Adds a textbox visualization to the dashboard.
* @returns {void}
Expand All @@ -382,11 +374,26 @@ export class RvRevealView extends LitElement {
}

/**
* Gets the RVDashboard instance from the underlying RevealView object.
* @returns {RVDashboard} The RVDashboard instance.
* Adds a visualization to the dashboard.
* @returns {void}
*/
getRVDashboard(): any {
return this._revealView ? this._revealView.dashboard : null;
addVisualization(): void {
this._revealView._dashboardView._delegate.addWidgetTriggered();
}

/**
* Copies a visualization to the clipboard.
* If a string ID is provided, the visualization with that ID is copied.
* If a number index is provided, the visualization at that index is copied.
* @param {string | number} input The ID or index of the visualization to copy
* @returns {void}
*/
copy(input: string | number): void {
const widgets = this._revealView._dashboardView.__widgets;
const sourceWidget = typeof input === "string" ? widgets.find((widget: any) => widget._widget._id === input) : widgets[input];
if (sourceWidget) {
this._revealView._dashboardView.widgetCopied(sourceWidget._widget);
}
}

/**
Expand Down Expand Up @@ -445,6 +452,24 @@ export class RvRevealView extends LitElement {
this._revealView._dashboardView.exportToFormat("pptx");
}

/**
* Gets the RVDashboard instance from the underlying RevealView object.
* @returns {RVDashboard} The RVDashboard instance.
*/
getRVDashboard(): any {
return this._revealView ? this._revealView.dashboard : null;
}

/**
* Pastes a visualization from the clipboard.
* If a target RevealView component is provided, the visualization is pasted to that component.
* @param {RvRevealView} target The target RevealView component to paste the visualization to.
* @returns {void}
*/
paste(target?: RvRevealView): void {
target?.paste() ?? this._revealView._dashboardView.pasteWidget();
}

/**
* Refreshes the data in the dashboard.
* If no parameter is provided, the entire dashboard is refreshed.
Expand Down

0 comments on commit 584289d

Please sign in to comment.