ullGenerator refactoring notes / new relation handling

Relation Project

The aim is to allow usage of any valid fields with arbitrary complex relations to be used by the generator.

The first step is for the list view to allow proper display, order and search for any related column.

 

The syntax of the string representation of a relation column is "Relation1->Relation2->field_name"

Example for table UllUser: "UllLocation->Creator->display_name"

 

What is new?

  1. UllTableConfiguration got a few new properties
    • listColumns, orderColumns: array of columns using the relation syntax above
    • customRelationNames: allows giving custom relation names (e.g. UllVentoryItemModel->UllVentoryItemType->name = "Type")
    • foreignRelationNames: tables with a relation to the current table should use the given name (e.g "UllUser" => "User")
  2. UllTableToolGenerator::__construct() optionally takes an array of columns, if none are given it checks if the ullTableConfiguration for the current model has configured listColumns.
    If not it falls back for compatibility reasons to the active fields of the columnConfigCollection
  3. UllTableToolGenerator::buildColumnsConfig() checks for related columns and gets the related columnConfigurations
  4. Introduced ullQuery. ullQuery is a Wrapper for Doctrine_Query which can handle the new relation column syntax.
    Currently a few basic methods are implemented (addSelect(), addWhere(), addOrderby(), getSql(), execute()
  5. UllTableToolGenerator::getQuery() builds a clean ullQuery, which selects only the active fields, and handles the relations by adding FROM parts. This drastically reduces the number of queries in list views.
  6. BaseUllTableToolActions::getFilterFromRequest() uses the ullQuery from the generator and adds ullFilter and orderBy handling
  7. ullGeneratorForm::updateDefaults() sets the defaults properly for the relation columns. For relation columns it sets the value as array in the format array('value' => $value, 'id' => $id) This is used e.g. by the ullWidgetUllEntityRead to show the displayname without an extra query, but also create a user popup link using the id (= primary key)
  8. ullWidget optionally takes the value in array format (see above)

 

 

refactor ColumnConfig as an object (array currently)

Ticket: http://www.ullright.org/ullFlow/edit/doc/402

 

Basic transformation from array to object: done.

  • e.g. ullVentoryGenerator: to add fields like type and manufacturer one has to simulate a complete cc array also with empty key/value pairs like "widgetOptions"  - done
  • e.g. ullVentoryGenerator: common labels like "Comment" aren't beautified/translated, because the whole buildColumnsConfig() method is overwritten.
  • A specialized generator for a module (e.g. ullVentory) should try to translate the labels also using the "local" i18n messages file

handle hidden fields

  • columns that are marked "is_hidden" should be added to the form as sfWidgetFormInputHidden, and shell not be rendered as a normal form row.
  • clarify ullGenerator::getActiveColumns(). At the moment it returns all columns which aren't completely disabled. what about hidden fields? Somthing like getRenderedColumns() ?!?
  • it shell be possible for all metaWidgets to be marked as "is_hidden". A "ullMetaWidgetHidden" makes no sense, as the Validator must stay the same as in the original metaWidget type.