mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-07-30 08:26:55 +03:00
feat(form-decompile,form-compile): семантика title (кластер G)
Над-генерация заголовков элементов из имени. Различаем: - нет ключа title → авто-вывод из имени (помощь модели при создании форм); - title: "" → подавить (<Title> не эмитим); - непустая строка → как есть. - compiler PS1+PY: Emit-Title/emit_title + Emit-Label проверяют наличие ключа, а не truthiness (раньше "" триггерило авто-вывод). - decompiler: ставит title:"" для авто-выводящих типов (page/popup/label, непривязанные поля, button без команды), когда <Title> в оригинале отсутствует. - docs/form-dsl-spec: семантика title. - tests: pages демонстрирует title:"" (+snapshot, сертифицирован в 1С). АварийныйРежим: diff 13→1. Регресс 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
e777ded8d2
commit
4ba1e595bf
@@ -1,4 +1,4 @@
|
||||
# form-compile v1.25 — Compile 1C managed form from JSON or object metadata
|
||||
# form-compile v1.26 — Compile 1C managed form from JSON or object metadata
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[string]$JsonPath,
|
||||
@@ -2022,13 +2022,15 @@ function Title-FromName {
|
||||
}
|
||||
|
||||
function Emit-Title {
|
||||
# Нет ключа title → авто-вывод из имени (помощь модели).
|
||||
# Явный title: "" (или null) → подавить (заголовок не эмитим).
|
||||
# Явный непустой → эмитим как есть.
|
||||
param($el, [string]$name, [string]$indent, [switch]$auto)
|
||||
$title = $el.title
|
||||
if (-not $title -and $auto -and $name) {
|
||||
$title = Title-FromName -name $name
|
||||
}
|
||||
if ($title) {
|
||||
Emit-MLText -tag "Title" -text "$title" -indent $indent
|
||||
$hasKey = $null -ne $el.PSObject.Properties['title']
|
||||
if ($hasKey) {
|
||||
if ($el.title) { Emit-MLText -tag "Title" -text "$($el.title)" -indent $indent }
|
||||
} elseif ($auto -and $name) {
|
||||
Emit-MLText -tag "Title" -text "$(Title-FromName -name $name)" -indent $indent
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2434,7 +2436,8 @@ function Emit-Label {
|
||||
X "$indent<LabelDecoration name=`"$name`" id=`"$id`">"
|
||||
$inner = "$indent`t"
|
||||
|
||||
$labelTitle = if ($el.title) { "$($el.title)" } else { Title-FromName -name $name }
|
||||
$hasTitleKey = $null -ne $el.PSObject.Properties['title']
|
||||
$labelTitle = if ($hasTitleKey) { "$($el.title)" } else { Title-FromName -name $name }
|
||||
if ($labelTitle) {
|
||||
$formatted = if ($el.hyperlink -eq $true) { "true" } else { "false" }
|
||||
X "$inner<Title formatted=`"$formatted`">"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# form-compile v1.25 — Compile 1C managed form from JSON or object metadata
|
||||
# form-compile v1.26 — Compile 1C managed form from JSON or object metadata
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
import argparse
|
||||
import copy
|
||||
@@ -1611,11 +1611,13 @@ def title_from_name(name):
|
||||
|
||||
|
||||
def emit_title(lines, el, name, indent, auto=False):
|
||||
title = el.get('title')
|
||||
if not title and auto and name:
|
||||
title = title_from_name(name)
|
||||
if title:
|
||||
emit_mltext(lines, indent, 'Title', str(title))
|
||||
# Нет ключа title → авто-вывод из имени (помощь модели).
|
||||
# Явный title "" (или None) → подавить. Явный непустой → как есть.
|
||||
if 'title' in el:
|
||||
if el.get('title'):
|
||||
emit_mltext(lines, indent, 'Title', str(el['title']))
|
||||
elif auto and name:
|
||||
emit_mltext(lines, indent, 'Title', title_from_name(name))
|
||||
|
||||
|
||||
# --- Type emitter ---
|
||||
@@ -2088,7 +2090,7 @@ def emit_label(lines, el, name, eid, indent):
|
||||
lines.append(f'{indent}<LabelDecoration name="{name}" id="{eid}">')
|
||||
inner = f'{indent}\t'
|
||||
|
||||
label_title = el.get('title') or title_from_name(name)
|
||||
label_title = str(el['title'] or '') if 'title' in el else title_from_name(name)
|
||||
if label_title:
|
||||
formatted = 'true' if el.get('hyperlink') is True else 'false'
|
||||
lines.append(f'{inner}<Title formatted="{formatted}">')
|
||||
|
||||
Reference in New Issue
Block a user