mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-06-14 18:04:58 +03:00
feat(form-decompile,form-compile): valueType — тип значений ValueList (Settings TypeDescription)
Ключ valueType у реквизита формы: <Settings xsi:type="v8:TypeDescription"> — уточнение типа значений у реквизита типа ValueList (СписокЗначений). В корпусе 341/341 именно на ValueList. Грамматика значения = как у type (включая составной "A | B" и квалификаторы string/decimal/date). Forgiving-синонимы: typeDescription (1С «ОписаниеТипов» / зеркало XML xsi:type), описаниеТипов, типЗначений — канон valueType (декомпилятор пишет его). ≠ дин-список Settings (xsi:type="DynamicList", отдельный ключ settings). Emit-Type параметризован тегом-обёрткой (Type / Settings), Decompile-Type работает на любом type-узле. Зеркало py (байт-в-байт). Кейс attributes-types (составной string(50)|decimal(10,2)) сертифицирован в 1С. Регресс 39/39 ps1+py. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# form-compile v1.77 — Compile 1C managed form from JSON or object metadata
|
||||
# form-compile v1.78 — Compile 1C managed form from JSON or object metadata
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[string]$JsonPath,
|
||||
@@ -2019,10 +2019,12 @@ function Resolve-TypeStr {
|
||||
}
|
||||
|
||||
function Emit-Type {
|
||||
param($typeStr, [string]$indent)
|
||||
# $tag/$tagAttrs — обёртка (по умолчанию <Type>); для уточнения типа значений ValueList
|
||||
# вызывается с tag="Settings", tagAttrs=' xsi:type="v8:TypeDescription"'.
|
||||
param($typeStr, [string]$indent, [string]$tag = "Type", [string]$tagAttrs = "")
|
||||
|
||||
if (-not $typeStr) {
|
||||
X "$indent<Type/>"
|
||||
X "$indent<$tag$tagAttrs/>"
|
||||
return
|
||||
}
|
||||
|
||||
@@ -2031,12 +2033,12 @@ function Emit-Type {
|
||||
# Composite type: "Type1 | Type2" or "Type1 + Type2"
|
||||
$parts = $typeString -split '\s*[|+]\s*'
|
||||
|
||||
X "$indent<Type>"
|
||||
X "$indent<$tag$tagAttrs>"
|
||||
foreach ($part in $parts) {
|
||||
$part = $part.Trim()
|
||||
Emit-SingleType -typeStr $part -indent "$indent`t"
|
||||
}
|
||||
X "$indent</Type>"
|
||||
X "$indent</$tag>"
|
||||
}
|
||||
|
||||
function Emit-SingleType {
|
||||
@@ -4394,6 +4396,15 @@ function Emit-Attributes {
|
||||
} else {
|
||||
X "$inner<Type/>"
|
||||
}
|
||||
# valueType: уточнение типа значений ValueList → <Settings xsi:type="v8:TypeDescription">
|
||||
# (та же грамматика типа, что и Type, включая составной "A | B"). Forgiving-синонимы.
|
||||
$vtSpec = $null
|
||||
foreach ($k in @('valueType','typeDescription','описаниеТипов','типЗначений')) {
|
||||
if ($attr.PSObject.Properties[$k] -and $attr.$k) { $vtSpec = $attr.$k; break }
|
||||
}
|
||||
if ($vtSpec) {
|
||||
Emit-Type -typeStr "$vtSpec" -indent $inner -tag "Settings" -tagAttrs ' xsi:type="v8:TypeDescription"'
|
||||
}
|
||||
|
||||
if ($attr.main -eq $true) {
|
||||
X "$inner<MainAttribute>true</MainAttribute>"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# form-compile v1.77 — Compile 1C managed form from JSON or object metadata
|
||||
# form-compile v1.78 — Compile 1C managed form from JSON or object metadata
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
import argparse
|
||||
import copy
|
||||
@@ -2894,18 +2894,20 @@ def emit_single_type(lines, type_str, indent):
|
||||
lines.append(f'{indent}<v8:Type>{type_str}</v8:Type>')
|
||||
|
||||
|
||||
def emit_type(lines, type_str, indent):
|
||||
def emit_type(lines, type_str, indent, tag="Type", tag_attrs=""):
|
||||
# tag/tag_attrs — обёртка (по умолчанию <Type>); для valueType ValueList вызывается с
|
||||
# tag="Settings", tag_attrs=' xsi:type="v8:TypeDescription"'.
|
||||
if not type_str:
|
||||
lines.append(f'{indent}<Type/>')
|
||||
lines.append(f'{indent}<{tag}{tag_attrs}/>')
|
||||
return
|
||||
|
||||
type_string = str(type_str)
|
||||
parts = [p.strip() for p in re.split(r'[|+]', type_string)]
|
||||
|
||||
lines.append(f'{indent}<Type>')
|
||||
lines.append(f'{indent}<{tag}{tag_attrs}>')
|
||||
for part in parts:
|
||||
emit_single_type(lines, part, f'{indent}\t')
|
||||
lines.append(f'{indent}</Type>')
|
||||
lines.append(f'{indent}</{tag}>')
|
||||
|
||||
|
||||
# --- Element emitters ---
|
||||
@@ -4118,6 +4120,15 @@ def emit_attributes(lines, attrs, indent):
|
||||
emit_type(lines, str(attr['type']), inner)
|
||||
else:
|
||||
lines.append(f'{inner}<Type/>')
|
||||
# valueType: ОписаниеТипов значений ValueList → <Settings xsi:type="v8:TypeDescription">
|
||||
# (та же грамматика типа, включая составной "A | B"). Forgiving-синонимы.
|
||||
vt_spec = None
|
||||
for k in ('valueType', 'typeDescription', 'описаниеТипов', 'типЗначений'):
|
||||
if attr.get(k):
|
||||
vt_spec = attr[k]
|
||||
break
|
||||
if vt_spec:
|
||||
emit_type(lines, str(vt_spec), inner, tag="Settings", tag_attrs=' xsi:type="v8:TypeDescription"')
|
||||
|
||||
if attr.get('main') is True:
|
||||
lines.append(f'{inner}<MainAttribute>true</MainAttribute>')
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# form-decompile v0.53 — Decompile 1C managed Form.xml to JSON DSL (draft)
|
||||
# form-decompile v0.54 — Decompile 1C managed Form.xml to JSON DSL (draft)
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
# ВНИМАНИЕ: раундтрип не гарантируется. Навык исключён из авто-использования моделью.
|
||||
param(
|
||||
@@ -1672,6 +1672,12 @@ if ($attrsNode) {
|
||||
$ao = [ordered]@{}
|
||||
$ao['name'] = $a.GetAttribute("name")
|
||||
$ty = Decompile-Type ($a.SelectSingleNode("lf:Type", $ns)); if ($ty) { $ao['type'] = $ty }
|
||||
# valueType: <Settings xsi:type="v8:TypeDescription"> — уточнение типа значений ValueList
|
||||
# (та же грамматика типа). Дин-список Settings (xsi:type="DynamicList") обрабатывается отдельно.
|
||||
$setNode = $a.SelectSingleNode("lf:Settings", $ns)
|
||||
if ($setNode -and $setNode.GetAttribute("type", $NS_XSI) -match 'TypeDescription$') {
|
||||
$vt = Decompile-Type $setNode; if ($vt) { $ao['valueType'] = $vt }
|
||||
}
|
||||
if ((Get-Child $a 'MainAttribute') -eq 'true') { $ao['main'] = $true }
|
||||
$vw = Decompile-XrFlag $a 'View'; if ($null -ne $vw) { $ao['view'] = $vw }
|
||||
$ed = Decompile-XrFlag $a 'Edit'; if ($null -ne $ed) { $ao['edit'] = $ed }
|
||||
|
||||
@@ -740,6 +740,7 @@ Pages поддерживает `pagesRepresentation`: `None`, `TabsOnTop`, `Tabs
|
||||
| `edit` | bool/object | Редактирование по ролям (`<Edit>`). См. §4.1c |
|
||||
| `functionalOptions` | array | Функциональные опции (`<FunctionalOptions><Item>FunctionalOption.X</Item>…`). Массив имён; forgiving: `"X"`/`"FunctionalOption.X"`. Также у колонок (`columns[*]`) и команд (§7) |
|
||||
| `useAlways` | array | Поля, всегда читаемые (`<UseAlways><Field>Имя.Поле</Field>…`). Массив коротких имён полей (forgiving: с/без префикса `Имя.`). **Две формы**: этот массив на реквизите ИЛИ `useAlways: true` на колонке (`columns[*]`) — компилятор сливает. Для дин-списка — только массив (колонки не эмитятся, но формируют `<UseAlways>`) |
|
||||
| `valueType` | string | Тип значений у реквизита типа `ValueList` (`<Settings xsi:type="v8:TypeDescription">`). Грамматика — как у `type`, включая составной `A \| B`. Forgiving-синонимы: `typeDescription` (≈1С «ОписаниеТипов» / XML), `описаниеТипов`, `типЗначений`. Пример: `"valueType": "CatalogRef.Контрагенты"` |
|
||||
| `savedData` | bool | Сохраняемые данные (`<SavedData>`) |
|
||||
| `save` | bool/string/array | Сохранение значения в пользовательских настройках (`<Save><Field>…`). `true` → `<Field>имя</Field>`; строка/массив строк → под-поля с авто-префиксом `имя.` (путь с точкой / UUID `1/0:…` / совпадающее с именем — берётся как есть). Нет ключа или `false` → не эмитится. Пример периода: `["Период","EndDate","StartDate","Variant"]` |
|
||||
| `fillChecking` | string | `Show`, `DontShow` |
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
{ "name": "Дата", "type": "dateTime", "title": "" },
|
||||
{ "name": "Булево", "type": "boolean" },
|
||||
{ "name": "Период", "type": "СтандартныйПериод", "save": ["Период", "EndDate", "StartDate", "Variant"] },
|
||||
{ "name": "СписокЗначений", "type": "ValueList" },
|
||||
{ "name": "СписокЗначений", "type": "ValueList", "valueType": "string(50) | decimal(10,2)" },
|
||||
{ "name": "Идентификатор", "type": "v8:UUID" }
|
||||
]
|
||||
}
|
||||
|
||||
+13
@@ -126,6 +126,19 @@
|
||||
<Type>
|
||||
<v8:Type>v8:ValueListType</v8:Type>
|
||||
</Type>
|
||||
<Settings xsi:type="v8:TypeDescription">
|
||||
<v8:Type>xs:string</v8:Type>
|
||||
<v8:StringQualifiers>
|
||||
<v8:Length>50</v8:Length>
|
||||
<v8:AllowedLength>Variable</v8:AllowedLength>
|
||||
</v8:StringQualifiers>
|
||||
<v8:Type>xs:decimal</v8:Type>
|
||||
<v8:NumberQualifiers>
|
||||
<v8:Digits>10</v8:Digits>
|
||||
<v8:FractionDigits>2</v8:FractionDigits>
|
||||
<v8:AllowedSign>Any</v8:AllowedSign>
|
||||
</v8:NumberQualifiers>
|
||||
</Settings>
|
||||
</Attribute>
|
||||
<Attribute name="Идентификатор" id="20">
|
||||
<Title>
|
||||
|
||||
Reference in New Issue
Block a user