sandstorm/lazydatasource
最新稳定版本:3.0
Composer 安装命令:
composer require sandstorm/lazydatasource
包简介
Neos package implementing a lazy data source for the UI; so that the elements are loaded lazily on demand.
README 文档
README
Inspector Data Sources in Neos are usually eager, this means the UI sends a single request to the backend to load all options, and then doing the filtering client-side.
This package implements additional Inspector Editors, behaving like the standard SelectBoxEditor with data sources, but delegates filtering and searching to the server-side.
This greatly improves Neos UI performance for data sources with big collections (100s of elements).
Getting started
-
Default composer installation via:
composer require sandstorm/lazydatasource
-
for a single select:
In your
NodeTypes.yaml, activate the custom editor by usingSandstorm.LazyDataSource/Inspector/Editors/DataSourceSelectEditorinstead ofNeos.Neos/Inspector/Editors/SelectBoxEditor. **All configuration options of the data source-based select apply as usual.Additionally, we support the following additional
editorOptions:dataSourceMakeNodeIndependent: if set to TRUE, the currently selected node is NOT sent to the data source on the backend, increasing the cache lifetime on the client (e.g. the system can re-use elements from other nodes)
Example:
'Neos.Demo:Document.Page': properties: test: ui: inspector: group: 'document' ##### THIS IS THE RELEVANT CONFIG: editor: 'Sandstorm.LazyDataSource/Inspector/Editors/DataSourceSelectEditor' ##### all Select options (e.g. dataSourceAdditionalData) work as usual. editorOptions: placeholder: Choose dataSourceIdentifier: lazy-editor-test
-
for a multi select:
In your
NodeTypes.yaml, activate the custom editor by usingSandstorm.LazyDataSource/Inspector/Editors/DataSourceSelectEditorinstead ofNeos.Neos/Inspector/Editors/SelectBoxEditor. **All configuration options of the data source-based select apply as usual.Additionally, we support the following additional
editorOptions:dataSourceMakeNodeIndependent: if set to TRUE, the currently selected node is NOT sent to the data source on the backend, increasing the cache lifetime on the client (e.g. the system can re-use elements from other nodes)
Example:
'Neos.Demo:Document.Page': properties: test2: ##### Do not forget to set the property type to array<string> type: array<string> ui: inspector: group: 'document' ##### THIS IS THE RELEVANT CONFIG: editor: 'Sandstorm.LazyDataSource/Inspector/Editors/DataSourceSelectEditor' ##### all Select options (e.g. dataSourceAdditionalData) work as usual. editorOptions: allowEmpty: true multiple: true placeholder: Choose dataSourceIdentifier: lazy-editor-test
Do not forget to set the property type to
array<string>. -
In your
DataSourceimplementation on the server, use theLazyDataSourceTraitand implement the two methodsgetDataForIdentifiers()andsearchData(). Do not implementgetData()(as this is provided by the trait).getDataForIdentifiers()is called during the initial call, when the client-side needs to resolve entries for certain identifiers.searchData()is called when the user has entered a search term, and needs to perform the searching.
The return value for both methods needs to be the same as for normal data sources.
Example:
use Neos\Neos\Service\DataSource\AbstractDataSource; use Neos\ContentRepository\Domain\Model\NodeInterface; class MyLazyDataSource extends AbstractDataSource { use LazyDataSourceTrait; static protected $identifier = 'lazy-editor-test'; protected function getDataForIdentifiers(array $identifiers, NodeInterface $node = null, array $arguments = []) { $options = []; foreach ($identifiers as $id) { $options[$id] = ['label' => 'My Label for ' . $id]; } return $options; } protected function searchData(string $searchTerm, NodeInterface $node = null, array $arguments = []) { $options = []; $options['key'] = ['label' => 'My Label ' . $searchTerm]; return $options; } }
Development
This project works with yarn. The build process given by the neos developers is not very configurable, only the target dir for the buildprocess is adjustable by package.json.
nvm install
If you don't have yarn already installed:
brew install yarn
Build the app:
./dev.sh setup ./dev.sh build
Contribute
You are very welcome to contribute by merge requests, adding issues etc.
统计信息
- 总下载量: 39.34k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 10
- 点击次数: 1
- 依赖项目数: 3
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-11-12