mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-06-11 00:14:56 +03:00
feat(skd-compile): @autoDates — дефолты use=Always + denyIncompleteValues=true
Производные &НачалоПериода/&КонецПериода требуют заполненный период, поэтому сам параметр теперь по умолчанию получает use=Always и denyIncompleteValues=true. В объектной форме явные значения перекрывают. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -119,7 +119,7 @@ Shorthand: `"Имя [Заголовок]: тип = Выражение #noField #
|
||||
Shorthand: `"Имя [Заголовок]: тип = значение @флаги"`. `[Заголовок]` опциональный — добавляет `<title>` (LocalStringType).
|
||||
|
||||
Флаги shorthand:
|
||||
- `@autoDates` — добавляет к параметру StandardPeriod пару дат `НачалоПериода`/`КонецПериода`, вычисляемых из него. Используй их в тексте запроса как `&НачалоПериода`/`&КонецПериода`; пользователь выбирает только сам период.
|
||||
- `@autoDates` — добавляет к параметру StandardPeriod пару дат `НачалоПериода`/`КонецПериода`, вычисляемых из него. Используй их в тексте запроса как `&НачалоПериода`/`&КонецПериода`; пользователь выбирает только сам период. По умолчанию сам параметр получает `use=Always` и `denyIncompleteValues=true` (чтобы производные даты всегда были заполнены); в объектной форме можно явно переопределить.
|
||||
- `@valueList` — `<valueListAllowed>true</valueListAllowed>` — разрешает передавать список значений
|
||||
- `@hidden` — скрытый параметр: `availableAsField=false` + исключается из `"dataParameters": "auto"`
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# skd-compile v1.17 — Compile 1C DCS from JSON
|
||||
# skd-compile v1.18 — Compile 1C DCS from JSON
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[string]$DefinitionFile,
|
||||
@@ -1006,13 +1006,18 @@ function Emit-SingleParam {
|
||||
}
|
||||
|
||||
# DenyIncompleteValues
|
||||
if ($p -isnot [string] -and $p.denyIncompleteValues -eq $true) {
|
||||
$deny = $parsed.denyIncompleteValues -eq $true -or (
|
||||
$null -ne $p -and $p -isnot [string] -and $p.denyIncompleteValues -eq $true)
|
||||
if ($deny) {
|
||||
X "`t`t<denyIncompleteValues>true</denyIncompleteValues>"
|
||||
}
|
||||
|
||||
# Use
|
||||
if ($p -isnot [string] -and $p.use) {
|
||||
X "`t`t<use>$(Esc-Xml "$($p.use)")</use>"
|
||||
# Use — object form wins, else parsed (set by @autoDates default)
|
||||
$useVal = $null
|
||||
if ($null -ne $p -and $p -isnot [string] -and $p.use) { $useVal = "$($p.use)" }
|
||||
elseif ($parsed.use) { $useVal = "$($parsed.use)" }
|
||||
if ($useVal) {
|
||||
X "`t`t<use>$(Esc-Xml $useVal)</use>"
|
||||
}
|
||||
|
||||
X "`t</parameter>"
|
||||
@@ -1039,6 +1044,15 @@ function Emit-Parameters {
|
||||
if ($p.autoDates -eq $true) { $parsed.autoDates = $true }
|
||||
}
|
||||
|
||||
# @autoDates implies use=Always + denyIncompleteValues=true by default
|
||||
# (derived &НачалоПериода/&КонецПериода need a populated period).
|
||||
# Explicit values in object form override these defaults.
|
||||
if ($parsed.autoDates) {
|
||||
$isObj = ($p -isnot [string]) -and ($null -ne $p)
|
||||
if (-not ($isObj -and $null -ne $p.use)) { $parsed.use = 'Always' }
|
||||
if (-not ($isObj -and $null -ne $p.denyIncompleteValues)) { $parsed.denyIncompleteValues = $true }
|
||||
}
|
||||
|
||||
Emit-SingleParam -p $p -parsed $parsed
|
||||
|
||||
# Track parameter for auto dataParameters
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# skd-compile v1.17 — Compile 1C DCS from JSON
|
||||
# skd-compile v1.18 — Compile 1C DCS from JSON
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
import argparse
|
||||
import json
|
||||
@@ -867,12 +867,19 @@ def emit_single_param(lines, p, parsed):
|
||||
lines.append('\t\t</availableValue>')
|
||||
|
||||
# DenyIncompleteValues
|
||||
if p is not None and not isinstance(p, str) and p.get('denyIncompleteValues') is True:
|
||||
deny = parsed.get('denyIncompleteValues') is True or (
|
||||
p is not None and not isinstance(p, str) and p.get('denyIncompleteValues') is True)
|
||||
if deny:
|
||||
lines.append('\t\t<denyIncompleteValues>true</denyIncompleteValues>')
|
||||
|
||||
# Use
|
||||
use_val = None
|
||||
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>')
|
||||
use_val = str(p['use'])
|
||||
elif parsed.get('use'):
|
||||
use_val = str(parsed['use'])
|
||||
if use_val:
|
||||
lines.append(f'\t\t<use>{esc_xml(use_val)}</use>')
|
||||
|
||||
lines.append('\t</parameter>')
|
||||
|
||||
@@ -906,6 +913,16 @@ def emit_parameters(lines, defn):
|
||||
if p.get('autoDates') is True:
|
||||
parsed['autoDates'] = True
|
||||
|
||||
# @autoDates implies use=Always + denyIncompleteValues=true by default
|
||||
# (derived &НачалоПериода/&КонецПериода need a populated period).
|
||||
# Explicit values in object form override these defaults.
|
||||
if parsed.get('autoDates'):
|
||||
is_obj = p is not None and not isinstance(p, str)
|
||||
if not (is_obj and p.get('use') is not None):
|
||||
parsed['use'] = 'Always'
|
||||
if not (is_obj and p.get('denyIncompleteValues') is not None):
|
||||
parsed['denyIncompleteValues'] = True
|
||||
|
||||
emit_single_param(lines, p, parsed)
|
||||
|
||||
# Track parameter for auto dataParameters
|
||||
|
||||
@@ -33,6 +33,8 @@
|
||||
<v8:startDate>0001-01-01T00:00:00</v8:startDate>
|
||||
<v8:endDate>0001-01-01T00:00:00</v8:endDate>
|
||||
</value>
|
||||
<denyIncompleteValues>true</denyIncompleteValues>
|
||||
<use>Always</use>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>НачалоПериода</name>
|
||||
|
||||
@@ -68,6 +68,8 @@
|
||||
<v8:startDate>0001-01-01T00:00:00</v8:startDate>
|
||||
<v8:endDate>0001-01-01T00:00:00</v8:endDate>
|
||||
</value>
|
||||
<denyIncompleteValues>true</denyIncompleteValues>
|
||||
<use>Always</use>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>НачалоПериода</name>
|
||||
|
||||
@@ -63,6 +63,8 @@
|
||||
<v8:startDate>0001-01-01T00:00:00</v8:startDate>
|
||||
<v8:endDate>0001-01-01T00:00:00</v8:endDate>
|
||||
</value>
|
||||
<denyIncompleteValues>true</denyIncompleteValues>
|
||||
<use>Always</use>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>НачалоПериода</name>
|
||||
|
||||
@@ -60,6 +60,8 @@
|
||||
<v8:startDate>0001-01-01T00:00:00</v8:startDate>
|
||||
<v8:endDate>0001-01-01T00:00:00</v8:endDate>
|
||||
</value>
|
||||
<denyIncompleteValues>true</denyIncompleteValues>
|
||||
<use>Always</use>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>НачалоПериода</name>
|
||||
|
||||
Reference in New Issue
Block a user