feat(form-decompile,form-compile): измерения планировщика (dimensions) — Planner Phase 1

Расширение Phase 1 кластера Chart-Settings: реквизит pl:Planner теперь несёт
измерения планировщика (<pl:dimension> — «Измерения» в конфигураторе) с элементами.

DSL planner.dimensions[]: объект разреза (value — ссылка xr:DesignTimeRef или nil,
text-заголовок, цвета, font) + elements[] (элементы измерения, РЕКУРСИВНЫ — могут
нести вложенные elements, как показывает UI колонкой «Элементы»; поле
showOnlySubordinatesAreas). Тип value авто-выводится: ссылочный вид →
xsi:type="xr:DesignTimeRef", иначе xs:string. Пустой текст → самозакрывающийся
<pl:text/> (как в выгрузке). Общие хелперы Emit/Get-PlannerValue/Text применены
и к элементам расписания (items).

Раундтрип бит-в-бит: синтетика upload/epf/Диаграммы (items + 2 dimensions +
вложенные elements + period). Зеркало py (ps1==py байт-в-байт). Кейс chart-fields
расширен измерением (nil-разрез + xs:string-элемент + showOnlySubordinatesAreas),
сертифицирован загрузкой в 1С. Регресс 41/41 (ps1+py).

Ограничение: item.dimensionValues (привязка элемента расписания к элементам
измерений) пока всегда пустой.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Nick Shirokov
2026-06-10 13:57:54 +03:00
co-authored by Claude Opus 4.8
parent f064d53eb2
commit f534add7b4
6 changed files with 192 additions and 21 deletions
@@ -1,4 +1,4 @@
# form-compile v1.104 — Compile 1C managed form from JSON or object metadata
# form-compile v1.105 — Compile 1C managed form from JSON or object metadata
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
param(
[string]$JsonPath,
@@ -3048,6 +3048,27 @@ function Emit-PlannerColor {
param([string]$tag, $o, [string]$key, [string]$ind)
X "$ind<pl:$tag>$(Esc-Xml "$(PL-Get $o $key 'auto')")</pl:$tag>"
}
# <pl:text>/<pl:tooltip>… — пустое → самозакрывающийся тег (как в выгрузке платформы).
function Emit-PlannerText {
param([string]$tag, $v, [string]$ind)
if ([string]::IsNullOrEmpty("$v")) { X "$ind<pl:$tag/>" }
else { X "$ind<pl:$tag>$(Esc-Xml "$v")</pl:$tag>" }
}
# Признак ссылочного значения (объект разреза/элемент-ссылка) → xsi:type="xr:DesignTimeRef";
# иначе xs:string. Покрывает англ. (Enum.X.EnumValue.Y) и рус. (Справочник.X) метатипы.
function Test-PlannerRef {
param([string]$v)
return ($v -match '^(Enum|Catalog|Document|ChartOfAccounts|ChartOfCalculationTypes|ChartOfCharacteristicTypes|ExchangePlan|BusinessProcess|Task)\.' -or `
$v -match '\.EnumValue\.' -or $v -match 'EmptyRef$' -or `
$v -match '^(Перечисление|Справочник|Документ|ПланСчетов|ПланВидовХарактеристик|ПланВидовРасчета|ПланОбмена|БизнесПроцесс|Задача)\.')
}
# <pl:value> — nil (нет значения) / xr:DesignTimeRef (ссылка) / xs:string (строка/прочее).
function Emit-PlannerValue {
param($v, [string]$ind)
if ($null -eq $v -or "$v" -eq '') { X "$ind<pl:value xsi:nil=`"true`"/>"; return }
$t = if (Test-PlannerRef "$v") { 'xr:DesignTimeRef' } else { 'xs:string' }
X "$ind<pl:value xsi:type=`"$t`">$(Esc-Xml "$v")</pl:value>"
}
function Emit-PlannerFont {
param($o, [string]$ind)
$f = PL-Get $o 'font' $null
@@ -3114,12 +3135,9 @@ function Emit-PlannerItem {
param($it, [string]$ind)
X "$ind<pl:item>"
$ii = "$ind`t"
$val = PL-Get $it 'value' $null
if ($null -eq $val) { X "$ii<pl:value xsi:nil=`"true`"/>" }
else { X "$ii<pl:value xsi:type=`"xs:string`">$(Esc-Xml "$val")</pl:value>" }
X "$ii<pl:text>$(Esc-Xml "$(PL-Get $it 'text' '')")</pl:text>"
$tt = PL-Get $it 'tooltip' ''
if ("$tt" -eq '') { X "$ii<pl:tooltip/>" } else { X "$ii<pl:tooltip>$(Esc-Xml "$tt")</pl:tooltip>" }
Emit-PlannerValue (PL-Get $it 'value' $null) $ii
Emit-PlannerText 'text' (PL-Get $it 'text' '') $ii
Emit-PlannerText 'tooltip' (PL-Get $it 'tooltip' '') $ii
X "$ii<pl:begin>$(PL-Get $it 'begin' '0001-01-01T00:00:00')</pl:begin>"
X "$ii<pl:end>$(PL-Get $it 'end' '0001-01-01T00:00:00')</pl:end>"
Emit-PlannerColor 'borderColor' $it 'borderColor' $ii
@@ -3137,11 +3155,45 @@ function Emit-PlannerItem {
X "$ii<pl:editMode>$(Esc-Xml "$(PL-Get $it 'editMode' 'EnableEdit')")</pl:editMode>"
X "$ind</pl:item>"
}
# Элемент измерения (<pl:item> внутри <pl:dimension>) — рекурсивен: может нести вложенные
# элементы (UI: колонка «Элементы» у элемента). Порядок: value, text, цвета, font,
# вложенные элементы, showOnlySubordinatesAreas, textFormatted.
function Emit-PlannerDimElement {
param($el, [string]$ind)
X "$ind<pl:item>"
$ii = "$ind`t"
Emit-PlannerValue (PL-Get $el 'value' $null) $ii
Emit-PlannerText 'text' (PL-Get $el 'text' '') $ii
Emit-PlannerColor 'borderColor' $el 'borderColor' $ii
Emit-PlannerColor 'backColor' $el 'backColor' $ii
Emit-PlannerColor 'textColor' $el 'textColor' $ii
Emit-PlannerFont $el $ii
foreach ($sub in @(PL-Get $el 'elements' @())) { Emit-PlannerDimElement $sub $ii }
X "$ii<pl:showOnlySubordinatesAreas>$(PL-Bool (PL-Get $el 'showOnlySubordinatesAreas' $true))</pl:showOnlySubordinatesAreas>"
X "$ii<pl:textFormatted>$(PL-Bool (PL-Get $el 'textFormatted' $false))</pl:textFormatted>"
X "$ind</pl:item>"
}
# Измерение планировщика (<pl:dimension>) — объект разреза + его элементы.
function Emit-PlannerDimension {
param($d, [string]$ind)
X "$ind<pl:dimension>"
$di = "$ind`t"
Emit-PlannerValue (PL-Get $d 'value' $null) $di
Emit-PlannerText 'text' (PL-Get $d 'text' '') $di
Emit-PlannerColor 'borderColor' $d 'borderColor' $di
Emit-PlannerColor 'backColor' $d 'backColor' $di
Emit-PlannerColor 'textColor' $d 'textColor' $di
Emit-PlannerFont $d $di
foreach ($el in @(PL-Get $d 'elements' @())) { Emit-PlannerDimElement $el $di }
X "$di<pl:textFormatted>$(PL-Bool (PL-Get $d 'textFormatted' $false))</pl:textFormatted>"
X "$ind</pl:dimension>"
}
function Emit-PlannerSettings {
param($pl, [string]$ind)
X "$ind<Settings xmlns:pl=`"$($script:PLANNER_NS)`" xsi:type=`"pl:Planner`">"
$si = "$ind`t"
foreach ($it in @(PL-Get $pl 'items' @())) { Emit-PlannerItem $it $si }
foreach ($d in @(PL-Get $pl 'dimensions' @())) { Emit-PlannerDimension $d $si }
Emit-PlannerColor 'borderColor' $pl 'borderColor' $si
Emit-PlannerColor 'backColor' $pl 'backColor' $si
Emit-PlannerColor 'textColor' $pl 'textColor' $si
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# form-compile v1.104 — Compile 1C managed form from JSON or object metadata
# form-compile v1.105 — Compile 1C managed form from JSON or object metadata
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
import argparse
import copy
@@ -2740,6 +2740,31 @@ def emit_planner_color(lines, tag, o, key, ind):
lines.append(f'{ind}<pl:{tag}>{esc_xml(str(_pl_get(o, key, "auto")))}</pl:{tag}>')
def emit_planner_text(lines, tag, v, ind):
if v is None or str(v) == '':
lines.append(f'{ind}<pl:{tag}/>')
else:
lines.append(f'{ind}<pl:{tag}>{esc_xml(str(v))}</pl:{tag}>')
_PLANNER_REF_RE = re.compile(
r'^(Enum|Catalog|Document|ChartOfAccounts|ChartOfCalculationTypes|ChartOfCharacteristicTypes|ExchangePlan|BusinessProcess|Task)\.'
r'|\.EnumValue\.|EmptyRef$'
r'|^(Перечисление|Справочник|Документ|ПланСчетов|ПланВидовХарактеристик|ПланВидовРасчета|ПланОбмена|БизнесПроцесс|Задача)\.')
def test_planner_ref(v):
return bool(_PLANNER_REF_RE.search(str(v)))
def emit_planner_value(lines, v, ind):
if v is None or str(v) == '':
lines.append(f'{ind}<pl:value xsi:nil="true"/>')
return
t = 'xr:DesignTimeRef' if test_planner_ref(v) else 'xs:string'
lines.append(f'{ind}<pl:value xsi:type="{t}">{esc_xml(str(v))}</pl:value>')
def emit_planner_font(lines, o, ind):
f = _pl_get(o, 'font')
if f is None:
@@ -2814,17 +2839,9 @@ def emit_planner_timescale(lines, ts, ind):
def emit_planner_item(lines, it, ind):
lines.append(f'{ind}<pl:item>')
ii = f'{ind}\t'
val = _pl_get(it, 'value')
if val is None:
lines.append(f'{ii}<pl:value xsi:nil="true"/>')
else:
lines.append(f'{ii}<pl:value xsi:type="xs:string">{esc_xml(str(val))}</pl:value>')
lines.append(f'{ii}<pl:text>{esc_xml(str(_pl_get(it, "text", "")))}</pl:text>')
tt = _pl_get(it, 'tooltip', '')
if str(tt) == '':
lines.append(f'{ii}<pl:tooltip/>')
else:
lines.append(f'{ii}<pl:tooltip>{esc_xml(str(tt))}</pl:tooltip>')
emit_planner_value(lines, _pl_get(it, 'value'), ii)
emit_planner_text(lines, 'text', _pl_get(it, 'text', ''), ii)
emit_planner_text(lines, 'tooltip', _pl_get(it, 'tooltip', ''), ii)
lines.append(f'{ii}<pl:begin>{_pl_get(it, "begin", "0001-01-01T00:00:00")}</pl:begin>')
lines.append(f'{ii}<pl:end>{_pl_get(it, "end", "0001-01-01T00:00:00")}</pl:end>')
emit_planner_color(lines, 'borderColor', it, 'borderColor', ii)
@@ -2845,11 +2862,44 @@ def emit_planner_item(lines, it, ind):
lines.append(f'{ind}</pl:item>')
def emit_planner_dim_element(lines, el, ind):
lines.append(f'{ind}<pl:item>')
ii = f'{ind}\t'
emit_planner_value(lines, _pl_get(el, 'value'), ii)
emit_planner_text(lines, 'text', _pl_get(el, 'text', ''), ii)
emit_planner_color(lines, 'borderColor', el, 'borderColor', ii)
emit_planner_color(lines, 'backColor', el, 'backColor', ii)
emit_planner_color(lines, 'textColor', el, 'textColor', ii)
emit_planner_font(lines, el, ii)
for sub in _pl_get(el, 'elements', []):
emit_planner_dim_element(lines, sub, ii)
lines.append(f'{ii}<pl:showOnlySubordinatesAreas>{_pl_bool(_pl_get(el, "showOnlySubordinatesAreas", True))}</pl:showOnlySubordinatesAreas>')
lines.append(f'{ii}<pl:textFormatted>{_pl_bool(_pl_get(el, "textFormatted", False))}</pl:textFormatted>')
lines.append(f'{ind}</pl:item>')
def emit_planner_dimension(lines, d, ind):
lines.append(f'{ind}<pl:dimension>')
di = f'{ind}\t'
emit_planner_value(lines, _pl_get(d, 'value'), di)
emit_planner_text(lines, 'text', _pl_get(d, 'text', ''), di)
emit_planner_color(lines, 'borderColor', d, 'borderColor', di)
emit_planner_color(lines, 'backColor', d, 'backColor', di)
emit_planner_color(lines, 'textColor', d, 'textColor', di)
emit_planner_font(lines, d, di)
for el in _pl_get(d, 'elements', []):
emit_planner_dim_element(lines, el, di)
lines.append(f'{di}<pl:textFormatted>{_pl_bool(_pl_get(d, "textFormatted", False))}</pl:textFormatted>')
lines.append(f'{ind}</pl:dimension>')
def emit_planner_settings(lines, pl, ind):
lines.append(f'{ind}<Settings xmlns:pl="{PLANNER_NS}" xsi:type="pl:Planner">')
si = f'{ind}\t'
for it in _pl_get(pl, 'items', []):
emit_planner_item(lines, it, si)
for d in _pl_get(pl, 'dimensions', []):
emit_planner_dimension(lines, d, si)
emit_planner_color(lines, 'borderColor', pl, 'borderColor', si)
emit_planner_color(lines, 'backColor', pl, 'backColor', si)
emit_planner_color(lines, 'textColor', pl, 'textColor', si)