feat(skd-compile): parameters — title и presentation как синонимы

- parameter принимает presentation как синоним title (1C UI показывает
  подпись параметра как "Представление" — модель по аналогии пишет presentation)
- availableValues[] принимает title как синоним presentation (обратная
  ошибка: модель пишет title по аналогии с самим параметром)

Обе формы пишутся в один и тот же XML-узел. Версии: skd-compile v1.13 → v1.14.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Nick Shirokov
2026-04-16 20:37:00 +03:00
parent 1cea9e794e
commit 1b46eb4d85
4 changed files with 128 additions and 8 deletions
@@ -1,4 +1,4 @@
# skd-compile v1.13 — Compile 1C DCS from JSON
# skd-compile v1.14 — Compile 1C DCS from JSON
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
param(
[string]$DefinitionFile,
@@ -931,12 +931,15 @@ function Emit-SingleParam {
X "`t<parameter>"
X "`t`t<name>$(Esc-Xml $parsed.name)</name>"
# Title (from parsed first, then from object form)
# Title (from parsed first, then from object form; accept `presentation` as
# a synonym — 1C UI labels a parameter's caption "Представление").
$title = ""
if ($parsed.title) {
$title = "$($parsed.title)"
} elseif ($p -isnot [string] -and $p.title) {
$title = "$($p.title)"
} elseif ($p -isnot [string] -and $p.presentation) {
$title = "$($p.presentation)"
}
if ($title) {
Emit-MLText -tag "title" -text $title -indent "`t`t"
@@ -988,11 +991,13 @@ function Emit-SingleParam {
}
X "`t`t<availableValue>"
X "`t`t`t<value xsi:type=`"$avType`">$(Esc-Xml $avVal)</value>"
if ($av.presentation) {
# `title` accepted as synonym of `presentation` — both map to the same UI label.
$avPres = if ($av.presentation) { "$($av.presentation)" } elseif ($av.title) { "$($av.title)" } else { "" }
if ($avPres) {
X "`t`t`t<presentation xsi:type=`"v8:LocalStringType`">"
X "`t`t`t`t<v8:item>"
X "`t`t`t`t`t<v8:lang>ru</v8:lang>"
X "`t`t`t`t`t<v8:content>$(Esc-Xml "$($av.presentation)")</v8:content>"
X "`t`t`t`t`t<v8:content>$(Esc-Xml $avPres)</v8:content>"
X "`t`t`t`t</v8:item>"
X "`t`t`t</presentation>"
}
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# skd-compile v1.13 — Compile 1C DCS from JSON
# skd-compile v1.14 — Compile 1C DCS from JSON
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
import argparse
import json
@@ -802,12 +802,15 @@ def emit_single_param(lines, p, parsed):
lines.append('\t<parameter>')
lines.append(f'\t\t<name>{esc_xml(parsed["name"])}</name>')
# Title (from parsed first, then from object form)
# Title (from parsed first, then from object form; accept `presentation` as
# a synonym — 1C UI labels a parameter's caption "Представление").
title = ''
if parsed.get('title'):
title = str(parsed['title'])
elif p is not None and not isinstance(p, str) and p.get('title'):
title = str(p['title'])
elif p is not None and not isinstance(p, str) and p.get('presentation'):
title = str(p['presentation'])
if title:
emit_mltext(lines, '\t\t', 'title', title)
@@ -852,11 +855,13 @@ def emit_single_param(lines, p, parsed):
av_type = 'dcscor:DesignTimeValue'
lines.append('\t\t<availableValue>')
lines.append(f'\t\t\t<value xsi:type="{av_type}">{esc_xml(av_val)}</value>')
if av.get('presentation'):
# `title` accepted as synonym of `presentation` — both map to the same UI label.
av_pres = str(av.get('presentation') or av.get('title') or '')
if av_pres:
lines.append('\t\t\t<presentation xsi:type="v8:LocalStringType">')
lines.append('\t\t\t\t<v8:item>')
lines.append('\t\t\t\t\t<v8:lang>ru</v8:lang>')
lines.append(f'\t\t\t\t\t<v8:content>{esc_xml(str(av["presentation"]))}</v8:content>')
lines.append(f'\t\t\t\t\t<v8:content>{esc_xml(av_pres)}</v8:content>')
lines.append('\t\t\t\t</v8:item>')
lines.append('\t\t\t</presentation>')
lines.append('\t\t</availableValue>')
@@ -0,0 +1,27 @@
{
"name": "Parameter.presentation и availableValue.title — синонимы",
"params": { "outputPath": "Template.xml" },
"input": {
"dataSets": [{
"name": "Основной",
"query": "ВЫБРАТЬ Т.Сумма ИЗ Регистр КАК Т",
"fields": ["Сумма: decimal(15,2)"]
}],
"parameters": [
{
"name": "ПорядокОкругления",
"presentation": "Округление",
"type": "EnumRef.Округления",
"value": "Перечисление.Округления.Окр1_00",
"availableValues": [
{ "value": "Перечисление.Округления.Окр1_00", "title": "руб. коп" },
{ "value": "Перечисление.Округления.Окр1", "presentation": "руб." }
]
}
]
},
"validatePath": "Template.xml",
"expect": {
"files": ["Template.xml"]
}
}
@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="UTF-8"?>
<DataCompositionSchema xmlns="http://v8.1c.ru/8.1/data-composition-system/schema"
xmlns:dcscom="http://v8.1c.ru/8.1/data-composition-system/common"
xmlns:dcscor="http://v8.1c.ru/8.1/data-composition-system/core"
xmlns:dcsset="http://v8.1c.ru/8.1/data-composition-system/settings"
xmlns:v8="http://v8.1c.ru/8.1/data/core"
xmlns:v8ui="http://v8.1c.ru/8.1/data/ui"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<dataSource>
<name>ИсточникДанных1</name>
<dataSourceType>Local</dataSourceType>
</dataSource>
<dataSet xsi:type="DataSetQuery">
<name>Основной</name>
<field xsi:type="DataSetFieldField">
<dataPath>Сумма</dataPath>
<field>Сумма</field>
<valueType>
<v8:Type>xs:decimal</v8:Type>
<v8:NumberQualifiers>
<v8:Digits>15</v8:Digits>
<v8:FractionDigits>2</v8:FractionDigits>
<v8:AllowedSign>Any</v8:AllowedSign>
</v8:NumberQualifiers>
</valueType>
</field>
<dataSource>ИсточникДанных1</dataSource>
<query>ВЫБРАТЬ Т.Сумма ИЗ Регистр КАК Т</query>
</dataSet>
<parameter>
<name>ПорядокОкругления</name>
<title xsi:type="v8:LocalStringType">
<v8:item>
<v8:lang>ru</v8:lang>
<v8:content>Округление</v8:content>
</v8:item>
</title>
<valueType>
<v8:Type xmlns:d5p1="http://v8.1c.ru/8.1/data/enterprise/current-config">d5p1:EnumRef.Округления</v8:Type>
</valueType>
<value xsi:type="dcscor:DesignTimeValue">Перечисление.Округления.Окр1_00</value>
<availableValue>
<value xsi:type="dcscor:DesignTimeValue">Перечисление.Округления.Окр1_00</value>
<presentation xsi:type="v8:LocalStringType">
<v8:item>
<v8:lang>ru</v8:lang>
<v8:content>руб. коп</v8:content>
</v8:item>
</presentation>
</availableValue>
<availableValue>
<value xsi:type="dcscor:DesignTimeValue">Перечисление.Округления.Окр1</value>
<presentation xsi:type="v8:LocalStringType">
<v8:item>
<v8:lang>ru</v8:lang>
<v8:content>руб.</v8:content>
</v8:item>
</presentation>
</availableValue>
</parameter>
<settingsVariant>
<dcsset:name>Основной</dcsset:name>
<dcsset:presentation xsi:type="v8:LocalStringType">
<v8:item>
<v8:lang>ru</v8:lang>
<v8:content>Основной</v8:content>
</v8:item>
</dcsset:presentation>
<dcsset:settings xmlns:style="http://v8.1c.ru/8.1/data/ui/style" xmlns:sys="http://v8.1c.ru/8.1/data/ui/fonts/system" xmlns:web="http://v8.1c.ru/8.1/data/ui/colors/web" xmlns:win="http://v8.1c.ru/8.1/data/ui/colors/windows">
<dcsset:selection>
</dcsset:selection>
<dcsset:item xsi:type="dcsset:StructureItemGroup">
<dcsset:order>
<dcsset:item xsi:type="dcsset:OrderItemAuto"/>
</dcsset:order>
<dcsset:selection>
<dcsset:item xsi:type="dcsset:SelectedItemAuto"/>
</dcsset:selection>
</dcsset:item>
</dcsset:settings>
</settingsVariant>
</DataCompositionSchema>