Skip to content

Commit

Permalink
Merge branch 'feature/add-event-util-function' into feature/piechart-…
Browse files Browse the repository at this point in the history
…event
  • Loading branch information
maruk0chan committed Feb 16, 2024
2 parents f378750 + 50a1d6d commit 9009b3d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/utils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function emitSelectedEvent({
idPath,
}): void;

export function changeSelectedStyle({
export function updateSelectedElementClassName({
drawing,
selectedIds,
targetElementSelector,
Expand Down
26 changes: 25 additions & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,18 @@ export function checkIfHexColor(text) {
return regex.test(text);
}

/**
* Example usage: emitSelectedEvent.apply(null, [this, d.data["__togostanza_id__"]]);
* @date 16/02/2024
*
* @export
* @param {{ drawing: any; targetId: any; targetElementSelector: any; selectedElementSelector: any; idPath: any; }} param0
* @param {*} param0.drawing
* @param {*} param0.targetId
* @param {*} param0.targetElementSelector
* @param {*} param0.selectedElementSelector
* @param {*} param0.idPath
*/
export function emitSelectedEvent({
drawing,
targetId,
Expand All @@ -171,7 +183,19 @@ export function emitSelectedEvent({
);
}

export function changeSelectedStyle({
/**
* Add class name to selected elements
* @date 16/02/2024 - 11:04:27
*
* @export
* @param {{ drawing: any; selectedIds: any; targetElementSelector: any; selectedElementClassName: any; idPath: any; }} param0
* @param {*} param0.drawing
* @param {*} param0.selectedIds
* @param {*} param0.targetElementSelector
* @param {*} param0.selectedElementClassName
* @param {*} param0.idPath
*/
export function updateSelectedElementClassName({
drawing,
selectedIds,
targetElementSelector,
Expand Down
7 changes: 5 additions & 2 deletions stanzas/piechart/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import {
import getStanzaColors from "../../lib/ColorGenerator";
import Legend from "../../lib/Legend2";
import MetaStanza from "../../lib/MetaStanza";
import { emitSelectedEvent, changeSelectedStyle } from "../../lib/utils";
import {
emitSelectedEvent,
updateSelectedElementClassName,
} from "../../lib/utils";

export default class Piechart extends MetaStanza {
legend: Legend;
Expand Down Expand Up @@ -142,7 +145,7 @@ export default class Piechart extends MetaStanza {

handleEvent(event) {
if (this.params["event-incoming_change_selected_nodes"]) {
changeSelectedStyle.apply(null, [
updateSelectedElementClassName.apply(null, [
{
selectedIds: event.detail,
...this.selectedEventParams,
Expand Down

0 comments on commit 9009b3d

Please sign in to comment.