APY / APYDataGridBundle

Symfony Datagrid Bundle
MIT License
493 stars 343 forks source link

[WIP][3.0] Goals and new features #462

Open Abhoryo opened 11 years ago

Abhoryo commented 11 years ago

The goal of this issue is to talk about the new version 3.0 of this bundle. You can propose some change or new feature. You can also comment about existing propositions.

  1. Configured grids [BC breaks]
    • Summary
      This bundle now works with configured grids (Yaml, XML and annotation).
    • Comment
      Yaml, XML and annotation configurations can coexist and priorities can be defined in the configuration.
      Each grid have an unique identifier and has an unique instance in the container.
      Grids are loaded once in the compiler pass of the bundle and can be access with the apy_grid service.
    • Plus
      Add a variable system to able a user to define easily some values of the grid in PHP and twig. e.g.: In yaml: values: %%var6%%, in PHP: $grid->setVariable('var6', array(0 => 'False', 1 => 'True'));
  2. Simplify the usage [BC breaks]
    • Summary
      A grid can be directly displayed in a template without any PHP code: {{ render_grid('my_grid_id') }}
    • Comment
      Export and mass action requests are catched by a listener on the kernel.controller event.
      A grid is prepared when the render is called.
      A user can add or change some properties of the grid in PHP.
      $grid = $container->get('apy_grid')->getGrid('my_grid_id'); $grid->getColumn('my_column_id')->setVisible(false);
    • Warning
      The bundle must define some method to interact with row actions, mass actions, exports...
  3. Update columns [BC Breaks]
    See version 2.2
    • Summary
      Each type of column can be a collection of values and each value is treated like the defined type.
      In 2.1, values in an array column are treated like a text column.
      New Country, Language, Locale and Year columns with their select filter.
      New operators: Doesn't start with, Doesn't end with, Not between exclusive, Not between inclusive.
    • Comment
      The array column disappears.
  4. Load entities [BC breaks]
    • Summary
      Load whole entities instead of just the necessary fields.
      In this version, only the entity and vector sources will be implemented by the team. But another sources can be implemented thanks to the tests.
    • Comment
      This implies that some option are no longer needed (source, ...).
      Plus, we have to work with classes instead of simple array. this can cause problems with mapped fields.
    • Warning
      We have to compare the memory usage before and after this change.
      Can we also keep the old version to reduce ce memory usage?
  5. Tests
    • Summary
      In this version we'll try to add tests as much as possible especially for the sources classes.
  6. Cookbook
    • Summary
      A cookbook will be create. You will find specific solutions for specific needs.
    • Comment
      The specific needs will first be the existing issues.
  7. Optimize Ajax loading
    • Summary Don't reload the whole grid.
    • Comment
    • Warning
  8. Auto typing of the mapped field
    • Summary
    • Comment
    • Warning
  9. Fix 2.0 problems
    • 550 Avoid conflicts with column block id and type.

    • Todo: Add row click action
rogamoore commented 11 years ago

It would be nice if there were a possibility to add custom parameters to the column annotation:

* @GRID\Column(title="my own column name", size="120", type="text", my_custom_parameter="xyz")

With this you could set flags or add some custom information which then could be used in the template blocks.

Example: * @GRID\Column(title="name", type="text", createEditLink=true)

{% block grid_column_cell %}
  {% if column.createEditLink %}
      <a href="{{ path('...', {'id': row.field('id')}) }}">{{ value }}</a>
  {% else %}
      {{ value }}
  {% endif %}
{% endblock grid_column_cell %}

Example 2: * @GRID\Column(title="title", type="text", showSubtitle=true, subtitleField="subtitle")

{% block grid_column_cell %}
      {{ value }}
  {% if column.showSubtitle %}
<br><small>{{ row.field(column.subtitleField) }}</small>
  {% endif %}
{% endblock grid_column_cell %}
Abhoryo commented 11 years ago

I love this idea. This should be possible with the magic __get() method in the Column class. This can cause problems with yaml and xml configuration though.

rogamoore commented 11 years ago

There could also be a container array: * @GRID\Column(title="name", type="text", custom_params={createEditLink=true}) although I'm not sure if this syntax is correct for annotations.

Then we don't need any magic - we just need to add a getter/setter in the Column class as for all the other parameters. I will see if I can try this next week.

Abhoryo commented 11 years ago

Yeah I prefer a params option. This solution don't cause problems with xml and yaml configuration.

This isn't for the 3.0 so you can add it to the 2.1.