mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-06-12 08:54:57 +03:00
feat(skd-compile): hidden, valueListAllowed, drilldown, groupHeaderTemplate, dataPath fix
- fix: calculatedField dataPath fallback from "field" key (#5) - fix: groupHeaderTemplate vs groupTemplate, groupName support (#7) - feat: @valueList / valueListAllowed for parameters (#4) - feat: @hidden / hidden params + "dataParameters": "auto" (#1) - feat: drilldown in template params — DetailsAreaTemplateParameter + appearance (#2+#3) - fix(template-add): improved error message with path hint (#6) - docs: SKILL.md updated with new keys and examples - version bump: skd-compile v1.4, template-add v1.2 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -97,7 +97,14 @@ powershell.exe -NoProfile -File .claude/skills/skd-compile/scripts/skd-compile.p
|
||||
]
|
||||
```
|
||||
|
||||
`@autoDates` — автоматически генерирует параметры `ДатаНачала` и `ДатаОкончания` с выражениями `&Период.ДатаНачала` / `&Период.ДатаОкончания` и `availableAsField=false`. Заменяет 5 строк на 1.
|
||||
Флаги shorthand:
|
||||
- `@autoDates` — автоматически генерирует параметры `ДатаНачала` и `ДатаОкончания` с выражениями `&Период.ДатаНачала` / `&Период.ДатаОкончания` и `availableAsField=false`
|
||||
- `@valueList` — `<valueListAllowed>true</valueListAllowed>` — разрешает передавать список значений
|
||||
- `@hidden` — скрытый параметр: `availableAsField=false` + исключается из `"dataParameters": "auto"`
|
||||
|
||||
Объектная форма: `hidden: true`, `valueListAllowed: true`, `availableAsField: false`.
|
||||
|
||||
В варианте настроек `"dataParameters": "auto"` автоматически генерирует записи для всех не-hidden параметров с `userSettingID`.
|
||||
|
||||
### Фильтры — shorthand
|
||||
|
||||
@@ -235,15 +242,32 @@ powershell.exe -NoProfile -File .claude/skills/skd-compile/scripts/skd-compile.p
|
||||
|
||||
Raw XML (`"template": "<...>"`) остаётся как fallback. Детект: если есть `rows` — DSL, иначе — raw.
|
||||
|
||||
### Расшифровка (drilldown) в параметрах шаблона
|
||||
|
||||
Ключ `drilldown` в параметре шаблона автоматически генерирует `DetailsAreaTemplateParameter` и привязку `Расшифровка` в appearance ячеек:
|
||||
|
||||
```json
|
||||
"parameters": [
|
||||
{ "name": "Сырье", "expression": "ПоступлениеСырья", "drilldown": "ПоступлениеСырья" }
|
||||
]
|
||||
```
|
||||
|
||||
Генерирует: `ExpressionAreaTemplateParameter` (обычный) + `DetailsAreaTemplateParameter` с именем `Расшифровка_ПоступлениеСырья`, `fieldExpression` по полю `ИмяРесурса`, `mainAction=DrillDown`. Ячейки `{Сырье}` автоматически получают appearance `Расшифровка = Расшифровка_ПоступлениеСырья`.
|
||||
|
||||
### Привязки макетов к группировкам
|
||||
|
||||
```json
|
||||
"groupTemplates": [
|
||||
{ "groupField": "Счет", "templateType": "GroupHeader", "template": "Макет1" },
|
||||
{ "groupField": "Счет", "templateType": "Header", "template": "Макет2" }
|
||||
{ "groupName": "ДанныеОтчета", "templateType": "GroupHeader", "template": "Макет1" },
|
||||
{ "groupField": "Счет", "templateType": "Header", "template": "Макет2" },
|
||||
{ "groupField": "Счет", "templateType": "OverallHeader", "template": "Макет3" }
|
||||
]
|
||||
```
|
||||
|
||||
`groupField` — привязка к полю группировки, `groupName` — к именованной группировке в структуре варианта.
|
||||
|
||||
`templateType`: `Header` (строки данных) → `<groupTemplate>`, `OverallHeader` (итоги) → `<groupTemplate>`, `GroupHeader` (шапка) → `<groupHeaderTemplate>`.
|
||||
|
||||
## Примеры
|
||||
|
||||
### Минимальный
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# skd-compile v1.3 — Compile 1C DCS from JSON
|
||||
# skd-compile v1.4 — Compile 1C DCS from JSON
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[string]$DefinitionFile,
|
||||
@@ -322,6 +322,18 @@ function Parse-ParamShorthand {
|
||||
$s = $s -replace '\s*@autoDates', ''
|
||||
}
|
||||
|
||||
# Extract @valueList flag
|
||||
if ($s -match '@valueList') {
|
||||
$result.valueListAllowed = $true
|
||||
$s = $s -replace '\s*@valueList', ''
|
||||
}
|
||||
|
||||
# Extract @hidden flag
|
||||
if ($s -match '@hidden') {
|
||||
$result.hidden = $true
|
||||
$s = $s -replace '\s*@hidden', ''
|
||||
}
|
||||
|
||||
# Split "Name: Type = Value"
|
||||
if ($s -match '^([^:]+):\s*(\S+)(\s*=\s*(.+))?$') {
|
||||
$result.name = $Matches[1].Trim()
|
||||
@@ -746,8 +758,9 @@ function Emit-CalcFields {
|
||||
if ($cf -is [string]) {
|
||||
$parsed = Parse-CalcShorthand $cf
|
||||
} else {
|
||||
$dp = if ($cf.dataPath) { "$($cf.dataPath)" } else { "$($cf.field)" }
|
||||
$parsed = @{
|
||||
dataPath = "$($cf.dataPath)"
|
||||
dataPath = $dp
|
||||
expression = "$($cf.expression)"
|
||||
}
|
||||
}
|
||||
@@ -854,11 +867,19 @@ function Emit-SingleParam {
|
||||
X "`t`t<expression>$(Esc-Xml $parsed.expression)</expression>"
|
||||
}
|
||||
|
||||
# Hidden implies availableAsField=false
|
||||
if ($parsed.hidden -eq $true) { $parsed.availableAsField = $false }
|
||||
|
||||
# AvailableAsField
|
||||
if ($parsed.availableAsField -eq $false) {
|
||||
X "`t`t<availableAsField>false</availableAsField>"
|
||||
}
|
||||
|
||||
# ValueListAllowed
|
||||
if ($parsed.valueListAllowed -eq $true) {
|
||||
X "`t`t<valueListAllowed>true</valueListAllowed>"
|
||||
}
|
||||
|
||||
# Use
|
||||
if ($p -isnot [string] -and $p.use) {
|
||||
X "`t`t<use>$(Esc-Xml "$($p.use)")</use>"
|
||||
@@ -867,6 +888,8 @@ function Emit-SingleParam {
|
||||
X "`t</parameter>"
|
||||
}
|
||||
|
||||
$script:allParams = @()
|
||||
|
||||
function Emit-Parameters {
|
||||
if (-not $def.parameters) { return }
|
||||
foreach ($p in $def.parameters) {
|
||||
@@ -881,11 +904,16 @@ function Emit-Parameters {
|
||||
}
|
||||
if ($p.expression) { $parsed.expression = "$($p.expression)" }
|
||||
if ($p.availableAsField -eq $false) { $parsed.availableAsField = $false }
|
||||
if ($p.valueListAllowed -eq $true) { $parsed.valueListAllowed = $true }
|
||||
if ($p.hidden -eq $true) { $parsed.hidden = $true }
|
||||
if ($p.autoDates -eq $true) { $parsed.autoDates = $true }
|
||||
}
|
||||
|
||||
Emit-SingleParam -p $p -parsed $parsed
|
||||
|
||||
# Track parameter for auto dataParameters
|
||||
$script:allParams += @{ name = $parsed.name; hidden = [bool]$parsed.hidden; type = "$($parsed.type)"; value = $parsed.value }
|
||||
|
||||
# @autoDates: auto-generate ДатаНачала and ДатаОкончания
|
||||
if ($parsed.autoDates) {
|
||||
$paramName = $parsed.name
|
||||
@@ -1005,7 +1033,7 @@ function Emit-ColorValue {
|
||||
}
|
||||
|
||||
function Emit-CellAppearance {
|
||||
param($style, [double]$width = 0, [bool]$vMerge = $false, [double]$minHeight = 0)
|
||||
param($style, [double]$width = 0, [bool]$vMerge = $false, [double]$minHeight = 0, $extraItems = @())
|
||||
$ind = "`t`t`t`t`t"
|
||||
X "`t`t`t`t<dcsat:appearance>"
|
||||
# Background color
|
||||
@@ -1098,6 +1126,8 @@ function Emit-CellAppearance {
|
||||
X "$ind`t<dcscor:value xsi:type=`"xs:boolean`">true</dcscor:value>"
|
||||
X "$ind</dcscor:item>"
|
||||
}
|
||||
# Extra appearance items (e.g. drilldown Расшифровка)
|
||||
foreach ($ei in $extraItems) { X $ei }
|
||||
X "`t`t`t`t</dcsat:appearance>"
|
||||
}
|
||||
|
||||
@@ -1128,6 +1158,14 @@ function Emit-AreaTemplateDSL {
|
||||
}
|
||||
if (-not $vMerge.ContainsKey(0)) { $vMerge[0] = @{} }
|
||||
|
||||
# Build drilldown map: param_name -> drilldown_value
|
||||
$drilldownMap = @{}
|
||||
if ($t.parameters) {
|
||||
foreach ($tp in $t.parameters) {
|
||||
if ($tp.drilldown) { $drilldownMap["$($tp.name)"] = "$($tp.drilldown)" }
|
||||
}
|
||||
}
|
||||
|
||||
X "`t<template>"
|
||||
X "`t`t<name>$(Esc-Xml "$($t.name)")</name>"
|
||||
X "`t`t<template xmlns:dcsat=`"http://v8.1c.ru/8.1/data-composition-system/area-template`" xsi:type=`"dcsat:AreaTemplate`">"
|
||||
@@ -1154,9 +1192,19 @@ function Emit-AreaTemplateDSL {
|
||||
$cellStr = "$cellVal"
|
||||
if ($cellStr -match '^\{(.+)\}$') {
|
||||
# Parameter reference
|
||||
$paramName = $Matches[1]
|
||||
X "`t`t`t`t`t<dcsat:item xsi:type=`"dcsat:Field`">"
|
||||
X "`t`t`t`t`t`t<dcsat:value xsi:type=`"dcscor:Parameter`">$(Esc-Xml $Matches[1])</dcsat:value>"
|
||||
X "`t`t`t`t`t`t<dcsat:value xsi:type=`"dcscor:Parameter`">$(Esc-Xml $paramName)</dcsat:value>"
|
||||
X "`t`t`t`t`t</dcsat:item>"
|
||||
# Build drilldown appearance extra items
|
||||
$cellExtraItems = @()
|
||||
if ($drilldownMap.ContainsKey($paramName)) {
|
||||
$ddVal = $drilldownMap[$paramName]
|
||||
$cellExtraItems += "`t`t`t`t`t<dcscor:item>"
|
||||
$cellExtraItems += "`t`t`t`t`t`t<dcscor:parameter>Расшифровка</dcscor:parameter>"
|
||||
$cellExtraItems += "`t`t`t`t`t`t<dcscor:value xsi:type=`"dcscor:Parameter`">Расшифровка_$ddVal</dcscor:value>"
|
||||
$cellExtraItems += "`t`t`t`t`t</dcscor:item>"
|
||||
}
|
||||
} else {
|
||||
# Static text
|
||||
X "`t`t`t`t`t<dcsat:item xsi:type=`"dcsat:Field`">"
|
||||
@@ -1171,7 +1219,9 @@ function Emit-AreaTemplateDSL {
|
||||
}
|
||||
# Appearance
|
||||
$h = if ($r -eq 0) { $minHeight } else { 0 }
|
||||
Emit-CellAppearance $style $w $startsVMerge $h
|
||||
if (-not $cellExtraItems) { $cellExtraItems = @() }
|
||||
Emit-CellAppearance $style $w $startsVMerge $h $cellExtraItems
|
||||
$cellExtraItems = @()
|
||||
}
|
||||
X "`t`t`t`t</dcsat:tableCell>"
|
||||
}
|
||||
@@ -1186,6 +1236,18 @@ function Emit-AreaTemplateDSL {
|
||||
X "`t`t`t<dcsat:name>$(Esc-Xml "$($tp.name)")</dcsat:name>"
|
||||
X "`t`t`t<dcsat:expression>$(Esc-Xml "$($tp.expression)")</dcsat:expression>"
|
||||
X "`t`t</parameter>"
|
||||
# Drilldown parameter
|
||||
if ($tp.drilldown) {
|
||||
$ddVal = "$($tp.drilldown)"
|
||||
X "`t`t<parameter xmlns:dcsat=`"http://v8.1c.ru/8.1/data-composition-system/area-template`" xsi:type=`"dcsat:DetailsAreaTemplateParameter`">"
|
||||
X "`t`t`t<dcsat:name>Расшифровка_$(Esc-Xml $ddVal)</dcsat:name>"
|
||||
X "`t`t`t<dcsat:fieldExpression>"
|
||||
X "`t`t`t`t<dcsat:field>ИмяРесурса</dcsat:field>"
|
||||
X "`t`t`t`t<dcsat:expression>`"$(Esc-Xml $ddVal)`"</dcsat:expression>"
|
||||
X "`t`t`t</dcsat:fieldExpression>"
|
||||
X "`t`t`t<dcsat:mainAction>DrillDown</dcsat:mainAction>"
|
||||
X "`t`t</parameter>"
|
||||
}
|
||||
}
|
||||
}
|
||||
X "`t</template>"
|
||||
@@ -1211,6 +1273,18 @@ function Emit-Templates {
|
||||
X "`t`t`t<dcsat:name>$(Esc-Xml "$($tp.name)")</dcsat:name>"
|
||||
X "`t`t`t<dcsat:expression>$(Esc-Xml "$($tp.expression)")</dcsat:expression>"
|
||||
X "`t`t</parameter>"
|
||||
# Drilldown parameter
|
||||
if ($tp.drilldown) {
|
||||
$ddVal = "$($tp.drilldown)"
|
||||
X "`t`t<parameter xmlns:dcsat=`"http://v8.1c.ru/8.1/data-composition-system/area-template`" xsi:type=`"dcsat:DetailsAreaTemplateParameter`">"
|
||||
X "`t`t`t<dcsat:name>Расшифровка_$(Esc-Xml $ddVal)</dcsat:name>"
|
||||
X "`t`t`t<dcsat:fieldExpression>"
|
||||
X "`t`t`t`t<dcsat:field>ИмяРесурса</dcsat:field>"
|
||||
X "`t`t`t`t<dcsat:expression>`"$(Esc-Xml $ddVal)`"</dcsat:expression>"
|
||||
X "`t`t`t</dcsat:fieldExpression>"
|
||||
X "`t`t`t<dcsat:mainAction>DrillDown</dcsat:mainAction>"
|
||||
X "`t`t</parameter>"
|
||||
}
|
||||
}
|
||||
}
|
||||
X "`t</template>"
|
||||
@@ -1222,11 +1296,20 @@ function Emit-Templates {
|
||||
function Emit-GroupTemplates {
|
||||
if (-not $def.groupTemplates) { return }
|
||||
foreach ($gt in $def.groupTemplates) {
|
||||
X "`t<groupTemplate>"
|
||||
X "`t`t<groupField>$(Esc-Xml "$($gt.groupField)")</groupField>"
|
||||
X "`t`t<templateType>$(Esc-Xml "$($gt.templateType)")</templateType>"
|
||||
$ttype = if ($gt.templateType) { "$($gt.templateType)" } else { "Header" }
|
||||
$isHeader = ($ttype -eq 'GroupHeader')
|
||||
$tag = if ($isHeader) { 'groupHeaderTemplate' } else { 'groupTemplate' }
|
||||
$xmlTType = if ($isHeader) { 'Header' } else { $ttype }
|
||||
|
||||
X "`t<$tag>"
|
||||
if ($gt.groupName) {
|
||||
X "`t`t<groupName>$(Esc-Xml "$($gt.groupName)")</groupName>"
|
||||
} elseif ($gt.groupField) {
|
||||
X "`t`t<groupField>$(Esc-Xml "$($gt.groupField)")</groupField>"
|
||||
}
|
||||
X "`t`t<templateType>$(Esc-Xml $xmlTType)</templateType>"
|
||||
X "`t`t<template>$(Esc-Xml "$($gt.template)")</template>"
|
||||
X "`t</groupTemplate>"
|
||||
X "`t</$tag>"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1868,7 +1951,22 @@ function Emit-SettingsVariants {
|
||||
}
|
||||
|
||||
# DataParameters
|
||||
if ($s.dataParameters) {
|
||||
if ($s.dataParameters -eq 'auto') {
|
||||
# Auto-generate dataParameters for all non-hidden params
|
||||
$autoDP = @()
|
||||
foreach ($ap in $script:allParams) {
|
||||
if (-not $ap.hidden) {
|
||||
$dpItem = New-Object PSObject
|
||||
$dpItem | Add-Member -NotePropertyName "parameter" -NotePropertyValue $ap.name
|
||||
$dpItem | Add-Member -NotePropertyName "use" -NotePropertyValue $false
|
||||
$dpItem | Add-Member -NotePropertyName "userSettingID" -NotePropertyValue "auto"
|
||||
$autoDP += $dpItem
|
||||
}
|
||||
}
|
||||
if ($autoDP.Count -gt 0) {
|
||||
Emit-DataParameters -items $autoDP -indent "`t`t`t"
|
||||
}
|
||||
} elseif ($s.dataParameters) {
|
||||
Emit-DataParameters -items $s.dataParameters -indent "`t`t`t"
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# skd-compile v1.3 — Compile 1C DCS from JSON
|
||||
# skd-compile v1.4 — Compile 1C DCS from JSON
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
import argparse
|
||||
import json
|
||||
@@ -233,6 +233,16 @@ def parse_param_shorthand(s):
|
||||
result['autoDates'] = True
|
||||
s = re.sub(r'\s*@autoDates', '', s)
|
||||
|
||||
# Extract @valueList flag
|
||||
if '@valueList' in s:
|
||||
result['valueListAllowed'] = True
|
||||
s = re.sub(r'\s*@valueList', '', s)
|
||||
|
||||
# Extract @hidden flag
|
||||
if '@hidden' in s:
|
||||
result['hidden'] = True
|
||||
s = re.sub(r'\s*@hidden', '', s)
|
||||
|
||||
# Split "Name: Type = Value"
|
||||
m = re.match(r'^([^:]+):\s*(\S+)(\s*=\s*(.+))?$', s)
|
||||
if m:
|
||||
@@ -598,7 +608,7 @@ def emit_calc_fields(lines, defn):
|
||||
is_obj = False
|
||||
else:
|
||||
parsed = {
|
||||
'dataPath': str(cf.get('dataPath', '')),
|
||||
'dataPath': str(cf.get('dataPath') or cf.get('field', '')),
|
||||
'expression': str(cf.get('expression', '')),
|
||||
}
|
||||
is_obj = True
|
||||
@@ -724,10 +734,18 @@ def emit_single_param(lines, p, parsed):
|
||||
if parsed.get('expression'):
|
||||
lines.append(f'\t\t<expression>{esc_xml(parsed["expression"])}</expression>')
|
||||
|
||||
# Hidden implies availableAsField=false
|
||||
if parsed.get('hidden'):
|
||||
parsed['availableAsField'] = False
|
||||
|
||||
# AvailableAsField
|
||||
if parsed.get('availableAsField') is False:
|
||||
lines.append('\t\t<availableAsField>false</availableAsField>')
|
||||
|
||||
# ValueListAllowed
|
||||
if parsed.get('valueListAllowed'):
|
||||
lines.append('\t\t<valueListAllowed>true</valueListAllowed>')
|
||||
|
||||
# Use
|
||||
if p is not None and not isinstance(p, str) and p.get('use'):
|
||||
lines.append(f'\t\t<use>{esc_xml(str(p["use"]))}</use>')
|
||||
@@ -735,7 +753,12 @@ def emit_single_param(lines, p, parsed):
|
||||
lines.append('\t</parameter>')
|
||||
|
||||
|
||||
_all_params = []
|
||||
|
||||
|
||||
def emit_parameters(lines, defn):
|
||||
global _all_params
|
||||
_all_params = []
|
||||
if not defn.get('parameters'):
|
||||
return
|
||||
for p in defn['parameters']:
|
||||
@@ -752,11 +775,23 @@ def emit_parameters(lines, defn):
|
||||
parsed['expression'] = str(p['expression'])
|
||||
if p.get('availableAsField') is False:
|
||||
parsed['availableAsField'] = False
|
||||
if p.get('valueListAllowed') is True:
|
||||
parsed['valueListAllowed'] = True
|
||||
if p.get('hidden') is True:
|
||||
parsed['hidden'] = True
|
||||
if p.get('autoDates') is True:
|
||||
parsed['autoDates'] = True
|
||||
|
||||
emit_single_param(lines, p, parsed)
|
||||
|
||||
# Track parameter for auto dataParameters
|
||||
_all_params.append({
|
||||
'name': parsed['name'],
|
||||
'hidden': bool(parsed.get('hidden')),
|
||||
'type': parsed.get('type', ''),
|
||||
'value': parsed.get('value'),
|
||||
})
|
||||
|
||||
# @autoDates: auto-generate ДатаНачала and ДатаОкончания
|
||||
if parsed.get('autoDates'):
|
||||
param_name = parsed['name']
|
||||
@@ -827,7 +862,7 @@ def _emit_color_value(lines, color, indent):
|
||||
lines.append(f'{indent}<dcscor:value xsi:type="v8ui:Color">{esc_xml(color)}</dcscor:value>')
|
||||
|
||||
|
||||
def _emit_cell_appearance(lines, style, width=0, v_merge=False, min_height=0):
|
||||
def _emit_cell_appearance(lines, style, width=0, v_merge=False, min_height=0, extra_items=None):
|
||||
ind = '\t\t\t\t\t'
|
||||
lines.append('\t\t\t\t<dcsat:appearance>')
|
||||
# Background color
|
||||
@@ -909,6 +944,10 @@ def _emit_cell_appearance(lines, style, width=0, v_merge=False, min_height=0):
|
||||
lines.append(f'{ind}\t<dcscor:parameter>\u041e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0442\u044c\u041f\u043e\u0412\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u0438</dcscor:parameter>')
|
||||
lines.append(f'{ind}\t<dcscor:value xsi:type="xs:boolean">true</dcscor:value>')
|
||||
lines.append(f'{ind}</dcscor:item>')
|
||||
# Extra appearance items (e.g. drilldown)
|
||||
if extra_items:
|
||||
for ei in extra_items:
|
||||
lines.append(ei)
|
||||
lines.append('\t\t\t\t</dcsat:appearance>')
|
||||
|
||||
|
||||
@@ -935,6 +974,13 @@ def _emit_area_template_dsl(lines, t):
|
||||
if 0 not in v_merge:
|
||||
v_merge[0] = {}
|
||||
|
||||
# Build drilldown map: param_name -> drilldown_value
|
||||
drilldown_map = {}
|
||||
if t.get('parameters'):
|
||||
for tp in t['parameters']:
|
||||
if tp.get('drilldown'):
|
||||
drilldown_map[str(tp['name'])] = str(tp['drilldown'])
|
||||
|
||||
lines.append('\t<template>')
|
||||
lines.append(f'\t\t<name>{esc_xml(str(t["name"]))}</name>')
|
||||
lines.append('\t\t<template xmlns:dcsat="http://v8.1c.ru/8.1/data-composition-system/area-template" xsi:type="dcsat:AreaTemplate">')
|
||||
@@ -957,13 +1003,22 @@ def _emit_area_template_dsl(lines, t):
|
||||
if is_merged:
|
||||
_emit_cell_appearance(lines, style, w, True)
|
||||
else:
|
||||
cell_extra_items = []
|
||||
if cell_val is not None and str(cell_val) != '':
|
||||
cell_str = str(cell_val)
|
||||
m = re.match(r'^\{(.+)\}$', cell_str)
|
||||
if m:
|
||||
param_name = m.group(1)
|
||||
lines.append('\t\t\t\t\t<dcsat:item xsi:type="dcsat:Field">')
|
||||
lines.append(f'\t\t\t\t\t\t<dcsat:value xsi:type="dcscor:Parameter">{esc_xml(m.group(1))}</dcsat:value>')
|
||||
lines.append(f'\t\t\t\t\t\t<dcsat:value xsi:type="dcscor:Parameter">{esc_xml(param_name)}</dcsat:value>')
|
||||
lines.append('\t\t\t\t\t</dcsat:item>')
|
||||
# Build drilldown appearance extra items
|
||||
if param_name in drilldown_map:
|
||||
dd_val = drilldown_map[param_name]
|
||||
cell_extra_items.append('\t\t\t\t\t<dcscor:item>')
|
||||
cell_extra_items.append(f'\t\t\t\t\t\t<dcscor:parameter>\u0420\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0430</dcscor:parameter>')
|
||||
cell_extra_items.append(f'\t\t\t\t\t\t<dcscor:value xsi:type="dcscor:Parameter">\u0420\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0430_{dd_val}</dcscor:value>')
|
||||
cell_extra_items.append('\t\t\t\t\t</dcscor:item>')
|
||||
else:
|
||||
lines.append('\t\t\t\t\t<dcsat:item xsi:type="dcsat:Field">')
|
||||
lines.append('\t\t\t\t\t\t<dcsat:value xsi:type="v8:LocalStringType">')
|
||||
@@ -974,7 +1029,7 @@ def _emit_area_template_dsl(lines, t):
|
||||
lines.append('\t\t\t\t\t\t</dcsat:value>')
|
||||
lines.append('\t\t\t\t\t</dcsat:item>')
|
||||
h = min_height if r == 0 else 0
|
||||
_emit_cell_appearance(lines, style, w, starts_v_merge, h)
|
||||
_emit_cell_appearance(lines, style, w, starts_v_merge, h, cell_extra_items or None)
|
||||
lines.append('\t\t\t\t</dcsat:tableCell>')
|
||||
lines.append('\t\t\t</dcsat:item>')
|
||||
|
||||
@@ -985,6 +1040,17 @@ def _emit_area_template_dsl(lines, t):
|
||||
lines.append(f'\t\t\t<dcsat:name>{esc_xml(str(tp["name"]))}</dcsat:name>')
|
||||
lines.append(f'\t\t\t<dcsat:expression>{esc_xml(str(tp["expression"]))}</dcsat:expression>')
|
||||
lines.append('\t\t</parameter>')
|
||||
# Drilldown parameter
|
||||
if tp.get('drilldown'):
|
||||
dd_val = str(tp['drilldown'])
|
||||
lines.append('\t\t<parameter xmlns:dcsat="http://v8.1c.ru/8.1/data-composition-system/area-template" xsi:type="dcsat:DetailsAreaTemplateParameter">')
|
||||
lines.append(f'\t\t\t<dcsat:name>\u0420\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0430_{esc_xml(dd_val)}</dcsat:name>')
|
||||
lines.append('\t\t\t<dcsat:fieldExpression>')
|
||||
lines.append('\t\t\t\t<dcsat:field>\u0418\u043c\u044f\u0420\u0435\u0441\u0443\u0440\u0441\u0430</dcsat:field>')
|
||||
lines.append(f'\t\t\t\t<dcsat:expression>"{esc_xml(dd_val)}"</dcsat:expression>')
|
||||
lines.append('\t\t\t</dcsat:fieldExpression>')
|
||||
lines.append('\t\t\t<dcsat:mainAction>DrillDown</dcsat:mainAction>')
|
||||
lines.append('\t\t</parameter>')
|
||||
lines.append('\t</template>')
|
||||
|
||||
|
||||
@@ -1007,6 +1073,17 @@ def emit_templates(lines, defn):
|
||||
lines.append(f'\t\t\t<dcsat:name>{esc_xml(str(tp["name"]))}</dcsat:name>')
|
||||
lines.append(f'\t\t\t<dcsat:expression>{esc_xml(str(tp["expression"]))}</dcsat:expression>')
|
||||
lines.append('\t\t</parameter>')
|
||||
# Drilldown parameter
|
||||
if tp.get('drilldown'):
|
||||
dd_val = str(tp['drilldown'])
|
||||
lines.append('\t\t<parameter xmlns:dcsat="http://v8.1c.ru/8.1/data-composition-system/area-template" xsi:type="dcsat:DetailsAreaTemplateParameter">')
|
||||
lines.append(f'\t\t\t<dcsat:name>\u0420\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0430_{esc_xml(dd_val)}</dcsat:name>')
|
||||
lines.append('\t\t\t<dcsat:fieldExpression>')
|
||||
lines.append('\t\t\t\t<dcsat:field>\u0418\u043c\u044f\u0420\u0435\u0441\u0443\u0440\u0441\u0430</dcsat:field>')
|
||||
lines.append(f'\t\t\t\t<dcsat:expression>"{esc_xml(dd_val)}"</dcsat:expression>')
|
||||
lines.append('\t\t\t</dcsat:fieldExpression>')
|
||||
lines.append('\t\t\t<dcsat:mainAction>DrillDown</dcsat:mainAction>')
|
||||
lines.append('\t\t</parameter>')
|
||||
lines.append('\t</template>')
|
||||
|
||||
|
||||
@@ -1016,11 +1093,19 @@ def emit_group_templates(lines, defn):
|
||||
if not defn.get('groupTemplates'):
|
||||
return
|
||||
for gt in defn['groupTemplates']:
|
||||
lines.append('\t<groupTemplate>')
|
||||
lines.append(f'\t\t<groupField>{esc_xml(str(gt["groupField"]))}</groupField>')
|
||||
lines.append(f'\t\t<templateType>{esc_xml(str(gt["templateType"]))}</templateType>')
|
||||
ttype = str(gt.get('templateType', '')) or 'Header'
|
||||
is_header = (ttype == 'GroupHeader')
|
||||
tag = 'groupHeaderTemplate' if is_header else 'groupTemplate'
|
||||
xml_ttype = 'Header' if is_header else ttype
|
||||
|
||||
lines.append(f'\t<{tag}>')
|
||||
if gt.get('groupName'):
|
||||
lines.append(f'\t\t<groupName>{esc_xml(str(gt["groupName"]))}</groupName>')
|
||||
elif gt.get('groupField'):
|
||||
lines.append(f'\t\t<groupField>{esc_xml(str(gt["groupField"]))}</groupField>')
|
||||
lines.append(f'\t\t<templateType>{esc_xml(xml_ttype)}</templateType>')
|
||||
lines.append(f'\t\t<template>{esc_xml(str(gt["template"]))}</template>')
|
||||
lines.append('\t</groupTemplate>')
|
||||
lines.append(f'\t</{tag}>')
|
||||
|
||||
|
||||
# === Settings Variants ===
|
||||
@@ -1540,7 +1625,19 @@ def emit_settings_variants(lines, defn):
|
||||
emit_output_parameters(lines, s['outputParameters'], '\t\t\t')
|
||||
|
||||
# DataParameters
|
||||
if s.get('dataParameters'):
|
||||
if s.get('dataParameters') == 'auto':
|
||||
# Auto-generate dataParameters for all non-hidden params
|
||||
auto_dp = []
|
||||
for ap in _all_params:
|
||||
if not ap['hidden']:
|
||||
auto_dp.append({
|
||||
'parameter': ap['name'],
|
||||
'use': False,
|
||||
'userSettingID': 'auto',
|
||||
})
|
||||
if auto_dp:
|
||||
emit_data_parameters(lines, auto_dp, '\t\t\t')
|
||||
elif s.get('dataParameters'):
|
||||
emit_data_parameters(lines, s['dataParameters'], '\t\t\t')
|
||||
|
||||
# Structure (supports string shorthand)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# template-add v1.1 — Add template to 1C object
|
||||
# template-add v1.2 — Add template to 1C object
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
@@ -37,7 +37,7 @@ $tmpl = $typeMap[$TemplateType]
|
||||
|
||||
$rootXmlPath = Join-Path $SrcDir "$ObjectName.xml"
|
||||
if (-not (Test-Path $rootXmlPath)) {
|
||||
Write-Error "Корневой файл обработки не найден: $rootXmlPath"
|
||||
Write-Error "Корневой файл объекта не найден: $rootXmlPath`nОжидается: <SrcDir>/<ObjectName>/<ObjectName>.xml`nПодсказка: SrcDir должен указывать на папку типа объектов (например Reports), а не на корень конфигурации"
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# add-template v1.0 — Add template to 1C object
|
||||
# add-template v1.2 — Add template to 1C object
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
|
||||
import argparse
|
||||
@@ -63,7 +63,9 @@ def main():
|
||||
|
||||
root_xml_path = os.path.join(src_dir, f"{object_name}.xml")
|
||||
if not os.path.exists(root_xml_path):
|
||||
print(f"Корневой файл обработки не найден: {root_xml_path}", file=sys.stderr)
|
||||
print(f"Корневой файл объекта не найден: {root_xml_path}", file=sys.stderr)
|
||||
print(f"Ожидается: <SrcDir>/<ObjectName>/<ObjectName>.xml", file=sys.stderr)
|
||||
print(f"Подсказка: SrcDir должен указывать на папку типа объектов (например Reports), а не на корень конфигурации", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
processor_dir = os.path.join(src_dir, object_name)
|
||||
|
||||
Reference in New Issue
Block a user