mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-06-12 00:44:57 +03:00
feat(skd): DesignTimeValue in filters, Format as LocalStringType, OrGroup in conditionalAppearance
- Auto-detect DesignTimeValue type for enum/catalog/chart-of-accounts references in filter values (both skd-edit and skd-compile) - Treat Формат appearance parameter as v8:LocalStringType (alongside Текст/Заголовок) - Support OrGroup in conditionalAppearance filters via " or " syntax in skd-edit shorthand - Bump skd-edit v1.5, skd-compile v1.6 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# skd-compile v1.5 — Compile 1C DCS from JSON
|
||||
# skd-compile v1.6 — Compile 1C DCS from JSON
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[string]$DefinitionFile,
|
||||
@@ -481,6 +481,9 @@ function Parse-FilterShorthand {
|
||||
} elseif ($valPart -match '^\d+(\.\d+)?$') {
|
||||
$result.value = $valPart
|
||||
$result["valueType"] = "xs:decimal"
|
||||
} elseif ($valPart -match '^(Перечисление|Справочник|ПланСчетов|Документ|ПланВидовХарактеристик|ПланВидовРасчета)\.') {
|
||||
$result.value = $valPart
|
||||
$result["valueType"] = "dcscor:DesignTimeValue"
|
||||
} else {
|
||||
$result.value = $valPart
|
||||
$result["valueType"] = "xs:string"
|
||||
@@ -1520,7 +1523,7 @@ function Emit-AppearanceValue {
|
||||
X "$indent`t<dcscor:value xsi:type=`"v8ui:Color`">$(Esc-Xml $actualVal)</dcscor:value>"
|
||||
} elseif ($actualVal -eq "true" -or $actualVal -eq "false") {
|
||||
X "$indent`t<dcscor:value xsi:type=`"xs:boolean`">$actualVal</dcscor:value>"
|
||||
} elseif ($key -eq "Текст" -or $key -eq "Заголовок") {
|
||||
} elseif ($key -eq "Текст" -or $key -eq "Заголовок" -or $key -eq "Формат") {
|
||||
X "$indent`t<dcscor:value xsi:type=`"v8:LocalStringType`">"
|
||||
X "$indent`t`t<v8:item>"
|
||||
X "$indent`t`t`t<v8:lang>ru</v8:lang>"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# skd-compile v1.5 — Compile 1C DCS from JSON
|
||||
# skd-compile v1.6 — Compile 1C DCS from JSON
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
import argparse
|
||||
import json
|
||||
@@ -371,6 +371,9 @@ def parse_filter_shorthand(s):
|
||||
elif re.match(r'^\d+(\.\d+)?$', val_part):
|
||||
result['value'] = val_part
|
||||
result['valueType'] = 'xs:decimal'
|
||||
elif re.match(r'^(Перечисление|Справочник|ПланСчетов|Документ|ПланВидовХарактеристик|ПланВидовРасчета)\.', val_part):
|
||||
result['value'] = val_part
|
||||
result['valueType'] = 'dcscor:DesignTimeValue'
|
||||
else:
|
||||
result['value'] = val_part
|
||||
result['valueType'] = 'xs:string'
|
||||
@@ -1281,7 +1284,7 @@ def emit_appearance_value(lines, key, val, indent):
|
||||
lines.append(f'{indent}\t<dcscor:value xsi:type="v8ui:Color">{esc_xml(actual_val)}</dcscor:value>')
|
||||
elif actual_val == 'true' or actual_val == 'false':
|
||||
lines.append(f'{indent}\t<dcscor:value xsi:type="xs:boolean">{actual_val}</dcscor:value>')
|
||||
elif key == '\u0422\u0435\u043a\u0441\u0442' or key == '\u0417\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a':
|
||||
elif key in ('\u0422\u0435\u043a\u0441\u0442', '\u0417\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a', '\u0424\u043e\u0440\u043c\u0430\u0442'):
|
||||
lines.append(f'{indent}\t<dcscor:value xsi:type="v8:LocalStringType">')
|
||||
lines.append(f'{indent}\t\t<v8:item>')
|
||||
lines.append(f'{indent}\t\t\t<v8:lang>ru</v8:lang>')
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# skd-edit v1.4 — Atomic 1C DCS editor
|
||||
# skd-edit v1.5 — Atomic 1C DCS editor
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
@@ -357,6 +357,9 @@ function Parse-FilterShorthand {
|
||||
} elseif ($valPart -match '^\d+(\.\d+)?$') {
|
||||
$result.value = $valPart
|
||||
$result["valueType"] = "xs:decimal"
|
||||
} elseif ($valPart -match '^(Перечисление|Справочник|ПланСчетов|Документ|ПланВидовХарактеристик|ПланВидовРасчета)\.') {
|
||||
$result.value = $valPart
|
||||
$result["valueType"] = "dcscor:DesignTimeValue"
|
||||
} else {
|
||||
$result.value = $valPart
|
||||
$result["valueType"] = "xs:string"
|
||||
@@ -503,12 +506,17 @@ function Parse-ConditionalAppearanceShorthand {
|
||||
$result.fields = @($forPart -split '\s*,\s*' | ForEach-Object { $_.Trim() } | Where-Object { $_ })
|
||||
}
|
||||
|
||||
# Parse "when" filter
|
||||
# Parse "when" filter (supports " or " for OrGroup)
|
||||
if ($whenIdx -ge 0) {
|
||||
$whenEnd = $s.Length
|
||||
if ($forIdx -gt $whenIdx) { $whenEnd = $forIdx }
|
||||
$whenPart = $s.Substring($whenIdx + 6, $whenEnd - $whenIdx - 6).Trim()
|
||||
$result.filter = Parse-FilterShorthand $whenPart
|
||||
$orParts = $whenPart -split '\s+or\s+'
|
||||
if ($orParts.Count -gt 1) {
|
||||
$result.filter = @($orParts | ForEach-Object { Parse-FilterShorthand $_.Trim() })
|
||||
} else {
|
||||
$result.filter = Parse-FilterShorthand $whenPart
|
||||
}
|
||||
}
|
||||
|
||||
# Parse main part: "Param = Value"
|
||||
@@ -973,6 +981,20 @@ function Build-VariantFragment {
|
||||
return $lines -join "`r`n"
|
||||
}
|
||||
|
||||
function Emit-FilterComparison {
|
||||
param($f, [string]$indent)
|
||||
$lines = @()
|
||||
$lines += "$indent<dcsset:item xsi:type=`"dcsset:FilterItemComparison`">"
|
||||
$lines += "$indent`t<dcsset:left xsi:type=`"dcscor:Field`">$(Esc-Xml $f.field)</dcsset:left>"
|
||||
$lines += "$indent`t<dcsset:comparisonType>$(Esc-Xml $f.op)</dcsset:comparisonType>"
|
||||
if ($null -ne $f.value) {
|
||||
$vt = if ($f["valueType"]) { $f["valueType"] } else { "xs:string" }
|
||||
$lines += "$indent`t<dcsset:right xsi:type=`"$vt`">$(Esc-Xml "$($f.value)")</dcsset:right>"
|
||||
}
|
||||
$lines += "$indent</dcsset:item>"
|
||||
return $lines
|
||||
}
|
||||
|
||||
function Build-ConditionalAppearanceItemFragment {
|
||||
param($parsed, [string]$indent)
|
||||
|
||||
@@ -996,15 +1018,17 @@ function Build-ConditionalAppearanceItemFragment {
|
||||
# filter
|
||||
if ($parsed.filter) {
|
||||
$lines += "$i`t<dcsset:filter>"
|
||||
$f = $parsed.filter
|
||||
$lines += "$i`t`t<dcsset:item xsi:type=`"dcsset:FilterItemComparison`">"
|
||||
$lines += "$i`t`t`t<dcsset:left xsi:type=`"dcscor:Field`">$(Esc-Xml $f.field)</dcsset:left>"
|
||||
$lines += "$i`t`t`t<dcsset:comparisonType>$(Esc-Xml $f.op)</dcsset:comparisonType>"
|
||||
if ($null -ne $f.value) {
|
||||
$vt = if ($f["valueType"]) { $f["valueType"] } else { "xs:string" }
|
||||
$lines += "$i`t`t`t<dcsset:right xsi:type=`"$vt`">$(Esc-Xml "$($f.value)")</dcsset:right>"
|
||||
if ($parsed.filter -is [array]) {
|
||||
# OrGroup
|
||||
$lines += "$i`t`t<dcsset:item xsi:type=`"dcsset:FilterItemGroup`">"
|
||||
$lines += "$i`t`t`t<dcsset:groupType>OrGroup</dcsset:groupType>"
|
||||
foreach ($f in $parsed.filter) {
|
||||
$lines += Emit-FilterComparison $f "$i`t`t`t"
|
||||
}
|
||||
$lines += "$i`t`t</dcsset:item>"
|
||||
} else {
|
||||
$lines += Emit-FilterComparison $parsed.filter "$i`t`t"
|
||||
}
|
||||
$lines += "$i`t`t</dcsset:item>"
|
||||
$lines += "$i`t</dcsset:filter>"
|
||||
} else {
|
||||
$lines += "$i`t<dcsset:filter/>"
|
||||
@@ -1013,18 +1037,25 @@ function Build-ConditionalAppearanceItemFragment {
|
||||
# appearance
|
||||
$lines += "$i`t<dcsset:appearance>"
|
||||
|
||||
# Auto-detect value type
|
||||
$val = $parsed.value
|
||||
$valType = "xs:string"
|
||||
if ($val -match '^(web|style|win):') {
|
||||
$valType = "v8ui:Color"
|
||||
} elseif ($val -eq "true" -or $val -eq "false") {
|
||||
$valType = "xs:boolean"
|
||||
}
|
||||
|
||||
$lines += "$i`t`t<dcscor:item xsi:type=`"dcsset:SettingsParameterValue`">"
|
||||
$lines += "$i`t`t`t<dcscor:parameter>$(Esc-Xml $parsed.param)</dcscor:parameter>"
|
||||
$lines += "$i`t`t`t<dcscor:value xsi:type=`"$valType`">$(Esc-Xml $val)</dcscor:value>"
|
||||
|
||||
if ($val -match '^(web|style|win):') {
|
||||
$lines += "$i`t`t`t<dcscor:value xsi:type=`"v8ui:Color`">$(Esc-Xml $val)</dcscor:value>"
|
||||
} elseif ($val -eq "true" -or $val -eq "false") {
|
||||
$lines += "$i`t`t`t<dcscor:value xsi:type=`"xs:boolean`">$(Esc-Xml $val)</dcscor:value>"
|
||||
} elseif ($parsed.param -eq "Формат" -or $parsed.param -eq "Текст" -or $parsed.param -eq "Заголовок") {
|
||||
$lines += "$i`t`t`t<dcscor:value xsi:type=`"v8:LocalStringType`">"
|
||||
$lines += "$i`t`t`t`t<v8:item>"
|
||||
$lines += "$i`t`t`t`t`t<v8:lang>ru</v8:lang>"
|
||||
$lines += "$i`t`t`t`t`t<v8:content>$(Esc-Xml $val)</v8:content>"
|
||||
$lines += "$i`t`t`t`t</v8:item>"
|
||||
$lines += "$i`t`t`t</dcscor:value>"
|
||||
} else {
|
||||
$lines += "$i`t`t`t<dcscor:value xsi:type=`"xs:string`">$(Esc-Xml $val)</dcscor:value>"
|
||||
}
|
||||
|
||||
$lines += "$i`t`t</dcscor:item>"
|
||||
$lines += "$i`t</dcsset:appearance>"
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# skd-edit v1.4 — Atomic 1C DCS editor (Python port)
|
||||
# skd-edit v1.5 — Atomic 1C DCS editor (Python port)
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
import argparse
|
||||
import os
|
||||
@@ -350,6 +350,9 @@ def parse_filter_shorthand(s):
|
||||
elif re.match(r'^\d+(\.\d+)?$', val_part):
|
||||
result["value"] = val_part
|
||||
result["valueType"] = "xs:decimal"
|
||||
elif re.match(r'^(Перечисление|Справочник|ПланСчетов|Документ|ПланВидовХарактеристик|ПланВидовРасчета)\.', val_part):
|
||||
result["value"] = val_part
|
||||
result["valueType"] = "dcscor:DesignTimeValue"
|
||||
else:
|
||||
result["value"] = val_part
|
||||
result["valueType"] = "xs:string"
|
||||
@@ -480,7 +483,11 @@ def parse_conditional_appearance_shorthand(s):
|
||||
if for_idx > when_idx:
|
||||
when_end = for_idx
|
||||
when_part = s[when_idx + 6:when_end].strip()
|
||||
result["filter"] = parse_filter_shorthand(when_part)
|
||||
or_parts = re.split(r'\s+or\s+', when_part)
|
||||
if len(or_parts) > 1:
|
||||
result["filter"] = [parse_filter_shorthand(p.strip()) for p in or_parts]
|
||||
else:
|
||||
result["filter"] = parse_filter_shorthand(when_part)
|
||||
|
||||
main_part = s[:main_end].strip()
|
||||
eq_idx = main_part.find("=")
|
||||
@@ -866,6 +873,16 @@ def build_variant_fragment(parsed, indent):
|
||||
return "\r\n".join(lines)
|
||||
|
||||
|
||||
def _emit_filter_comparison(lines, f, indent):
|
||||
lines.append(f'{indent}<dcsset:item xsi:type="dcsset:FilterItemComparison">')
|
||||
lines.append(f'{indent}\t<dcsset:left xsi:type="dcscor:Field">{esc_xml(f["field"])}</dcsset:left>')
|
||||
lines.append(f"{indent}\t<dcsset:comparisonType>{esc_xml(f['op'])}</dcsset:comparisonType>")
|
||||
if f.get("value") is not None:
|
||||
vt = f.get("valueType", "xs:string")
|
||||
lines.append(f'{indent}\t<dcsset:right xsi:type="{vt}">{esc_xml(str(f["value"]))}</dcsset:right>')
|
||||
lines.append(f"{indent}</dcsset:item>")
|
||||
|
||||
|
||||
def build_conditional_appearance_item_fragment(parsed, indent):
|
||||
i = indent
|
||||
lines = [f"{i}<dcsset:item>"]
|
||||
@@ -881,15 +898,17 @@ def build_conditional_appearance_item_fragment(parsed, indent):
|
||||
lines.append(f"{i}\t<dcsset:selection/>")
|
||||
|
||||
if parsed.get("filter"):
|
||||
f = parsed["filter"]
|
||||
flt = parsed["filter"]
|
||||
lines.append(f"{i}\t<dcsset:filter>")
|
||||
lines.append(f'{i}\t\t<dcsset:item xsi:type="dcsset:FilterItemComparison">')
|
||||
lines.append(f'{i}\t\t\t<dcsset:left xsi:type="dcscor:Field">{esc_xml(f["field"])}</dcsset:left>')
|
||||
lines.append(f"{i}\t\t\t<dcsset:comparisonType>{esc_xml(f['op'])}</dcsset:comparisonType>")
|
||||
if f.get("value") is not None:
|
||||
vt = f.get("valueType", "xs:string")
|
||||
lines.append(f'{i}\t\t\t<dcsset:right xsi:type="{vt}">{esc_xml(str(f["value"]))}</dcsset:right>')
|
||||
lines.append(f"{i}\t\t</dcsset:item>")
|
||||
if isinstance(flt, list):
|
||||
# OrGroup
|
||||
lines.append(f'{i}\t\t<dcsset:item xsi:type="dcsset:FilterItemGroup">')
|
||||
lines.append(f"{i}\t\t\t<dcsset:groupType>OrGroup</dcsset:groupType>")
|
||||
for f in flt:
|
||||
_emit_filter_comparison(lines, f, f"{i}\t\t\t")
|
||||
lines.append(f"{i}\t\t</dcsset:item>")
|
||||
else:
|
||||
_emit_filter_comparison(lines, flt, f"{i}\t\t")
|
||||
lines.append(f"{i}\t</dcsset:filter>")
|
||||
else:
|
||||
lines.append(f"{i}\t<dcsset:filter/>")
|
||||
@@ -897,15 +916,23 @@ def build_conditional_appearance_item_fragment(parsed, indent):
|
||||
# appearance
|
||||
lines.append(f"{i}\t<dcsset:appearance>")
|
||||
val = parsed["value"]
|
||||
val_type = "xs:string"
|
||||
if re.match(r'^(web|style|win):', val):
|
||||
val_type = "v8ui:Color"
|
||||
elif val in ("true", "false"):
|
||||
val_type = "xs:boolean"
|
||||
|
||||
lines.append(f'{i}\t\t<dcscor:item xsi:type="dcsset:SettingsParameterValue">')
|
||||
lines.append(f"{i}\t\t\t<dcscor:parameter>{esc_xml(parsed['param'])}</dcscor:parameter>")
|
||||
lines.append(f'{i}\t\t\t<dcscor:value xsi:type="{val_type}">{esc_xml(val)}</dcscor:value>')
|
||||
|
||||
if re.match(r'^(web|style|win):', val):
|
||||
lines.append(f'{i}\t\t\t<dcscor:value xsi:type="v8ui:Color">{esc_xml(val)}</dcscor:value>')
|
||||
elif val in ("true", "false"):
|
||||
lines.append(f'{i}\t\t\t<dcscor:value xsi:type="xs:boolean">{esc_xml(val)}</dcscor:value>')
|
||||
elif parsed["param"] in ("Формат", "Текст", "Заголовок"):
|
||||
lines.append(f'{i}\t\t\t<dcscor:value xsi:type="v8:LocalStringType">')
|
||||
lines.append(f"{i}\t\t\t\t<v8:item>")
|
||||
lines.append(f"{i}\t\t\t\t\t<v8:lang>ru</v8:lang>")
|
||||
lines.append(f"{i}\t\t\t\t\t<v8:content>{esc_xml(val)}</v8:content>")
|
||||
lines.append(f"{i}\t\t\t\t</v8:item>")
|
||||
lines.append(f"{i}\t\t\t</dcscor:value>")
|
||||
else:
|
||||
lines.append(f'{i}\t\t\t<dcscor:value xsi:type="xs:string">{esc_xml(val)}</dcscor:value>')
|
||||
|
||||
lines.append(f"{i}\t\t</dcscor:item>")
|
||||
lines.append(f"{i}\t</dcsset:appearance>")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user