-
Notifications
You must be signed in to change notification settings - Fork 71
Description
Hey !
Pathfinder is still a great tool for our corporation, we couldn't get by without it actually.
I'd like to extend some of the functions, and I bet the modules/plugins are the place to be for that, so I quickly setup a dev setup on my dev computer, got a Pathfinder that work (without redis and websocket, but don't need them) and everything seems to be going fine.
I duplicated empty.js, changed the module name, the infos for it, ... added the following line in plugins.ini :
PYMOUS = ./app/ui/module/pymous
I let Gulp do his thing, but I can't get the module to be visible/activated in the Layout Settings !
No error on compilation, no error in the logs, ... so I'm a bit stuck at the moment.
I hope someone have an advice on what I may be doing wrong.
Thanks for the work !
P.S : Here is the full pymous.js (patent pending) as it is right now :
define([
// dependencies for this module
"module/base", // abstract `parent` module class definition [required]
"app/render", // ... for demo purpose, we load a Render helper object
], (BaseModule, Render) => {
"use strict";
/**
* PymousModule class
* -> skeleton for custom module plugins
* @type {PymousModule}
*/
let PymousModule = class PymousModule extends BaseModule {
constructor(config = {}) {
super(Object.assign({}, new.target.defaultConfig, config));
}
/**
* initial module render method
* -> implementation is enforced by BaseModule
* -> must return a single node element
* @param mapId
* @param systemData
* @returns {HTMLElement}
*/
render(mapId, systemData) {
this._systemData = systemData;
// ... append your custom module body
let bodyEl = Object.assign(document.createElement("div"), {
className: this._config.bodyClassName,
});
this.moduleElement.append(bodyEl);
return this.moduleElement;
}
/**
* init module
*/
init() {
super.init();
}
beforeHide() {
super.beforeHide();
}
beforeDestroy() {
super.beforeDestroy();
}
onSortableEvent(name, e) {
super.onSortableEvent(name, e);
console.log("onSortableEvent", name, e);
}
update(systemData) {
let activeMap = BaseModule.Util.getMapModule().getActiveMap();
console.log("Log from Pymous");
// console.log(activeMap, systemData);
// console.log("Test", BaseModule.Util.getMapModule().getActiveMap().getSystems());
return super.update(systemData).then(
(systemData) =>
new Promise((resolve) => {
this.renderJson("update()", { systemData });
// ... custom (async) code e.g. request external API and update module
// -> resolve() Promise when module is updated.
resolve({
action: "update",
data: {
module: this,
},
});
})
);
}
};
PymousModule.isPlugin = true; // module is defined as 'plugin'
PymousModule.scope = "system"; // module scope controls how module gets updated and what type of data is injected
PymousModule.sortArea = "a"; // default sortable area
PymousModule.position = 15; // default sort/order position within sortable area
PymousModule.label = "Pymous : I have no idea what i am doing here."; // static module label (e.g. description)
PymousModule.defaultConfig = {
className: "pf-system-pymous-module", // class for module
sortTargetAreas: ["a", "b", "c"], // sortable areas where module can be dragged into
headline: "Pymous Module",
};
return PymousModule;
});