mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-07-18 16:49:41 +03:00
feat(form-decompile,form-compile): DisplayImportance + MinValue/MaxValue + verticalSpacing + rowsPicture LoadTransparent + autoMaxWidth/RowPictureDataPath fixes
Раундтрип TOTAL 25→21, match 146→153. Батч из 6 хвостовых находок:
- DisplayImportance: атрибут открывающего тега ЛЮБОГО элемента (адаптивная
важность VeryHigh/High/Usual/Low/VeryLow). Хелпер DI-Attr/di_attr внедрён в
открывающие теги; декомпилятор захватывает в диспетчере (атрибут узла).
- MinValue/MaxValue (input): типизированные (xsi:type). Тип сохраняется через
тип JSON-значения: число → xs:decimal, строка → xs:string.
- verticalSpacing: generic-скаляр группы (<VerticalSpacing>).
- rowsPicture: объектная форма {src, loadTransparent} — компилятор хардкодил
LoadTransparent=false, теперь факт. значение (792 false / 327 true в корпусе).
- autoMaxWidth: суппресс multiLineDefault-эвристики (декомпилятор фиксирует факт.
значение; multiLine-input без тега → autoMaxWidth:true).
- RowPictureDataPath: снят гейт hasMainTable у реинъекции smart-default (дин-список
без mainTable тоже несёт <RowPictureDataPath>; ""-маркер ловит реальное отсутствие).
Зеркало py (компилятор). Кейсы input-fields/groups расширены и сертифицированы
загрузкой в 1С. Регресс 39/39 в обоих рантаймах.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# form-compile v1.91 — Compile 1C managed form from JSON or object metadata
|
||||
# form-compile v1.92 — Compile 1C managed form from JSON or object metadata
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[string]$JsonPath,
|
||||
@@ -2314,6 +2314,14 @@ function Emit-CompanionTitle {
|
||||
X "$indent</Title>"
|
||||
}
|
||||
|
||||
# DisplayImportance — атрибут открывающего тега элемента (адаптивная важность: VeryHigh/High/Usual/Low/VeryLow).
|
||||
# Возвращает ` DisplayImportance="X"` или "" (для companion-эмиттеров без $el → "" молча).
|
||||
function DI-Attr {
|
||||
param($el)
|
||||
if ($null -ne $el -and $el.displayImportance) { return " DisplayImportance=`"$(Esc-Xml "$($el.displayImportance)")`"" }
|
||||
return ""
|
||||
}
|
||||
|
||||
function Emit-Companion {
|
||||
param([string]$tag, [string]$name, [string]$indent, $content = $null)
|
||||
$id = New-Id
|
||||
@@ -2323,7 +2331,7 @@ function Emit-Companion {
|
||||
return
|
||||
}
|
||||
$inner = "$indent`t"
|
||||
X "$indent<$tag name=`"$name`" id=`"$id`">"
|
||||
X "$indent<$tag name=`"$name`" id=`"$id`"$(DI-Attr $el)>"
|
||||
if (Test-CompanionStructured $content) {
|
||||
# структурированная форма (own-content). Порядок как у платформы: own-content (флаги/hyperlink/
|
||||
# layout/оформление) ПЕРЕД Title (в корпусе layout-first 582 vs 10).
|
||||
@@ -2362,7 +2370,7 @@ function Emit-CompanionPanel {
|
||||
X "$indent<$tag name=`"$name`" id=`"$id`"/>"
|
||||
return
|
||||
}
|
||||
X "$indent<$tag name=`"$name`" id=`"$id`">"
|
||||
X "$indent<$tag name=`"$name`" id=`"$id`"$(DI-Attr $el)>"
|
||||
if ($halign) { X "$indent`t<HorizontalAlign>$halign</HorizontalAlign>" }
|
||||
if ($emitAfFalse) { X "$indent`t<Autofill>false</Autofill>" }
|
||||
if ($hasChildren) {
|
||||
@@ -2427,7 +2435,7 @@ function Emit-Addition {
|
||||
param($el, [string]$name, [int]$id, [string]$typeKey, [string]$indent)
|
||||
$map = $script:additionTypeMap[$typeKey]
|
||||
$source = if ($el.source) { "$($el.source)" } elseif ($script:currentTableName) { $script:currentTableName } else { '' }
|
||||
X "$indent<$($map.Tag) name=`"$name`" id=`"$id`">"
|
||||
X "$indent<$($map.Tag) name=`"$name`" id=`"$id`"$(DI-Attr $el)>"
|
||||
Emit-AdditionBody -props $el -source $source -srcType $map.Type -addName $name -indent $indent
|
||||
X "$indent</$($map.Tag)>"
|
||||
}
|
||||
@@ -2616,7 +2624,7 @@ function Emit-Element {
|
||||
# pages-specific
|
||||
"pagesRepresentation"=1
|
||||
# button-specific
|
||||
"type"=1;"command"=1;"commandName"=1;"stdCommand"=1;"defaultButton"=1;"locationInCommandBar"=1
|
||||
"type"=1;"command"=1;"commandName"=1;"stdCommand"=1;"defaultButton"=1;"locationInCommandBar"=1;"displayImportance"=1
|
||||
# picture/decoration
|
||||
"src"=1;"valuesPicture"=1;"loadTransparent"=1;"headerPicture"=1;"footerPicture"=1
|
||||
# cmdBar-specific
|
||||
@@ -2628,10 +2636,10 @@ function Emit-Element {
|
||||
# generic-скаляры (pass-through) + точечные
|
||||
"verticalAlign"=1;"throughAlign"=1;"enableContentChange"=1;"pictureSize"=1;"titleHeight"=1
|
||||
"childItemsWidth"=1;"showLeftMargin"=1;"cellHyperlink"=1;"viewMode"=1;"verticalScrollBar"=1
|
||||
"rowInputMode"=1;"mask"=1;"createButton"=1;"fixingInTable"=1
|
||||
"rowInputMode"=1;"mask"=1;"createButton"=1;"fixingInTable"=1;"verticalSpacing"=1
|
||||
# InputField choice-скаляры
|
||||
"choiceListButton"=1;"quickChoice"=1;"autoChoiceIncomplete"=1
|
||||
"choiceForm"=1;"choiceHistoryOnInput"=1;"footerDataPath"=1
|
||||
"choiceForm"=1;"choiceHistoryOnInput"=1;"footerDataPath"=1;"minValue"=1;"maxValue"=1
|
||||
# Button — пометка toggle-кнопки (ключ 'checked', не 'check' — во избежание конфликта с типом)
|
||||
"checked"=1
|
||||
}
|
||||
@@ -2840,6 +2848,7 @@ $script:genericScalars = @(
|
||||
@{ Tag='Mask'; Key='mask'; Kind='value' }
|
||||
@{ Tag='CreateButton'; Key='createButton'; Kind='bool' }
|
||||
@{ Tag='FixingInTable'; Key='fixingInTable'; Kind='value' }
|
||||
@{ Tag='VerticalSpacing'; Key='verticalSpacing'; Kind='value' }
|
||||
)
|
||||
|
||||
function Emit-GenericScalars {
|
||||
@@ -3009,7 +3018,7 @@ function Emit-TitleLocation {
|
||||
function Emit-Group {
|
||||
param($el, [string]$name, [int]$id, [string]$indent)
|
||||
|
||||
X "$indent<UsualGroup name=`"$name`" id=`"$id`">"
|
||||
X "$indent<UsualGroup name=`"$name`" id=`"$id`"$(DI-Attr $el)>"
|
||||
$inner = "$indent`t"
|
||||
|
||||
Emit-Title -el $el -name $name -indent $inner
|
||||
@@ -3080,7 +3089,7 @@ function Emit-Group {
|
||||
function Emit-ColumnGroup {
|
||||
param($el, [string]$name, [int]$id, [string]$indent)
|
||||
|
||||
X "$indent<ColumnGroup name=`"$name`" id=`"$id`">"
|
||||
X "$indent<ColumnGroup name=`"$name`" id=`"$id`"$(DI-Attr $el)>"
|
||||
$inner = "$indent`t"
|
||||
|
||||
Emit-Title -el $el -name $name -indent $inner
|
||||
@@ -3122,7 +3131,7 @@ function Emit-ColumnGroup {
|
||||
function Emit-Input {
|
||||
param($el, [string]$name, [int]$id, [string]$indent)
|
||||
|
||||
X "$indent<InputField name=`"$name`" id=`"$id`">"
|
||||
X "$indent<InputField name=`"$name`" id=`"$id`"$(DI-Attr $el)>"
|
||||
$inner = "$indent`t"
|
||||
|
||||
if ($el.path) { X "$inner<DataPath>$($el.path)</DataPath>" }
|
||||
@@ -3171,6 +3180,13 @@ function Emit-Input {
|
||||
)) {
|
||||
if ($el.($p[0])) { X "$inner<$($p[1])>$(Esc-Xml "$($el.($p[0]))")</$($p[1])>" }
|
||||
}
|
||||
# MinValue/MaxValue — типизированное. JSON-число → xs:decimal, строка → xs:string (тип сохранён декомпилятором).
|
||||
foreach ($p in @(@('minValue','MinValue'), @('maxValue','MaxValue'))) {
|
||||
if ($null -ne $el.($p[0])) {
|
||||
$mvt = if ($el.($p[0]) -is [string]) { 'xs:string' } else { 'xs:decimal' }
|
||||
X "$inner<$($p[1]) xsi:type=`"$mvt`">$(Esc-Xml "$($el.($p[0]))")</$($p[1])>"
|
||||
}
|
||||
}
|
||||
if ($el.choiceButtonRepresentation) { X "$inner<ChoiceButtonRepresentation>$($el.choiceButtonRepresentation)</ChoiceButtonRepresentation>" }
|
||||
Emit-Layout -el $el -indent $inner -multiLineDefault ([bool]($el.multiLine -eq $true))
|
||||
|
||||
@@ -3204,7 +3220,7 @@ function Emit-Input {
|
||||
function Emit-Check {
|
||||
param($el, [string]$name, [int]$id, [string]$indent)
|
||||
|
||||
X "$indent<CheckBoxField name=`"$name`" id=`"$id`">"
|
||||
X "$indent<CheckBoxField name=`"$name`" id=`"$id`"$(DI-Attr $el)>"
|
||||
$inner = "$indent`t"
|
||||
|
||||
if ($el.path) { X "$inner<DataPath>$($el.path)</DataPath>" }
|
||||
@@ -3595,7 +3611,7 @@ function Emit-TypeLink {
|
||||
function Emit-Radio {
|
||||
param($el, [string]$name, [int]$id, [string]$indent)
|
||||
|
||||
X "$indent<RadioButtonField name=`"$name`" id=`"$id`">"
|
||||
X "$indent<RadioButtonField name=`"$name`" id=`"$id`"$(DI-Attr $el)>"
|
||||
$inner = "$indent`t"
|
||||
|
||||
if ($el.path) { X "$inner<DataPath>$($el.path)</DataPath>" }
|
||||
@@ -3656,7 +3672,7 @@ function Emit-DecorationTitle {
|
||||
function Emit-Label {
|
||||
param($el, [string]$name, [int]$id, [string]$indent)
|
||||
|
||||
X "$indent<LabelDecoration name=`"$name`" id=`"$id`">"
|
||||
X "$indent<LabelDecoration name=`"$name`" id=`"$id`"$(DI-Attr $el)>"
|
||||
$inner = "$indent`t"
|
||||
|
||||
# Порядок как у платформы: own-content (флаги/hyperlink/layout/оформление) ПЕРЕД Title
|
||||
@@ -3680,7 +3696,7 @@ function Emit-Label {
|
||||
function Emit-LabelField {
|
||||
param($el, [string]$name, [int]$id, [string]$indent)
|
||||
|
||||
X "$indent<LabelField name=`"$name`" id=`"$id`">"
|
||||
X "$indent<LabelField name=`"$name`" id=`"$id`"$(DI-Attr $el)>"
|
||||
$inner = "$indent`t"
|
||||
|
||||
if ($el.path) { X "$inner<DataPath>$($el.path)</DataPath>" }
|
||||
@@ -3747,7 +3763,7 @@ function Emit-Table {
|
||||
param($el, [string]$name, [int]$id, [string]$indent)
|
||||
|
||||
$script:currentTableName = $name # дефолт source для кастомных дополнений в commandBar
|
||||
X "$indent<Table name=`"$name`" id=`"$id`">"
|
||||
X "$indent<Table name=`"$name`" id=`"$id`"$(DI-Attr $el)>"
|
||||
$inner = "$indent`t"
|
||||
|
||||
if ($el.path) { X "$inner<DataPath>$($el.path)</DataPath>" }
|
||||
@@ -3796,9 +3812,12 @@ function Emit-Table {
|
||||
if ($el.enableDrag -eq $true) { X "$inner<EnableDrag>true</EnableDrag>" }
|
||||
if ($el.rowPictureDataPath) { X "$inner<RowPictureDataPath>$($el.rowPictureDataPath)</RowPictureDataPath>" }
|
||||
if ($el.rowsPicture) {
|
||||
# Строка = Ref (LoadTransparent дефолт false); объект {src, loadTransparent} → факт. значение
|
||||
$rpSrc = if ($el.rowsPicture -is [string]) { $el.rowsPicture } else { $el.rowsPicture.src }
|
||||
$rpLt = if ($el.rowsPicture -isnot [string] -and $el.rowsPicture.loadTransparent -eq $true) { 'true' } else { 'false' }
|
||||
X "$inner<RowsPicture>"
|
||||
X "$inner`t<xr:Ref>$($el.rowsPicture)</xr:Ref>"
|
||||
X "$inner`t<xr:LoadTransparent>false</xr:LoadTransparent>"
|
||||
X "$inner`t<xr:Ref>$rpSrc</xr:Ref>"
|
||||
X "$inner`t<xr:LoadTransparent>$rpLt</xr:LoadTransparent>"
|
||||
X "$inner</RowsPicture>"
|
||||
}
|
||||
# Блок свойств дин-список-таблицы (помечена эвристикой 11b.4)
|
||||
@@ -3853,7 +3872,7 @@ function Emit-Table {
|
||||
function Emit-Pages {
|
||||
param($el, [string]$name, [int]$id, [string]$indent)
|
||||
|
||||
X "$indent<Pages name=`"$name`" id=`"$id`">"
|
||||
X "$indent<Pages name=`"$name`" id=`"$id`"$(DI-Attr $el)>"
|
||||
$inner = "$indent`t"
|
||||
|
||||
Emit-Title -el $el -name $name -indent $inner
|
||||
@@ -3885,7 +3904,7 @@ function Emit-Pages {
|
||||
function Emit-Page {
|
||||
param($el, [string]$name, [int]$id, [string]$indent)
|
||||
|
||||
X "$indent<Page name=`"$name`" id=`"$id`">"
|
||||
X "$indent<Page name=`"$name`" id=`"$id`"$(DI-Attr $el)>"
|
||||
$inner = "$indent`t"
|
||||
|
||||
Emit-Title -el $el -name $name -indent $inner -auto
|
||||
@@ -3922,7 +3941,7 @@ function Emit-Page {
|
||||
function Emit-Button {
|
||||
param($el, [string]$name, [int]$id, [string]$indent, [bool]$inCmdBar = $false)
|
||||
|
||||
X "$indent<Button name=`"$name`" id=`"$id`">"
|
||||
X "$indent<Button name=`"$name`" id=`"$id`"$(DI-Attr $el)>"
|
||||
$inner = "$indent`t"
|
||||
# (общие свойства — через Emit-Layout ниже; отдельный вызов был бы двойной эмиссией)
|
||||
|
||||
@@ -4020,7 +4039,7 @@ function Emit-Button {
|
||||
function Emit-PictureDecoration {
|
||||
param($el, [string]$name, [int]$id, [string]$indent)
|
||||
|
||||
X "$indent<PictureDecoration name=`"$name`" id=`"$id`">"
|
||||
X "$indent<PictureDecoration name=`"$name`" id=`"$id`"$(DI-Attr $el)>"
|
||||
$inner = "$indent`t"
|
||||
|
||||
Emit-DecorationTitle -el $el -name $name -indent $inner
|
||||
@@ -4056,7 +4075,7 @@ function Emit-PictureDecoration {
|
||||
function Emit-PictureField {
|
||||
param($el, [string]$name, [int]$id, [string]$indent)
|
||||
|
||||
X "$indent<PictureField name=`"$name`" id=`"$id`">"
|
||||
X "$indent<PictureField name=`"$name`" id=`"$id`"$(DI-Attr $el)>"
|
||||
$inner = "$indent`t"
|
||||
|
||||
if ($el.path) { X "$inner<DataPath>$($el.path)</DataPath>" }
|
||||
@@ -4092,7 +4111,7 @@ function Emit-PictureField {
|
||||
function Emit-Calendar {
|
||||
param($el, [string]$name, [int]$id, [string]$indent)
|
||||
|
||||
X "$indent<CalendarField name=`"$name`" id=`"$id`">"
|
||||
X "$indent<CalendarField name=`"$name`" id=`"$id`"$(DI-Attr $el)>"
|
||||
$inner = "$indent`t"
|
||||
|
||||
if ($el.path) { X "$inner<DataPath>$($el.path)</DataPath>" }
|
||||
@@ -4137,7 +4156,7 @@ function Emit-Calendar {
|
||||
function Emit-CommandBar {
|
||||
param($el, [string]$name, [int]$id, [string]$indent)
|
||||
|
||||
X "$indent<CommandBar name=`"$name`" id=`"$id`">"
|
||||
X "$indent<CommandBar name=`"$name`" id=`"$id`"$(DI-Attr $el)>"
|
||||
$inner = "$indent`t"
|
||||
|
||||
Emit-Title -el $el -name $name -indent $inner
|
||||
@@ -4166,7 +4185,7 @@ function Emit-CommandBar {
|
||||
function Emit-ButtonGroup {
|
||||
param($el, [string]$name, [int]$id, [string]$indent)
|
||||
|
||||
X "$indent<ButtonGroup name=`"$name`" id=`"$id`">"
|
||||
X "$indent<ButtonGroup name=`"$name`" id=`"$id`"$(DI-Attr $el)>"
|
||||
$inner = "$indent`t"
|
||||
|
||||
Emit-Title -el $el -name $name -indent $inner
|
||||
@@ -4198,7 +4217,7 @@ function Emit-ButtonGroup {
|
||||
function Emit-Popup {
|
||||
param($el, [string]$name, [int]$id, [string]$indent)
|
||||
|
||||
X "$indent<Popup name=`"$name`" id=`"$id`">"
|
||||
X "$indent<Popup name=`"$name`" id=`"$id`"$(DI-Attr $el)>"
|
||||
$inner = "$indent`t"
|
||||
|
||||
Emit-Title -el $el -name $name -indent $inner -auto
|
||||
@@ -4931,9 +4950,11 @@ function ApplyDynamicListTableHeuristic {
|
||||
if ($null -eq $el.PSObject.Properties["commandBarLocation"]) {
|
||||
$el | Add-Member -NotePropertyName "commandBarLocation" -NotePropertyValue "None" -Force
|
||||
}
|
||||
# RowPictureDataPath: умный дефолт <Список>.DefaultPicture, если ключ ОТСУТСТВУЕТ
|
||||
# и есть основная таблица. Пустая строка (suppress-маркер) НЕ перезатирается.
|
||||
if ($hasMainTable -and ($null -eq $el.PSObject.Properties["rowPictureDataPath"])) {
|
||||
# RowPictureDataPath: умный дефолт <Список>.DefaultPicture, если ключ ОТСУТСТВУЕТ.
|
||||
# Декомпилятор опускает ключ при rpdp == smart-default (ждёт реинъекции); реальное отсутствие
|
||||
# фиксирует ""-маркером (НЕ перезатирается). Гейт hasMainTable снят: дин-список без mainTable
|
||||
# (напр. query-based) тоже несёт RowPictureDataPath.
|
||||
if ($null -eq $el.PSObject.Properties["rowPictureDataPath"]) {
|
||||
$el | Add-Member -NotePropertyName "rowPictureDataPath" -NotePropertyValue "$listName.DefaultPicture" -Force
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# form-compile v1.91 — Compile 1C managed form from JSON or object metadata
|
||||
# form-compile v1.92 — Compile 1C managed form from JSON or object metadata
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
import argparse
|
||||
import copy
|
||||
@@ -1258,6 +1258,13 @@ def esc_xml(s):
|
||||
return s.replace('&', '&').replace('<', '<').replace('>', '>')
|
||||
|
||||
|
||||
def di_attr(el):
|
||||
# DisplayImportance — атрибут открывающего тега элемента (адаптивная важность). "" если нет.
|
||||
if isinstance(el, dict) and el.get('displayImportance'):
|
||||
return f' DisplayImportance="{esc_xml(str(el["displayImportance"]))}"'
|
||||
return ''
|
||||
|
||||
|
||||
# Базовая директория для @file-ссылок в query динсписка (устанавливается в main)
|
||||
QUERY_BASE_DIR = None
|
||||
|
||||
@@ -1796,7 +1803,7 @@ KNOWN_KEYS = {
|
||||
"commandBarLocation", "searchStringLocation", "viewStatusLocation", "searchControlLocation",
|
||||
"excludedCommands",
|
||||
"pagesRepresentation",
|
||||
"type", "command", "commandName", "stdCommand", "defaultButton", "locationInCommandBar",
|
||||
"type", "command", "commandName", "stdCommand", "defaultButton", "locationInCommandBar", "displayImportance",
|
||||
"commandBar", "contextMenu", "commandSource",
|
||||
"src", "valuesPicture", "loadTransparent", "headerPicture", "footerPicture",
|
||||
"autofill",
|
||||
@@ -1816,10 +1823,10 @@ KNOWN_KEYS = {
|
||||
# generic-скаляры (pass-through)
|
||||
"verticalAlign", "throughAlign", "enableContentChange", "pictureSize", "titleHeight",
|
||||
"childItemsWidth", "showLeftMargin", "cellHyperlink", "viewMode", "verticalScrollBar",
|
||||
"rowInputMode", "mask", "createButton", "fixingInTable",
|
||||
"rowInputMode", "mask", "createButton", "fixingInTable", "verticalSpacing",
|
||||
# InputField choice-скаляры
|
||||
"choiceListButton", "quickChoice", "autoChoiceIncomplete",
|
||||
"choiceForm", "choiceHistoryOnInput", "footerDataPath",
|
||||
"choiceForm", "choiceHistoryOnInput", "footerDataPath", "minValue", "maxValue",
|
||||
# Button — пометка toggle-кнопки
|
||||
"checked",
|
||||
}
|
||||
@@ -2436,7 +2443,7 @@ def emit_addition(lines, el, name, eid, type_key, indent):
|
||||
# Кастомное дополнение (тип-элемент в commandBar): source дефолтит в текущую таблицу.
|
||||
m = ADDITION_TYPE_MAP[type_key]
|
||||
source = el.get('source') or _current_table_name['name'] or ''
|
||||
lines.append(f'{indent}<{m["tag"]} name="{name}" id="{eid}">')
|
||||
lines.append(f'{indent}<{m["tag"]} name="{name}" id="{eid}"{di_attr(el)}>')
|
||||
emit_addition_body(lines, el, source, m['type'], name, indent)
|
||||
lines.append(f'{indent}</{m["tag"]}>')
|
||||
|
||||
@@ -2689,6 +2696,7 @@ GENERIC_SCALARS = [
|
||||
('Mask', 'mask', 'value'),
|
||||
('CreateButton', 'createButton', 'bool'),
|
||||
('FixingInTable', 'fixingInTable', 'value'),
|
||||
('VerticalSpacing', 'verticalSpacing', 'value'),
|
||||
]
|
||||
|
||||
|
||||
@@ -3071,7 +3079,7 @@ def emit_element(lines, el, indent, in_cmd_bar=False):
|
||||
|
||||
|
||||
def emit_group(lines, el, name, eid, indent):
|
||||
lines.append(f'{indent}<UsualGroup name="{name}" id="{eid}">')
|
||||
lines.append(f'{indent}<UsualGroup name="{name}" id="{eid}"{di_attr(el)}>')
|
||||
inner = f'{indent}\t'
|
||||
|
||||
emit_title(lines, el, name, inner)
|
||||
@@ -3141,7 +3149,7 @@ def emit_group(lines, el, name, eid, indent):
|
||||
|
||||
|
||||
def emit_column_group(lines, el, name, eid, indent):
|
||||
lines.append(f'{indent}<ColumnGroup name="{name}" id="{eid}">')
|
||||
lines.append(f'{indent}<ColumnGroup name="{name}" id="{eid}"{di_attr(el)}>')
|
||||
inner = f'{indent}\t'
|
||||
|
||||
emit_title(lines, el, name, inner)
|
||||
@@ -3178,7 +3186,7 @@ def emit_column_group(lines, el, name, eid, indent):
|
||||
|
||||
|
||||
def emit_input(lines, el, name, eid, indent):
|
||||
lines.append(f'{indent}<InputField name="{name}" id="{eid}">')
|
||||
lines.append(f'{indent}<InputField name="{name}" id="{eid}"{di_attr(el)}>')
|
||||
inner = f'{indent}\t'
|
||||
|
||||
if el.get('path'):
|
||||
@@ -3227,6 +3235,11 @@ def emit_input(lines, el, name, eid, indent):
|
||||
('choiceFoldersAndItems', 'ChoiceFoldersAndItems'), ('footerDataPath', 'FooterDataPath')):
|
||||
if el.get(key):
|
||||
lines.append(f'{inner}<{tag}>{esc_xml(str(el[key]))}</{tag}>')
|
||||
# MinValue/MaxValue — типизированное. JSON-число → xs:decimal, строка → xs:string (тип сохранён декомпилятором).
|
||||
for key, tag in (('minValue', 'MinValue'), ('maxValue', 'MaxValue')):
|
||||
if el.get(key) is not None:
|
||||
mvt = 'xs:string' if isinstance(el[key], str) else 'xs:decimal'
|
||||
lines.append(f'{inner}<{tag} xsi:type="{mvt}">{esc_xml(str(el[key]))}</{tag}>')
|
||||
if el.get('choiceButtonRepresentation'):
|
||||
lines.append(f'{inner}<ChoiceButtonRepresentation>{el["choiceButtonRepresentation"]}</ChoiceButtonRepresentation>')
|
||||
emit_layout(lines, el, inner, multi_line_default=(el.get('multiLine') is True))
|
||||
@@ -3260,7 +3273,7 @@ def emit_input(lines, el, name, eid, indent):
|
||||
|
||||
|
||||
def emit_check(lines, el, name, eid, indent):
|
||||
lines.append(f'{indent}<CheckBoxField name="{name}" id="{eid}">')
|
||||
lines.append(f'{indent}<CheckBoxField name="{name}" id="{eid}"{di_attr(el)}>')
|
||||
inner = f'{indent}\t'
|
||||
|
||||
if el.get('path'):
|
||||
@@ -3303,7 +3316,7 @@ def emit_check(lines, el, name, eid, indent):
|
||||
|
||||
|
||||
def emit_radio_button_field(lines, el, name, eid, indent):
|
||||
lines.append(f'{indent}<RadioButtonField name="{name}" id="{eid}">')
|
||||
lines.append(f'{indent}<RadioButtonField name="{name}" id="{eid}"{di_attr(el)}>')
|
||||
inner = f'{indent}\t'
|
||||
|
||||
if el.get('path'):
|
||||
@@ -3354,7 +3367,7 @@ def emit_decoration_title(lines, el, name, indent, auto=False):
|
||||
|
||||
|
||||
def emit_label(lines, el, name, eid, indent):
|
||||
lines.append(f'{indent}<LabelDecoration name="{name}" id="{eid}">')
|
||||
lines.append(f'{indent}<LabelDecoration name="{name}" id="{eid}"{di_attr(el)}>')
|
||||
inner = f'{indent}\t'
|
||||
|
||||
# Порядок как у платформы: own-content (флаги/hyperlink/layout/оформление) ПЕРЕД Title
|
||||
@@ -3377,7 +3390,7 @@ def emit_label(lines, el, name, eid, indent):
|
||||
|
||||
|
||||
def emit_label_field(lines, el, name, eid, indent):
|
||||
lines.append(f'{indent}<LabelField name="{name}" id="{eid}">')
|
||||
lines.append(f'{indent}<LabelField name="{name}" id="{eid}"{di_attr(el)}>')
|
||||
inner = f'{indent}\t'
|
||||
|
||||
if el.get('path'):
|
||||
@@ -3446,7 +3459,7 @@ def emit_dynlist_table_block(lines, el, indent):
|
||||
|
||||
def emit_table(lines, el, name, eid, indent):
|
||||
_current_table_name['name'] = name # дефолт source для кастомных дополнений в commandBar
|
||||
lines.append(f'{indent}<Table name="{name}" id="{eid}">')
|
||||
lines.append(f'{indent}<Table name="{name}" id="{eid}"{di_attr(el)}>')
|
||||
inner = f'{indent}\t'
|
||||
|
||||
if el.get('path'):
|
||||
@@ -3511,9 +3524,13 @@ def emit_table(lines, el, name, eid, indent):
|
||||
if el.get('rowPictureDataPath'):
|
||||
lines.append(f'{inner}<RowPictureDataPath>{el["rowPictureDataPath"]}</RowPictureDataPath>')
|
||||
if el.get('rowsPicture'):
|
||||
# Строка = Ref (LoadTransparent дефолт false); объект {src, loadTransparent} → факт. значение
|
||||
rp = el['rowsPicture']
|
||||
rp_src = rp if isinstance(rp, str) else rp.get('src')
|
||||
rp_lt = 'true' if (not isinstance(rp, str) and rp.get('loadTransparent') is True) else 'false'
|
||||
lines.append(f'{inner}<RowsPicture>')
|
||||
lines.append(f'{inner}\t<xr:Ref>{el["rowsPicture"]}</xr:Ref>')
|
||||
lines.append(f'{inner}\t<xr:LoadTransparent>false</xr:LoadTransparent>')
|
||||
lines.append(f'{inner}\t<xr:Ref>{rp_src}</xr:Ref>')
|
||||
lines.append(f'{inner}\t<xr:LoadTransparent>{rp_lt}</xr:LoadTransparent>')
|
||||
lines.append(f'{inner}</RowsPicture>')
|
||||
# Блок свойств дин-список-таблицы (помечена эвристикой)
|
||||
if el.get('_dynList'):
|
||||
@@ -3566,7 +3583,7 @@ def emit_table(lines, el, name, eid, indent):
|
||||
|
||||
|
||||
def emit_pages(lines, el, name, eid, indent):
|
||||
lines.append(f'{indent}<Pages name="{name}" id="{eid}">')
|
||||
lines.append(f'{indent}<Pages name="{name}" id="{eid}"{di_attr(el)}>')
|
||||
inner = f'{indent}\t'
|
||||
|
||||
emit_title(lines, el, name, inner)
|
||||
@@ -3593,7 +3610,7 @@ def emit_pages(lines, el, name, eid, indent):
|
||||
|
||||
|
||||
def emit_page(lines, el, name, eid, indent):
|
||||
lines.append(f'{indent}<Page name="{name}" id="{eid}">')
|
||||
lines.append(f'{indent}<Page name="{name}" id="{eid}"{di_attr(el)}>')
|
||||
inner = f'{indent}\t'
|
||||
|
||||
emit_title(lines, el, name, inner, auto=True)
|
||||
@@ -3627,7 +3644,7 @@ def emit_page(lines, el, name, eid, indent):
|
||||
|
||||
|
||||
def emit_button(lines, el, name, eid, indent, in_cmd_bar=False):
|
||||
lines.append(f'{indent}<Button name="{name}" id="{eid}">')
|
||||
lines.append(f'{indent}<Button name="{name}" id="{eid}"{di_attr(el)}>')
|
||||
inner = f'{indent}\t'
|
||||
# (общие свойства — через emit_layout ниже; отдельный вызов был бы двойной эмиссией)
|
||||
|
||||
@@ -3714,7 +3731,7 @@ def emit_button(lines, el, name, eid, indent, in_cmd_bar=False):
|
||||
|
||||
|
||||
def emit_picture_decoration(lines, el, name, eid, indent):
|
||||
lines.append(f'{indent}<PictureDecoration name="{name}" id="{eid}">')
|
||||
lines.append(f'{indent}<PictureDecoration name="{name}" id="{eid}"{di_attr(el)}>')
|
||||
inner = f'{indent}\t'
|
||||
|
||||
emit_decoration_title(lines, el, name, inner)
|
||||
@@ -3750,7 +3767,7 @@ def emit_picture_decoration(lines, el, name, eid, indent):
|
||||
|
||||
|
||||
def emit_picture_field(lines, el, name, eid, indent):
|
||||
lines.append(f'{indent}<PictureField name="{name}" id="{eid}">')
|
||||
lines.append(f'{indent}<PictureField name="{name}" id="{eid}"{di_attr(el)}>')
|
||||
inner = f'{indent}\t'
|
||||
|
||||
if el.get('path'):
|
||||
@@ -3789,7 +3806,7 @@ def emit_picture_field(lines, el, name, eid, indent):
|
||||
|
||||
|
||||
def emit_calendar(lines, el, name, eid, indent):
|
||||
lines.append(f'{indent}<CalendarField name="{name}" id="{eid}">')
|
||||
lines.append(f'{indent}<CalendarField name="{name}" id="{eid}"{di_attr(el)}>')
|
||||
inner = f'{indent}\t'
|
||||
|
||||
if el.get('path'):
|
||||
@@ -3830,7 +3847,7 @@ def emit_calendar(lines, el, name, eid, indent):
|
||||
|
||||
|
||||
def emit_command_bar(lines, el, name, eid, indent):
|
||||
lines.append(f'{indent}<CommandBar name="{name}" id="{eid}">')
|
||||
lines.append(f'{indent}<CommandBar name="{name}" id="{eid}"{di_attr(el)}>')
|
||||
inner = f'{indent}\t'
|
||||
|
||||
emit_title(lines, el, name, inner)
|
||||
@@ -3860,7 +3877,7 @@ def emit_command_bar(lines, el, name, eid, indent):
|
||||
|
||||
|
||||
def emit_popup(lines, el, name, eid, indent):
|
||||
lines.append(f'{indent}<Popup name="{name}" id="{eid}">')
|
||||
lines.append(f'{indent}<Popup name="{name}" id="{eid}"{di_attr(el)}>')
|
||||
inner = f'{indent}\t'
|
||||
|
||||
emit_title(lines, el, name, inner, auto=True)
|
||||
@@ -3884,7 +3901,7 @@ def emit_popup(lines, el, name, eid, indent):
|
||||
|
||||
|
||||
def emit_button_group(lines, el, name, eid, indent):
|
||||
lines.append(f'{indent}<ButtonGroup name="{name}" id="{eid}">')
|
||||
lines.append(f'{indent}<ButtonGroup name="{name}" id="{eid}"{di_attr(el)}>')
|
||||
inner = f'{indent}\t'
|
||||
|
||||
emit_title(lines, el, name, inner)
|
||||
@@ -4845,9 +4862,10 @@ def main():
|
||||
el['tableAutofill'] = False
|
||||
if 'commandBarLocation' not in el:
|
||||
el['commandBarLocation'] = 'None'
|
||||
# RowPictureDataPath: умный дефолт <Список>.DefaultPicture, если ключ ОТСУТСТВУЕТ
|
||||
# и есть основная таблица. Пустая строка (suppress-маркер) НЕ перезатирается.
|
||||
if has_main_table and 'rowPictureDataPath' not in el:
|
||||
# RowPictureDataPath: умный дефолт <Список>.DefaultPicture, если ключ ОТСУТСТВУЕТ.
|
||||
# Декомпилятор опускает при rpdp == smart-default; реальное отсутствие → ""-маркер (не
|
||||
# перезатирается). Гейт has_main_table снят: дин-список без mainTable тоже несёт RowPictureDataPath.
|
||||
if 'rowPictureDataPath' not in el:
|
||||
el['rowPictureDataPath'] = f'{list_name}.DefaultPicture'
|
||||
if isinstance(el.get('children'), list):
|
||||
for child in el['children']:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# form-decompile v0.68 — Decompile 1C managed Form.xml to JSON DSL (draft)
|
||||
# form-decompile v0.69 — Decompile 1C managed Form.xml to JSON DSL (draft)
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
# ВНИМАНИЕ: раундтрип не гарантируется. Навык исключён из авто-использования моделью.
|
||||
param(
|
||||
@@ -765,7 +765,12 @@ function Add-Layout {
|
||||
$soi = Get-Child $node 'SkipOnInput'; if ($null -ne $soi) { $obj['skipOnInput'] = ($soi -eq 'true') }
|
||||
if ((Get-Child $node 'EnableStartDrag') -eq 'true') { $obj['enableStartDrag'] = $true }
|
||||
$fdm = Get-Child $node 'FileDragMode'; if ($fdm) { $obj['fileDragMode'] = $fdm }
|
||||
if ((Get-Child $node 'AutoMaxWidth') -eq 'false') { $obj['autoMaxWidth'] = $false }
|
||||
# AutoMaxWidth: компилятор додумывает false для multiLine-input без явного ключа (multiLineDefault).
|
||||
# Захват факт. значения; multiLine-input без тега → autoMaxWidth:true (суппресс эвристики).
|
||||
$amwNode = Get-Child $node 'AutoMaxWidth'
|
||||
if ($amwNode -eq 'false') { $obj['autoMaxWidth'] = $false }
|
||||
elseif ($amwNode -eq 'true') { $obj['autoMaxWidth'] = $true }
|
||||
elseif ((Get-Child $node 'MultiLine') -eq 'true') { $obj['autoMaxWidth'] = $true }
|
||||
$mw = Get-Child $node 'MaxWidth'; if ($mw) { $obj['maxWidth'] = [int]$mw }
|
||||
if ((Get-Child $node 'AutoMaxHeight') -eq 'false') { $obj['autoMaxHeight'] = $false }
|
||||
$mh = Get-Child $node 'MaxHeight'; if ($mh) { $obj['maxHeight'] = [int]$mh }
|
||||
@@ -1136,6 +1141,7 @@ $GENERIC_SCALARS = @(
|
||||
@{ Tag='Mask'; Key='mask'; Kind='value' }
|
||||
@{ Tag='CreateButton'; Key='createButton'; Kind='bool' }
|
||||
@{ Tag='FixingInTable'; Key='fixingInTable'; Kind='value' }
|
||||
@{ Tag='VerticalSpacing'; Key='verticalSpacing'; Kind='value' }
|
||||
)
|
||||
|
||||
# Захват generic-скаляров. Специфичная обработка (если ключ уже задан) — побеждает.
|
||||
@@ -1388,6 +1394,18 @@ function Decompile-Element {
|
||||
foreach ($p in @('ChoiceForm','ChoiceHistoryOnInput','ChoiceFoldersAndItems','FooterDataPath')) {
|
||||
$v = Get-Child $node $p; if ($null -ne $v) { $obj[($p.Substring(0,1).ToLower()+$p.Substring(1))] = $v }
|
||||
}
|
||||
# MinValue/MaxValue — типизированное (<MinValue xsi:type="xs:decimal">N). Тип кодируем в JSON-тип:
|
||||
# xs:decimal/int → число (компилятор → xs:decimal), иначе → строка (компилятор → xs:string).
|
||||
foreach ($p in @('MinValue','MaxValue')) {
|
||||
$mn = $node.SelectSingleNode("lf:$p", $ns)
|
||||
if ($mn) {
|
||||
$xt = $mn.GetAttribute("type", $NS_XSI); $txt = $mn.InnerText
|
||||
$key = $p.Substring(0,1).ToLower() + $p.Substring(1)
|
||||
if ($xt -match 'decimal|int') {
|
||||
if ($txt -match '^-?\d+$') { $obj[$key] = [int]$txt } elseif ($txt -match '^-?\d+\.\d+$') { $obj[$key] = [decimal]$txt } else { $obj[$key] = $txt }
|
||||
} else { $obj[$key] = $txt }
|
||||
}
|
||||
}
|
||||
$cbr = Get-Child $node 'ChoiceButtonRepresentation'; if ($cbr) { $obj['choiceButtonRepresentation'] = $cbr }
|
||||
if ((Get-Child $node 'TextEdit') -eq 'false') { $obj['textEdit'] = $false }
|
||||
$cl = Decompile-ChoiceList $node; if ($cl) { $obj['choiceList'] = $cl }
|
||||
@@ -1507,7 +1525,13 @@ function Decompile-Element {
|
||||
$soin = Get-Child $node 'SearchOnInput'; if ($soin) { $obj['searchOnInput'] = $soin }
|
||||
if ((Get-Child $node 'AutoMarkIncomplete') -eq 'true') { $obj['markIncomplete'] = $true }
|
||||
$itv = Get-Child $node 'InitialTreeView'; if ($itv) { $obj['initialTreeView'] = $itv }
|
||||
$rpRef = $node.SelectSingleNode("lf:RowsPicture/xr:Ref", $ns); if ($rpRef) { $obj['rowsPicture'] = $rpRef.InnerText }
|
||||
# RowsPicture: src (xr:Ref) + LoadTransparent (дефолт false). При true → объектная форма.
|
||||
$rpRef = $node.SelectSingleNode("lf:RowsPicture/xr:Ref", $ns)
|
||||
if ($rpRef) {
|
||||
$rpLt = $node.SelectSingleNode("lf:RowsPicture/xr:LoadTransparent", $ns)
|
||||
if ($rpLt -and $rpLt.InnerText -eq 'true') { $obj['rowsPicture'] = [ordered]@{ src = $rpRef.InnerText; loadTransparent = $true } }
|
||||
else { $obj['rowsPicture'] = $rpRef.InnerText }
|
||||
}
|
||||
$rpdp = Get-Child $node 'RowPictureDataPath'
|
||||
# --- Блок дин-список-таблицы (признак: дочерний <UpdateOnDataChange>) ---
|
||||
if (Has-Child $node 'UpdateOnDataChange') {
|
||||
@@ -1605,6 +1629,8 @@ function Decompile-Element {
|
||||
'ViewStatusAddition' { $obj[$key] = $name; Add-AdditionCore $obj $node $name }
|
||||
'SearchControlAddition' { $obj[$key] = $name; Add-AdditionCore $obj $node $name }
|
||||
}
|
||||
# DisplayImportance — атрибут открывающего тега (адаптивная важность отображения), захват «как есть».
|
||||
$di = $node.GetAttribute("DisplayImportance"); if ($di) { $obj['displayImportance'] = $di }
|
||||
# title: "" — подавление авто-вывода: для типов, где компилятор вывел бы
|
||||
# заголовок из имени, а в оригинале <Title> отсутствует.
|
||||
if (-not $obj.Contains('title')) {
|
||||
|
||||
Reference in New Issue
Block a user