Appearance
EA Script API Reference
All methods below are available inside your script.js plugin registration function via this.
js
plugins["my-plugin"] = function () {
// this.addLanguage(...)
// this.addRole(...)
// etc.
}addLanguage(code, key, value)
Registers i18n translation strings for your plugin. Will not overwrite a namespace that is already registered.
| Parameter | Type | Description |
|---|---|---|
code | "ar" | "en" | Locale code |
key | string | Namespace (e.g. "music", "form") |
value | object | Key/value translation pairs |
js
this.addLanguage("en", "music", {
name: "Music",
playlist: "Playlist"
});
this.addLanguage("ar", "music", {
name: "الموسيقى",
playlist: "قائمة التشغيل"
});In Vue templates, use translations with $t("namespace.key"):
vue
<h5>{{ $t("music.name") }}</h5>addRole(role)
Registers a permission role for your plugin. Roles control access to actions (create, save, delete, etc.) and are configurable by administrators.
| Parameter | Type | Description |
|---|---|---|
role.id | string | Unique role identifier |
role.text | string | Display name |
role.key | string | i18n key for the role label |
role.roles | object | Map of permission keys to permission definitions |
Each permission inside role.roles:
| Property | Type | Description |
|---|---|---|
text | string | Display name |
key | string | i18n key |
value | boolean | Default value (false = denied by default) |
js
this.addRole({
id: "music",
text: "Music",
key: "music.name",
roles: {
create: { text: "Create", key: "button.create", value: false },
save: { text: "Save", key: "button.save", value: false },
delete: { text: "Delete", key: "button.delete", value: false }
}
});In Vue components, check permissions with the role() helper:
vue
<Button v-if="role('music', 'delete')" icon="pi pi-trash" />addTask(item)
Mounts a Vue component onto the EA dashboard as a task/widget tile.
| Parameter | Type | Description |
|---|---|---|
item.name | string | Unique component route name |
item.id | string | Task identifier |
item.file | string[] | File path array passed to loadModule |
js
this.addTask({
name: "/[music]widget.vue",
id: "init-music",
file: ["music", "widget.vue"]
});The
filearray resolves relative to the plugin's version folder.["music", "widget.vue"]loads1.0.0/widget.vuefrom themusicplugin.
addWidget(item)
Registers a standalone widget component (similar to addTask but used for embeddable widgets rather than full task views).
| Parameter | Type | Description |
|---|---|---|
item.name | string | Unique component name |
item.file | string[] | File path array passed to loadModule |
js
this.addWidget({
name: "/[music]player.vue",
file: ["music", "player.vue"]
});addToSetting(route)
Adds a navigation entry to the Settings sidebar in the EA application.
| Parameter | Type | Description |
|---|---|---|
route.label | string | Sidebar display label |
route.key | string | i18n key for the label |
route.icon | string | Icon class (MDI or PrimeIcons) |
route.to | string | Route path this item navigates to |
js
this.addToSetting({
label: "Music",
key: "music.name",
icon: "mdi mdi-book-music",
to: "/app/setting/music"
});The
topath must match thepathyou register withaddPage(..., "setting").
addToToolbar(route)
Adds a button or link to the application toolbar.
| Parameter | Type | Description |
|---|---|---|
route | object | Route config pushed to the toolbar array |
js
this.addToToolbar({
icon: "pi pi-music",
to: "/app/music"
});addToDashboard(cat, item)
Adds a navigation item inside an existing dashboard category.
| Parameter | Type | Description |
|---|---|---|
cat | string | Category name in navigation (must already exist) |
item | object | Navigation item config |
item.to | string | Route path used as the item key |
js
this.addToDashboard("Main", {
label: "Music",
key: "music.name",
icon: "mdi mdi-book-music",
to: "/app/music"
});addToDashboardRoot(cat, item, routes)
Creates or replaces a root-level dashboard category. Optionally inserts it at a specific position.
| Parameter | Type | Description |
|---|---|---|
cat | string | Category key in navigation |
item | object | Category config object |
item.order | number? | Optional insertion index |
routes | string[] | Route paths belonging to this category |
js
this.addToDashboardRoot("Music", {
label: "Music",
icon: "mdi mdi-book-music",
order: 2
}, ["/app/music", "/app/music/playlist"]);addToExplorer(data)
Registers your plugin with the application explorer, making it discoverable as an installed application.
| Parameter | Type | Description |
|---|---|---|
data.id | string | Unique key in the application registry |
data | object | Full application descriptor |
js
this.addToExplorer({
id: "music",
label: "Music",
icon: "mdi mdi-book-music"
});addPage(page, to)
Registers a Vue component as a routed page inside the EA application.
| Parameter | Type | Description |
|---|---|---|
page.name | string | Unique route name |
page.path | string | Route path |
page.file | string[] | File path array passed to loadModule |
to | string | Parent route name. Defaults to "app". Use "setting" for settings pages |
If a route with page.name already exists, the registration is skipped silently.
js
// Register a settings page
this.addPage({
name: "/[music]setting.vue",
path: "/app/setting/music",
file: ["music", "setting.vue"]
}, "setting");
// Register a main app page
this.addPage({
name: "/[music]index.vue",
path: "/app/music",
file: ["music", "index.vue"]
}, "app");Typical plugin registration pattern
js
plugins["music"] = function () {
// 1. Register translations
this.addLanguage("en", "music", { name: "Music", playlist: "Playlist" });
this.addLanguage("ar", "music", { name: "الموسيقى", playlist: "قائمة التشغيل" });
// 2. Register roles
this.addRole({
id: "music",
text: "Music",
key: "music.name",
roles: {
create: { text: "Create", key: "button.create", value: false },
save: { text: "Save", key: "button.save", value: false },
delete: { text: "Delete", key: "button.delete", value: false }
}
});
// 3. Mount dashboard widget
this.addTask({
name: "/[music]widget.vue",
id: "init-music",
file: ["music", "widget.vue"]
});
// 4. Add Settings sidebar entry
this.addToSetting({
label: "Music",
key: "music.name",
icon: "mdi mdi-book-music",
to: "/app/setting/music"
});
// 5. Register settings page route
this.addPage({
name: "/[music]setting.vue",
path: "/app/setting/music",
file: ["music", "setting.vue"]
}, "setting");
}