Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to extend grid with Javascript extensions #240

Merged
merged 2 commits into from Apr 10, 2019

Conversation

zuk3975
Copy link
Contributor

@zuk3975 zuk3975 commented Apr 9, 2019

Added tutorial that explains how to use Javascript extensions for grid.

@zuk3975
Copy link
Contributor Author

zuk3975 commented Apr 9, 2019

@matks my first ps tutorial 😄

@matks
Copy link
Contributor

matks commented Apr 9, 2019

@matks my first ps tutorial 😄

# Extend a grid with Javascript extensions. Preparation
Javascript grid extensions supplements grid functionality and enhances user experience.
Copy link
Contributor

@matks matks Apr 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Javascript grid extensions supplements grid functionality and enhances user experience.
Javascript grid extensions supplement grid behavior and enhance user experience.

# Extend a grid with Javascript extensions. Preparation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preparation ?

BulkActionCheckboxExtension which enables interactive selection of bulk actions and so on.

In this tutorial we use an example of taxes grid to show how to use extensions.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
In this tutorial we use an example of taxes grid to show how to use extensions.
In this tutorial we use a grid that display taxes items to show how to use extensions.

To start we will need to have a plain grid already created in php side
(you can find more docs about grid here https://devdocs.prestashop.com/1.7/development/components/grid).
After following some guides we should be ready. Our grid looks like this:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
After following some guides we should be ready. Our grid looks like this:
After following the Grid documentation directions you should now have a fully working php grid. The twig template should look like this:

```
{{< figure src="../../img/taxes_grid.png" title="Taxes grid example" >}}
Although the grid looks complete, none of the actions are working yet.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Although the grid looks complete, none of the actions are working yet.
Although the grid looks complete, none of the actions are working yet because the javascript behavior is not enabled yet.

{{< figure src="../../img/taxes_grid.png" title="Taxes grid example" >}}
Although the grid looks complete, none of the actions are working yet.
To get started, create javascript file for your page and add entry in your webpack config.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are 3 steps here, write it as a list then explain each step 😉

For our example, index.js will land in `admin-dev/themes/new-theme/js/pages/tax/index.js`, then
we add an entry point in `admin-dev/themes/new-theme/.webpack/common.js`.
Don't forget to add your compiled file path to html script tag (same as with pagination bundle above).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to show the code 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it's kinda from another topic. Like 'how to add javascript to html' 😄

# Adding extensions

Lets open our index.js and start by importing Grid component from `admin-dev/themes/new-theme/js/components/grid/grid.js`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First show the code snippet, then explain what it does 😉


```
import Grid from '../../components/grid/grid';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add JS comments to explain sections

});
```
That's it, the last thing to do is to run the compiler and extensions should be working.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to guide the reader to the "compiler" section with npm commands

@zuk3975
Copy link
Contributor Author

zuk3975 commented Apr 9, 2019

@matks addressed your comments

@matks
Copy link
Contributor

matks commented Apr 10, 2019

Thank you @zuk3975

@matks matks merged commit bf0deaf into PrestaShop:master Apr 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants