mirror of
https://github.com/SuiteCRM/SuiteCRM-Core.git
synced 2025-09-04 10:14:13 +08:00
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:
parent
a41ab09f58
commit
2f5472f3c3
19 changed files with 266 additions and 42 deletions
|
@ -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
|
||||
|
|
54
tests/unit/core/src/Service/ChartDefinitionProviderTest.php
Normal file
54
tests/unit/core/src/Service/ChartDefinitionProviderTest.php
Normal 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);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue