diff --git a/application/dashlet.class.inc.php b/application/dashlet.class.inc.php index ea5419bdf..2e2945fa4 100644 --- a/application/dashlet.class.inc.php +++ b/application/dashlet.class.inc.php @@ -202,6 +202,24 @@ abstract class Dashlet $this->OnUpdate(); } + /** + * @return array Rel. path to the app. root of the JS files required by the dashlet + * @since 3.0.0 + */ + public function GetJSFilesRelPaths(): array + { + return []; + } + + /** + * @return array Rel. path to the app. root of the CSS files required by the dashlet + * @since 3.0.0 + */ + public function GetCSSFilesRelPaths(): array + { + return []; + } + /** * @param \WebPage $oPage * @param bool $bEditMode @@ -224,6 +242,9 @@ abstract class Dashlet $oDashletContainer->AddCSSClasses($this->aCSSClasses); } + $oDashletContainer->AddMultipleJsFilesRelPaths($this->GetJSFilesRelPaths()); + $oDashletContainer->AddMultipleCssFilesRelPaths($this->GetCSSFilesRelPaths()); + try { if (get_class($this->oModelReflection) == 'ModelReflectionRuntime') { $oBlock = $this->Render($oPage, $bEditMode, $aExtraParams); @@ -1674,6 +1695,33 @@ class DashletGroupByPie extends DashletGroupBy ); } + /** + * @inheritDoc + */ + public function GetJSFilesRelPaths(): array + { + return array_merge( + parent::GetJSFilesRelPaths(), + [ + 'js/d3.js', + 'js/c3.js', + ] + ); + } + + /** + * @inheritDoc + */ + public function GetCSSFilesRelPaths(): array + { + return array_merge( + parent::GetCSSFilesRelPaths(), + [ + 'css/c3.min.css', + ] + ); + } + /** * @inheritdoc */ diff --git a/pages/csvimport.php b/pages/csvimport.php index c9925110d..896dbe3eb 100644 --- a/pages/csvimport.php +++ b/pages/csvimport.php @@ -661,6 +661,12 @@ EOF $sCreated = json_encode(Dict::Format('UI:CSVImportCreated_items', $iCreated)); $sModified = json_encode(Dict::Format('UI:CSVImportModified_items', $iModified)); $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'); + $oPage->add_script( <<< EOF function CSVGoBack() diff --git a/pages/schema.php b/pages/schema.php index f1be35ff3..25c41c2a2 100644 --- a/pages/schema.php +++ b/pages/schema.php @@ -537,6 +537,11 @@ 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'); + // - Add markup $oPage->add( << @@ -545,6 +550,7 @@ function DisplayRelatedClassesGraph($oPage, $sClass) EOF ); + // - Add scripts $oPage->add_ready_script( <</templates/) to the default page template */ const DEFAULT_PAGE_TEMPLATE_REL_PATH = 'pages/backoffice/itopwebpage/layout'; @@ -146,8 +156,6 @@ class iTopWebPage extends NiceWebPage implements iTabbedPage $this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/icon_select.js'); $this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/raphael-min.js'); $this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/selectize.min.js'); - $this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/d3.js'); - $this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/c3.js'); $this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/jquery.multiselect.js'); $this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/ajaxfileupload.js'); $this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/jquery.mousewheel.js'); @@ -196,7 +204,6 @@ class iTopWebPage extends NiceWebPage implements iTabbedPage // TODO 3.0.0: Add only what's necessary $this->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot().'css/jquery-ui-timepicker-addon.css'); $this->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot().'css/magnific-popup.css'); - $this->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot().'css/c3.min.css'); $this->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot().'node_modules/tippy.js/dist/tippy.css'); $this->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot().'node_modules/tippy.js/animations/shift-away-subtle.css'); $this->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot().'css/font-awesome/css/all.min.css');