mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-12 23:14:18 +01:00
N°3685 - Use WebResourcesHelper for D3/C3.js usages
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with iTop. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
use Combodo\iTop\Application\Helper\WebResourcesHelper;
|
||||
use Combodo\iTop\Application\UI\Base\Component\Dashlet\DashletContainer;
|
||||
use Combodo\iTop\Application\UI\Base\Component\Dashlet\DashletFactory;
|
||||
use Combodo\iTop\Application\UI\Base\Component\Html\Html;
|
||||
@@ -1702,10 +1703,7 @@ class DashletGroupByPie extends DashletGroupBy
|
||||
{
|
||||
return array_merge(
|
||||
parent::GetJSFilesRelPaths(),
|
||||
[
|
||||
'js/d3.js',
|
||||
'js/c3.js',
|
||||
]
|
||||
WebResourcesHelper::GetJSFilesRelPathsForC3JS()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1716,9 +1714,7 @@ class DashletGroupByPie extends DashletGroupBy
|
||||
{
|
||||
return array_merge(
|
||||
parent::GetCSSFilesRelPaths(),
|
||||
[
|
||||
'css/c3.min.css',
|
||||
]
|
||||
WebResourcesHelper::GetCSSFilesRelPathsForC3JS()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
use Combodo\iTop\Application\Helper\WebResourcesHelper;
|
||||
use Combodo\iTop\Application\UI\Base\Component\Alert\AlertUIBlockFactory;
|
||||
use Combodo\iTop\Application\UI\Base\Component\Button\ButtonUIBlockFactory;
|
||||
use Combodo\iTop\Application\UI\Base\Component\CollapsibleSection\CollapsibleSectionUIBlockFactory;
|
||||
@@ -663,9 +664,7 @@ EOF
|
||||
$sUnchanged = json_encode(Dict::Format('UI:CSVImportUnchanged_items', $iUnchanged));
|
||||
|
||||
// Add graphs dependencies
|
||||
$oPage->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot().'css/c3.min.css');
|
||||
$oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/d3.js');
|
||||
$oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/c3.js');
|
||||
WebResourcesHelper::EnableC3JSToWebPage($oPage);
|
||||
|
||||
$oPage->add_script(
|
||||
<<< EOF
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
use Combodo\iTop\Application\Helper\WebResourcesHelper;
|
||||
use Combodo\iTop\Application\UI\Base\Component\Button\ButtonUIBlockFactory;
|
||||
use Combodo\iTop\Application\UI\Base\Component\DataTable\DataTableUIBlockFactory;
|
||||
use Combodo\iTop\Application\UI\Base\Component\Input\Select\Select;
|
||||
@@ -538,9 +539,7 @@ function DisplayRelatedClassesGraph($oPage, $sClass)
|
||||
// 3) Processing data and building graph
|
||||
//
|
||||
// - Add graphs dependencies
|
||||
$oPage->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot().'css/c3.min.css');
|
||||
$oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/d3.js');
|
||||
$oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/c3.js');
|
||||
WebResourcesHelper::EnableC3JSToWebPage($oPage);
|
||||
// - Add markup
|
||||
$oPage->add(
|
||||
<<<EOF
|
||||
|
||||
@@ -20,6 +20,45 @@ use utils;
|
||||
*/
|
||||
class WebResourcesHelper
|
||||
{
|
||||
/**
|
||||
* Add necessary files (JS/CSS) to be able to use d3/c3.js in the page
|
||||
*
|
||||
* @param \WebPage $oPage
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function EnableC3JSToWebPage(WebPage &$oPage): void
|
||||
{
|
||||
foreach (static::GetCSSFilesRelPathsForC3JS() as $sFile) {
|
||||
$oPage->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot().$sFile);
|
||||
}
|
||||
|
||||
foreach (static::GetJSFilesRelPathsForC3JS() as $sFile) {
|
||||
$oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().$sFile);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[] Relative URLs to the CSS files necessary for d3/c3.js
|
||||
*/
|
||||
public static function GetCSSFilesRelPathsForC3JS(): array
|
||||
{
|
||||
return [
|
||||
'css/c3.min.css',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[] Relative URLs to the JS files necessary for d3/c3.js
|
||||
*/
|
||||
public static function GetJSFilesRelPathsForC3JS(): array
|
||||
{
|
||||
return [
|
||||
'js/d3.js',
|
||||
'js/c3.js',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Add necessary files (JS/CSS) to be able to use simple_graph in the page
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user