REF - Cleanup array key checking to use array_key_exists
[civicrm-core.git] / CRM / Contact / Page / DashBoard.php
index 07f6c78ea3f1177b03ff1ffecd626e8b72acb8d3..48ea3ac19cecaad86b62c767605d7fe3dc895d3d 100644 (file)
@@ -44,24 +44,21 @@ class CRM_Contact_Page_DashBoard extends CRM_Core_Page {
       }
     }
 
-    $loader = new Civi\Angular\AngularLoader();
+    $loader = Civi::service('angularjs.loader');
+    $loader->addModules('crmDashboard');
     $loader->setPageName('civicrm/dashboard');
 
     // For each dashlet that requires an angular directive, load the angular module which provides that directive
-    $modules = [];
     foreach (CRM_Core_BAO_Dashboard::getContactDashlets() as $dashlet) {
       if (!empty($dashlet['directive'])) {
         foreach ($loader->getAngular()->getModules() as $name => $module) {
           if (!empty($module['exports'][$dashlet['directive']])) {
-            $modules[] = $name;
+            $loader->addModules($name);
             continue;
           }
         }
       }
     }
-    $loader->setModules($modules);
-
-    $loader->load();
 
     return parent::run();
   }
@@ -79,7 +76,9 @@ class CRM_Contact_Page_DashBoard extends CRM_Core_Page {
     $partials = [];
     foreach (CRM_Core_BAO_Dashboard::getContactDashlets() as $dashlet) {
       if (!empty($dashlet['directive'])) {
-        $partials["~/$moduleName/directives/{$dashlet['directive']}.html"] = "<{$dashlet['directive']}></{$dashlet['directive']}>";
+        // FIXME: Wrapping each directive in <div id='bootstrap-theme'> produces invalid html (duplicate ids in the dom)
+        // but it's the only practical way to selectively apply boostrap3 theming to specific dashlets
+        $partials["~/$moduleName/directives/{$dashlet['directive']}.html"] = "<div id='bootstrap-theme'><{$dashlet['directive']}></{$dashlet['directive']}></div>";
       }
     }
     return $partials;