mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-07-25 22:21:01 +03:00
feat(skd-compile): useInXxx и use=false на conditionalAppearance item
Расширение DSL для бит-перфект roundtrip на условном оформлении: - use: false — отключённое правило (эмитится в начале item) - useInDontUse: array — список областей где правило НЕ применяется (\"group\", \"hierarchicalGroup\", \"overall\", \"fieldsHeader\", \"header\", \"parameters\", \"filter\", \"resourceFieldsHeader\", \"overallHeader\", \"overallResourceFieldsHeader\") Compile эмитит <dcsset:useInGroup>DontUse</...> и т.п. в платформенном порядке. Семантика: \"useIn\" в платформе — это белый список применения правила; DSL хранит инверсный список (что отключено) — короче для редких ограничений. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
32e06cbc56
commit
eee5aaafd3
@@ -1,4 +1,4 @@
|
|||||||
# skd-compile v1.50 — Compile 1C DCS from JSON
|
# skd-compile v1.51 — Compile 1C DCS from JSON
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
param(
|
param(
|
||||||
[string]$DefinitionFile,
|
[string]$DefinitionFile,
|
||||||
@@ -2192,6 +2192,11 @@ function Emit-ConditionalAppearance {
|
|||||||
foreach ($ca in $items) {
|
foreach ($ca in $items) {
|
||||||
X "$indent`t<dcsset:item>"
|
X "$indent`t<dcsset:item>"
|
||||||
|
|
||||||
|
# use=false — отключённое правило (эмитим до selection — XML-порядок)
|
||||||
|
if ($ca.use -eq $false) {
|
||||||
|
X "$indent`t`t<dcsset:use>false</dcsset:use>"
|
||||||
|
}
|
||||||
|
|
||||||
# Selection (which fields to apply to; empty = all)
|
# Selection (which fields to apply to; empty = all)
|
||||||
if ($ca.selection -and $ca.selection.Count -gt 0) {
|
if ($ca.selection -and $ca.selection.Count -gt 0) {
|
||||||
X "$indent`t`t<dcsset:selection>"
|
X "$indent`t`t<dcsset:selection>"
|
||||||
@@ -2234,6 +2239,22 @@ function Emit-ConditionalAppearance {
|
|||||||
X "$indent`t`t<dcsset:userSettingID>$(Esc-Xml $uid)</dcsset:userSettingID>"
|
X "$indent`t`t<dcsset:userSettingID>$(Esc-Xml $uid)</dcsset:userSettingID>"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# useInXxx — список областей где правило НЕ применяется (DontUse).
|
||||||
|
# Порядок имитирует платформенный (group → hierarchicalGroup → overall → ...).
|
||||||
|
if ($ca.useInDontUse -and $ca.useInDontUse.Count -gt 0) {
|
||||||
|
$useInOrder = @('group','hierarchicalGroup','overall',
|
||||||
|
'fieldsHeader','header','parameters','filter',
|
||||||
|
'resourceFieldsHeader','overallHeader','overallResourceFieldsHeader')
|
||||||
|
$set = @{}
|
||||||
|
foreach ($n in $ca.useInDontUse) { $set["$n"] = $true }
|
||||||
|
foreach ($n in $useInOrder) {
|
||||||
|
if ($set.ContainsKey($n)) {
|
||||||
|
$tag = "useIn" + ($n.Substring(0,1).ToUpper()) + ($n.Substring(1))
|
||||||
|
X "$indent`t`t<dcsset:$tag>DontUse</dcsset:$tag>"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
X "$indent`t</dcsset:item>"
|
X "$indent`t</dcsset:item>"
|
||||||
}
|
}
|
||||||
if ($null -ne $blockViewMode) {
|
if ($null -ne $blockViewMode) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# skd-compile v1.50 — Compile 1C DCS from JSON
|
# skd-compile v1.51 — Compile 1C DCS from JSON
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
import argparse
|
import argparse
|
||||||
import json
|
import json
|
||||||
@@ -1836,6 +1836,9 @@ def emit_conditional_appearance(lines, items, indent, block_view_mode=None):
|
|||||||
for ca in items:
|
for ca in items:
|
||||||
lines.append(f'{indent}\t<dcsset:item>')
|
lines.append(f'{indent}\t<dcsset:item>')
|
||||||
|
|
||||||
|
if ca.get('use') is False:
|
||||||
|
lines.append(f'{indent}\t\t<dcsset:use>false</dcsset:use>')
|
||||||
|
|
||||||
# Selection
|
# Selection
|
||||||
if ca.get('selection') and len(ca['selection']) > 0:
|
if ca.get('selection') and len(ca['selection']) > 0:
|
||||||
lines.append(f'{indent}\t\t<dcsset:selection>')
|
lines.append(f'{indent}\t\t<dcsset:selection>')
|
||||||
@@ -1870,6 +1873,17 @@ def emit_conditional_appearance(lines, items, indent, block_view_mode=None):
|
|||||||
uid = new_uuid() if str(ca['userSettingID']) == 'auto' else str(ca['userSettingID'])
|
uid = new_uuid() if str(ca['userSettingID']) == 'auto' else str(ca['userSettingID'])
|
||||||
lines.append(f'{indent}\t\t<dcsset:userSettingID>{esc_xml(uid)}</dcsset:userSettingID>')
|
lines.append(f'{indent}\t\t<dcsset:userSettingID>{esc_xml(uid)}</dcsset:userSettingID>')
|
||||||
|
|
||||||
|
# useInXxx — список областей где правило НЕ применяется (DontUse)
|
||||||
|
if ca.get('useInDontUse'):
|
||||||
|
use_in_order = ['group', 'hierarchicalGroup', 'overall',
|
||||||
|
'fieldsHeader', 'header', 'parameters', 'filter',
|
||||||
|
'resourceFieldsHeader', 'overallHeader', 'overallResourceFieldsHeader']
|
||||||
|
s = set(ca['useInDontUse'])
|
||||||
|
for n in use_in_order:
|
||||||
|
if n in s:
|
||||||
|
tag = 'useIn' + n[0].upper() + n[1:]
|
||||||
|
lines.append(f'{indent}\t\t<dcsset:{tag}>DontUse</dcsset:{tag}>')
|
||||||
|
|
||||||
lines.append(f'{indent}\t</dcsset:item>')
|
lines.append(f'{indent}\t</dcsset:item>')
|
||||||
if block_view_mode is not None:
|
if block_view_mode is not None:
|
||||||
lines.append(f'{indent}\t<dcsset:viewMode>{esc_xml(str(block_view_mode))}</dcsset:viewMode>')
|
lines.append(f'{indent}\t<dcsset:viewMode>{esc_xml(str(block_view_mode))}</dcsset:viewMode>')
|
||||||
|
|||||||
Reference in New Issue
Block a user