Skip to content

Commit

Permalink
PR fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
mfendeksilverstripe committed Oct 14, 2024
1 parent 97c03db commit 556cb36
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
20 changes: 7 additions & 13 deletions code/ReportAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,7 @@ public function Reports()
}

return $output
// Provide a good default for the reports order, otherwise this will be using sort by namespace
->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);
}

Expand Down Expand Up @@ -250,14 +248,16 @@ public function getEditForm($id = null, $fields = null)
GridFieldPaginator::create()
);

$titleLabel = _t('SilverStripe\\Reports\\ReportAdmin.ReportTitle', 'Title');
$descriptionLabel = _t('SilverStripe\\Reports\\ReportAdmin.ReportDescription', 'Description');

// Configure the filter header filter search form
$generalField = BasicSearchContext::config()->get('general_search_field_name');
$searchFieldList = FieldList::create([
HiddenField::create($generalField),
TextField::create('Title'),
TextField::create('Description'),
TextField::create('Title', $titleLabel),
TextField::create('Description', $descriptionLabel),
]);

$searchContext = BasicSearchContext::create(Report::class);
$searchContext->setFields($searchFieldList);

Expand All @@ -266,22 +266,16 @@ public function getEditForm($id = null, $fields = null)
'Title',
'Description',
];

foreach ($filters as $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);
}

$filterHeader->setSearchContext($searchContext);

$gridField = GridField::create('Reports', false, $this->Reports(), $gridFieldConfig);
$columns->setDisplayFields(array(
'title' => _t('SilverStripe\\Reports\\ReportAdmin.ReportTitle', 'Title'),
'description' => _t('SilverStripe\\Reports\\ReportAdmin.ReportDescription', 'Description'),
'title' => $titleLabel,
'description' => $descriptionLabel,
));

$columns->setFieldFormatting([
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
],
"require": {
"php": "^8.1",
"silverstripe/framework": "^5",
"silverstripe/framework": "^5.2",
"silverstripe/admin": "^2",
"silverstripe/versioned": "^2",
"silverstripe/config": "^2",
Expand Down

0 comments on commit 556cb36

Please sign in to comment.