Customizing Desktop

Desktop is a complex widget created with Webix Jet, the MV* framework for Webix Library. It is a ready-to-use application with minimum configuration settings, but it has API for redefining the logic of inner modules.

You will need to study the source code to customize views and models.

Jet App and Inner Modules

Desktop is built as a Jet App and wrapped into a Webix view, so you can initialize it in either of the ways.

Views

The interface of Desktop is split into parts (views). Each view is a class that extends the JetView class and has own handlers for setting the configuration and logic.

The sources for interface parts (Jet Views) are located in the sources/views folder.

views
  desk.js
  menu.js
  ...

Go to the Class Map page to see the list of all Jet views in Desktop and where they are in the interface.

Models/Services

Desktop models contain the logic for loading and storing data, uploading avatars, working with templates etc. They are defined as Jet Services.

The sources for models (Jet Services) are located in the sources/models folder.

models
  Windows.js
  Helpers.js
  Local.js

You can get services using getService() method:

$$('mydesktop').getService('helpers');

Customizing Views

  • you can override the config() method for changes in the UI
  • you can override the init() for changes in the UI and behavior
  • you can override any existing method but with a caution
  • you can add and call your own methods

To start, create your own view class and inherit it from one of the default views or from desktop.views.JetView:

class MyMenu extends desktop.views["menu"] {
    config() {
        //get JSON object with configuration
        const ui = super.config();
        ... //some changes depending on a particular view
        return ui;
    }
    init() {
        // call default logic
        super.init();
        // custom logic below
        this.doSomething();
    }
    doSomething() {
        // do something on init
    }
}

Then replace the default view via the override map:

webix.ui({
    view: "desktop",
    apps: myApps,
    systemParams: getParams(),
    override: new Map([[desktop.views["menu"], MyMenu]])
})

Notes

1. We do not recommend to remove any component from the interface as the inner logic might still try accessing it. Instead, hide the components.

class CustomToolbar extends desktop.views["toolbar"] {
    init(view) {
        // default logic
        super.init();
        // hide a button
        view.queryView('button').hide();
    }
}

2. You can access component instances within a Jet view by:

  • using the $$(id) method of JetView.

It works for an inner component that is assigned the localId setting.

init() {
    // default logic
    super.init();
    // get instance of the component with "list" localId
    const list = this.$$("list");
}
init(view) {
    // default logic
    super.init();
    // get instance of the button
    const button = view.queryView("button");
}

3. You can find out whether the app is currently compact from any view or service method as:

const compact = this.getParam('compact', true);

4. You can get state properties from any view or service method as:

const state = this.app.getState();
// or
const state = this.getParam('state');

Customizing Jet Services

By customizing Jet services, you can add and call your own methods. You can also override any existing method, but you should do it with caution.

The steps are the same as for customizing a view:

  • create your own service class and inherit it from one of the default services;
  • replace the default service via the override map.

Backward Compatibility

Desktop is extremely flexible when it comes to customizations. However, keep in mind the following:

  • The inner logic of Desktop modules may change in future releases.
  • We will try to maintain method signatures, but breaking changes might happen if they are necessary for further development of the widget.

Code for Edge Сhromium must be with different syntax.

Back to top