PrestaShop / prestafony-project

Some resources to help you migrate PrestaShop to Symfony 3
https://github.com/PrestaShop/prestafony-project/projects/1
11 stars 8 forks source link

Make grid.js extendable without modifying it #52

Closed sarjon closed 4 years ago

sarjon commented 6 years ago

In order to extend javascript functionality of grid, we need to be able to dynamically plug additional features to it.

Here's an idea of how it could be done:

// column-toggle-handler.js

class ColumnToggleHandler() {
    run(event, grid) {
        // do stuff
    }
}

// some/specific/page/script.js

const grid = new Grid('#my-grid');

// you just add handlers that you actually need
// it can be the same for column, grid actions & etc.
// maybe fire some event so modules/other script can register their own handlers for the grid
grid.addColumnHandler(new ColumnToggleHandler());

grid.init();
sarjon commented 6 years ago

Related PR https://github.com/PrestaShop/PrestaShop/pull/9342

sarjon commented 6 years ago

can we close this as PrestaShop/PrestaShop#9342 is merged?