Files
mixtape/zero.Backoffice.UI/old_app/core/plugin.ts
T

92 lines
1.5 KiB
TypeScript
Raw Normal View History

2020-10-16 11:23:54 +02:00
class Plugin
{
2021-05-08 15:20:23 +02:00
_name;
_onInstall;
2020-10-16 11:23:54 +02:00
routes = [];
2020-10-18 23:47:59 +02:00
editors = [];
2020-10-19 14:48:21 +02:00
lists = [];
2020-10-16 11:23:54 +02:00
constructor(name)
{
2021-05-08 15:20:23 +02:00
this._name = name;
2020-10-16 11:23:54 +02:00
}
get name()
{
2021-05-08 15:20:23 +02:00
return this._name;
2020-10-16 11:23:54 +02:00
}
get install()
{
2021-05-08 15:20:23 +02:00
return this._onInstall;
2020-10-16 11:23:54 +02:00
}
set install(callback)
{
2021-05-08 15:20:23 +02:00
this._onInstall = callback;
2020-10-16 11:23:54 +02:00
}
/*
* Add a new vue form renderer to the global configuration
*/
2020-10-18 23:47:59 +02:00
addEditor(config)
2020-10-16 11:23:54 +02:00
{
2020-10-18 23:47:59 +02:00
this.editors.push(config);
2020-10-16 11:23:54 +02:00
}
2020-10-19 14:48:21 +02:00
2020-10-16 11:23:54 +02:00
/*
* Adds new form renderers to the global configuration
* Can either by an array (where a key of the child object is `alias`) or an object where the key is the renderer alias
*/
2020-10-18 23:47:59 +02:00
addEditors(editors)
2020-10-16 11:23:54 +02:00
{
2020-10-18 23:47:59 +02:00
let items = !Array.isArray(editors) ? Object.values(editors) : editors;
items.forEach(item => this.addEditor(item));
2020-10-16 11:23:54 +02:00
}
2020-10-19 14:48:21 +02:00
/*
* Add a new vue list renderer to the global configuration
*/
2021-01-30 16:52:36 +01:00
addList(list)
2020-10-19 14:48:21 +02:00
{
2021-01-30 16:52:36 +01:00
this.lists.push(list);
2020-10-19 14:48:21 +02:00
}
/*
* Adds new list renderers to the global configuration
* Can either by an array (where a key of the child object is `alias`) or an object where the key is the renderer alias
*/
addLists(lists)
{
let items = !Array.isArray(lists) ? Object.values(lists) : lists;
items.forEach(item => this.addList(item));
}
2020-10-16 11:23:54 +02:00
/*
* Add a new route to vue-router
*/
addRoute(route)
{
this.routes.push(route);
}
2020-10-19 14:48:21 +02:00
2020-10-16 11:23:54 +02:00
/*
* Adds new routes to vue-router
*/
addRoutes(routes)
{
2020-10-16 14:02:10 +02:00
routes.forEach(route => this.addRoute(route));
2020-10-16 11:23:54 +02:00
}
};
export default Plugin;