Add initial chart configuration for listview

- Create charts.yaml configuration.
- Add chart interface.
- Add chart service to fetch chart config.
This commit is contained in:
Dillon-Brown 2020-07-13 15:28:49 +01:00
parent a41ab09f58
commit 2f5472f3c3
19 changed files with 266 additions and 42 deletions

View file

@ -4,6 +4,7 @@ namespace App\Tests;
use App\Service\AclManagerInterface;
use App\Service\BulkActionDefinitionProvider;
use App\Service\ChartDefinitionProvider;
use Codeception\Test\Unit;
use Exception;
use SuiteCRM\Core\Legacy\AclHandler;
@ -79,6 +80,26 @@ final class ViewDefinitionsHandlerTest extends Unit
]
];
$chartDefinitions = [
'modules' => [
'Accounts' => [
'key' => 'annual_revenue',
'labelKey' => 'ANNUAL_REVENUE_BY_ACCOUNTS',
'type' => 'line',
],
'Opportunities' => [
'key' => 'pipeline_by_sales_state',
'labelKey' => 'PIPELINE_BY_SALES_STAGE',
'params' => 'bar',
],
'Leads' => [
'key' => 'leads_by_source',
'labelKey' => 'LEADS_BY_SOURCE',
'params' => 'line',
],
],
];
/** @var AclManagerInterface $aclManager */
$aclManager = $this->make(
@ -101,6 +122,10 @@ final class ViewDefinitionsHandlerTest extends Unit
$aclManager
);
$chartDefinitionProvider = new ChartDefinitionProvider(
$chartDefinitions
);
$this->viewDefinitionHandler = new ViewDefinitionsHandler(
$projectDir,
$legacyDir,
@ -109,7 +134,8 @@ final class ViewDefinitionsHandlerTest extends Unit
$legacyScope,
$moduleNameMapper,
$fieldDefinitionsHandler,
$bulkActionProvider
$bulkActionProvider,
$chartDefinitionProvider
);
// Needed for aspect mock

View file

@ -0,0 +1,54 @@
<?php
namespace App\Tests;
use App\Service\ChartDefinitionProvider;
use Codeception\Test\Unit;
use Exception;
class ChartDefinitionProviderTest extends Unit
{
/**
* @var UnitTester
*/
protected $tester;
/**
* @var ChartDefinitionProvider
*/
protected $service;
/**
* @throws Exception
*/
protected function _before(): void
{
$listViewAvailableCharts = [
'modules' => [
'Accounts' => [
'key' => 'annual_revenue',
'labelKey' => 'ANNUAL_REVENUE_BY_ACCOUNTS',
'type' => 'line',
],
'Opportunities' => [
'key' => 'pipeline_by_sales_state',
'labelKey' => 'PIPELINE_BY_SALES_STAGE',
'type' => 'bar',
],
'Leads' => [
'key' => 'leads_by_source',
'labelKey' => 'LEADS_BY_SOURCE',
'type' => 'line',
]
]
];
$this->service = new ChartDefinitionProvider($listViewAvailableCharts);
}
public function testDefaultActionsRetrieval(): void
{
$actions = $this->service->getCharts('accounts');
static::assertNotNull($actions);
}
}