Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
numberblock.php
1<?php
2
4
14
15
21class NumberBlock extends Base
22{
23 const VIEW_KEY = 'numberBlock';
24
27
31 public function __construct()
32 {
33 parent::__construct();
34 $this->setHeight(380);
35 $this->setLabel(Loc::getMessage('REPORT_NUMBER_BLOCK_VIEW_LABEL'));
36 $this->setLogoUri('/bitrix/images/report/visualconstructor/view-number-block.jpg');
37 $this->setComponentName('bitrix:report.visualconstructor.widget.content.numberblock');
38 $this->setCompatibleDataType(Common::SINGLE_REPORT_TYPE);
39 $this->setJsClassName('BX.Report.VisualConstructor.Widget.Content.NumberBlock');
40 }
41
49 {
50 $form = parent::prepareWidgetFormBeforeRender($form);
51
52 $secondReportConfigsContainer = $form->getField('report_configurations_container_2');
53
54
55 if ($secondReportConfigsContainer instanceof Container)
56 {
57 $firstGroupedReportContainer = $secondReportConfigsContainer;
58
59 $thirdReportConfigsContainer = $form->getField('report_configurations_container_3');
60 if ($thirdReportConfigsContainer instanceof Container)
61 {
62 $lastGroupedReportContainer = $thirdReportConfigsContainer;
63 }
64 else
65 {
66 $lastGroupedReportContainer = $secondReportConfigsContainer;
67 }
68
69 $div = new Div();
70 $div->setKey('report_configuration_big_container');
71 $div->addClass('report-configuration-big-container');
72 $form->addFieldBefore($div->start(), $firstGroupedReportContainer);
73 $form->addFieldAfter($div->end(), $lastGroupedReportContainer);
74 }
75
76 return $form;
77 }
78
85 public function collectWidgetHandlerFormElements(BaseWidget $widgetHandler)
86 {
87 parent::collectWidgetHandlerFormElements($widgetHandler);
88 $widgetHandler->getFormElement('color')->setDisplay(false);
89 }
90
99 public function collectReportHandlerFormElements($reportHandler)
100 {
101 parent::collectReportHandlerFormElements($reportHandler);
102 $removeReportControlFormElement = $reportHandler->getFormElementByDataAttribute('role', 'report-remove-button');
103
104
105 if ($removeReportControlFormElement)
106 {
107 $removeReportControlFormElement->setDisplay(false);
108 }
109
110 if (!$reportHandler->getConfiguration('color'))
111 {
112 $reportHandler->getConfiguration('color')->setValue('#4fc3f7');
113 $reportHandler->getFormElement('head_container_start')->addInlineStyle('background-color', '#4fc3f7');
114 $reportHandler->getFormElement('main_container_start')->addInlineStyle('background-color', '#4fc3f75f');
115 }
116
118 $whatWillCalculateField = $reportHandler->getFormElement('calculate');
119 $labelField = $reportHandler->getFormElement('label');
120 if ($whatWillCalculateField)
121 {
122 $labelField->addJsEventListener($whatWillCalculateField, $whatWillCalculateField::JS_EVENT_ON_CHANGE, array(
123 'class' => 'BX.Report.VisualConstructor.FieldEventHandlers.Title',
124 'action' => 'whatWillCalculateChange',
125 ));
126 $labelField->addAssets(array(
127 'js' => array('/bitrix/js/report/js/visualconstructor/fields/reporttitle.js')
128 ));
129 }
130 }
131
140 public function prepareWidgetContent(Widget $widget, $withCalculatedData = false)
141 {
142 $resultWidget = parent::prepareWidgetContent($widget, $withCalculatedData);
143
144 if ($withCalculatedData)
145 {
146 $resultWidget['content']['params']['color'] = $widget->getWidgetHandler()->getReportHandlers()[0]->getFormElement('color')->getValue();
147 $resultWidget['config']['title'] = $widget->getWidgetHandler()->getReportHandlers()[0]->getFormElement('label')->getValue();
148 }
149
150 return $resultWidget;
151 }
152
153
160 public function getReportDefaultColor($num)
161 {
162 $defaultColorList = array(
163 "#4fc3f7"
164 );
165
166 return $defaultColorList[$num % count($defaultColorList)];
167 }
168
169
170}
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
addFieldAfter($newField, $targetField)
Definition form.php:99
addFieldBefore($newField, $targetField)
Definition form.php:63
setCompatibleDataType($compatibleDataType)
Definition view.php:121
collectReportHandlerFormElements($reportHandler)
Definition view.php:289
prepareWidgetContent(Widget $widget, $withCalculatedData=false)