feat(form-info): показывать главную AutoCommandBar формы с учётом CommandBarLocation

Раньше AutoCommandBar (id=-1) полностью скрывалась как companion-элемент.
Из-за этого модель не видела главную панель и часто добавляла избыточную
дополнительную cmdBar снизу формы по образцу старых сгенерённых форм.

Теперь:
- AutoCommandBar формы выводится отдельным разделом с флагами
  (autofill/no-autofill, align=...) и списком кастомных кнопок.
- Позиция секции зависит от свойства формы CommandBarLocation:
  Auto/Top — над деревом элементов (нативное поведение платформы),
  Bottom — под деревом, None — секция скрыта.
- Если панель пустая с дефолтным autofill — выводится одной строкой.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Nick Shirokov
2026-05-01 21:04:26 +03:00
co-authored by Claude Opus 4.7
parent 6b63177687
commit 6650d2b516
2 changed files with 113 additions and 3 deletions
+64 -2
View File
@@ -1,8 +1,8 @@
# form-info v1.2 — Analyze 1C managed form structure
# form-info v1.3 — Analyze 1C managed form structure
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
param(
[Parameter(Mandatory=$true)]
[Alias('Path')]
[Alias('Path')]
[string]$FormPath,
[int]$Limit = 150,
[int]$Offset = 0,
@@ -436,6 +436,62 @@ if ($formEvents -and $formEvents.HasChildNodes) {
}
}
# --- Main AutoCommandBar (form's id=-1 panel) ---
function Format-MainAcb($acbNode) {
if (-not $acbNode) { return @() }
$result = @()
$autofillNode = $acbNode.SelectSingleNode("d:Autofill", $ns)
$autofill = $true
if ($autofillNode -and $autofillNode.InnerText -eq "false") { $autofill = $false }
$halignNode = $acbNode.SelectSingleNode("d:HorizontalAlign", $ns)
$flags = @()
$flags += if ($autofill) { "autofill" } else { "no-autofill" }
if ($halignNode) { $flags += "align=$($halignNode.InnerText)" }
$header = "AutoCommandBar [$($flags -join ', ')]"
$childItemsNode = $acbNode.SelectSingleNode("d:ChildItems", $ns)
$buttons = @()
if ($childItemsNode) {
foreach ($btn in $childItemsNode.ChildNodes) {
if ($btn.NodeType -ne "Element") { continue }
if ($skipElements.ContainsKey($btn.LocalName)) { continue }
$bName = $btn.GetAttribute("name")
$cmdNode = $btn.SelectSingleNode("d:CommandName", $ns)
$cmdRef = if ($cmdNode) { $cmdNode.InnerText } else { "" }
$locNode = $btn.SelectSingleNode("d:LocationInCommandBar", $ns)
$locStr = if ($locNode) { " [$($locNode.InnerText)]" } else { "" }
$tag = Get-ElementTag $btn
if ($cmdRef) {
$buttons += " $tag $bName -> $cmdRef$locStr"
} else {
$buttons += " $tag $bName$locStr"
}
}
}
if ($buttons.Count -eq 0 -and $autofill -and -not $halignNode) {
# Default empty panel — terse one-liner
return @("AutoCommandBar [autofill]")
}
$result += $header
$result += $buttons
return $result
}
# Determine position from CommandBarLocation form property
$cbLocNode = $root.SelectSingleNode("d:CommandBarLocation", $ns)
$cbLoc = if ($cbLocNode) { $cbLocNode.InnerText } else { "Auto" }
$mainAcbNode = $root.SelectSingleNode("d:AutoCommandBar", $ns)
$acbLines = @()
if ($cbLoc -ne "None" -and $mainAcbNode) {
$acbLines = Format-MainAcb $mainAcbNode
}
# AutoCommandBar above Elements (Auto/Top)
if ($acbLines.Count -gt 0 -and ($cbLoc -eq "Auto" -or $cbLoc -eq "Top")) {
$lines += ""
$lines += $acbLines
}
# --- Element tree ---
$childItems = $root.SelectSingleNode("d:ChildItems", $ns)
@@ -446,6 +502,12 @@ if ($childItems) {
$lines += $treeLines.ToArray()
}
# AutoCommandBar below Elements (Bottom)
if ($acbLines.Count -gt 0 -and $cbLoc -eq "Bottom") {
$lines += ""
$lines += $acbLines
}
# --- Attributes ---
$attrsNode = $root.SelectSingleNode("d:Attributes", $ns)