mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-09-15 22:35:23 +03:00
feat(skd): DataSetFieldFolder + GroupItemAuto + empty-field selection
Закрывает три gap'a, выявленных при полном прогоне ERP+ACC: 1. DataSetFieldFolder — поле-папка для UI-группировки полей в композиторе настроек. Только dataPath + title, без valueType/role. - DSL: object form поля с `folder: true`. - Compile: при folder=true → <field xsi:type="DataSetFieldFolder">. - Decompile: распознать xsi:type, эмитить object form. 2. GroupItemAuto — пустой <item xsi:type="GroupItemAuto"/> в groupItems (auto-grouping, аналогично "Auto" в selection). - DSL: строка "Auto" в groupFields. - Compile/decompile: round-trip. 3. Empty <field/> в conditionalAppearance/selection (wildcard — apply to all). Раньше — SelectionItem: sentinel. Теперь эмитим как "Auto" (семантический эквивалент через SelectedItemAuto). Новый тест dataset-folder-and-auto-group (round-trip). Versions: compile v1.34→v1.35, decompile v0.16→v0.17. На предыдущем прогоне ERP+ACC: 227 sentinel'ов (218 DataSetFieldFolder + 7 GroupItemAuto + 2 SelectionItem). После — 0.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# skd-compile v1.34 — Compile 1C DCS from JSON
|
||||
# skd-compile v1.35 — Compile 1C DCS from JSON
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[string]$DefinitionFile,
|
||||
@@ -848,6 +848,19 @@ function Emit-Field {
|
||||
if ($null -ne $fieldDef.inputParameters) {
|
||||
$f["inputParameters"] = $fieldDef.inputParameters
|
||||
}
|
||||
# folder: true → DataSetFieldFolder (поле-папка для UI-группировки, только dataPath+title)
|
||||
if ($fieldDef.folder -eq $true) {
|
||||
$f["folder"] = $true
|
||||
}
|
||||
}
|
||||
|
||||
# DataSetFieldFolder — только dataPath + title (для UI-группировки полей в композиторе)
|
||||
if ($f["folder"]) {
|
||||
X "$indent<field xsi:type=`"DataSetFieldFolder`">"
|
||||
X "$indent`t<dataPath>$(Esc-Xml $f.dataPath)</dataPath>"
|
||||
if ($f.title) { Emit-MLText -tag "title" -text $f.title -indent "$indent`t" }
|
||||
X "$indent</field>"
|
||||
return
|
||||
}
|
||||
|
||||
X "$indent<field xsi:type=`"DataSetFieldField`">"
|
||||
@@ -2239,6 +2252,11 @@ function Emit-GroupItems {
|
||||
X "$indent<dcsset:groupItems>"
|
||||
foreach ($field in $groupBy) {
|
||||
if ($field -is [string]) {
|
||||
if ($field -eq 'Auto') {
|
||||
# Auto-группировка (по аналогии с "Auto" в selection)
|
||||
X "$indent`t<dcsset:item xsi:type=`"dcsset:GroupItemAuto`"/>"
|
||||
continue
|
||||
}
|
||||
X "$indent`t<dcsset:item xsi:type=`"dcsset:GroupItemField`">"
|
||||
X "$indent`t`t<dcsset:field>$(Esc-Xml $field)</dcsset:field>"
|
||||
X "$indent`t`t<dcsset:groupType>Items</dcsset:groupType>"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# skd-compile v1.34 — Compile 1C DCS from JSON
|
||||
# skd-compile v1.35 — Compile 1C DCS from JSON
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
import argparse
|
||||
import json
|
||||
@@ -642,6 +642,18 @@ def emit_field(lines, field_def, indent):
|
||||
# inputParameters — массив элементов, типизированных по форме value
|
||||
if field_def.get('inputParameters') is not None:
|
||||
f['inputParameters'] = field_def['inputParameters']
|
||||
# folder: true → DataSetFieldFolder
|
||||
if field_def.get('folder') is True:
|
||||
f['folder'] = True
|
||||
|
||||
# DataSetFieldFolder — только dataPath + title
|
||||
if f.get('folder'):
|
||||
lines.append(f'{indent}<field xsi:type="DataSetFieldFolder">')
|
||||
lines.append(f'{indent}\t<dataPath>{esc_xml(f["dataPath"])}</dataPath>')
|
||||
if f.get('title'):
|
||||
emit_mltext(lines, f'{indent}\t', 'title', f['title'])
|
||||
lines.append(f'{indent}</field>')
|
||||
return
|
||||
|
||||
lines.append(f'{indent}<field xsi:type="DataSetFieldField">')
|
||||
lines.append(f'{indent}\t<dataPath>{esc_xml(f["dataPath"])}</dataPath>')
|
||||
@@ -1861,6 +1873,9 @@ def emit_group_items(lines, group_by, indent):
|
||||
lines.append(f'{indent}<dcsset:groupItems>')
|
||||
for field in group_by:
|
||||
if isinstance(field, str):
|
||||
if field == 'Auto':
|
||||
lines.append(f'{indent}\t<dcsset:item xsi:type="dcsset:GroupItemAuto"/>')
|
||||
continue
|
||||
lines.append(f'{indent}\t<dcsset:item xsi:type="dcsset:GroupItemField">')
|
||||
lines.append(f'{indent}\t\t<dcsset:field>{esc_xml(field)}</dcsset:field>')
|
||||
lines.append(f'{indent}\t\t<dcsset:groupType>Items</dcsset:groupType>')
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# skd-decompile v0.16 — Decompile 1C DCS Template.xml to JSON DSL (draft)
|
||||
# skd-decompile v0.17 — Decompile 1C DCS Template.xml to JSON DSL (draft)
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
@@ -1152,6 +1152,9 @@ function Build-SelectionItem {
|
||||
if (-not $xt) {
|
||||
$fName = Get-Text $item "dcsset:field"
|
||||
if ($fName) { return $fName }
|
||||
# Пустой <field/> → wildcard (apply to all) — эквивалентно Auto
|
||||
$fieldEl = $item.SelectSingleNode("dcsset:field", $ns)
|
||||
if ($fieldEl) { return 'Auto' }
|
||||
}
|
||||
switch ($xt) {
|
||||
'SelectedItemAuto' { return 'Auto' }
|
||||
@@ -1352,7 +1355,9 @@ function Get-GroupFields {
|
||||
if (-not $gi) { return ,$gFields }
|
||||
foreach ($gItem in $gi.SelectNodes("dcsset:item", $ns)) {
|
||||
$gxt = Get-LocalXsiType $gItem
|
||||
if ($gxt -eq 'GroupItemField') {
|
||||
if ($gxt -eq 'GroupItemAuto') {
|
||||
$gFields += 'Auto'
|
||||
} elseif ($gxt -eq 'GroupItemField') {
|
||||
$gf = Get-Text $gItem "dcsset:field"
|
||||
$pat = Get-Text $gItem "dcsset:periodAdditionType"
|
||||
$gt = Get-Text $gItem "dcsset:groupType"
|
||||
@@ -1613,10 +1618,20 @@ function Build-DataSet {
|
||||
$fi = 0
|
||||
foreach ($fn in $fieldNodes) {
|
||||
$fxsi = Get-LocalXsiType $fn
|
||||
if ($fxsi -ne 'DataSetFieldField') {
|
||||
$fields += (New-Sentinel -kind "FieldType:$fxsi" -loc "$loc/field[$fi]" -detail 'Тип поля не DataSetFieldField')
|
||||
} else {
|
||||
if ($fxsi -eq 'DataSetFieldField') {
|
||||
$fields += (Build-Field -fieldNode $fn -loc "$loc/field[$fi]")
|
||||
} elseif ($fxsi -eq 'DataSetFieldFolder') {
|
||||
# Поле-папка для UI-группировки (только dataPath+title, без типа/роли)
|
||||
$folderObj = [ordered]@{
|
||||
field = (Get-Text $fn "r:dataPath")
|
||||
folder = $true
|
||||
}
|
||||
$titleNode = $fn.SelectSingleNode("r:title", $ns)
|
||||
$title = Get-MLText $titleNode
|
||||
if ($title) { $folderObj['title'] = $title }
|
||||
$fields += $folderObj
|
||||
} else {
|
||||
$fields += (New-Sentinel -kind "FieldType:$fxsi" -loc "$loc/field[$fi]" -detail 'Тип поля не DataSetFieldField/Folder')
|
||||
}
|
||||
$fi++
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user