fix(form-compile,form-decompile): Popup-с-картинкой → PictureDecoration (дизамбигуация типа) + Button DataPath

Корень: тип-детекция элемента видела ключ 'picture' РАНЬШЕ 'popup'/'button' в списке
типов. Но 'picture' это и тип (PictureDecoration), и свойство-иконка у popup/button/cmdBar
(оба строковые → не развязать по значению). Попап «{ popup, picture, representation }»
ошибочно компилировался как <PictureDecoration name="StdPicture.X"> → терялся весь попап
+ каскад. Решение: понизить приоритет picture/picField (в конец TYPE_KEYS) — тип-ключ
владельца выигрывает.

+ Button DataPath: кнопки общих команд несут <DataPath> (Объект.Ref, Items.X.CurrentData.Поле,
2706 в корпусе) — привязка команды к контексту. Не захватывался. Добавлен ключ path у button.

TOTAL diff lines выборки 2.17: 2727 → 2489 (-238). Снапшот button-group (+popup с картинкой)
сертифицирован в 1С (8.3.24). Регресс form-compile 34/34 зелёный на ps + python.
decompile v0.41, compile v1.59.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Nick Shirokov
2026-06-07 15:28:21 +03:00
parent 5112dbec9e
commit 4430ebc42e
5 changed files with 44 additions and 10 deletions
@@ -1,4 +1,4 @@
# form-compile v1.58 — Compile 1C managed form from JSON or object metadata
# form-compile v1.59 — Compile 1C managed form from JSON or object metadata
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
param(
[string]$JsonPath,
@@ -2392,7 +2392,9 @@ function Emit-Element {
$typeKey = $null
$xmlTag = $null
foreach ($key in @("columnGroup","buttonGroup","group","input","check","radio","label","labelField","table","pages","page","button","picture","picField","calendar","cmdBar","popup")) {
# picture/picField — НИЗКИЙ приоритет: 'picture' это и тип (PictureDecoration), и свойство-иконка
# у popup/button/cmdBar. Тип-ключ владельца (popup/button/…) должен выиграть.
foreach ($key in @("columnGroup","buttonGroup","group","input","check","radio","label","labelField","table","pages","page","button","calendar","cmdBar","popup","picField","picture")) {
if ($el.$key -ne $null) {
$typeKey = $key
break
@@ -3384,6 +3386,8 @@ function Emit-Button {
X "$inner<CommandName>Form.StandardCommand.$sc</CommandName>"
}
}
# DataPath — привязка команды кнопки к контексту (Объект.Ref, Items.X.CurrentData.Поле)
if ($el.path) { X "$inner<DataPath>$($el.path)</DataPath>" }
$btnAuto = -not ($el.command -or $el.commandName -or $el.stdCommand)
Emit-Title -el $el -name $name -indent $inner -auto:$btnAuto
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# form-compile v1.58 — Compile 1C managed form from JSON or object metadata
# form-compile v1.59 — Compile 1C managed form from JSON or object metadata
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
import argparse
import copy
@@ -1796,8 +1796,10 @@ KNOWN_KEYS = {
"userSettingsGroup", "rowsPicture",
}
# picture/picField — НИЗКИЙ приоритет: 'picture' это и тип (PictureDecoration), и свойство-иконка
# у popup/button/cmdBar. Тип-ключ владельца (popup/button/…) должен выиграть.
TYPE_KEYS = ["columnGroup", "buttonGroup", "group", "input", "check", "radio", "label", "labelField", "table", "pages", "page",
"button", "picture", "picField", "calendar", "cmdBar", "popup"]
"button", "calendar", "cmdBar", "popup", "picField", "picture"]
# Synonyms: model often writes XML name or Russian (ПолеПереключателя/RadioButtonField → radio)
ELEMENT_TYPE_SYNONYMS = {
@@ -3081,6 +3083,9 @@ def emit_button(lines, el, name, eid, indent, in_cmd_bar=False):
lines.append(f'{inner}<CommandName>Form.Item.{m.group(1)}.StandardCommand.{m.group(2)}</CommandName>')
else:
lines.append(f'{inner}<CommandName>Form.StandardCommand.{sc}</CommandName>')
# DataPath — привязка команды кнопки к контексту (Объект.Ref, Items.X.CurrentData.Поле)
if el.get('path'):
lines.append(f'{inner}<DataPath>{el["path"]}</DataPath>')
emit_title(lines, el, name, inner, auto=not (el.get('command') or el.get('commandName') or el.get('stdCommand')))
emit_common_flags(lines, el, inner)
@@ -1,4 +1,4 @@
# form-decompile v0.40 — Decompile 1C managed Form.xml to JSON DSL (draft)
# form-decompile v0.41 — Decompile 1C managed Form.xml to JSON DSL (draft)
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
# ВНИМАНИЕ: раундтрип не гарантируется. Навык исключён из авто-использования моделью.
param(
@@ -1188,6 +1188,7 @@ function Decompile-Element {
elseif ($cmd -match '^Form\.Item\.(.+)\.StandardCommand\.(.+)$') { $obj['stdCommand'] = "$($matches[1]).$($matches[2])" }
else { $obj['commandName'] = $cmd }
}
$dp = Get-Child $node 'DataPath'; if ($dp) { $obj['path'] = $dp }
Add-CommonProps $obj $node $name
$type = Get-Child $node 'Type'
if ($type) { $tmap=@{'CommandBarButton'='commandBar';'UsualButton'='usual';'Hyperlink'='hyperlink';'CommandBarHyperlink'='hyperlink'}; if ($tmap.ContainsKey($type)) { $obj['type']=$tmap[$type] } else { $obj['type']=$type } }
@@ -22,7 +22,10 @@
{ "button": "Вверх", "command": "Вверх" },
{ "button": "Вниз", "command": "Вниз" }
]},
{ "buttonGroup": "ГруппаГлобальныеКоманды", "commandSource": "FormCommandPanelGlobalCommands" }
{ "buttonGroup": "ГруппаГлобальныеКоманды", "commandSource": "FormCommandPanelGlobalCommands" },
{ "popup": "ПодменюПечать", "title": "Печать", "picture": "StdPicture.Print", "representation": "PictureAndText", "children": [
{ "button": "ПечатьСчёта", "command": "Выполнить" }
]}
]}
],
"attributes": [
@@ -45,11 +45,32 @@
<CommandSource>FormCommandPanelGlobalCommands</CommandSource>
<ExtendedTooltip name="ГруппаГлобальныеКомандыРасширеннаяПодсказка" id="12"/>
</ButtonGroup>
<Popup name="ПодменюПечать" id="13">
<Title>
<v8:item>
<v8:lang>ru</v8:lang>
<v8:content>Печать</v8:content>
</v8:item>
</Title>
<Picture>
<xr:Ref>StdPicture.Print</xr:Ref>
<xr:LoadTransparent>true</xr:LoadTransparent>
</Picture>
<Representation>PictureAndText</Representation>
<ExtendedTooltip name="ПодменюПечатьРасширеннаяПодсказка" id="14"/>
<ChildItems>
<Button name="ПечатьСчёта" id="15">
<Type>CommandBarButton</Type>
<CommandName>Form.Command.Выполнить</CommandName>
<ExtendedTooltip name="ПечатьСчётаРасширеннаяПодсказка" id="16"/>
</Button>
</ChildItems>
</Popup>
</ChildItems>
</CommandBar>
</ChildItems>
<Attributes>
<Attribute name="Объект" id="13">
<Attribute name="Объект" id="17">
<Type>
<v8:Type>cfg:DataProcessorObject.ГруппыКнопок</v8:Type>
</Type>
@@ -57,7 +78,7 @@
</Attribute>
</Attributes>
<Commands>
<Command name="Выполнить" id="14">
<Command name="Выполнить" id="18">
<Title>
<v8:item>
<v8:lang>ru</v8:lang>
@@ -73,7 +94,7 @@
<Action>ВыполнитьОбработка</Action>
<Shortcut>Ctrl+Enter</Shortcut>
</Command>
<Command name="Вверх" id="15">
<Command name="Вверх" id="19">
<Title>
<v8:item>
<v8:lang>ru</v8:lang>
@@ -83,7 +104,7 @@
<Action>ВверхОбработка</Action>
<CurrentRowUse>DontUse</CurrentRowUse>
</Command>
<Command name="Вниз" id="16">
<Command name="Вниз" id="20">
<Title>
<v8:item>
<v8:lang>ru</v8:lang>