mirror of
https://github.com/a2nt/cms-niceties.git
synced 2024-10-22 11:05:46 +02:00
IMPR: GridField Inline editor config
This commit is contained in:
parent
bcfd8918fa
commit
b64e4878c4
24
README.md
24
README.md
@ -1 +1,23 @@
|
||||
# cms-niceties
|
||||
# cms-niceties
|
||||
Some useful CMS objects and extensions
|
||||
|
||||
## Usefull UNIX console utilities
|
||||
|
||||
### Code search (find . -name "*.*" | xargs grep "some text" replacement)
|
||||
|
||||
ag "some text" ./
|
||||
https://github.com/ggreer/the_silver_searcher
|
||||
|
||||
### File content with code hightlighting (cat replacement)
|
||||
|
||||
bat ./app/src/Pages/Page.php
|
||||
https://github.com/sharkdp/bat
|
||||
|
||||
### File listing (ls replacement)
|
||||
|
||||
exa -aTL3 ./app
|
||||
https://github.com/ogham/exa
|
||||
|
||||
### git diff tool with bat code hightlighting (git show)
|
||||
|
||||
https://github.com/dandavison/delta
|
59
src/Forms/GridField/GridFieldConfig_Inline.php
Normal file
59
src/Forms/GridField/GridFieldConfig_Inline.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace A2nt\CMSNiceties\Forms\GridField;
|
||||
|
||||
|
||||
use SilverStripe\Forms\GridField\GridFieldButtonRow;
|
||||
use SilverStripe\Forms\GridField\GridFieldConfig;
|
||||
use SilverStripe\Forms\GridField\GridFieldDeleteAction;
|
||||
use SilverStripe\Forms\GridField\GridFieldDetailForm;
|
||||
use SilverStripe\Forms\GridField\GridFieldEditButton;
|
||||
use SilverStripe\Forms\GridField\GridFieldFilterHeader;
|
||||
use SilverStripe\Forms\GridField\GridFieldPageCount;
|
||||
use SilverStripe\Forms\GridField\GridFieldPaginator;
|
||||
use SilverStripe\Forms\GridField\GridFieldToolbarHeader;
|
||||
use Symbiote\GridFieldExtensions\GridFieldAddNewInlineButton;
|
||||
use Symbiote\GridFieldExtensions\GridFieldEditableColumns;
|
||||
use Symbiote\GridFieldExtensions\GridFieldTitleHeader;
|
||||
|
||||
class GridFieldConfig_Inline extends GridFieldConfig
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @param bool $showDetails Whether the `Details form` should display or not, leave as null to use default
|
||||
* @param bool $showAdd Whether the `Add` button should display or not, leave as null to use default
|
||||
* @param int $itemsPerPage - How many items per page should show up
|
||||
*/
|
||||
public function __construct($showDetails = false, $showAdd = true, $itemsPerPage = 100)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this
|
||||
->addComponent(new GridFieldTitleHeader())
|
||||
->addComponent(new GridFieldEditableColumns());
|
||||
|
||||
if($showDetails) {
|
||||
$this
|
||||
->addComponent(new GridFieldDetailForm(null, true, $showAdd))
|
||||
->addComponent(new GridFieldEditButton());
|
||||
}
|
||||
|
||||
$this
|
||||
->addComponent($pagination = new GridFieldPaginator($itemsPerPage))
|
||||
->addComponent($filter = new GridFieldFilterHeader())
|
||||
->addComponent(new GridFieldPageCount('toolbar-header-right'))
|
||||
->addComponent(new GridFieldButtonRow('before'))
|
||||
->addComponent(new GridFieldToolbarHeader())
|
||||
->addComponent(new GridFieldDeleteAction());
|
||||
|
||||
if($showAdd) {
|
||||
$this->addComponent(new GridFieldAddNewInlineButton());
|
||||
}
|
||||
|
||||
$pagination->setThrowExceptionOnBadDataType(false);
|
||||
$filter->setThrowExceptionOnBadDataType(false);
|
||||
|
||||
$this->extend('updateConfig');
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user