mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-07-19 09:09:41 +03:00
feat(skd-decompile): чтение availableValues на полях dataSet
Build-Field теперь читает <availableValue> на DataSetFieldField, типизирует value по xsi:type (boolean/decimal/string/dateTime), сохраняет presentation как multilang dict если возможно. Поле переходит в object form если есть availableValues. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
# skd-decompile v0.25 — Decompile 1C DCS Template.xml to JSON DSL (draft)
|
# skd-decompile v0.26 — Decompile 1C DCS Template.xml to JSON DSL (draft)
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory)]
|
[Parameter(Mandatory)]
|
||||||
@@ -540,10 +540,33 @@ function Build-Field {
|
|||||||
$appNode = $fieldNode.SelectSingleNode("r:appearance", $ns)
|
$appNode = $fieldNode.SelectSingleNode("r:appearance", $ns)
|
||||||
$appearance = Get-AppearanceDict $appNode
|
$appearance = Get-AppearanceDict $appNode
|
||||||
$presExpr = Get-Text $fieldNode "r:presentationExpression"
|
$presExpr = Get-Text $fieldNode "r:presentationExpression"
|
||||||
|
# availableValues on dataset field
|
||||||
|
$avNodes = $fieldNode.SelectNodes("r:availableValue", $ns)
|
||||||
|
$availableValues = @()
|
||||||
|
foreach ($av in $avNodes) {
|
||||||
|
$avVN = $av.SelectSingleNode("r:value", $ns)
|
||||||
|
$avPN = $av.SelectSingleNode("r:presentation", $ns)
|
||||||
|
$avEntry = [ordered]@{}
|
||||||
|
if ($avVN) {
|
||||||
|
$avType = Get-LocalXsiType $avVN
|
||||||
|
$avText = $avVN.InnerText
|
||||||
|
if ($avType -eq 'boolean') { $avEntry['value'] = ($avText -eq 'true') }
|
||||||
|
elseif ($avType -eq 'decimal') {
|
||||||
|
if ($avText -match '^-?\d+$') { $avEntry['value'] = [int]$avText }
|
||||||
|
else { $avEntry['value'] = [double]$avText }
|
||||||
|
}
|
||||||
|
else { $avEntry['value'] = $avText }
|
||||||
|
}
|
||||||
|
if ($avPN) {
|
||||||
|
$avPres = Get-MLText $avPN
|
||||||
|
if ($avPres) { $avEntry['presentation'] = $avPres }
|
||||||
|
}
|
||||||
|
$availableValues += $avEntry
|
||||||
|
}
|
||||||
|
|
||||||
# Можно ли роль положить в shorthand-строку?
|
# Можно ли роль положить в shorthand-строку?
|
||||||
$roleInString = $roleRendered -and $roleRendered.isString
|
$roleInString = $roleRendered -and $roleRendered.isString
|
||||||
$needsObject = $title -or $appearance -or $presExpr -or ($typeShort -is [array]) -or ($roleRendered -and -not $roleInString) -or $orderExpression -or $inputParameters
|
$needsObject = $title -or $appearance -or $presExpr -or ($typeShort -is [array]) -or ($roleRendered -and -not $roleInString) -or $orderExpression -or $inputParameters -or ($availableValues.Count -gt 0)
|
||||||
|
|
||||||
if (-not $needsObject) {
|
if (-not $needsObject) {
|
||||||
# shorthand: "Name: type @role K=V #restrict"
|
# shorthand: "Name: type @role K=V #restrict"
|
||||||
@@ -575,6 +598,7 @@ function Build-Field {
|
|||||||
if ($inputParameters) { $obj['inputParameters'] = $inputParameters }
|
if ($inputParameters) { $obj['inputParameters'] = $inputParameters }
|
||||||
if ($restrictTokens) { $obj['restrict'] = ($restrictTokens | ForEach-Object { $_ -replace '^#','' }) }
|
if ($restrictTokens) { $obj['restrict'] = ($restrictTokens | ForEach-Object { $_ -replace '^#','' }) }
|
||||||
if ($presExpr) { $obj['presentationExpression'] = $presExpr }
|
if ($presExpr) { $obj['presentationExpression'] = $presExpr }
|
||||||
|
if ($availableValues.Count -gt 0) { $obj['availableValues'] = $availableValues }
|
||||||
if ($appearance) { $obj['appearance'] = $appearance }
|
if ($appearance) { $obj['appearance'] = $appearance }
|
||||||
return $obj
|
return $obj
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user