mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-06-12 17:04:57 +03:00
feat(skd-decompile): чтение attributeUseRestriction на DataSet field
DataSet field может иметь <attributeUseRestriction> наравне с <useRestriction> — те же 4 подэлемента (field/condition/group/order), но ограничения применяются к атрибутам ссылочного поля (например, "запретить выбирать атрибуты Контрагента в фильтре"). Compile-side уже принимал attrRestrict в JSON; decompile теперь его заполняет. Item переходит в object form при наличии attrRestrict. Эффект на sample30: −257 строк diff. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# skd-decompile v0.39 — Decompile 1C DCS Template.xml to JSON DSL (draft)
|
||||
# skd-decompile v0.40 — Decompile 1C DCS Template.xml to JSON DSL (draft)
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
@@ -541,6 +541,8 @@ function Build-Field {
|
||||
$roleExtras = if ($roleInfo) { $roleInfo.extras } else { [ordered]@{} }
|
||||
$roleRendered = Render-Role -tokens $roleTokens -extras $roleExtras
|
||||
$restrictTokens = Get-RestrictionTokens $fieldNode.SelectSingleNode("r:useRestriction", $ns)
|
||||
# <attributeUseRestriction> — те же 4 флага, но для атрибутов ссылочного поля
|
||||
$attrRestrictTokens = Get-RestrictionTokens $fieldNode.SelectSingleNode("r:attributeUseRestriction", $ns)
|
||||
$appNode = $fieldNode.SelectSingleNode("r:appearance", $ns)
|
||||
$appearance = Get-AppearanceDict $appNode
|
||||
$presExpr = Get-Text $fieldNode "r:presentationExpression"
|
||||
@@ -570,7 +572,7 @@ function Build-Field {
|
||||
|
||||
# Можно ли роль положить в shorthand-строку?
|
||||
$roleInString = $roleRendered -and $roleRendered.isString
|
||||
$needsObject = $title -or $appearance -or $presExpr -or ($typeShort -is [array]) -or ($roleRendered -and -not $roleInString) -or $orderExpression -or $inputParameters -or ($availableValues.Count -gt 0)
|
||||
$needsObject = $title -or $appearance -or $presExpr -or ($typeShort -is [array]) -or ($roleRendered -and -not $roleInString) -or $orderExpression -or $inputParameters -or ($availableValues.Count -gt 0) -or ($attrRestrictTokens -and $attrRestrictTokens.Count -gt 0)
|
||||
|
||||
if (-not $needsObject) {
|
||||
# shorthand: "Name: type @role K=V #restrict"
|
||||
@@ -601,6 +603,9 @@ function Build-Field {
|
||||
if ($orderExpression) { $obj['orderExpression'] = $orderExpression }
|
||||
if ($inputParameters) { $obj['inputParameters'] = $inputParameters }
|
||||
if ($restrictTokens) { $obj['restrict'] = ($restrictTokens | ForEach-Object { $_ -replace '^#','' }) }
|
||||
if ($attrRestrictTokens -and $attrRestrictTokens.Count -gt 0) {
|
||||
$obj['attrRestrict'] = ($attrRestrictTokens | ForEach-Object { $_ -replace '^#','' })
|
||||
}
|
||||
if ($presExpr) { $obj['presentationExpression'] = $presExpr }
|
||||
if ($availableValues.Count -gt 0) { $obj['availableValues'] = $availableValues }
|
||||
if ($appearance) { $obj['appearance'] = $appearance }
|
||||
|
||||
Reference in New Issue
Block a user