From 23186d76e8632683f6658e42c93488ac854d65d5 Mon Sep 17 00:00:00 2001 From: Thomas Steur Date: Tue, 4 Mar 2014 03:54:21 +0100 Subject: [PATCH] refs #57 make sure text ellipsis works and label is always only one line. moved test fixture to insights plugin as demonstration for other plugin developers as it is very insights related anyway --- plugins/Insights/API.php | 2 +- plugins/Insights/Controller.php | 2 +- plugins/Insights/javascripts/insightsDataTable.js | 8 ++++++++ plugins/Insights/tests/ApiTest.php | 5 +++-- .../tests}/Fixtures/SomeVisitsDifferentPathsOnTwoDays.php | 6 ++++-- 5 files changed, 17 insertions(+), 6 deletions(-) rename {tests/PHPUnit => plugins/Insights/tests}/Fixtures/SomeVisitsDifferentPathsOnTwoDays.php (94%) diff --git a/plugins/Insights/API.php b/plugins/Insights/API.php index 131bc65c01e..08eedc1f557 100644 --- a/plugins/Insights/API.php +++ b/plugins/Insights/API.php @@ -58,7 +58,7 @@ public function getInsightsOverview($idSite, $period, $date) for ($index = $firstTableId; $index <= $lastTableId; $index++) { if (!in_array($index, $reportTableIds)) { - DataTable\Manager::getInstance()->deleteTable($index); + $dataTableManager->deleteTable($index); } } diff --git a/plugins/Insights/Controller.php b/plugins/Insights/Controller.php index 6512487a9fe..8526052215c 100644 --- a/plugins/Insights/Controller.php +++ b/plugins/Insights/Controller.php @@ -13,7 +13,7 @@ use Piwik\View; /** - * + * Insights Controller */ class Controller extends \Piwik\Plugin\Controller { diff --git a/plugins/Insights/javascripts/insightsDataTable.js b/plugins/Insights/javascripts/insightsDataTable.js index c031ade4b74..18780b4d7a3 100644 --- a/plugins/Insights/javascripts/insightsDataTable.js +++ b/plugins/Insights/javascripts/insightsDataTable.js @@ -40,6 +40,14 @@ this.initOrderBy(domElem); this.initComparedToXPeriodsAgo(domElem); this.initFilterBy(domElem); + this.setFixWidthToMakeEllipsisWork(domElem); + }, + + setFixWidthToMakeEllipsisWork: function (domElem) { + var width = domElem.width(); + if (width) { + $('td.label', domElem).width(parseInt(width * 0.60, 10)); + } }, _changeParameter: function (params) { diff --git a/plugins/Insights/tests/ApiTest.php b/plugins/Insights/tests/ApiTest.php index c62a20aab46..1e0818d8c7c 100644 --- a/plugins/Insights/tests/ApiTest.php +++ b/plugins/Insights/tests/ApiTest.php @@ -11,6 +11,7 @@ use Piwik\DataTable; use Piwik\Plugins\Insights\API; use Piwik\API\Request as ApiRequest; +use Piwik\Plugins\Insights\tests\Fixtures\SomeVisitsDifferentPathsOnTwoDays; /** * @group Insights @@ -21,7 +22,7 @@ class ApiTest extends \IntegrationTestCase { /** - * @var \Test_Piwik_Fixture_SomeVisitsDifferentPathsOnTwoDays + * @var SomeVisitsDifferentPathsOnTwoDays */ public static $fixture = null; @@ -240,4 +241,4 @@ private function assertRows($expectedLabels, DataTable $dataTable) } } -ApiTest::$fixture = new \Test_Piwik_Fixture_SomeVisitsDifferentPathsOnTwoDays(); \ No newline at end of file +ApiTest::$fixture = new SomeVisitsDifferentPathsOnTwoDays(); \ No newline at end of file diff --git a/tests/PHPUnit/Fixtures/SomeVisitsDifferentPathsOnTwoDays.php b/plugins/Insights/tests/Fixtures/SomeVisitsDifferentPathsOnTwoDays.php similarity index 94% rename from tests/PHPUnit/Fixtures/SomeVisitsDifferentPathsOnTwoDays.php rename to plugins/Insights/tests/Fixtures/SomeVisitsDifferentPathsOnTwoDays.php index 2486dcf6492..6fc2861b926 100644 --- a/tests/PHPUnit/Fixtures/SomeVisitsDifferentPathsOnTwoDays.php +++ b/plugins/Insights/tests/Fixtures/SomeVisitsDifferentPathsOnTwoDays.php @@ -5,13 +5,15 @@ * @link http://piwik.org * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */ -use Piwik\Date; +namespace Piwik\Plugins\Insights\tests\Fixtures; + +use Piwik\Date; /** * Adds one website and tracks several visits from one visitor on * different days that span about a month apart. */ -class Test_Piwik_Fixture_SomeVisitsDifferentPathsOnTwoDays extends Test_Piwik_BaseFixture +class SomeVisitsDifferentPathsOnTwoDays extends \Test_Piwik_BaseFixture { public $idSite = 1; public $date1 = '2010-12-14';