From 6e3f8ff982850d5f4ac7e86e7506964e2e45f701 Mon Sep 17 00:00:00 2001 From: Aaron Carlino Date: Wed, 7 Nov 2018 16:31:28 +1300 Subject: [PATCH 01/13] Update translations --- lang/da.yml | 7 +++++++ lang/nl.yml | 7 +++++++ 2 files changed, 14 insertions(+) create mode 100644 lang/da.yml create mode 100644 lang/nl.yml diff --git a/lang/da.yml b/lang/da.yml new file mode 100644 index 00000000..c89332ae --- /dev/null +++ b/lang/da.yml @@ -0,0 +1,7 @@ +da: + SilverStripe\Reports\ReportAdmin: + MENUTITLE: Rapporter + ReportTitle: Titel + SilverStripe\Reports\SideReport: + OtherGroupTitle: Andre + REPEMPTY: 'Rapporten {title} er tom.' diff --git a/lang/nl.yml b/lang/nl.yml new file mode 100644 index 00000000..f2539bb3 --- /dev/null +++ b/lang/nl.yml @@ -0,0 +1,7 @@ +nl: + SilverStripe\Reports\ReportAdmin: + MENUTITLE: Rapporten + ReportTitle: Naam + SilverStripe\Reports\SideReport: + OtherGroupTitle: Overig + REPEMPTY: 'Het {title} rapport is leeg.' From 9ec437d0334156a55cf004422cdde93962947224 Mon Sep 17 00:00:00 2001 From: Aaron Carlino Date: Wed, 7 Nov 2018 17:57:46 +1300 Subject: [PATCH 02/13] Update translations --- lang/da.yml | 7 +++++++ lang/nl.yml | 7 +++++++ 2 files changed, 14 insertions(+) create mode 100644 lang/da.yml create mode 100644 lang/nl.yml diff --git a/lang/da.yml b/lang/da.yml new file mode 100644 index 00000000..c89332ae --- /dev/null +++ b/lang/da.yml @@ -0,0 +1,7 @@ +da: + SilverStripe\Reports\ReportAdmin: + MENUTITLE: Rapporter + ReportTitle: Titel + SilverStripe\Reports\SideReport: + OtherGroupTitle: Andre + REPEMPTY: 'Rapporten {title} er tom.' diff --git a/lang/nl.yml b/lang/nl.yml new file mode 100644 index 00000000..f2539bb3 --- /dev/null +++ b/lang/nl.yml @@ -0,0 +1,7 @@ +nl: + SilverStripe\Reports\ReportAdmin: + MENUTITLE: Rapporten + ReportTitle: Naam + SilverStripe\Reports\SideReport: + OtherGroupTitle: Overig + REPEMPTY: 'Het {title} rapport is leeg.' From c48cb248dcee8c2d4bd682af68d611dd496fcd86 Mon Sep 17 00:00:00 2001 From: Vagrant Default User Date: Wed, 7 Nov 2018 21:37:37 +1300 Subject: [PATCH 03/13] Update translations --- lang/da.yml | 7 +++++++ lang/nl.yml | 7 +++++++ lang/pl.yml | 7 +++++++ 3 files changed, 21 insertions(+) create mode 100644 lang/da.yml create mode 100644 lang/nl.yml create mode 100644 lang/pl.yml diff --git a/lang/da.yml b/lang/da.yml new file mode 100644 index 00000000..c89332ae --- /dev/null +++ b/lang/da.yml @@ -0,0 +1,7 @@ +da: + SilverStripe\Reports\ReportAdmin: + MENUTITLE: Rapporter + ReportTitle: Titel + SilverStripe\Reports\SideReport: + OtherGroupTitle: Andre + REPEMPTY: 'Rapporten {title} er tom.' diff --git a/lang/nl.yml b/lang/nl.yml new file mode 100644 index 00000000..f2539bb3 --- /dev/null +++ b/lang/nl.yml @@ -0,0 +1,7 @@ +nl: + SilverStripe\Reports\ReportAdmin: + MENUTITLE: Rapporten + ReportTitle: Naam + SilverStripe\Reports\SideReport: + OtherGroupTitle: Overig + REPEMPTY: 'Het {title} rapport is leeg.' diff --git a/lang/pl.yml b/lang/pl.yml new file mode 100644 index 00000000..7f200b85 --- /dev/null +++ b/lang/pl.yml @@ -0,0 +1,7 @@ +pl: + SilverStripe\Reports\ReportAdmin: + MENUTITLE: Raporty + ReportTitle: Tytuł + SilverStripe\Reports\SideReport: + OtherGroupTitle: Inne + REPEMPTY: 'Raport {title} jest pusty' From dea66bc037e8531c8746a397c2ba21e84a94c464 Mon Sep 17 00:00:00 2001 From: Aaron Carlino Date: Thu, 8 Nov 2018 16:25:42 +1300 Subject: [PATCH 04/13] Update translations --- lang/da.yml | 7 +++++++ lang/nl.yml | 7 +++++++ lang/pl.yml | 7 +++++++ lang/sv.yml | 7 +++++++ 4 files changed, 28 insertions(+) create mode 100644 lang/da.yml create mode 100644 lang/nl.yml create mode 100644 lang/pl.yml create mode 100644 lang/sv.yml diff --git a/lang/da.yml b/lang/da.yml new file mode 100644 index 00000000..c89332ae --- /dev/null +++ b/lang/da.yml @@ -0,0 +1,7 @@ +da: + SilverStripe\Reports\ReportAdmin: + MENUTITLE: Rapporter + ReportTitle: Titel + SilverStripe\Reports\SideReport: + OtherGroupTitle: Andre + REPEMPTY: 'Rapporten {title} er tom.' diff --git a/lang/nl.yml b/lang/nl.yml new file mode 100644 index 00000000..f2539bb3 --- /dev/null +++ b/lang/nl.yml @@ -0,0 +1,7 @@ +nl: + SilverStripe\Reports\ReportAdmin: + MENUTITLE: Rapporten + ReportTitle: Naam + SilverStripe\Reports\SideReport: + OtherGroupTitle: Overig + REPEMPTY: 'Het {title} rapport is leeg.' diff --git a/lang/pl.yml b/lang/pl.yml new file mode 100644 index 00000000..7f200b85 --- /dev/null +++ b/lang/pl.yml @@ -0,0 +1,7 @@ +pl: + SilverStripe\Reports\ReportAdmin: + MENUTITLE: Raporty + ReportTitle: Tytuł + SilverStripe\Reports\SideReport: + OtherGroupTitle: Inne + REPEMPTY: 'Raport {title} jest pusty' diff --git a/lang/sv.yml b/lang/sv.yml new file mode 100644 index 00000000..ce219356 --- /dev/null +++ b/lang/sv.yml @@ -0,0 +1,7 @@ +sv: + SilverStripe\Reports\ReportAdmin: + MENUTITLE: Rapporter + ReportTitle: Titel + SilverStripe\Reports\SideReport: + OtherGroupTitle: Annat + REPEMPTY: 'Rapporten {title} är tom.' From edecbabe610bafd76045da3652dfa498e16dfb67 Mon Sep 17 00:00:00 2001 From: Guy Marriott Date: Fri, 16 Nov 2018 15:09:45 +1300 Subject: [PATCH 05/13] NEW Allow reports to specify breadcrumbs for child reports --- code/Report.php | 17 +++++++++++++---- code/ReportAdmin.php | 16 +++++++++++++--- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/code/Report.php b/code/Report.php index dad52df2..3a87e659 100644 --- a/code/Report.php +++ b/code/Report.php @@ -29,6 +29,7 @@ use SilverStripe\ORM\SS_List; use SilverStripe\Security\Member; use SilverStripe\Security\Permission; use SilverStripe\Security\Security; +use SilverStripe\View\ArrayData; use SilverStripe\View\ViewableData; /** @@ -464,10 +465,8 @@ class Report extends ViewableData /** - * Return the name of this report, which - * is used by the templates to render the - * name of the report in the report tree, - * the left hand pane inside ReportAdmin. + * Return the name of this report, which is used by the templates to render the name of the report in the report + * tree, the left hand pane inside ReportAdmin. * * @return string */ @@ -475,4 +474,14 @@ class Report extends ViewableData { return $this->title(); } + + /** + * Return additional breadcrumbs for this report. Useful when this report is a child of another. + * + * @return ArrayData[] + */ + public function getBreadcrumbs() + { + return []; + } } diff --git a/code/ReportAdmin.php b/code/ReportAdmin.php index 8173681e..b18a1d9f 100644 --- a/code/ReportAdmin.php +++ b/code/ReportAdmin.php @@ -172,11 +172,21 @@ class ReportAdmin extends LeftAndMain implements PermissionProvider // Uses session state for current record otherwise. $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 $items->push(new ArrayData(array( - 'Title' => $this->reportObject->title(), - 'Link' => Controller::join_links($this->Link(), '?' . http_build_query(array('q' => $this->request->requestVar('q')))) + 'Title' => $report->title(), + 'Link' => Controller::join_links( + $this->Link(), + '?' . http_build_query(array('q' => $this->request->requestVar('q'))) + ) ))); } From d6b1c071b6c04d44c13ac1737f406495381caec1 Mon Sep 17 00:00:00 2001 From: Guy Marriott Date: Mon, 19 Nov 2018 11:48:23 +1300 Subject: [PATCH 06/13] NEW Adding tests for new report breadcrumbs feature --- tests/ReportAdminTest.php | 75 +++++++++++++++++++++++++++ tests/ReportAdminTest/FakeReport.php | 13 +++++ tests/ReportAdminTest/FakeReport2.php | 24 +++++++++ 3 files changed, 112 insertions(+) create mode 100644 tests/ReportAdminTest.php create mode 100644 tests/ReportAdminTest/FakeReport.php create mode 100644 tests/ReportAdminTest/FakeReport2.php diff --git a/tests/ReportAdminTest.php b/tests/ReportAdminTest.php new file mode 100644 index 00000000..97e5b49c --- /dev/null +++ b/tests/ReportAdminTest.php @@ -0,0 +1,75 @@ +mockController($noExtraCrumbs); + $breadcrumbs = $controller->BreadCrumbs(); + + $this->assertCount(2, $breadcrumbs); + + $this->assertArraySubset([ + 'Title' => 'Reports', + 'Link' => 'admin/reports/', + ], $breadcrumbs[0]->toMap(), true, 'Link to top level reports is within breadcrumbs'); + + $this->assertArraySubset([ + 'Title' => 'Fake report' + ], $breadcrumbs[1]->toMap(), true, 'Current report is within breadcrumbs'); + + $extraCrumbs = FakeReport2::create(); + $controller = $this->mockController($extraCrumbs); + $breadcrumbs = $controller->Breadcrumbs(); + + $this->assertCount(3, $breadcrumbs); + + $this->assertArraySubset([ + 'Title' => 'Reports', + 'Link' => 'admin/reports/', + ], $breadcrumbs[0]->toMap(), true, 'Link to top level reports is within breadcrumbs (again)'); + + $this->assertArraySubset([ + 'Title' => 'Fake report title', + 'Link' => 'admin/reports/show/SilverStripe-Reports-Tests-ReportAdminTest-FakeReport', + ], $breadcrumbs[1]->toMap(), true, 'Custom breadcrumb appears'); + + $this->assertArraySubset([ + 'Title' => 'Fake report two' + ], $breadcrumbs[2]->toMap(), true, 'Current report is still within breadcrumbs'); + } + + /** + * @param Report $report + * @return ReportAdmin + * @throws \ReflectionException + */ + protected function mockController(Report $report) + { + $reflector = new ReflectionClass($controller = ReportAdmin::create()); + + $reportClass = $reflector->getProperty('reportClass'); + $reportClass->setAccessible(true); + $reportClass->setValue($controller, get_class($report)); + + $reportObject = $reflector->getProperty('reportObject'); + $reportObject->setAccessible(true); + $reportObject->setValue($controller, $report); + + $controller->setRequest(Controller::curr()->getRequest()); + + return $controller; + } +} diff --git a/tests/ReportAdminTest/FakeReport.php b/tests/ReportAdminTest/FakeReport.php new file mode 100644 index 00000000..c0a377c8 --- /dev/null +++ b/tests/ReportAdminTest/FakeReport.php @@ -0,0 +1,13 @@ + 'Fake report title', + 'Link' => FakeReport::singleton()->getLink() + ])]; + } +} From 52a234410d9337b812e6b1ef615850c0b3df3f7a Mon Sep 17 00:00:00 2001 From: Guy Marriott Date: Tue, 20 Nov 2018 17:52:48 +1300 Subject: [PATCH 07/13] NEW Extracting out the method to determine parameters (filters) for update the report sourceRecords --- code/Report.php | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/code/Report.php b/code/Report.php index 3a87e659..5eee3d0c 100644 --- a/code/Report.php +++ b/code/Report.php @@ -346,12 +346,7 @@ class Report extends ViewableData */ public function getReportField() { - $params = []; - if (Injector::inst()->has(HTTPRequest::class)) { - /** @var HTTPRequest $request */ - $request = Injector::inst()->get(HTTPRequest::class); - $params = $request->param('filters') ?: $request->requestVar('filters') ?: []; - } + $params = $this->getSourceParams(); $items = $this->sourceRecords($params, null, null); $gridFieldConfig = GridFieldConfig::create()->addComponents( @@ -484,4 +479,23 @@ class Report extends ViewableData { return []; } + + /** + * Get source params for the report to filter by + * + * @return array + */ + protected function getSourceParams() + { + $params = []; + if (Injector::inst()->has(HTTPRequest::class)) { + /** @var HTTPRequest $request */ + $request = Injector::inst()->get(HTTPRequest::class); + $params = $request->param('filters') ?: $request->requestVar('filters') ?: []; + } + + $this->extend('updateSourceParams', $params); + + return $params; + } } From a344110a10acc4897b864c714c9b202b633a06a7 Mon Sep 17 00:00:00 2001 From: Dylan Wagstaff Date: Fri, 15 Jun 2018 17:46:23 +1200 Subject: [PATCH 08/13] Add supported module badge to readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 7cc50613..30c71851 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # Reports [![Build Status](https://secure.travis-ci.org/silverstripe/silverstripe-reports.png?branch=master)](http://travis-ci.org/silverstripe/silverstripe-reports) +[![SilverStripe supported module](https://img.shields.io/badge/silverstripe-supported-0071C4.svg)](https://www.silverstripe.org/software/addons/silverstripe-commercially-supported-module-list/) ## Introduction From ebe98f487a035986b3b68b51d9546b774f7665c8 Mon Sep 17 00:00:00 2001 From: Maxime Rainville Date: Tue, 26 Jun 2018 17:39:51 +1200 Subject: [PATCH 09/13] Increment travis root version to 4.3.x-dev --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4cab1605..10c64607 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ cache: env: global: - - COMPOSER_ROOT_VERSION=4.2.x-dev + - COMPOSER_ROOT_VERSION=4.3.x-dev - CORE_RELEASE=master matrix: @@ -31,7 +31,7 @@ before_script: - composer validate - if [[ $DB == PGSQL ]]; then composer require silverstripe/postgresql:2.0.x-dev --no-update; fi - if [[ $DB == SQLITE ]]; then composer require silverstripe/sqlite3:2.0.x-dev --no-update; fi - - composer require silverstripe/recipe-core:4.2.x-dev silverstripe/admin:1.2.x-dev silverstripe/versioned:1.2.x-dev --no-update + - composer require silverstripe/recipe-core:4.3.x-dev silverstripe/admin:1.3.x-dev silverstripe/versioned:1.3.x-dev --no-update - if [[ $PHPCS_TEST ]]; then composer global require squizlabs/php_codesniffer:^3 --prefer-dist --no-interaction --no-progress --no-suggest -o; fi - composer install --prefer-dist --no-interaction --no-progress --no-suggest --optimize-autoloader --verbose --profile From 9270206c3bd2fe35bb263ad43ad3a5d87360873a Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Mon, 16 Jul 2018 17:07:00 +1200 Subject: [PATCH 10/13] NEW Use Injector to create new class instances and pass $params Also adds a couple of missing PHPDoc annotations for IDE hints --- code/Report.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/code/Report.php b/code/Report.php index c9727a86..dad52df2 100644 --- a/code/Report.php +++ b/code/Report.php @@ -164,11 +164,11 @@ class Report extends ViewableData if ($this->hasMethod('sourceRecords')) { return $this->sourceRecords($params, null, null); } else { - $query = $this->sourceQuery(); - $results = new ArrayList(); + $query = $this->sourceQuery($params); + $results = ArrayList::create(); foreach ($query->execute() as $data) { $class = $this->dataClass(); - $result = new $class($data); + $result = Injector::inst()->create($class, $data); $results->push($result); } return $results; @@ -362,7 +362,9 @@ class Report extends ViewableData new GridFieldDataColumns(), new GridFieldPaginator() ); - $gridField = new GridField('Report', null, $items, $gridFieldConfig); + /** @var GridField $gridField */ + $gridField = GridField::create('Report', null, $items, $gridFieldConfig); + /** @var GridFieldDataColumns $columns */ $columns = $gridField->getConfig()->getComponentByType(GridFieldDataColumns::class); $displayFields = []; $fieldCasting = []; From bc70b87721c8278111e39e0af69db1052af7333f Mon Sep 17 00:00:00 2001 From: Maxime Rainville Date: Fri, 27 Jul 2018 17:06:38 +1200 Subject: [PATCH 11/13] FIX Apply missing class to report header. --- templates/SilverStripe/Reports/Includes/ReportAdmin_Content.ss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/SilverStripe/Reports/Includes/ReportAdmin_Content.ss b/templates/SilverStripe/Reports/Includes/ReportAdmin_Content.ss index 03f2cfb0..5af437d1 100644 --- a/templates/SilverStripe/Reports/Includes/ReportAdmin_Content.ss +++ b/templates/SilverStripe/Reports/Includes/ReportAdmin_Content.ss @@ -2,7 +2,7 @@
<% with $EditForm %> -
+
<% include SilverStripe\\Admin\\BackLink_Button %> <% with $Controller %> <% include SilverStripe\\Admin\\CMSBreadcrumbs %> From 9d94712c0470391a4ff99c5555104420d94d7551 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Guevremont?= Date: Fri, 4 Jan 2019 21:30:42 -0500 Subject: [PATCH 12/13] Create fr.yml Missing french translation --- lang/fr.yml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 lang/fr.yml diff --git a/lang/fr.yml b/lang/fr.yml new file mode 100644 index 00000000..ee05f49c --- /dev/null +++ b/lang/fr.yml @@ -0,0 +1,7 @@ +fr: + SilverStripe\Reports\ReportAdmin: + MENUTITLE: Rapports + ReportTitle: Titre + SilverStripe\Reports\SideReport: + OtherGroupTitle: Autre + REPEMPTY: 'Le rapport {title} est vide.' From 9b89812058d70246991ccd12847927d9a4c5bf4b Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Sun, 21 Apr 2019 11:27:08 +1200 Subject: [PATCH 13/13] Remove obsolete branch alias --- composer.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/composer.json b/composer.json index 42f178cc..0bb29571 100644 --- a/composer.json +++ b/composer.json @@ -31,9 +31,6 @@ "phpunit/phpunit": "^5.7" }, "extra": { - "branch-alias": { - "4.x-dev": "4.4.x-dev" - }, "expose": [ "javascript" ]