mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-06-15 10:24:57 +03:00
feat(form-decompile,form-compile): поле DataSet динсписка — useRestriction/attributeUseRestriction/inputParameters (остаток кластера C)
Обычное поле набора <Field DataSetFieldField> может нести ограничения использования и
связь по параметрам выбора:
- <dcssch:useRestriction> {field?,condition?,group?,order?} (54 формы) — где поле НЕ
использовать (отбор/группировка/порядок/как поле);
- <dcssch:attributeUseRestriction> та же структура (18) — ограничения для реквизитов поля;
- <dcssch:inputParameters> (6) — связь по параметрам выбора (как у параметра дин-списка).
DSL: settings.fields[].useRestriction / attributeUseRestriction (объект {field,condition,
group,order} bool | флаг-строка "#noField #noFilter #noGroup #noOrder" | массив) +
inputParameters. Общие хелперы Get-RestrictList/Emit-RestrictBlock (ps1) и parse_restrict/
emit_restrict_block (py); inputParameters переиспользует Emit-DLInputParameters. Декомпилятор
Build-RestrictObj + Build-DLInputParameters.
Порядок детей поля (из корпус-сигнатур, подтверждён загрузкой в 1С): dataPath, field,
title, useRestriction, attributeUseRestriction, presentationExpression, valueType,
appearance, inputParameters.
Выборка 69 форм с field-props: field-property потерь 0 (match 36→39, TOTAL 396→150,
cascade LOST 111→12). Кейс dynamic-list-form (+useRestriction/attributeUseRestriction
на поле Code) сертифицирован загрузкой в 1С. Регресс 43/43, ps1==py байт-в-байт.
Кластер C (DataSet динсписка) закрыт: Field valueType + CalculatedField + field
presentationExpression/appearance + field useRestriction/attributeUseRestriction/
inputParameters. Остаток (BACKLOG): нюансы пустого value (xs:string vs nil;
LocalStringType self-closing) + отдельный InputField multiple-value кластер.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# form-compile v1.141 — Compile 1C managed form from JSON or object metadata
|
||||
# form-compile v1.142 — Compile 1C managed form from JSON or object metadata
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[string]$JsonPath,
|
||||
@@ -2141,6 +2141,31 @@ function Emit-CalcFields {
|
||||
}
|
||||
}
|
||||
|
||||
# Ограничения использования поля/вычисляемого поля (useRestriction / attributeUseRestriction).
|
||||
# Значение: объект {field?,condition?,group?,order?} | флаг-строка "#noField #noFilter #noGroup #noOrder" | массив.
|
||||
function Get-RestrictList {
|
||||
param($ur)
|
||||
$out = @()
|
||||
if (-not $ur) { return ,$out }
|
||||
if ($ur -is [System.Management.Automation.PSCustomObject] -or $ur -is [hashtable]) {
|
||||
foreach ($k in 'field','condition','group','order') { if ($ur.$k -eq $true) { $out += $k } }
|
||||
} elseif ($ur -is [string]) {
|
||||
foreach ($tok in ($ur -split '\s+')) { $t = $tok.Trim().TrimStart('#'); if ($t) { $out += $(if ($script:calcRestrictMap[$t]) { $script:calcRestrictMap[$t] } else { $t }) } }
|
||||
} else {
|
||||
foreach ($r in $ur) { $rr = "$r"; $out += $(if ($script:calcRestrictMap[$rr]) { $script:calcRestrictMap[$rr] } else { $rr }) }
|
||||
}
|
||||
return ,$out
|
||||
}
|
||||
|
||||
function Emit-RestrictBlock {
|
||||
param([string]$tag, $ur, [string]$indent)
|
||||
$r = Get-RestrictList $ur
|
||||
if ($r.Count -eq 0) { return }
|
||||
X "$indent<dcssch:$tag>"
|
||||
foreach ($k in @('field','condition','group','order')) { if ($r -contains $k) { X "$indent`t<dcssch:$k>true</dcssch:$k>" } }
|
||||
X "$indent</dcssch:$tag>"
|
||||
}
|
||||
|
||||
# --- 5. Type emitter ---
|
||||
|
||||
$script:formTypeSynonyms = New-Object System.Collections.Hashtable
|
||||
@@ -5626,6 +5651,9 @@ function Emit-Attributes {
|
||||
Emit-MLItems -val $fld.title -indent "$si`t`t"
|
||||
X "$si`t</dcssch:title>"
|
||||
}
|
||||
# Ограничения использования поля — после title, перед presentationExpression (порядок исходника)
|
||||
Emit-RestrictBlock 'useRestriction' $fld.useRestriction "$si`t"
|
||||
Emit-RestrictBlock 'attributeUseRestriction' $fld.attributeUseRestriction "$si`t"
|
||||
# presentationExpression поля — перед valueType (порядок исходника)
|
||||
if ($fld.presentationExpression) { X "$si`t<dcssch:presentationExpression>$(Esc-Xml "$($fld.presentationExpression)")</dcssch:presentationExpression>" }
|
||||
# valueType поля набора (тип значения; вычисляемые/кастомные поля)
|
||||
@@ -5636,6 +5664,8 @@ function Emit-Attributes {
|
||||
foreach ($prop in $fld.appearance.PSObject.Properties) { Emit-AppearanceValue -key $prop.Name -val $prop.Value -indent "$si`t`t" }
|
||||
X "$si`t</dcssch:appearance>"
|
||||
}
|
||||
# inputParameters поля (связь по параметрам выбора) — в конце
|
||||
if ($fld.inputParameters) { Emit-DLInputParameters -ip $fld.inputParameters -indent "$si`t" }
|
||||
X "$si</Field>"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# form-compile v1.141 — Compile 1C managed form from JSON or object metadata
|
||||
# form-compile v1.142 — Compile 1C managed form from JSON or object metadata
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
import argparse
|
||||
import copy
|
||||
@@ -1832,6 +1832,31 @@ def emit_calc_fields(lines, calc_fields, indent):
|
||||
lines.append(f'{indent}</CalculatedField>')
|
||||
|
||||
|
||||
# Ограничения использования поля/вычисляемого поля (useRestriction / attributeUseRestriction).
|
||||
# Значение: объект {field?,condition?,group?,order?} | флаг-строка "#noField …" | массив.
|
||||
def parse_restrict(ur):
|
||||
if not ur:
|
||||
return []
|
||||
if isinstance(ur, dict):
|
||||
return [k for k in ('field', 'condition', 'group', 'order') if ur.get(k)]
|
||||
if isinstance(ur, str):
|
||||
return [_CALC_RESTRICT_MAP.get(t.strip().lstrip('#'), t.strip().lstrip('#')) for t in ur.split() if t.strip()]
|
||||
if isinstance(ur, list):
|
||||
return [_CALC_RESTRICT_MAP.get(str(r), str(r)) for r in ur]
|
||||
return []
|
||||
|
||||
|
||||
def emit_restrict_block(lines, tag, ur, indent):
|
||||
r = parse_restrict(ur)
|
||||
if not r:
|
||||
return
|
||||
lines.append(f'{indent}<dcssch:{tag}>')
|
||||
for k in ('field', 'condition', 'group', 'order'):
|
||||
if k in r:
|
||||
lines.append(f'{indent}\t<dcssch:{k}>true</dcssch:{k}>')
|
||||
lines.append(f'{indent}</dcssch:{tag}>')
|
||||
|
||||
|
||||
def emit_conditional_appearance(lines, items, indent, block_view_mode=None, block_user_setting_id=None, wrap_tag='dcsset:conditionalAppearance'):
|
||||
has_items = bool(items) and len(items) > 0
|
||||
has_block_meta = (block_view_mode is not None) or (block_user_setting_id is not None)
|
||||
@@ -5373,6 +5398,9 @@ def emit_attributes(lines, attrs, indent, conditional_appearance=None):
|
||||
lines.append(f'{si}\t<dcssch:title xsi:type="v8:LocalStringType">')
|
||||
emit_ml_items(lines, f'{si}\t\t', fld['title'])
|
||||
lines.append(f'{si}\t</dcssch:title>')
|
||||
# Ограничения использования поля — после title, перед presentationExpression
|
||||
emit_restrict_block(lines, 'useRestriction', fld.get('useRestriction'), f'{si}\t')
|
||||
emit_restrict_block(lines, 'attributeUseRestriction', fld.get('attributeUseRestriction'), f'{si}\t')
|
||||
# presentationExpression поля — перед valueType (порядок исходника)
|
||||
if fld.get('presentationExpression'):
|
||||
lines.append(f'{si}\t<dcssch:presentationExpression>{esc_xml(str(fld["presentationExpression"]))}</dcssch:presentationExpression>')
|
||||
@@ -5385,6 +5413,9 @@ def emit_attributes(lines, attrs, indent, conditional_appearance=None):
|
||||
for ak, av in fld['appearance'].items():
|
||||
emit_appearance_value(lines, ak, av, f'{si}\t\t')
|
||||
lines.append(f'{si}\t</dcssch:appearance>')
|
||||
# inputParameters поля (связь по параметрам выбора) — в конце
|
||||
if fld.get('inputParameters'):
|
||||
emit_dl_input_parameters(lines, fld['inputParameters'], f'{si}\t')
|
||||
lines.append(f'{si}</Field>')
|
||||
# Вычисляемые поля DataSet (<CalculatedField>) — после Field*, до Parameter*.
|
||||
emit_calc_fields(lines, s.get('calculatedFields'), si)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# form-decompile v0.114 — Decompile 1C managed Form.xml to JSON DSL (draft)
|
||||
# form-decompile v0.115 — Decompile 1C managed Form.xml to JSON DSL (draft)
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
# ВНИМАНИЕ: раундтрип не гарантируется. Навык исключён из авто-использования моделью.
|
||||
param(
|
||||
@@ -1246,6 +1246,14 @@ function Decompile-Type {
|
||||
return ($parts -join ' | ')
|
||||
}
|
||||
|
||||
# Ограничения использования (useRestriction/attributeUseRestriction) → объект {field?,condition?,group?,order?}.
|
||||
function Build-RestrictObj {
|
||||
param($node)
|
||||
$r = [ordered]@{}
|
||||
foreach ($k in 'field','condition','group','order') { if ((Get-Child $node $k) -eq 'true') { $r[$k] = $true } }
|
||||
return $r
|
||||
}
|
||||
|
||||
# Вычисляемое поле DataSet динамического списка (<CalculatedField>) → объектная модель.
|
||||
# Зеркало эмиссии form-compile (Emit-CalcFields). Грамматика — как skd calculatedFields,
|
||||
# + форм-extras presentationExpression/orderExpression (в namespace dcscommon).
|
||||
@@ -2619,6 +2627,12 @@ if ($attrsNode) {
|
||||
if ($null -ne $fpe -and $fpe -ne '') { $fo['presentationExpression'] = $fpe }
|
||||
$fappNode = $fn.SelectSingleNode("dcssch:appearance", $ns)
|
||||
if ($fappNode) { $fap = Get-SettingsAppearance $fappNode; if ($fap -and $fap.Count -gt 0) { $fo['appearance'] = $fap } }
|
||||
$furNode = $fn.SelectSingleNode("dcssch:useRestriction", $ns)
|
||||
if ($furNode) { $fur = Build-RestrictObj $furNode; if ($fur.Count -gt 0) { $fo['useRestriction'] = $fur } }
|
||||
$faurNode = $fn.SelectSingleNode("dcssch:attributeUseRestriction", $ns)
|
||||
if ($faurNode) { $faur = Build-RestrictObj $faurNode; if ($faur.Count -gt 0) { $fo['attributeUseRestriction'] = $faur } }
|
||||
$fipNode = $fn.SelectSingleNode("dcssch:inputParameters", $ns)
|
||||
if ($fipNode) { $fip = Build-DLInputParameters $fipNode; if (@($fip).Count -gt 0) { $fo['inputParameters'] = $fip } }
|
||||
[void]$fields.Add($fo)
|
||||
}
|
||||
$so['fields'] = @($fields)
|
||||
|
||||
@@ -940,7 +940,7 @@ Forgiving-синонимы типа: XML-имя (`SpreadSheetDocumentField`) и
|
||||
| `query` | string | Текст запроса (`ManualQuery=true`). Поддерживает `@file.sql` (путь относительно JSON) |
|
||||
| `dynamicDataRead` | bool | Динамическое считывание. **Умолчание `true`** — указывать только для отключения (`false`) |
|
||||
| `autoFillAvailableFields` | bool | Автозаполнение доступных полей (`<AutoFillAvailableFields>`). **Умолчание `true`** — указывать только для отключения (`false`; тогда поля берутся из явного запроса, не авто). Эмитится первым в `<Settings>` |
|
||||
| `fields` | array | Явные поля набора (редко): `{ field, dataPath?, title?, valueType?, presentationExpression?, appearance?, nested? }` — для переопределения свойств поля. `valueType` — тип значения (грамматика типа). `presentationExpression` — выражение представления поля (строка). `appearance` — оформление/формат поля: объект `{ Параметр: Значение }` (та же грамматика, что `appearance` условного оформления, напр. `{ "Формат": "ДЛ=9", "ЦветТекста": "web:Gray" }`). `nested: true` помечает поле-вложенный набор (`DataSetFieldNestedDataSet` = реквизит табличной части объекта; дефолт — `DataSetFieldField`). Обычно поля выводятся из запроса автоматически |
|
||||
| `fields` | array | Явные поля набора (редко): `{ field, dataPath?, title?, useRestriction?, attributeUseRestriction?, valueType?, presentationExpression?, appearance?, inputParameters?, nested? }` — для переопределения свойств поля. `useRestriction`/`attributeUseRestriction` — ограничения использования: объект `{ field?, condition?, group?, order? }` (bool) или флаг-строка `"#noField #noFilter #noGroup #noOrder"`. `valueType` — тип значения (грамматика типа). `presentationExpression` — выражение представления поля (строка). `appearance` — оформление/формат поля: объект `{ Параметр: Значение }` (та же грамматика, что `appearance` условного оформления, напр. `{ "Формат": "ДЛ=9", "ЦветТекста": "web:Gray" }`). `inputParameters` — связь по параметрам выбора (как у параметра дин-списка). `nested: true` помечает поле-вложенный набор (`DataSetFieldNestedDataSet` = реквизит табличной части объекта; дефолт — `DataSetFieldField`). Обычно поля выводятся из запроса автоматически |
|
||||
| `calculatedFields` | array | Вычисляемые поля набора (см. ниже) |
|
||||
| `parameters` | array | Параметры схемы запроса (`DataCompositionSchemaParameter`) — см. ниже |
|
||||
| `order` | array | Сортировка списка (см. ниже) |
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
"parameters": [ { "name": "ВыборТовара", "type": "CatalogRef.Товары", "valueListAllowed": true, "value": null } ],
|
||||
"fields": [
|
||||
{ "field": "Code", "title": "Код", "presentationExpression": "\"№\" + Code",
|
||||
"useRestriction": { "condition": true, "group": true },
|
||||
"attributeUseRestriction": { "field": true },
|
||||
"appearance": { "Формат": "ДЛ=9", "ЦветТекста": "web:Gray" } }
|
||||
],
|
||||
"grouping": "Description > Code",
|
||||
|
||||
+7
@@ -109,6 +109,13 @@
|
||||
<v8:content>Код</v8:content>
|
||||
</v8:item>
|
||||
</dcssch:title>
|
||||
<dcssch:useRestriction>
|
||||
<dcssch:condition>true</dcssch:condition>
|
||||
<dcssch:group>true</dcssch:group>
|
||||
</dcssch:useRestriction>
|
||||
<dcssch:attributeUseRestriction>
|
||||
<dcssch:field>true</dcssch:field>
|
||||
</dcssch:attributeUseRestriction>
|
||||
<dcssch:presentationExpression>"№" + Code</dcssch:presentationExpression>
|
||||
<dcssch:appearance>
|
||||
<dcscor:item xsi:type="dcsset:SettingsParameterValue">
|
||||
|
||||
Reference in New Issue
Block a user