mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-08-09 21:13:22 +03:00
feat(skd): orderExpression — сортировка поля по выражению (round-trip)
- skd-compile (ps1+py): object-form ключ orderExpression{expression,orderType,autoOrder}
→ <r:orderExpression><dcscom:expression/><dcscom:orderType/><dcscom:autoOrder/>
- skd-decompile: читает <r:orderExpression> → object form поля, без SilentDrop warning
- SKILL.md skd-compile: одна строка в "Дополнительные ключи объектной формы"
- docs/skd-dsl-spec.md: пример в объектной форме поля
- Новый тест field-order-expression (round-trip bit-perfect)
- Versions: compile v1.28→v1.29, decompile v0.10→v0.11
На сэмпле 30 ERP-отчётов: SilentDrop:orderExpression 11 → 0.
This commit is contained in:
@@ -110,6 +110,7 @@ powershell.exe -NoProfile -File "${CLAUDE_SKILL_DIR}/scripts/skd-compile.ps1" -V
|
||||
Дополнительные ключи объектной формы:
|
||||
- `"presentationExpression": "<выражение>"` — что показывать вместо значения поля. Исходное значение остаётся «под капотом» для перехода/расшифровки.
|
||||
- `"appearance": { "<параметр>": "<значение>" }` — оформление колонки по умолчанию (применяется во всех вариантах настроек). Ключи — параметры платформы (`ГоризонтальноеПоложение`, `МинимальнаяШирина`, `Формат`, `Текст` и т.п.).
|
||||
- `"orderExpression": { "expression": "<выражение>", "orderType": "Asc"/"Desc", "autoOrder": true/false }` — сортировка поля по выражению (например `ЕстьNULL(Поле.Порядок, 10000)`).
|
||||
|
||||
```json
|
||||
{ "field": "Сумма", "title": "Сумма продажи", "type": "decimal(15,2)",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# skd-compile v1.28 — Compile 1C DCS from JSON
|
||||
# skd-compile v1.29 — Compile 1C DCS from JSON
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[string]$DefinitionFile,
|
||||
@@ -767,6 +767,10 @@ function Emit-Field {
|
||||
if ($fieldDef.attrRestrict) {
|
||||
$f["attrRestrict"] = @($fieldDef.attrRestrict)
|
||||
}
|
||||
# orderExpression — {expression, orderType, autoOrder}
|
||||
if ($fieldDef.orderExpression) {
|
||||
$f["orderExpression"] = $fieldDef.orderExpression
|
||||
}
|
||||
}
|
||||
|
||||
X "$indent<field xsi:type=`"DataSetFieldField`">"
|
||||
@@ -829,6 +833,19 @@ function Emit-Field {
|
||||
X "$indent`t</role>"
|
||||
}
|
||||
|
||||
# OrderExpression — после role, до valueType
|
||||
if ($f["orderExpression"]) {
|
||||
$oe = $f["orderExpression"]
|
||||
$expr = if ($oe.expression) { "$($oe.expression)" } else { '' }
|
||||
$oType = if ($oe.orderType) { "$($oe.orderType)" } else { 'Asc' }
|
||||
$autoOrder = if ($null -ne $oe.autoOrder) { $(if ($oe.autoOrder) { 'true' } else { 'false' }) } else { 'false' }
|
||||
X "$indent`t<orderExpression>"
|
||||
X "$indent`t`t<dcscom:expression>$(Esc-Xml $expr)</dcscom:expression>"
|
||||
X "$indent`t`t<dcscom:orderType>$oType</dcscom:orderType>"
|
||||
X "$indent`t`t<dcscom:autoOrder>$autoOrder</dcscom:autoOrder>"
|
||||
X "$indent`t</orderExpression>"
|
||||
}
|
||||
|
||||
# ValueType
|
||||
if ($f.type) {
|
||||
X "$indent`t<valueType>"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# skd-compile v1.28 — Compile 1C DCS from JSON
|
||||
# skd-compile v1.29 — Compile 1C DCS from JSON
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
import argparse
|
||||
import json
|
||||
@@ -584,6 +584,9 @@ def emit_field(lines, field_def, indent):
|
||||
# attrRestrict
|
||||
if field_def.get('attrRestrict'):
|
||||
f['attrRestrict'] = list(field_def['attrRestrict'])
|
||||
# orderExpression — {expression, orderType, autoOrder}
|
||||
if field_def.get('orderExpression'):
|
||||
f['orderExpression'] = field_def['orderExpression']
|
||||
|
||||
lines.append(f'{indent}<field xsi:type="DataSetFieldField">')
|
||||
lines.append(f'{indent}\t<dataPath>{esc_xml(f["dataPath"])}</dataPath>')
|
||||
@@ -633,6 +636,19 @@ def emit_field(lines, field_def, indent):
|
||||
lines.append(f'{indent}\t\t<dcscom:{k}>{esc_xml(str(v))}</dcscom:{k}>')
|
||||
lines.append(f'{indent}\t</role>')
|
||||
|
||||
# OrderExpression — после role, до valueType
|
||||
if f.get('orderExpression'):
|
||||
oe = f['orderExpression']
|
||||
expr = str(oe.get('expression', ''))
|
||||
o_type = str(oe.get('orderType', 'Asc'))
|
||||
auto = oe.get('autoOrder', False)
|
||||
auto_str = 'true' if auto else 'false'
|
||||
lines.append(f'{indent}\t<orderExpression>')
|
||||
lines.append(f'{indent}\t\t<dcscom:expression>{esc_xml(expr)}</dcscom:expression>')
|
||||
lines.append(f'{indent}\t\t<dcscom:orderType>{o_type}</dcscom:orderType>')
|
||||
lines.append(f'{indent}\t\t<dcscom:autoOrder>{auto_str}</dcscom:autoOrder>')
|
||||
lines.append(f'{indent}\t</orderExpression>')
|
||||
|
||||
# ValueType
|
||||
if f.get('type'):
|
||||
lines.append(f'{indent}\t<valueType>')
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# skd-decompile v0.10 — Decompile 1C DCS Template.xml to JSON DSL (draft)
|
||||
# skd-decompile v0.11 — Decompile 1C DCS Template.xml to JSON DSL (draft)
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
@@ -345,12 +345,19 @@ function Build-Field {
|
||||
param($fieldNode, [string]$loc)
|
||||
# Silent-drop detection (non-blocking warnings only)
|
||||
Check-InputParameters -parentNode $fieldNode -loc $loc
|
||||
$orderExpr = $fieldNode.SelectSingleNode("r:orderExpression", $ns)
|
||||
if ($orderExpr) {
|
||||
$expr = Get-Text $orderExpr "dcscom:expression"
|
||||
if ($expr) {
|
||||
$null = Add-Warning -kind 'SilentDrop:orderExpression' -loc "$loc/orderExpression" -detail "Поле имеет orderExpression='$expr' — не воспроизводится в DSL"
|
||||
}
|
||||
# orderExpression теперь поддерживается в DSL — читается ниже в needsObject
|
||||
$orderExprNode = $fieldNode.SelectSingleNode("r:orderExpression", $ns)
|
||||
$orderExpression = $null
|
||||
if ($orderExprNode) {
|
||||
$oeExpr = Get-Text $orderExprNode "dcscom:expression"
|
||||
$oeType = Get-Text $orderExprNode "dcscom:orderType"
|
||||
$oeAuto = Get-Text $orderExprNode "dcscom:autoOrder"
|
||||
$orderExpression = [ordered]@{}
|
||||
if ($oeExpr) { $orderExpression['expression'] = $oeExpr }
|
||||
if ($oeType) { $orderExpression['orderType'] = $oeType }
|
||||
# autoOrder=false — это дефолт; emit'им только если true (или явно записан false)
|
||||
if ($oeAuto -eq 'true') { $orderExpression['autoOrder'] = $true }
|
||||
elseif ($oeAuto -eq 'false') { $orderExpression['autoOrder'] = $false }
|
||||
}
|
||||
$dataPath = Get-Text $fieldNode "r:dataPath"
|
||||
$fieldName = Get-Text $fieldNode "r:field"
|
||||
@@ -369,7 +376,7 @@ function Build-Field {
|
||||
|
||||
# Можно ли роль положить в shorthand-строку?
|
||||
$roleInString = $roleRendered -and $roleRendered.isString
|
||||
$needsObject = $title -or $appearance -or $presExpr -or ($typeShort -is [array]) -or ($roleRendered -and -not $roleInString)
|
||||
$needsObject = $title -or $appearance -or $presExpr -or ($typeShort -is [array]) -or ($roleRendered -and -not $roleInString) -or $orderExpression
|
||||
|
||||
if (-not $needsObject) {
|
||||
# shorthand: "Name: type @role K=V #restrict"
|
||||
@@ -397,6 +404,7 @@ function Build-Field {
|
||||
if ($title) { $obj['title'] = $title }
|
||||
if ($typeShort) { $obj['type'] = $typeShort }
|
||||
if ($roleRendered) { $obj['role'] = $roleRendered.value }
|
||||
if ($orderExpression) { $obj['orderExpression'] = $orderExpression }
|
||||
if ($restrictTokens) { $obj['restrict'] = ($restrictTokens | ForEach-Object { $_ -replace '^#','' }) }
|
||||
if ($presExpr) { $obj['presentationExpression'] = $presExpr }
|
||||
if ($appearance) { $obj['appearance'] = $appearance }
|
||||
|
||||
@@ -141,7 +141,8 @@
|
||||
"restrict": ["noFilter", "noGroup"],
|
||||
"attrRestrict": ["noFilter"],
|
||||
"appearance": { "Формат": "ЧДЦ=2" },
|
||||
"presentationExpression": "Формат(Сумма, \"ЧДЦ=2\")"
|
||||
"presentationExpression": "Формат(Сумма, \"ЧДЦ=2\")",
|
||||
"orderExpression": { "expression": "ЕстьNULL(Поле.Порядок, 10000)", "orderType": "Asc", "autoOrder": false }
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "Поле: orderExpression (сортировка по выражению)",
|
||||
"preRun": [
|
||||
{
|
||||
"script": "skd-compile/scripts/skd-compile",
|
||||
"input": {
|
||||
"dataSets": [{
|
||||
"name": "Тест",
|
||||
"query": "ВЫБРАТЬ * ИЗ Справочник.ВидыРасчета",
|
||||
"fields": [
|
||||
{ "field": "ВидРасчета", "type": "CatalogRef.ВидыРасчета", "orderExpression": { "expression": "ЕстьNULL(ВидРасчета.Порядок, 10000)", "orderType": "Asc", "autoOrder": false } }
|
||||
]
|
||||
}]
|
||||
},
|
||||
"args": { "-DefinitionFile": "{inputFile}", "-OutputPath": "Template.xml" },
|
||||
"cwd": "{workDir}"
|
||||
}
|
||||
],
|
||||
"params": { "templatePath": "Template.xml" },
|
||||
"outputPath": "decompiled.json"
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?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>
|
||||
<orderExpression>
|
||||
<dcscom:expression>ЕстьNULL(ВидРасчета.Порядок, 10000)</dcscom:expression>
|
||||
<dcscom:orderType>Asc</dcscom:orderType>
|
||||
<dcscom:autoOrder>false</dcscom:autoOrder>
|
||||
</orderExpression>
|
||||
<valueType>
|
||||
<v8:Type xmlns:d5p1="http://v8.1c.ru/8.1/data/enterprise/current-config">d5p1:CatalogRef.ВидыРасчета</v8:Type>
|
||||
</valueType>
|
||||
</field>
|
||||
<dataSource>ИсточникДанных1</dataSource>
|
||||
<query>ВЫБРАТЬ * ИЗ Справочник.ВидыРасчета</query>
|
||||
</dataSet>
|
||||
<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>
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"dataSets": [
|
||||
{
|
||||
"name": "Тест",
|
||||
"query": "ВЫБРАТЬ * ИЗ Справочник.ВидыРасчета",
|
||||
"fields": [
|
||||
{
|
||||
"field": "ВидРасчета",
|
||||
"type": "CatalogRef.ВидыРасчета",
|
||||
"orderExpression": {
|
||||
"expression": "ЕстьNULL(ВидРасчета.Порядок, 10000)",
|
||||
"orderType": "Asc",
|
||||
"autoOrder": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user