Plugin options
Every option that a plugin can set in its index.js.
On this page
A plugin describes itself with exports.<option> lines in its index.js. This is the index.js of the sample Products plugin:
exports.icon = 'ti ti-box';
exports.name = '@(Products)';
exports.position = 1;
exports.permissions = [{ id: 'products', name: 'Products' }];
exports.visible = user => user.sa || user.permissions.includes('products');
exports.routes = [
{ url: '/products/{id}/', html: 'detail' }
];
exports.config = [
{ id: 'city', name: 'City', value: 23 }
];
exports.install = function() {
ROUTE('+API ? -products --> Products/list');
};Options
| Option | What it does |
|---|---|
name | Name in the menu, on the home tile and as the group title in Settings. @(...) marks the text for translation. |
icon | Icon in the menu and on the home tile, a Total.js icon class such as ti ti-box. |
position | Order in the menu and on the home screen. Lower numbers come first. |
permissions | Permissions that the plugin offers to OpenPlatform, as a list of { id, name }. |
visible | A function that gets the signed-in user and returns true when the user may see the plugin. The samples return true for the admin account (user.sa) and for users with the plugin permission. |
hidden | true keeps the plugin out of the menu and the home screen. See Remove a plugin. |
routes | Extra screens, as a list of { url, html }. See Add a detail page. |
config | Settings shown in Settings, as a list of { id, name, value }. See Add plugin settings. |
import | An HTML file in public that is loaded into every page of the admin. The admin plugin uses it for the account button. |
install | A function that runs on start. Put the ROUTE lines of the plugin here. |
ROUTE lines for actions
A line such as ROUTE('+API ? -products --> Products/list'); makes the action Products/list available to the screens under the name products:
+means only signed-in users can call it.?stands for the admin address,/admin/.-productsis a call without data;+productssends data to the action, as in+settings_save.- After
-->comes the name of the action inschemas.
A screen calls it with exports.tapi('products', ...), and a script with a token.