Skip to content

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.

ParameterTypeDescription
code"ar" | "en"Locale code
keystringNamespace (e.g. "music", "form")
valueobjectKey/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.

ParameterTypeDescription
role.idstringUnique role identifier
role.textstringDisplay name
role.keystringi18n key for the role label
role.rolesobjectMap of permission keys to permission definitions

Each permission inside role.roles:

PropertyTypeDescription
textstringDisplay name
keystringi18n key
valuebooleanDefault 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.

ParameterTypeDescription
item.namestringUnique component route name
item.idstringTask identifier
item.filestring[]File path array passed to loadModule
js
this.addTask({
    name: "/[music]widget.vue",
    id: "init-music",
    file: ["music", "widget.vue"]
});

The file array resolves relative to the plugin's version folder. ["music", "widget.vue"] loads 1.0.0/widget.vue from the music plugin.

addWidget(item)

Registers a standalone widget component (similar to addTask but used for embeddable widgets rather than full task views).

ParameterTypeDescription
item.namestringUnique component name
item.filestring[]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.

ParameterTypeDescription
route.labelstringSidebar display label
route.keystringi18n key for the label
route.iconstringIcon class (MDI or PrimeIcons)
route.tostringRoute path this item navigates to
js
this.addToSetting({
    label: "Music",
    key: "music.name",
    icon: "mdi mdi-book-music",
    to: "/app/setting/music"
});

The to path must match the path you register with addPage(..., "setting").

addToToolbar(route)

Adds a button or link to the application toolbar.

ParameterTypeDescription
routeobjectRoute 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.

ParameterTypeDescription
catstringCategory name in navigation (must already exist)
itemobjectNavigation item config
item.tostringRoute 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.

ParameterTypeDescription
catstringCategory key in navigation
itemobjectCategory config object
item.ordernumber?Optional insertion index
routesstring[]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.

ParameterTypeDescription
data.idstringUnique key in the application registry
dataobjectFull 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.

ParameterTypeDescription
page.namestringUnique route name
page.pathstringRoute path
page.filestring[]File path array passed to loadModule
tostringParent 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");
}