stepapo/data

Component for Nette Framework and Nextras ORM, that helps generate datasets from collections with paging, sorting and filtering capability.

1.1.0 2022-01-05 16:29 UTC

This package is auto-updated.

Last update: 2022-01-05 16:30:39 UTC


README

Component for Nette Framework, that helps generate datasets from Nextras ORM collections with paging, sorting and filtering capability. The docs show basic example and ways of configuring datasets.

Example

Let's create a list of all persons in database sorted alphabeticaly by name. The list shows 10 items per page, is sortable by name, birthday and filterable by gender. Name contains a link to person's detail page. It is possible to switch between table view and grid view.

Definition

collection: %collection%
repository: %repository%
itemsPerPage: 10
columns:
    fullname:
        label: Name
        link:
            destination: PersonDetail:deafult
            args:
                id: id
        sort:
            isDefault: true
    gender:
        label: Gender
        columnName: genderLabel
        filter:
            options: %genderFilterOptions%
            prompt: Both        
    birthday:
        label: Birthday
        align: right
        latteFilter:
            name: date
            args: j. n. Y
        sort:
views:
    table:
    grid:

Component

public function createComponentPersonDataset()
{
    return Stepapo\Dataset\UI\Dataset::createFromNeon(__DIR__ . '/personDataset.neon', [
        'collection' => $this->orm->personRepository->findAll()
        'repository' => $this->orm->personRepository
        'genderFilterOptions' => ['m' => 'Male', 'f' => 'Female']
    ]);
}

Template

{control personDataset}

Configuration

Dataset

collection:
repository:
parentEntity:
itemsPerPage:
translator:
imageStorage:
itemClassCallback:
idColumnName:
alwaysRetrieveItems:
columns:
    example column: # include Column configuration
     another example column: # include Column configuration
views:
    table: # include View configuration
    list: # include View configuration
text: # include Text configuration
search: # include Search configuration

Column

label:
description:
width:
align:
columnName:
prepend:
append:
valueTemplateFile:
hide:
class:
filter: # include Filter configuration
sort: # include Sort configuration
latteFilter: # include LatteFilter configuration
link: # include Link configuration

View

label:
datasetTemplate:
itemListTemplate:
itemTemplate:
valueTemplate:
filterListTemplate:
filterTemplate:
paginationTemplate:
sortingTemplate:
displayTemplate:
searchTemplate:
itemFactoryCallback:
isDefault:

Search

placeholder:
prepareCallback:
suggestCallback:
searchFunction: # include OrmFunction configuration
sortFunction: # include OrmFunction configuration 

Text

search:
sort:
display:
previous:
next:
noResults:
searchResults:
didYouMean:

Filter

prompt:
collapse:
columnName:
function:
hide:
options:
    example option: # include Option configuration
    another example option: # include Option configuration

Sort

idDefault:
direction:
function: # include OrmFunction configuration

Link

destination:
args:

LatteFilter

name:
args:

Option

name:
label:
condition:

OrmFunction

class:
args: