nepttune/base-list-component

Base list component for Nepttune

v6.0.2 2018-12-08 00:37 UTC

README

🅱️ Base list component for Nepttune

Packagist Packagist

Code Climate Scrutinizer Code Quality

Functionality

This package introduces base list component with commonly used functionality in ublaboo/datagrid.

  • Overriden render() method selects template which renders list subcomponent.
  • Precreated createComponentList method creates and sets up datagrid instance based on class constants. It also sets translator and standard getDataSource function. Inherited class is required to implement modifyList method where you add custom columns and actions to your grid.

Dependencies

How to use

  • Inherit from \Nepttune\Component\BaseListComponent.

  • Inject repository class.

  • Override class contants, which define how your list is set up.

    • ACTIVE [bool] (default true) defines whether the grid should use active column.
      • If true, status column active is added to the grid with Yes/No options and predefined on-change action.
      • If true, default datasource function add where clause active >= 0.
    • ACTIVE_FILTER [bool] (default false) defines whether the filter by the column active should be included.
      • If true and ACTIVE is false, noothing happens.
      • Filter includes options Yes/No/All.
    • ADD [bool/string] (default false) defines whether the add action should be included.
      • If enabled an add button appears in grid. Button redirects to destination provided in value of this parameter.
    • EDIT [bool/string] (default false) defines whether the edit action should be included.
      • If enabled edit button appears in grid. Button redirects to destination provided in value of this parameter.
    • DELETE [bool] (default true) defines whether the delete action should be included.
      • If true and ACTIVE is also true, delete action updated value of column active to -1.
      • If true and ACTIVE is false, delete action deletes the record.
    • INLINE_ADD [bool] (default false) defines whether inline add should be included.
      • If true, you are expected to override modifyInlineForm method and add inputs to match your columns.
    • INLINE_EDIT [bool] (default false) defines whether inline edit should be included.
      • If true, you are expected to override modifyInlineForm method and add inputs to match your columns.
      • You can also override setInlineDefaults method to specify how the defaults should be set.
    • SORT [array] (default ['active' => 'DESC']) defines default sort.
    • PER_PAGE [array] (default [10 => '10', 20 => '20', 50 => '50', 100 => '100']) defines options for per page selectbox.
    • PER_PAGE_DEFAULT [int] (default 10) defines default value for page selectbox.
  • Implement the modifyList method, where you add other columns and actions to your grid.

  • If needed, override any of the methods to achieve desired behavior.

  • There is a class \Nepttune\Component\BaseEnumerator (also bundled in this package), which is simple implementation of BaseListComponent. This list adds columns name and description, and also enables inline add and inline edit.