PR fixes.

This commit is contained in:
Mojmir Fendek 2024-10-14 13:37:13 +13:00
parent 97c03dbba5
commit 556cb36638
2 changed files with 8 additions and 14 deletions

View File

@ -119,9 +119,7 @@ class ReportAdmin extends LeftAndMain implements PermissionProvider
} }
return $output return $output
// Provide a good default for the reports order, otherwise this will be using sort by namespace
->sort('Title', 'ASC') ->sort('Title', 'ASC')
// Provide a good default for the data class, otherwise this will use the class of the first item in the list
->setDataClass(Report::class); ->setDataClass(Report::class);
} }
@ -250,14 +248,16 @@ class ReportAdmin extends LeftAndMain implements PermissionProvider
GridFieldPaginator::create() GridFieldPaginator::create()
); );
$titleLabel = _t('SilverStripe\\Reports\\ReportAdmin.ReportTitle', 'Title');
$descriptionLabel = _t('SilverStripe\\Reports\\ReportAdmin.ReportDescription', 'Description');
// Configure the filter header filter search form // Configure the filter header filter search form
$generalField = BasicSearchContext::config()->get('general_search_field_name'); $generalField = BasicSearchContext::config()->get('general_search_field_name');
$searchFieldList = FieldList::create([ $searchFieldList = FieldList::create([
HiddenField::create($generalField), HiddenField::create($generalField),
TextField::create('Title'), TextField::create('Title', $titleLabel),
TextField::create('Description'), TextField::create('Description', $descriptionLabel),
]); ]);
$searchContext = BasicSearchContext::create(Report::class); $searchContext = BasicSearchContext::create(Report::class);
$searchContext->setFields($searchFieldList); $searchContext->setFields($searchFieldList);
@ -266,22 +266,16 @@ class ReportAdmin extends LeftAndMain implements PermissionProvider
'Title', 'Title',
'Description', 'Description',
]; ];
foreach ($filters as $fieldName) { foreach ($filters as $fieldName) {
$fieldFilter = PartialMatchFilter::create($fieldName); $fieldFilter = PartialMatchFilter::create($fieldName);
$fieldFilter->setModifiers([
// We want case-insensitive match to be consistent with other areas of the CMS
'nocase',
]);
$searchContext->addFilter($fieldFilter); $searchContext->addFilter($fieldFilter);
} }
$filterHeader->setSearchContext($searchContext); $filterHeader->setSearchContext($searchContext);
$gridField = GridField::create('Reports', false, $this->Reports(), $gridFieldConfig); $gridField = GridField::create('Reports', false, $this->Reports(), $gridFieldConfig);
$columns->setDisplayFields(array( $columns->setDisplayFields(array(
'title' => _t('SilverStripe\\Reports\\ReportAdmin.ReportTitle', 'Title'), 'title' => $titleLabel,
'description' => _t('SilverStripe\\Reports\\ReportAdmin.ReportDescription', 'Description'), 'description' => $descriptionLabel,
)); ));
$columns->setFieldFormatting([ $columns->setFieldFormatting([

View File

@ -21,7 +21,7 @@
], ],
"require": { "require": {
"php": "^8.1", "php": "^8.1",
"silverstripe/framework": "^5", "silverstripe/framework": "^5.2",
"silverstripe/admin": "^2", "silverstripe/admin": "^2",
"silverstripe/versioned": "^2", "silverstripe/versioned": "^2",
"silverstripe/config": "^2", "silverstripe/config": "^2",