Esempio n. 1
0
 /**
  * Process attribute addition from tree and than renders it.
  *
  * @param string $nodeId
  * @param string $treeType
  * @param Report $report
  * @param int $rowNumber
  * @param bool $trackableStructurePosition
  */
 public static function processAttributeAdditionFromTree($nodeId, $treeType, Report $report, $rowNumber, $trackableStructurePosition)
 {
     $nodeIdWithoutTreeType = ReportRelationsAndAttributesToTreeAdapter::removeTreeTypeFromNodeId($nodeId, $treeType);
     $moduleClassName = $report->getModuleClassName();
     $modelClassName = $moduleClassName::getPrimaryModelName();
     $form = new WizardActiveForm();
     $form->id = 'edit-form';
     $form->enableAjaxValidation = true;
     //ensures error validation populates correctly
     $wizardFormClassName = ReportToWizardFormAdapter::getFormClassNameByType($report->getType());
     $model = ComponentForReportFormFactory::makeByComponentType($moduleClassName, $modelClassName, $report->getType(), $treeType);
     $form->modelClassNameForError = $wizardFormClassName;
     $attribute = ReportRelationsAndAttributesToTreeAdapter::resolveAttributeByNodeId($nodeIdWithoutTreeType);
     $model->attributeIndexOrDerivedType = ReportRelationsAndAttributesToTreeAdapter::resolveAttributeByNodeId($nodeIdWithoutTreeType);
     $inputPrefixData = ReportRelationsAndAttributesToTreeAdapter::resolveInputPrefixData($wizardFormClassName, $treeType, (int) $rowNumber);
     $adapter = new ReportAttributeToElementAdapter($inputPrefixData, $model, $form, $treeType);
     $view = new AttributeRowForReportComponentView($adapter, (int) $rowNumber, $inputPrefixData, $attribute, (bool) $trackableStructurePosition, true, $treeType);
     $content = $view->render();
     $form->renderAddAttributeErrorSettingsScript($view::getFormId());
     Yii::app()->getClientScript()->setToAjaxMode();
     Yii::app()->getClientScript()->render($content);
     echo $content;
 }
 /**
  * @param integer $rowCount
  * @param WizardActiveForm $form
  * @return array
  */
 protected function renderItems(&$rowCount, WizardActiveForm $form)
 {
     assert('is_int($rowCount)');
     $items = array();
     $wizardFormClassName = $this->getWizardFormClassName();
     $treeType = ComponentForReportForm::TYPE_FILTERS;
     $trackableStructurePosition = false;
     //can we set this to false without jacking things up?
     $report = $this->params["relationModel"];
     if (null != ($stickyData = StickyReportUtil::getDataByKey($report->id))) {
         StickyReportUtil::resolveStickyDataToReport($report, $stickyData);
     }
     foreach ($report->getFilters() as $filterForReportForm) {
         if ($filterForReportForm->availableAtRunTime) {
             $nodeIdWithoutTreeType = $filterForReportForm->attributeIndexOrDerivedType;
             $inputPrefixData = ReportRelationsAndAttributesToTreeAdapter::resolveInputPrefixData($wizardFormClassName, $treeType, $rowCount);
             $adapter = new RuntimeReportAttributeToElementAdapter($inputPrefixData, $filterForReportForm, $form, $treeType);
             $view = new AttributeRowForReportComponentView($adapter, $rowCount, $inputPrefixData, ReportRelationsAndAttributesToTreeAdapter::resolveAttributeByNodeId($nodeIdWithoutTreeType), (bool) $trackableStructurePosition, false, null);
             $view->addWrapper = false;
             $items[] = array('content' => $view->render());
         }
         $rowCount++;
     }
     return $items;
 }
 /**
  * @param integer $rowCount
  * @param array $componentData
  * @param bool $trackableStructurePosition
  * @return array
  */
 protected function renderItems(&$rowCount, $componentData, $trackableStructurePosition = false)
 {
     assert('is_int($rowCount)');
     assert('is_array($componentData)');
     assert('is_bool($trackableStructurePosition)');
     $items = array();
     $wizardFormClassName = get_class($this->model);
     foreach ($componentData as $component) {
         $nodeIdWithoutTreeType = $component->attributeIndexOrDerivedType;
         $inputPrefixData = ReportRelationsAndAttributesToTreeAdapter::resolveInputPrefixData($wizardFormClassName, $this->getTreeType(), $rowCount);
         $adapter = new ReportAttributeToElementAdapter($inputPrefixData, $component, $this->form, $this->getTreeType());
         $view = new AttributeRowForReportComponentView($adapter, $rowCount, $inputPrefixData, ReportRelationsAndAttributesToTreeAdapter::resolveAttributeByNodeId($nodeIdWithoutTreeType), (bool) $trackableStructurePosition, true, static::getTreeType());
         $view->addWrapper = false;
         $items[] = array('content' => $view->render());
         $rowCount++;
     }
     return $items;
 }