mirror of
https://github.com/silverstripe/silverstripe-frameworktest
synced 2024-10-22 11:06:02 +02:00
Merge branch '1' into 2
This commit is contained in:
commit
d08de7d8c3
4
.github/workflows/update-js.yml
vendored
4
.github/workflows/update-js.yml
vendored
@ -2,9 +2,9 @@ name: Update JS
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
# Run on a schedule of once per quarter
|
# At 4:20 AM UTC, on day 1 of the month, only in March and September
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '20 4 1 */3 *'
|
- cron: '20 4 1 3,9 *'
|
||||||
|
|
||||||
permissions: {}
|
permissions: {}
|
||||||
|
|
||||||
|
@ -15,6 +15,19 @@ SilverStripe\FrameworkTest\Model\Employee:
|
|||||||
extensions:
|
extensions:
|
||||||
- SilverStripe\FrameworkTest\Extension\TestDataObjectExtension
|
- SilverStripe\FrameworkTest\Extension\TestDataObjectExtension
|
||||||
|
|
||||||
|
SilverStripe\FrameworkTest\Fields\NestedGridField\RootNode:
|
||||||
|
extensions:
|
||||||
|
- SilverStripe\FrameworkTest\Extension\TestDataObjectExtension
|
||||||
|
SilverStripe\FrameworkTest\Fields\NestedGridField\BranchNode:
|
||||||
|
extensions:
|
||||||
|
- SilverStripe\FrameworkTest\Extension\TestDataObjectExtension
|
||||||
|
SilverStripe\FrameworkTest\Fields\NestedGridField\LeafNode:
|
||||||
|
extensions:
|
||||||
|
- SilverStripe\FrameworkTest\Extension\TestDataObjectExtension
|
||||||
|
SilverStripe\FrameworkTest\Fields\NestedGridField\NonRelationalData:
|
||||||
|
extensions:
|
||||||
|
- SilverStripe\FrameworkTest\Extension\TestDataObjectExtension
|
||||||
|
|
||||||
SilverStripe\ORM\DatabaseAdmin:
|
SilverStripe\ORM\DatabaseAdmin:
|
||||||
extensions:
|
extensions:
|
||||||
- SilverStripe\FrameworkTest\GridFieldArbitraryData\DatabaseBuildExtension
|
- SilverStripe\FrameworkTest\GridFieldArbitraryData\DatabaseBuildExtension
|
||||||
|
38
code/fields/NestedGridField/BranchNode.php
Normal file
38
code/fields/NestedGridField/BranchNode.php
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\FrameworkTest\Fields\NestedGridField;
|
||||||
|
|
||||||
|
use SilverStripe\Forms\GridField\GridFieldConfig;
|
||||||
|
use SilverStripe\Forms\GridField\GridFieldConfig_RecordEditor;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use Symbiote\GridFieldExtensions\GridFieldNestedForm;
|
||||||
|
|
||||||
|
class BranchNode extends DataObject
|
||||||
|
{
|
||||||
|
private static $table_name = 'NestedGridField_BranchNode';
|
||||||
|
|
||||||
|
private static $db = [
|
||||||
|
'Name' => 'Varchar(50)',
|
||||||
|
'Category' => 'Varchar(50)',
|
||||||
|
];
|
||||||
|
|
||||||
|
private static $has_one = [
|
||||||
|
'RootNode' => RootNode::class,
|
||||||
|
];
|
||||||
|
|
||||||
|
private static $has_many = [
|
||||||
|
'LeafNodes' => LeafNode::class,
|
||||||
|
];
|
||||||
|
|
||||||
|
private static $summary_fields = [
|
||||||
|
'Name',
|
||||||
|
'Category',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function getNestedConfig(): GridFieldConfig
|
||||||
|
{
|
||||||
|
$config = new GridFieldConfig_RecordEditor();
|
||||||
|
$config->addComponent(GridFieldNestedForm::create()->setRelationName('LeafNodes'));
|
||||||
|
return $config;
|
||||||
|
}
|
||||||
|
}
|
24
code/fields/NestedGridField/LeafNode.php
Normal file
24
code/fields/NestedGridField/LeafNode.php
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\FrameworkTest\Fields\NestedGridField;
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
|
class LeafNode extends DataObject
|
||||||
|
{
|
||||||
|
private static $table_name = 'NestedGridField_LeafNode';
|
||||||
|
|
||||||
|
private static $db = [
|
||||||
|
'Name' => 'Varchar(50)',
|
||||||
|
'Category'=>'Varchar(255)',
|
||||||
|
];
|
||||||
|
|
||||||
|
private static $has_one = [
|
||||||
|
'BranchNode' => BranchNode::class,
|
||||||
|
];
|
||||||
|
|
||||||
|
private static $summary_fields = [
|
||||||
|
'Name',
|
||||||
|
'Category',
|
||||||
|
];
|
||||||
|
}
|
40
code/fields/NestedGridField/NestedGridFieldAdmin.php
Normal file
40
code/fields/NestedGridField/NestedGridFieldAdmin.php
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\FrameworkTest\Fields\NestedGridField;
|
||||||
|
|
||||||
|
use RuntimeException;
|
||||||
|
use SilverStripe\Admin\ModelAdmin;
|
||||||
|
use SilverStripe\Forms\GridField\GridFieldConfig;
|
||||||
|
use Symbiote\GridFieldExtensions\GridFieldNestedForm;
|
||||||
|
|
||||||
|
class NestedGridFieldAdmin extends ModelAdmin
|
||||||
|
{
|
||||||
|
private static string $url_segment = 'nested-gridfield-section';
|
||||||
|
private static string $menu_title = 'Nested GridField Section';
|
||||||
|
private static string $menu_icon_class = 'font-icon-block-banner';
|
||||||
|
|
||||||
|
private static array $managed_models = [
|
||||||
|
'root-nodes' => [
|
||||||
|
'title' => 'Root Nodes',
|
||||||
|
'dataClass' => RootNode::class,
|
||||||
|
],
|
||||||
|
'non-relational-data' => [
|
||||||
|
'title' => 'Non-Relational Data',
|
||||||
|
'dataClass' => NonRelationalData::class,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
protected function getGridFieldConfig(): GridFieldConfig
|
||||||
|
{
|
||||||
|
$config = parent::getGridFieldConfig();
|
||||||
|
if ($this->modelClass === RootNode::class) {
|
||||||
|
$config->addComponent(GridFieldNestedForm::create()->setRelationName('BranchNodes'));
|
||||||
|
} else if ($this->modelClass === NonRelationalData::class) {
|
||||||
|
$config->addComponent(GridFieldNestedForm::create()->setRelationName('getList'));
|
||||||
|
} else {
|
||||||
|
throw new RuntimeException("Unexpected Model name: {$this->tab}");
|
||||||
|
}
|
||||||
|
|
||||||
|
return $config;
|
||||||
|
}
|
||||||
|
}
|
26
code/fields/NestedGridField/NonRelationalData.php
Normal file
26
code/fields/NestedGridField/NonRelationalData.php
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\FrameworkTest\Fields\NestedGridField;
|
||||||
|
|
||||||
|
use SilverStripe\FrameworkTest\Model\Company;
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
|
class NonRelationalData extends DataObject
|
||||||
|
{
|
||||||
|
private static $table_name = 'NestedGridField_NonRelationalData';
|
||||||
|
|
||||||
|
private static $db = [
|
||||||
|
'Name' => 'Varchar(50)',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function getList() {
|
||||||
|
$list = ArrayList::create();
|
||||||
|
$data = Company::get()->limit(5);
|
||||||
|
foreach ($data as $value) {
|
||||||
|
$list->push($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $list;
|
||||||
|
}
|
||||||
|
}
|
18
code/fields/NestedGridField/RootNode.php
Normal file
18
code/fields/NestedGridField/RootNode.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\FrameworkTest\Fields\NestedGridField;
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
|
class RootNode extends DataObject
|
||||||
|
{
|
||||||
|
private static $table_name = 'NestedGridField_RootNode';
|
||||||
|
|
||||||
|
private static $db = [
|
||||||
|
'Name' => 'Varchar(50)',
|
||||||
|
];
|
||||||
|
|
||||||
|
private static $has_many = [
|
||||||
|
'BranchNodes' => BranchNode::class,
|
||||||
|
];
|
||||||
|
}
|
17
code/fields/NestedGridField/SecurityAdminExtension.php
Normal file
17
code/fields/NestedGridField/SecurityAdminExtension.php
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\FrameworkTest\Fields\NestedGridField;
|
||||||
|
|
||||||
|
use SilverStripe\Core\Extension;
|
||||||
|
use SilverStripe\Security\Group;
|
||||||
|
use Symbiote\GridFieldExtensions\GridFieldNestedForm;
|
||||||
|
|
||||||
|
class SecurityAdminExtension extends Extension
|
||||||
|
{
|
||||||
|
public function updateGridFieldConfig($config)
|
||||||
|
{
|
||||||
|
if ($this->owner->getModelClass() === Group::class) {
|
||||||
|
$config->addComponent(GridFieldNestedForm::create()->setRelationName('Members'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user