mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-07-27 07:01:02 +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
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
param(
|
param(
|
||||||
[string]$JsonPath,
|
[string]$JsonPath,
|
||||||
@@ -2022,13 +2022,15 @@ function Title-FromName {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function Emit-Title {
|
function Emit-Title {
|
||||||
|
# Нет ключа title → авто-вывод из имени (помощь модели).
|
||||||
|
# Явный title: "" (или null) → подавить (заголовок не эмитим).
|
||||||
|
# Явный непустой → эмитим как есть.
|
||||||
param($el, [string]$name, [string]$indent, [switch]$auto)
|
param($el, [string]$name, [string]$indent, [switch]$auto)
|
||||||
$title = $el.title
|
$hasKey = $null -ne $el.PSObject.Properties['title']
|
||||||
if (-not $title -and $auto -and $name) {
|
if ($hasKey) {
|
||||||
$title = Title-FromName -name $name
|
if ($el.title) { Emit-MLText -tag "Title" -text "$($el.title)" -indent $indent }
|
||||||
}
|
} elseif ($auto -and $name) {
|
||||||
if ($title) {
|
Emit-MLText -tag "Title" -text "$(Title-FromName -name $name)" -indent $indent
|
||||||
Emit-MLText -tag "Title" -text "$title" -indent $indent
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2434,7 +2436,8 @@ function Emit-Label {
|
|||||||
X "$indent<LabelDecoration name=`"$name`" id=`"$id`">"
|
X "$indent<LabelDecoration name=`"$name`" id=`"$id`">"
|
||||||
$inner = "$indent`t"
|
$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) {
|
if ($labelTitle) {
|
||||||
$formatted = if ($el.hyperlink -eq $true) { "true" } else { "false" }
|
$formatted = if ($el.hyperlink -eq $true) { "true" } else { "false" }
|
||||||
X "$inner<Title formatted=`"$formatted`">"
|
X "$inner<Title formatted=`"$formatted`">"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/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
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
import argparse
|
import argparse
|
||||||
import copy
|
import copy
|
||||||
@@ -1611,11 +1611,13 @@ def title_from_name(name):
|
|||||||
|
|
||||||
|
|
||||||
def emit_title(lines, el, name, indent, auto=False):
|
def emit_title(lines, el, name, indent, auto=False):
|
||||||
title = el.get('title')
|
# Нет ключа title → авто-вывод из имени (помощь модели).
|
||||||
if not title and auto and name:
|
# Явный title "" (или None) → подавить. Явный непустой → как есть.
|
||||||
title = title_from_name(name)
|
if 'title' in el:
|
||||||
if title:
|
if el.get('title'):
|
||||||
emit_mltext(lines, indent, 'Title', str(title))
|
emit_mltext(lines, indent, 'Title', str(el['title']))
|
||||||
|
elif auto and name:
|
||||||
|
emit_mltext(lines, indent, 'Title', title_from_name(name))
|
||||||
|
|
||||||
|
|
||||||
# --- Type emitter ---
|
# --- Type emitter ---
|
||||||
@@ -2088,7 +2090,7 @@ 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}">')
|
||||||
inner = f'{indent}\t'
|
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:
|
if label_title:
|
||||||
formatted = 'true' if el.get('hyperlink') is True else 'false'
|
formatted = 'true' if el.get('hyperlink') is True else 'false'
|
||||||
lines.append(f'{inner}<Title formatted="{formatted}">')
|
lines.append(f'{inner}<Title formatted="{formatted}">')
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# form-decompile v0.4 — Decompile 1C managed Form.xml to JSON DSL (draft)
|
# form-decompile v0.5 — Decompile 1C managed Form.xml to JSON DSL (draft)
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
# ВНИМАНИЕ: раундтрип не гарантируется. Навык исключён из авто-использования моделью.
|
# ВНИМАНИЕ: раундтрип не гарантируется. Навык исключён из авто-использования моделью.
|
||||||
param(
|
param(
|
||||||
@@ -499,6 +499,15 @@ function Decompile-Element {
|
|||||||
if ($kids) { $obj['children'] = $kids }
|
if ($kids) { $obj['children'] = $kids }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
# title: "" — подавление авто-вывода: для типов, где компилятор вывел бы
|
||||||
|
# заголовок из имени, а в оригинале <Title> отсутствует.
|
||||||
|
if (-not $obj.Contains('title')) {
|
||||||
|
$autoTitle = $false
|
||||||
|
if ($tag -in @('LabelDecoration','Page','Popup')) { $autoTitle = $true }
|
||||||
|
elseif ($tag -eq 'Button') { $autoTitle = -not ($obj.Contains('command') -or $obj.Contains('stdCommand')) }
|
||||||
|
elseif ($tag -in @('InputField','CheckBoxField','RadioButtonField','LabelField','Table','CalendarField')) { $autoTitle = -not $obj.Contains('path') }
|
||||||
|
if ($autoTitle) { $obj['title'] = '' }
|
||||||
|
}
|
||||||
Add-Layout $obj $node
|
Add-Layout $obj $node
|
||||||
return $obj
|
return $obj
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,7 +110,7 @@
|
|||||||
| Свойство | Тип | Описание |
|
| Свойство | Тип | Описание |
|
||||||
|----------|-----|----------|
|
|----------|-----|----------|
|
||||||
| `name` | string | Имя элемента (по умолчанию — из значения ключа типа) |
|
| `name` | string | Имя элемента (по умолчанию — из значения ключа типа) |
|
||||||
| `title` | string | Заголовок |
|
| `title` | string | Заголовок. **Нет ключа** → авто-вывод из имени (для page/popup/label и непривязанных полей/кнопок). **`""`** → подавить (заголовок не выводится). Непустая строка → как есть |
|
||||||
| `hidden` | bool | `true` → `<Visible>false</Visible>` |
|
| `hidden` | bool | `true` → `<Visible>false</Visible>` |
|
||||||
| `disabled` | bool | `true` → `<Enabled>false</Enabled>` |
|
| `disabled` | bool | `true` → `<Enabled>false</Enabled>` |
|
||||||
| `readOnly` | bool | `true` → `<ReadOnly>true</ReadOnly>` |
|
| `readOnly` | bool | `true` → `<ReadOnly>true</ReadOnly>` |
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
"properties": { "autoTitle": false },
|
"properties": { "autoTitle": false },
|
||||||
"elements": [
|
"elements": [
|
||||||
{ "pages": "СтраницыМастера", "pagesRepresentation": "None", "children": [
|
{ "pages": "СтраницыМастера", "pagesRepresentation": "None", "children": [
|
||||||
{ "page": "Шаг1", "title": "Параметры", "children": [
|
{ "page": "Шаг1", "title": "", "children": [
|
||||||
{ "input": "Параметр1", "path": "Параметр1" }
|
{ "input": "Параметр1", "path": "Параметр1" }
|
||||||
]},
|
]},
|
||||||
{ "page": "Шаг2", "title": "Результат", "children": [
|
{ "page": "Шаг2", "title": "Результат", "children": [
|
||||||
|
|||||||
-6
@@ -14,12 +14,6 @@
|
|||||||
<ExtendedTooltip name="СтраницыМастераРасширеннаяПодсказка" id="2"/>
|
<ExtendedTooltip name="СтраницыМастераРасширеннаяПодсказка" id="2"/>
|
||||||
<ChildItems>
|
<ChildItems>
|
||||||
<Page name="Шаг1" id="3">
|
<Page name="Шаг1" id="3">
|
||||||
<Title>
|
|
||||||
<v8:item>
|
|
||||||
<v8:lang>ru</v8:lang>
|
|
||||||
<v8:content>Параметры</v8:content>
|
|
||||||
</v8:item>
|
|
||||||
</Title>
|
|
||||||
<ExtendedTooltip name="Шаг1РасширеннаяПодсказка" id="4"/>
|
<ExtendedTooltip name="Шаг1РасширеннаяПодсказка" id="4"/>
|
||||||
<ChildItems>
|
<ChildItems>
|
||||||
<InputField name="Параметр1" id="5">
|
<InputField name="Параметр1" id="5">
|
||||||
|
|||||||
Reference in New Issue
Block a user