mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-11 20:12:16 +00:00
32 lines
979 B
JavaScript
32 lines
979 B
JavaScript
// changes within tabulator are often not adequately broadcast to the external component
|
|
// this module exposes tabulator's internal events
|
|
// if external event name is not specified, the dispatched external event will be the camelCase version of the kebab-case internal event
|
|
|
|
import Module from "../../../../vendor/olifolkerd/tabulator5/src/js/core/Module.js";
|
|
import { convertCase } from "../../helpers/StringHelpers.js";
|
|
|
|
export default class InternalToExternalEventBroadcastModule extends Module {
|
|
static moduleName = "internalToExternalEventBroadcast";
|
|
static moduleInitNumber = 1;
|
|
|
|
constructor(table) {
|
|
super(table);
|
|
|
|
this.eventsToBroadcast = [
|
|
// example event
|
|
// {
|
|
// internal: "layout-refreshed",
|
|
// external: null,
|
|
// },
|
|
];
|
|
}
|
|
|
|
initialize() {
|
|
this.eventsToBroadcast.forEach((event) => {
|
|
this.subscribe(event.internal, () => {
|
|
this.dispatchExternal(event.external ?? convertCase(event.internal, "kebab", "camel"));
|
|
});
|
|
});
|
|
}
|
|
}
|