14 private $reportsInWidgetCount;
34 $view->prepareWidgetFormBeforeRender($this);
48 $boardId = $params[
'boardId'];
49 $action = $params[
'action'];
50 $saveButtonTitle = $params[
'saveButtonTitle'];
52 $form =
new static($view, $widget);
53 $form->setId(
'report_widget_configuration_form_' . $widget->
getGId());
54 $form->setAction($action);
55 $form->setBoarId($boardId);
56 $form->addDataAttribute(
'widget-id', $widget->
getGId());
57 $form->addWidgetConfigurationFormFullContent();
61 $footerContainer->setKey(
'footer_container');
62 $footerContainer->addClass(
'report-widget-configuration-form-footer-container');
63 $footerContainer->addDataAttribute(
'role',
'footer-container');
67 $buttonsContainer->addClass(
'report-widget-configuration-form-action-buttons-container');
69 $saveButton->addDataAttribute(
'type',
'save-button');
70 $saveButton->addClass(
'ui-btn');
71 $saveButton->addClass(
'ui-btn-md');
72 $saveButton->addClass(
'ui-btn-success');
73 $saveButton->setLabel($saveButtonTitle);
77 $cancelButton->addDataAttribute(
'type',
'cancel-button');
78 $cancelButton->addClass(
'ui-btn');
79 $cancelButton->addClass(
'ui-btn-md');
80 $cancelButton->addClass(
'ui-btn-link');
81 $cancelButton->setLabel(
Loc::getMessage(
'SAVE_WIDGET_CONFIG_CANCEL_BUTTON'));
84 $checkBoxContainer->addClass(
'report-configuration-footer-right-container');
87 $isPatternCheckBox->setLabel(
Loc::getMessage(
'SAVE_WIDGET_AS_PATTERN'));
89 $form->add($footerContainer->start());
90 $form->add($buttonsContainer->start());
91 $form->add($saveButton);
92 $form->add($cancelButton);
93 $form->add($buttonsContainer->end());
94 $form->add($checkBoxContainer->start());
95 $form->add($isPatternCheckBox);
96 $form->add($checkBoxContainer->end());
97 $form->add($footerContainer->end());
105 private function addWidgetConfigurationFormFullContent()
109 $formContentContainer->addClass(
'report-widget-configuration-form-content');
110 $formContentContainer->setKey(
'form_content_container');
111 $this->
add($formContentContainer->start());
112 $this->addWidgetConfigurationsBlock();
114 $reportsConfigurationsContainerWrapper =
new Fields\Div();
115 $reportsConfigurationsContainerWrapper->addClass(
'reports-configurations-container-wrapper');
116 $this->
add($reportsConfigurationsContainerWrapper->start());
117 $this->addReportsConfigurationsBlock();
118 $this->addReportAddButtonBlock();
119 $this->
add($reportsConfigurationsContainerWrapper->end());
122 $maxReportCountField->addDataAttribute(
'hidden-field',
'maxRenderReportCount');
123 $maxReportCountField->setValue($view::MAX_RENDER_REPORT_COUNT);
124 $this->
add($maxReportCountField);
127 $boardIdField->setValue($this->
getBoarId());
128 $this->
add($boardIdField);
131 $widgetIdField->setValue($this->
getWidget()->getGId());
132 $this->
add($widgetIdField);
135 $categoryKeyField->setValue($this->
getWidget()->getCategoryKey());
136 $this->
add($categoryKeyField);
138 $this->
add($formContentContainer->end());
141 private function addWidgetConfigurationsBlock()
143 $widgetConfigurationFields = $this->getWidgetConfigurationFields();
144 $widgetConfigurationsContainer =
new Fields\Div();
145 $widgetConfigurationsContainer->addClass(
'widgets-configurations-container');
147 $this->
add($widgetConfigurationsContainer->start());
148 foreach ($widgetConfigurationFields as $configurationField)
150 $this->
add($configurationField);
152 $this->
add($widgetConfigurationsContainer->end());
155 private function addReportsConfigurationsBlock()
157 $reportsConfigurationFields = $this->getReportConfigurationFields();
158 $reportsConfigurationsContainer =
new Fields\Div();
159 $reportsConfigurationsContainer->addClass(
'reports-configurations-container');
160 $reportsConfigurationsContainer->addDataAttribute(
'role',
'reports-configurations-container');
161 $reportsConfigurationsContainer->addDataAttribute(
'widget-id', $this->
getWidget()->getGId());
162 $this->
add($reportsConfigurationsContainer->start());
163 $this->reportsInWidgetCount = count($reportsConfigurationFields);
164 if($reportsConfigurationFields)
166 $reportConfigurationsContainer =
new Fields\Div();
167 $reportConfigurationsContainer->addClass(
'report-configuration-container');
168 $reportConfigurationsContainer->addDataAttribute(
'role',
'report-configuration-container');
169 $reportConfigurationsContainer->addDataAttribute(
'is-pseudo',
'0');
170 $reportConfigurationsContainer->addClass(
'report-configuration-container-visible');
173 foreach ($reportsConfigurationFields as $reportGId => $reportConfiguration)
176 $reportConfigurationsContainer->addDataAttribute(
'report-id', $reportGId);
177 $container =
new Fields\Container();
178 $container->setKey(
'report_configurations_container_' . $num);
179 $container->addDataAttribute(
'role',
'report-configuration-container');
183 $container->addElement($reportConfigurationsContainer->start());
185 foreach ($reportConfiguration[
'FIELDS'] as $configurationField)
187 $container->addElement($configurationField);
191 $container->addElement($reportConfigurationsContainer->end());
192 $this->
add($container);
196 $this->
add($reportsConfigurationsContainer->end());
199 private function addReportAddButtonBlock()
201 $addButtonContainer =
new Fields\Div();
202 $addButtonContainer->addClass(
'report-configuration-add-report-button-container');
203 $addButton =
new Fields\Button(
'widgetAddReportButton_' . $this->
getWidget()->getGId());
204 $addButton->addClass(
'add-report-to-widget-button');
206 if ($view::MAX_RENDER_REPORT_COUNT <= $this->reportsInWidgetCount)
208 $addButtonContainer->addClass(
'report-configuration-add-report-button-container-invisible');
211 $this->
add($addButtonContainer->start());
213 $this->
add($addButton);
214 $this->
add($addButtonContainer->end());
220 private function getWidgetConfigurationFields()
222 return $this->
getWidget()->getWidgetHandler()->getFormElements();
228 private function getReportConfigurationFields()
230 $reports = $this->
getWidget()->getReports();
231 $configurations = array();
232 foreach ($reports as $report)
234 $reportHandler = $report->getReportHandler();
235 $reportHandler->setView($this->view);
236 $configurations[$report->getGId()][
'FIELDS'] = $reportHandler->getFormElements();
238 return $configurations;
263 return $this->widget;
272 $this->widget = $widget;
280 return $this->boarId;
289 $this->boarId = $boarId;
static getMessage($code, $replace=null, $language=null)