mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-06-13 01:14:56 +03:00
fix(skd-compile): short form <dcsset:item> для StructureItemGroup внутри row/column
Анализ корпуса ERP (671 отчёт): items внутри dcsset:row/column/points/series ВСЕГДА используют короткую форму <dcsset:item> без xsi:type (531 случай, 0 explicit). В остальных контекстах — explicit <dcsset:item xsi:type="dcsset:StructureItemGroup">. Emit-StructureItem получил switch -shortGroup, который Emit-TableAxisBlock передаёт для nested children. Флаг наследуется recursive в детей через Emit-StructureItem рекурсию. Снапшоты регенерированы. sample30: −166 строк (1192 → 1026).
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# skd-compile v1.82 — Compile 1C DCS from JSON
|
||||
# skd-compile v1.83 — Compile 1C DCS from JSON
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[string]$DefinitionFile,
|
||||
@@ -2811,10 +2811,11 @@ function Emit-TableAxisBlock {
|
||||
if ($block.outputParameters) {
|
||||
Emit-OutputParameters -params $block.outputParameters -indent $indent
|
||||
}
|
||||
# nested children (StructureItemGroup внутри table row/column или chart axis)
|
||||
# nested children (StructureItemGroup внутри table row/column или chart axis).
|
||||
# Platform-pattern: items внутри row/column/points/series — ВСЕГДА short form (без xsi:type).
|
||||
if ($block.children) {
|
||||
foreach ($child in $block.children) {
|
||||
Emit-StructureItem -item $child -indent $indent
|
||||
Emit-StructureItem -item $child -indent $indent -shortGroup
|
||||
}
|
||||
}
|
||||
if ($block.viewMode) {
|
||||
@@ -2833,12 +2834,18 @@ function Emit-TableAxisBlock {
|
||||
}
|
||||
|
||||
function Emit-StructureItem {
|
||||
param($item, [string]$indent)
|
||||
param($item, [string]$indent, [switch]$shortGroup)
|
||||
|
||||
$type = if ($item.type) { "$($item.type)" } else { "group" }
|
||||
|
||||
if ($type -eq "group") {
|
||||
X "$indent<dcsset:item xsi:type=`"dcsset:StructureItemGroup`">"
|
||||
# Platform пишет короткую форму (без xsi:type) для groups внутри table row/column,
|
||||
# explicit StructureItemGroup в остальных случаях.
|
||||
if ($shortGroup) {
|
||||
X "$indent<dcsset:item>"
|
||||
} else {
|
||||
X "$indent<dcsset:item xsi:type=`"dcsset:StructureItemGroup`">"
|
||||
}
|
||||
|
||||
# use=false — отключённая ветка структуры
|
||||
if ($item.use -eq $false) {
|
||||
@@ -2870,10 +2877,15 @@ function Emit-StructureItem {
|
||||
Emit-OutputParameters -params $item.outputParameters -indent "$indent`t"
|
||||
}
|
||||
|
||||
# Nested children
|
||||
# Nested children — наследуем shortGroup от родителя (если родитель в short form,
|
||||
# то и дети остаются short, как делает platform внутри row/column).
|
||||
if ($item.children) {
|
||||
foreach ($child in $item.children) {
|
||||
Emit-StructureItem -item $child -indent "$indent`t"
|
||||
if ($shortGroup) {
|
||||
Emit-StructureItem -item $child -indent "$indent`t" -shortGroup
|
||||
} else {
|
||||
Emit-StructureItem -item $child -indent "$indent`t"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# skd-compile v1.82 — Compile 1C DCS from JSON
|
||||
# skd-compile v1.83 — Compile 1C DCS from JSON
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
import argparse
|
||||
import json
|
||||
@@ -2268,10 +2268,11 @@ def emit_table_axis_block(lines, block, indent, emit_name=True):
|
||||
emit_conditional_appearance(lines, block['conditionalAppearance'], indent)
|
||||
if block.get('outputParameters'):
|
||||
emit_output_parameters(lines, block['outputParameters'], indent)
|
||||
# nested children (StructureItemGroup внутри table row/column или chart axis)
|
||||
# nested children (StructureItemGroup внутри table row/column или chart axis).
|
||||
# Platform-pattern: items внутри row/column/points/series — ВСЕГДА short form (без xsi:type).
|
||||
if block.get('children'):
|
||||
for child in block['children']:
|
||||
emit_structure_item(lines, child, indent)
|
||||
emit_structure_item(lines, child, indent, short_group=True)
|
||||
if block.get('viewMode'):
|
||||
lines.append(f'{indent}<dcsset:viewMode>{esc_xml(str(block["viewMode"]))}</dcsset:viewMode>')
|
||||
if block.get('userSettingID'):
|
||||
@@ -2283,11 +2284,16 @@ def emit_table_axis_block(lines, block, indent, emit_name=True):
|
||||
lines.append(f'{indent}<dcsset:itemsViewMode>{esc_xml(str(block["itemsViewMode"]))}</dcsset:itemsViewMode>')
|
||||
|
||||
|
||||
def emit_structure_item(lines, item, indent):
|
||||
def emit_structure_item(lines, item, indent, short_group=False):
|
||||
item_type = str(item.get('type', 'group'))
|
||||
|
||||
if item_type == 'group':
|
||||
lines.append(f'{indent}<dcsset:item xsi:type="dcsset:StructureItemGroup">')
|
||||
# Platform пишет короткую форму (без xsi:type) для groups внутри table row/column,
|
||||
# explicit StructureItemGroup в остальных случаях.
|
||||
if short_group:
|
||||
lines.append(f'{indent}<dcsset:item>')
|
||||
else:
|
||||
lines.append(f'{indent}<dcsset:item xsi:type="dcsset:StructureItemGroup">')
|
||||
|
||||
if item.get('use') is False:
|
||||
lines.append(f'{indent}\t<dcsset:use>false</dcsset:use>')
|
||||
@@ -2311,10 +2317,10 @@ def emit_structure_item(lines, item, indent):
|
||||
if item.get('outputParameters'):
|
||||
emit_output_parameters(lines, item['outputParameters'], f'{indent}\t')
|
||||
|
||||
# Nested children
|
||||
# Nested children — наследуем short_group от родителя.
|
||||
if item.get('children'):
|
||||
for child in item['children']:
|
||||
emit_structure_item(lines, child, f'{indent}\t')
|
||||
emit_structure_item(lines, child, f'{indent}\t', short_group=short_group)
|
||||
|
||||
# viewMode/itemsViewMode/userSettingID/userSettingPresentation — context-dependent
|
||||
if item.get('viewMode'):
|
||||
|
||||
Reference in New Issue
Block a user