mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-09-20 00:45:54 +03:00
feat(form-decompile,form-compile): семантика TitleLocation (кластер G2)
Принцип: компилятор не эмитит значение, равное дефолту платформы (который платформа сама не пишет в XML). Умный дефолт (check→Right, radio→None) — отдельная вещь, эмитится (он ≠ дефолт платформы Left). - net ключа titleLocation → умный дефолт; titleLocation: "" → подавить (дефолт платформы); значение → эмитить с маппингом регистра. - compiler PS1+PY: Emit-TitleLocation/emit_title_location + Map-TitleLoc (общий маппинг; у check раньше его не было — сырьё). - decompiler: Add-TitleLocation (дефолт → опустить, нет тега → "", иначе значение). - docs/form-dsl-spec: семантика titleLocation у check/radio. - tests: input-fields расширен (Right-дефолт / ""-подавление / явный Top), сертифицирован. АварийныйРежим: полный MATCH. Регресс 32/32 PS1+PY, churn нулевой. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
4ba1e595bf
commit
0941fc717d
@@ -1,4 +1,4 @@
|
||||
# form-compile v1.26 — Compile 1C managed form from JSON or object metadata
|
||||
# form-compile v1.27 — Compile 1C managed form from JSON or object metadata
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[string]$JsonPath,
|
||||
@@ -2034,6 +2034,30 @@ function Emit-Title {
|
||||
}
|
||||
}
|
||||
|
||||
function Map-TitleLoc {
|
||||
param([string]$v)
|
||||
switch ("$v".ToLower()) {
|
||||
"none" { "None" }
|
||||
"left" { "Left" }
|
||||
"right" { "Right" }
|
||||
"top" { "Top" }
|
||||
"bottom" { "Bottom" }
|
||||
"auto" { "Auto" }
|
||||
default { "$v" }
|
||||
}
|
||||
}
|
||||
|
||||
# TitleLocation у check/radio: нет ключа → умный дефолт (Right/None), эмитится;
|
||||
# "" → подавить (= дефолт платформы, она его сама не пишет); значение → эмитить (маппинг регистра).
|
||||
function Emit-TitleLocation {
|
||||
param($el, [string]$indent, [string]$smartDefault)
|
||||
if ($null -ne $el.PSObject.Properties['titleLocation']) {
|
||||
if ($el.titleLocation) { X "$indent<TitleLocation>$(Map-TitleLoc "$($el.titleLocation)")</TitleLocation>" }
|
||||
} elseif ($smartDefault) {
|
||||
X "$indent<TitleLocation>$smartDefault</TitleLocation>"
|
||||
}
|
||||
}
|
||||
|
||||
function Emit-Group {
|
||||
param($el, [string]$name, [int]$id, [string]$indent)
|
||||
|
||||
@@ -2196,8 +2220,7 @@ function Emit-Check {
|
||||
Emit-Title -el $el -name $name -indent $inner -auto:(-not $el.path)
|
||||
Emit-CommonFlags -el $el -indent $inner
|
||||
|
||||
$tl = if ($el.titleLocation) { "$($el.titleLocation)" } else { "Right" }
|
||||
X "$inner<TitleLocation>$tl</TitleLocation>"
|
||||
Emit-TitleLocation -el $el -indent $inner -smartDefault "Right"
|
||||
|
||||
Emit-Layout -el $el -indent $inner
|
||||
|
||||
@@ -2337,18 +2360,7 @@ function Emit-Radio {
|
||||
Emit-Title -el $el -name $name -indent $inner -auto:(-not $el.path)
|
||||
Emit-CommonFlags -el $el -indent $inner
|
||||
|
||||
# TitleLocation default is None for radio (matches typical configurator behavior)
|
||||
$tl = if ($el.titleLocation) {
|
||||
switch ("$($el.titleLocation)") {
|
||||
"none" { "None" }
|
||||
"left" { "Left" }
|
||||
"right" { "Right" }
|
||||
"top" { "Top" }
|
||||
"bottom" { "Bottom" }
|
||||
default { "$($el.titleLocation)" }
|
||||
}
|
||||
} else { "None" }
|
||||
X "$inner<TitleLocation>$tl</TitleLocation>"
|
||||
Emit-TitleLocation -el $el -indent $inner -smartDefault "None"
|
||||
|
||||
# RadioButtonType: Auto | RadioButtons | Tumbler. Accept synonyms.
|
||||
$rbtRaw = if ($el.radioButtonType) { "$($el.radioButtonType)".Trim() } else { "Auto" }
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# form-compile v1.26 — Compile 1C managed form from JSON or object metadata
|
||||
# form-compile v1.27 — Compile 1C managed form from JSON or object metadata
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
import argparse
|
||||
import copy
|
||||
@@ -1620,6 +1620,23 @@ def emit_title(lines, el, name, indent, auto=False):
|
||||
emit_mltext(lines, indent, 'Title', title_from_name(name))
|
||||
|
||||
|
||||
_TITLE_LOC_MAP = {'none': 'None', 'left': 'Left', 'right': 'Right', 'top': 'Top', 'bottom': 'Bottom', 'auto': 'Auto'}
|
||||
|
||||
|
||||
def map_title_loc(v):
|
||||
return _TITLE_LOC_MAP.get(str(v).lower(), str(v))
|
||||
|
||||
|
||||
def emit_title_location(lines, el, indent, smart_default):
|
||||
# Нет ключа → умный дефолт (Right/None), эмитится. "" → подавить (дефолт платформы).
|
||||
# Значение → эмитить с маппингом регистра.
|
||||
if 'titleLocation' in el:
|
||||
if el.get('titleLocation'):
|
||||
lines.append(f"{indent}<TitleLocation>{map_title_loc(el['titleLocation'])}</TitleLocation>")
|
||||
elif smart_default:
|
||||
lines.append(f"{indent}<TitleLocation>{smart_default}</TitleLocation>")
|
||||
|
||||
|
||||
# --- Type emitter ---
|
||||
|
||||
V8_TYPES = {
|
||||
@@ -2007,8 +2024,7 @@ def emit_check(lines, el, name, eid, indent):
|
||||
emit_title(lines, el, name, inner, auto=not el.get('path'))
|
||||
emit_common_flags(lines, el, inner)
|
||||
|
||||
tl = el.get('titleLocation') or 'Right'
|
||||
lines.append(f'{inner}<TitleLocation>{tl}</TitleLocation>')
|
||||
emit_title_location(lines, el, inner, 'Right')
|
||||
|
||||
emit_layout(lines, el, inner)
|
||||
|
||||
@@ -2031,13 +2047,7 @@ def emit_radio_button_field(lines, el, name, eid, indent):
|
||||
emit_title(lines, el, name, inner, auto=not el.get('path'))
|
||||
emit_common_flags(lines, el, inner)
|
||||
|
||||
tl_raw = el.get('titleLocation')
|
||||
if tl_raw:
|
||||
loc_map = {'none': 'None', 'left': 'Left', 'right': 'Right', 'top': 'Top', 'bottom': 'Bottom'}
|
||||
tl = loc_map.get(str(tl_raw), str(tl_raw))
|
||||
else:
|
||||
tl = 'None'
|
||||
lines.append(f'{inner}<TitleLocation>{tl}</TitleLocation>')
|
||||
emit_title_location(lines, el, inner, 'None')
|
||||
|
||||
rbt = normalize_radio_button_type(el.get('radioButtonType'))
|
||||
lines.append(f'{inner}<RadioButtonType>{rbt}</RadioButtonType>')
|
||||
|
||||
Reference in New Issue
Block a user