mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-06-13 17:34:57 +03:00
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:
@@ -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)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# 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
|
||||
|
||||
import argparse
|
||||
@@ -484,6 +484,50 @@ def main():
|
||||
ct_str = f"[{ct}]" if ct else ""
|
||||
lines.append(f" {e_name}{ct_str} -> {e_handler}")
|
||||
|
||||
# --- Main AutoCommandBar (form's id=-1 panel) ---
|
||||
def format_main_acb(acb_node):
|
||||
if acb_node is None:
|
||||
return []
|
||||
autofill_node = acb_node.find("d:Autofill", NSMAP)
|
||||
autofill = not (autofill_node is not None and autofill_node.text == "false")
|
||||
halign_node = acb_node.find("d:HorizontalAlign", NSMAP)
|
||||
flags = ["autofill" if autofill else "no-autofill"]
|
||||
if halign_node is not None and halign_node.text:
|
||||
flags.append(f"align={halign_node.text}")
|
||||
ci_node = acb_node.find("d:ChildItems", NSMAP)
|
||||
buttons = []
|
||||
if ci_node is not None:
|
||||
for btn in ci_node:
|
||||
if not isinstance(btn.tag, str):
|
||||
continue
|
||||
ln = etree.QName(btn).localname
|
||||
if ln in SKIP_ELEMENTS:
|
||||
continue
|
||||
b_name = btn.get("name", "")
|
||||
cmd_node = btn.find("d:CommandName", NSMAP)
|
||||
cmd_ref = cmd_node.text if cmd_node is not None and cmd_node.text else ""
|
||||
loc_node = btn.find("d:LocationInCommandBar", NSMAP)
|
||||
loc_str = f" [{loc_node.text}]" if loc_node is not None and loc_node.text else ""
|
||||
tag = get_element_tag(btn)
|
||||
if cmd_ref:
|
||||
buttons.append(f" {tag} {b_name} -> {cmd_ref}{loc_str}")
|
||||
else:
|
||||
buttons.append(f" {tag} {b_name}{loc_str}")
|
||||
if not buttons and autofill and halign_node is None:
|
||||
return ["AutoCommandBar [autofill]"]
|
||||
return [f"AutoCommandBar [{', '.join(flags)}]"] + buttons
|
||||
|
||||
cb_loc_node = root.find("d:CommandBarLocation", NSMAP)
|
||||
cb_loc = cb_loc_node.text if cb_loc_node is not None and cb_loc_node.text else "Auto"
|
||||
main_acb_node = root.find("d:AutoCommandBar", NSMAP)
|
||||
acb_lines = []
|
||||
if cb_loc != "None" and main_acb_node is not None:
|
||||
acb_lines = format_main_acb(main_acb_node)
|
||||
|
||||
if acb_lines and cb_loc in ("Auto", "Top"):
|
||||
lines.append("")
|
||||
lines.extend(acb_lines)
|
||||
|
||||
# --- Element tree ---
|
||||
tree_state = {"has_collapsed": False}
|
||||
child_items = root.find("d:ChildItems", NSMAP)
|
||||
@@ -494,6 +538,10 @@ def main():
|
||||
build_tree(child_items, " ", tree_lines, expand, tree_state)
|
||||
lines.extend(tree_lines)
|
||||
|
||||
if acb_lines and cb_loc == "Bottom":
|
||||
lines.append("")
|
||||
lines.extend(acb_lines)
|
||||
|
||||
# --- Attributes ---
|
||||
attrs_node = root.find("d:Attributes", NSMAP)
|
||||
if attrs_node is not None:
|
||||
|
||||
Reference in New Issue
Block a user