Example #1
0
 /**
  * createDependencyJavascript
  * Builds the javascript required to execute calculated/dependent fields
  * and module-view dependences.
  *
  * @param array $fieldDefs The fields defs for the current module.
  * @param array $viewDefs the viewdefs for the current view.
  * @param string $view the current view type.
  */
 function createDependencyJavascript($fieldDefs, $viewDefs, $view, $module = null)
 {
     //Use a doWhen to wait for the page to be fulled loaded (!SUGAR.util.ajaxCallInProgress())
     // TODO check if this isn't broken...
     $js = "<script type=text/javascript>\n" . "SUGAR.util.doWhen('!SUGAR.util.ajaxCallInProgress()', function(){\n" . "SUGAR.forms.AssignmentHandler.registerView('{$view}');\n";
     if ($view == 'ConvertLead') {
         $fieldDefs = $this->prepareCalculationFields($fieldDefs, $module);
     }
     $js .= DependencyManager::getLinkFields($fieldDefs, $view);
     $dependencies = array_merge(DependencyManager::getDependenciesForFields($fieldDefs, $view), DependencyManager::getDependenciesForView($viewDefs, $view, $module));
     foreach ($dependencies as $dep) {
         $js .= $dep->getJavascript($view);
     }
     //Detail views do not use the view name as the input ID.
     $viewId = $view == "DetailView" ? "{$module}_detailview_tabs" : $view;
     $js .= "\nYAHOO.util.Event.onContentReady('{$viewId}', SUGAR.forms.AssignmentHandler.loadComplete);";
     $js .= "});</script>";
     return $js;
 }