31 $userId = $USER->getId();
32 $dashboardForUser = Dashboard::loadByBoardKeyAndUserId($boardKey, $userId);
33 if ($dashboardForUser)
35 $dashboardForUser->delete();
39 $analyticBoardProvider->
addFilter(
'boardKey', $boardKey);
40 $analyticBoard = $analyticBoardProvider->execute()->getFirstResult();
45 $filter = $analyticBoard->getFilter();
50 $filterId = $filter->getFilterParameters()[
'FILTER_ID'];
51 $options =
new Options($filterId, $filter::getPresetsList());
52 $options->setFilterSettingsArray($filter::getPresetsList());
64 return array(
'demoMode' => !$oldMode);
76 $componentName =
'bitrix:report.visualconstructor.board.controls';
77 $templateName =
'addform';
79 'BOARD_ID' => $boardId,
80 'REPORTS_CATEGORIES' => array(),
82 return new Component($componentName, $templateName, $params);
93 if ($formParams[
'boardId'])
95 if ($formParams[
'patternWidgetId'])
97 $widgetGId = $this->createWidgetFromExisting($formParams);
101 $this->
addError(
new Error(
'Should select view type or select from widget pattern'));
106 return array(
'widgetId' => $widgetGId);
120 private function createWidgetFromExisting($formParams)
123 if (!$dashboardForUser)
125 $this->
addError(
new Error(
'Can\'t create widget because current user has not board to edit'));
129 $widget = \Bitrix\Report\VisualConstructor\Entity\Widget::getWidgetByGId($formParams[
'patternWidgetId']);
131 $copy = $widget->getCopyForCurrentUser();
132 $cellId =
'cell_' . randString(4);
135 $row = Row::getRowDefaultEntity(array(
136 'cellIds' => array($cellId)
139 catch (ArgumentException $e)
141 $this->errorCollection[] =
new Error($e->getMessage());
145 $row->setBoardId($formParams[
'boardId']);
146 $copy->setWeight($cellId);
147 $copy->setGId(Util::generateUserUniqueId());
148 $copy->setIsPattern(
false);
149 $copy->setBoardId($formParams[
'boardId']);
150 $row->addWidgets($copy);
152 $dashboardForUser->addRows($row);
153 $dashboardForUser->save();
154 return $copy->getGId();