mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
NEW Allow reports to specify breadcrumbs for child reports
This commit is contained in:
parent
7d4d7c05e6
commit
edecbabe61
@ -29,6 +29,7 @@ use SilverStripe\ORM\SS_List;
|
|||||||
use SilverStripe\Security\Member;
|
use SilverStripe\Security\Member;
|
||||||
use SilverStripe\Security\Permission;
|
use SilverStripe\Security\Permission;
|
||||||
use SilverStripe\Security\Security;
|
use SilverStripe\Security\Security;
|
||||||
|
use SilverStripe\View\ArrayData;
|
||||||
use SilverStripe\View\ViewableData;
|
use SilverStripe\View\ViewableData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -464,10 +465,8 @@ class Report extends ViewableData
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the name of this report, which
|
* Return the name of this report, which is used by the templates to render the name of the report in the report
|
||||||
* is used by the templates to render the
|
* tree, the left hand pane inside ReportAdmin.
|
||||||
* name of the report in the report tree,
|
|
||||||
* the left hand pane inside ReportAdmin.
|
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
@ -475,4 +474,14 @@ class Report extends ViewableData
|
|||||||
{
|
{
|
||||||
return $this->title();
|
return $this->title();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return additional breadcrumbs for this report. Useful when this report is a child of another.
|
||||||
|
*
|
||||||
|
* @return ArrayData[]
|
||||||
|
*/
|
||||||
|
public function getBreadcrumbs()
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -172,11 +172,21 @@ class ReportAdmin extends LeftAndMain implements PermissionProvider
|
|||||||
// Uses session state for current record otherwise.
|
// Uses session state for current record otherwise.
|
||||||
$items[0]->Link = singleton('SilverStripe\\Reports\\ReportAdmin')->Link();
|
$items[0]->Link = singleton('SilverStripe\\Reports\\ReportAdmin')->Link();
|
||||||
|
|
||||||
if ($this->reportObject) {
|
if ($report = $this->reportObject) {
|
||||||
|
$breadcrumbs = $report->getBreadcrumbs();
|
||||||
|
if (!empty($breadcrumbs)) {
|
||||||
|
foreach ($breadcrumbs as $crumb) {
|
||||||
|
$items->push($crumb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//build breadcrumb trail to the current report
|
//build breadcrumb trail to the current report
|
||||||
$items->push(new ArrayData(array(
|
$items->push(new ArrayData(array(
|
||||||
'Title' => $this->reportObject->title(),
|
'Title' => $report->title(),
|
||||||
'Link' => Controller::join_links($this->Link(), '?' . http_build_query(array('q' => $this->request->requestVar('q'))))
|
'Link' => Controller::join_links(
|
||||||
|
$this->Link(),
|
||||||
|
'?' . http_build_query(array('q' => $this->request->requestVar('q')))
|
||||||
|
)
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user