mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-07-19 09:09:41 +03:00
feat(form-decompile,form-compile): Button Parameter (параметр команды кнопки)
Кнопка команды может нести <Parameter> (после CommandName) — параметр команды:
- xr:MDObjectRef (20 в корпусе 8.3.24): ссылка на объект метаданных, напр.
DocumentJournal.Взаимодействия (команда ShowInList «Показать в списке»);
- v8:TypeDescription (16): описание типа <v8:Type>cfg:DocumentRef.X</v8:Type>
(команда CreateByParameter «Создать по параметру»).
Декомпилятор не ловил → терялось (форма ЭлектронноеПисьмоИсходящее и др.).
DSL: ключ button.parameter (синоним «параметр»), дизамбигуация по форме значения —
строка → MDObjectRef (verbatim), объект {type} → TypeDescription (грамматика типа,
переиспользует Emit-Type с tag=Parameter). Декомпилятор: MDObjectRef → строка,
TypeDescription → {type} (Decompile-Type). Позиция: после CommandName.
Выборка 16 форм с Button Parameter: match 16/16, 0 потерь (оба вида). Кейс commands
(+кнопка с параметр:{type:CatalogRef} через рус-синоним) сертифицирован загрузкой в 1С —
позиция Parameter и синоним подтверждены. MDObjectRef-вариант: та же позиция эмиссии +
corpus round-trip (ShowInList требует list-контекст, синтетически не воспроизвести).
Регресс 43/43, ps1==py. parameter в knownKeys allowlist.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# form-compile v1.145 — Compile 1C managed form from JSON or object metadata
|
||||
# form-compile v1.146 — Compile 1C managed form from JSON or object metadata
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[string]$JsonPath,
|
||||
@@ -2922,7 +2922,7 @@ function Emit-Element {
|
||||
# pages-specific
|
||||
"pagesRepresentation"=1
|
||||
# button-specific
|
||||
"type"=1;"command"=1;"commandName"=1;"stdCommand"=1;"defaultButton"=1;"locationInCommandBar"=1;"displayImportance"=1
|
||||
"type"=1;"command"=1;"commandName"=1;"stdCommand"=1;"parameter"=1;"defaultButton"=1;"locationInCommandBar"=1;"displayImportance"=1
|
||||
# picture/decoration
|
||||
"src"=1;"valuesPicture"=1;"loadTransparent"=1;"headerPicture"=1;"footerPicture"=1
|
||||
# cmdBar-specific
|
||||
@@ -4718,6 +4718,16 @@ function Emit-Button {
|
||||
X "$inner<CommandName>Form.StandardCommand.$sc</CommandName>"
|
||||
}
|
||||
}
|
||||
# Parameter команды (после CommandName): строка → xr:MDObjectRef (объект метаданных);
|
||||
# объект {type} → v8:TypeDescription (грамматика типа). Forgiving-синоним 'параметр'.
|
||||
$btnParam = if ($null -ne $el.PSObject.Properties['parameter']) { $el.parameter } elseif ($null -ne $el.PSObject.Properties['параметр']) { $el.параметр } else { $null }
|
||||
if ($null -ne $btnParam) {
|
||||
if (($btnParam -is [System.Management.Automation.PSCustomObject] -or $btnParam -is [hashtable]) -and $btnParam.type) {
|
||||
Emit-Type -typeStr "$($btnParam.type)" -indent $inner -tag "Parameter" -tagAttrs ' xsi:type="v8:TypeDescription"'
|
||||
} else {
|
||||
X "$inner<Parameter xsi:type=`"xr:MDObjectRef`">$(Esc-Xml "$btnParam")</Parameter>"
|
||||
}
|
||||
}
|
||||
# DataPath — привязка команды кнопки к контексту (Объект.Ref, Items.X.CurrentData.Поле)
|
||||
if ($el.path) { X "$inner<DataPath>$($el.path)</DataPath>" }
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# form-compile v1.145 — Compile 1C managed form from JSON or object metadata
|
||||
# form-compile v1.146 — Compile 1C managed form from JSON or object metadata
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
import argparse
|
||||
import copy
|
||||
@@ -2023,7 +2023,7 @@ KNOWN_KEYS = {
|
||||
"commandBarLocation", "searchStringLocation", "viewStatusLocation", "searchControlLocation",
|
||||
"excludedCommands",
|
||||
"pagesRepresentation",
|
||||
"type", "command", "commandName", "stdCommand", "defaultButton", "locationInCommandBar", "displayImportance",
|
||||
"type", "command", "commandName", "stdCommand", "parameter", "defaultButton", "locationInCommandBar", "displayImportance",
|
||||
"commandBar", "contextMenu", "commandSource",
|
||||
"src", "valuesPicture", "loadTransparent", "headerPicture", "footerPicture",
|
||||
"autofill",
|
||||
@@ -4440,6 +4440,16 @@ 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>')
|
||||
# Parameter команды (после CommandName): строка → xr:MDObjectRef (объект метаданных);
|
||||
# объект {type} → v8:TypeDescription (грамматика типа). Forgiving-синоним 'параметр'.
|
||||
btn_param = el.get('parameter')
|
||||
if btn_param is None:
|
||||
btn_param = el.get('параметр')
|
||||
if btn_param is not None:
|
||||
if isinstance(btn_param, dict) and btn_param.get('type'):
|
||||
emit_type(lines, str(btn_param['type']), inner, tag='Parameter', tag_attrs=' xsi:type="v8:TypeDescription"')
|
||||
else:
|
||||
lines.append(f'{inner}<Parameter xsi:type="xr:MDObjectRef">{esc_xml(str(btn_param))}</Parameter>')
|
||||
# DataPath — привязка команды кнопки к контексту (Объект.Ref, Items.X.CurrentData.Поле)
|
||||
if el.get('path'):
|
||||
lines.append(f'{inner}<DataPath>{el["path"]}</DataPath>')
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# form-decompile v0.118 — Decompile 1C managed Form.xml to JSON DSL (draft)
|
||||
# form-decompile v0.119 — Decompile 1C managed Form.xml to JSON DSL (draft)
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
# ВНИМАНИЕ: раундтрип не гарантируется. Навык исключён из авто-использования моделью.
|
||||
param(
|
||||
@@ -2083,6 +2083,13 @@ function Decompile-Element {
|
||||
else { $obj['commandName'] = $cmd }
|
||||
}
|
||||
$dp = Get-Child $node 'DataPath'; if ($dp) { $obj['path'] = $dp }
|
||||
# Parameter команды: xr:MDObjectRef (объект метаданных, строка) или v8:TypeDescription (тип → {type})
|
||||
$btnParam = $node.SelectSingleNode("lf:Parameter", $ns)
|
||||
if ($btnParam) {
|
||||
$pxt = $btnParam.GetAttribute("type", $NS_XSI)
|
||||
if ($pxt -match 'TypeDescription$') { $pt = Decompile-Type $btnParam; if ($pt) { $obj['parameter'] = [ordered]@{ type = $pt } } }
|
||||
elseif ($btnParam.InnerText) { $obj['parameter'] = $btnParam.InnerText }
|
||||
}
|
||||
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 } }
|
||||
|
||||
Reference in New Issue
Block a user