mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
Compare commits
No commits in common. "b105bdffa382c1e34dfe2a05124817a281e1d9a8" and "61ecdb74e75948df332ba642e4601b8cd66dd3c5" have entirely different histories.
b105bdffa3
...
61ecdb74e7
@ -7,20 +7,13 @@ use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\Forms\Form;
|
||||
use SilverStripe\Forms\GridField\GridField;
|
||||
use SilverStripe\Forms\GridField\GridFieldButtonRow;
|
||||
use SilverStripe\Forms\GridField\GridFieldConfig;
|
||||
use SilverStripe\Forms\GridField\GridFieldDataColumns;
|
||||
use SilverStripe\Forms\GridField\GridFieldFilterHeader;
|
||||
use SilverStripe\Forms\GridField\GridFieldPageCount;
|
||||
use SilverStripe\Forms\GridField\GridFieldPaginator;
|
||||
use SilverStripe\Forms\GridField\GridFieldFooter;
|
||||
use SilverStripe\Forms\GridField\GridFieldSortableHeader;
|
||||
use SilverStripe\Forms\HiddenField;
|
||||
use SilverStripe\Forms\HTMLEditor\HTMLEditorConfig;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\Model\List\SS_List;
|
||||
use SilverStripe\Forms\TextField;
|
||||
use SilverStripe\ORM\Filters\PartialMatchFilter;
|
||||
use SilverStripe\ORM\Search\BasicSearchContext;
|
||||
use SilverStripe\Security\Member;
|
||||
use SilverStripe\Security\PermissionProvider;
|
||||
use SilverStripe\Security\Security;
|
||||
@ -111,16 +104,13 @@ class ReportAdmin extends LeftAndMain implements PermissionProvider
|
||||
*/
|
||||
public function Reports()
|
||||
{
|
||||
$output = ArrayList::create();
|
||||
$output = new ArrayList();
|
||||
foreach (Report::get_reports() as $report) {
|
||||
if ($report->canView()) {
|
||||
$output->push($report);
|
||||
}
|
||||
}
|
||||
|
||||
return $output
|
||||
->sort('Title', 'ASC')
|
||||
->setDataClass(Report::class);
|
||||
return $output;
|
||||
}
|
||||
|
||||
public function handleAction($request, $action)
|
||||
@ -237,56 +227,28 @@ class ReportAdmin extends LeftAndMain implements PermissionProvider
|
||||
$fields = $report->getCMSFields();
|
||||
} else {
|
||||
// List all reports
|
||||
$fields = FieldList::create();
|
||||
$fields = new FieldList();
|
||||
$gridFieldConfig = GridFieldConfig::create()->addComponents(
|
||||
// This is a container component that is required by filter header component
|
||||
GridFieldButtonRow::create('before'),
|
||||
$filterHeader = GridFieldFilterHeader::create(),
|
||||
GridFieldSortableHeader::create(),
|
||||
$columns = GridFieldDataColumns::create(),
|
||||
GridFieldPageCount::create(),
|
||||
GridFieldPaginator::create()
|
||||
GridFieldDataColumns::create(),
|
||||
GridFieldFooter::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', $titleLabel),
|
||||
TextField::create('Description', $descriptionLabel),
|
||||
]);
|
||||
$searchContext = BasicSearchContext::create(Report::class);
|
||||
$searchContext->setFields($searchFieldList);
|
||||
|
||||
// Setup filter configuration - partial match with case-insensitive modifier
|
||||
$filters = [
|
||||
'Title',
|
||||
'Description',
|
||||
];
|
||||
foreach ($filters as $fieldName) {
|
||||
$fieldFilter = PartialMatchFilter::create($fieldName);
|
||||
$searchContext->addFilter($fieldFilter);
|
||||
}
|
||||
$filterHeader->setSearchContext($searchContext);
|
||||
|
||||
$gridField = GridField::create('Reports', false, $this->Reports(), $gridFieldConfig);
|
||||
$columns = $gridField->getConfig()
|
||||
->getComponentByType(GridFieldDataColumns::class);
|
||||
$columns->setDisplayFields(array(
|
||||
'title' => $titleLabel,
|
||||
'description' => $descriptionLabel,
|
||||
'title' => _t('SilverStripe\\Reports\\ReportAdmin.ReportTitle', 'Title'),
|
||||
));
|
||||
|
||||
$columns->setFieldFormatting([
|
||||
'title' => '<a href=\"$Link\" class=\"grid-field__link-block\">$value ($CountForOverview)</a>'
|
||||
]);
|
||||
$columns->setFieldFormatting(array(
|
||||
'title' => '<a href=\"$Link\" class=\"grid-field__link-block\">$value ($CountForOverview)</a>'
|
||||
));
|
||||
$gridField->addExtraClass('all-reports-gridfield');
|
||||
$fields->push($gridField);
|
||||
}
|
||||
|
||||
$actions = FieldList::create();
|
||||
$form = Form::create($this, "EditForm", $fields, $actions);
|
||||
$actions = new FieldList();
|
||||
$form = new Form($this, "EditForm", $fields, $actions);
|
||||
$form->addExtraClass(
|
||||
'panel panel--padded panel--scrollable cms-edit-form cms-panel-padded' . $this->BaseCSSClasses()
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user