namesManagementService = $namesManagementService; } public function parseTree($treeSource, $puid, $luid) { $a = array_shift($treeSource); $result = []; if (isset($a['properties'])) { $name = ArrayHelper::getValue($a, 'name'); $result['text'] = $name ?? ''; $result['nodes'][] = $this->parseSubTree($a['properties'], $puid, $luid); } return $result; } private function parseSubTree($treeSource, $puid, $luid) { $_treeSource = $treeSource; if (!is_array($_treeSource)) { $_treeSource = [$_treeSource]; } $result = []; $PropertyAttributeValue = $this->namesManagementService->getPropertyAttributeValueColumnName(); $PropertyAttributeName = $this->namesManagementService->getPropertyAttributeNameColumnName(); foreach ($_treeSource as $item) { $anchor = ''; if (isset($item->LapStrings)) { if (is_array($item->LapStrings)) { foreach ($item->LapStrings as $item_LapStrings) { $tmp = $this->parseSubTree($item_LapStrings, $puid, $luid); if (!is_null($tmp)) { $result['nodes'][] = $tmp; } } } else { $tmp = $this->parseSubTree($item->LapStrings, $puid, $luid); if (!is_null($tmp)) { $result['nodes'][] = $tmp; } } } else { if (isset($item->LapAttributes)) { $attributes = $item->LapAttributes; if (!is_array($attributes)) { $attributes = [$attributes]; } foreach ($attributes as $attribute) { if (isset($attribute->{$PropertyAttributeName}) && $attribute->{$PropertyAttributeName} == 'Видимость') { $value = $attribute->{$PropertyAttributeValue}; if (!BooleanCaster::cast($value)) { return null; } } } } $anchor = md5(json_encode($item)); $result['href'] = Url::current([ 'puid' => $item->Plan->ReferenceUID, 'luid' => $item->LapUID, '#' => $anchor ]); } $result['text'] = "
{$item->LapName}
"; } return $result; } public function treeShow($view, $treeArray) { if (key_exists('node', $treeArray) || key_exists('text', $treeArray)) { $treeArray = [$treeArray]; } TreeParserAsset::register($view); $template = '
{search}
{tree}
'; return TreeView::widget([ 'header' => '', 'id' => 'tree_stage', 'data' => $treeArray, 'template' => $template, 'size' => TreeView::SIZE_SMALL, 'searchOptions' => [ 'inputOptions' => [ 'placeholder' => 'Введите этап...' ], 'clearButtonOptions' => [ 'title' => 'Clear', ], ], 'clientOptions' => [ 'onNodeSelected' => new JsExpression(' function(event, data) { if (data.href){ window.location.href = data.href; } }'), 'onRendered' => new JsExpression(' function() { window.highlighter(); }'), 'onNodeExpanded' => new JsExpression(' function() { window.widthSetter(); }'), 'borderColor' => 'var(--white)', 'enableLinks' => true, 'levels' => 5, ], ]); } }