Base list component
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 standardgetDataSource
function. Inherited class is required to implementmodifyList
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] (defaulttrue
) defines whether the grid should useactive
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
.
- If true, status column
-
ACTIVE_FILTER
[bool] (defaultfalse
) defines whether the filter by the columnactive
should be included.- If true and
ACTIVE
is false, noothing happens. - Filter includes options Yes/No/All.
- If true and
-
ADD
[bool/string] (defaultfalse
) 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] (defaultfalse
) 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] (defaulttrue
) defines whether the delete action should be included.- If true and
ACTIVE
is also true, delete action updated value of columnactive
to-1
. - If true and
ACTIVE
is false, delete action deletes the record.
- If true and
-
INLINE_ADD
[bool] (defaultfalse
) defines whether inline add should be included.- If true, you are expected to override
modifyInlineForm
method and add inputs to match your columns.
- If true, you are expected to override
-
INLINE_EDIT
[bool] (defaultfalse
) 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.
- If true, you are expected to override
-
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] (default10
) 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 columnsname
anddescription
, and also enables inline add and inline edit.