You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
99 lines
2.2 KiB
99 lines
2.2 KiB
|
|
/**
|
|
* This module defines a CompelExtension class.
|
|
*/
|
|
import {
|
|
helperFun,
|
|
builder,
|
|
Page
|
|
} from "jpc-like-websites";
|
|
|
|
|
|
/**
|
|
* Defines an extension that can be added to the jpclw-framework
|
|
*/
|
|
export class CompelExtension {
|
|
/**
|
|
* @type {string}
|
|
*/
|
|
name;
|
|
/**
|
|
* @type {string}
|
|
*/
|
|
diplayTitle;
|
|
/**
|
|
* @type {Array<SStoreDefinition>}
|
|
*/
|
|
stylings;
|
|
/**
|
|
* @type {Array<SStoreDefinition>}
|
|
*/
|
|
functions;
|
|
/**
|
|
* Predefined components. Usually of a higher (constructed) kind.
|
|
* @type {Object}
|
|
*/
|
|
components;
|
|
/**
|
|
* Extensions for/to the Page or the framework in general.
|
|
* @type {Object}
|
|
*/
|
|
frameworkControls;
|
|
/**
|
|
* Additional elements for the builder (likely referencing components)
|
|
* @type {Object}
|
|
*/
|
|
builderElements;
|
|
|
|
/**
|
|
* Additional helper functions
|
|
* @type {{*:Function}}
|
|
*/
|
|
helperFun;
|
|
|
|
/**
|
|
* functions that are supposed to be executed after install,
|
|
* to extend it that way.
|
|
* @type {Array<Function>}
|
|
*/
|
|
funAfterInstall
|
|
|
|
/**
|
|
*
|
|
* @param {string} name the working name of the extension
|
|
* @param {string} displayTitle the name under wich it will be displayed in the framework panel
|
|
*/
|
|
constructor(name = "", displayTitle = "") {
|
|
this.name = name;
|
|
this.displayTitle = displayTitle;
|
|
}
|
|
|
|
/**
|
|
* defines how jpc-like-websites is to be extended and executes that extension
|
|
*/
|
|
install() {
|
|
if (this.helperFun) {
|
|
helperFun.extensions = Object.assign(helperFun.extensions, this.helperFun);
|
|
}
|
|
|
|
if (this.builderElements) {
|
|
builder.extensions = Object.assign(builder.extensions, this.builderElements);
|
|
}
|
|
|
|
if (this.frameworkControls) {
|
|
Page.extensions = Object.assign(Page.extensions, this.frameworkControls);
|
|
}
|
|
|
|
if (this.stylings) {
|
|
for (const key of Object.keys(this.stylings)) {
|
|
Page.registerStyling(key, this.stylings[key]);
|
|
}
|
|
}
|
|
|
|
if (this.funAfterInstall) {
|
|
for (const fun of this.funAfterInstall) {
|
|
fun();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|