mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-07-05 10:48:56 +03:00
feat(form-compile): автоподстановка RowPictureDataPath для DynamicList с MainTable
Document/InformationRegister/AccumulationRegister List-генераторы теперь прописывают `Список.DefaultPicture` (как делает ERP/БП в 594/600 форм списка документов). Плюс fallback в эвристике DynamicList-таблицы: если у главного реквизита есть `settings.mainTable`, поле подставляется автоматически и для ручного DSL. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# form-compile v1.13 — Compile 1C managed form from JSON or object metadata
|
||||
# form-compile v1.14 — Compile 1C managed form from JSON or object metadata
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[string]$JsonPath,
|
||||
@@ -668,6 +668,7 @@ function Generate-DocumentListDSL($meta, [hashtable]$p) {
|
||||
|
||||
$tableEl = [ordered]@{
|
||||
table = "Список"; path = "Список"
|
||||
rowPictureDataPath = "Список.DefaultPicture"
|
||||
commandBarLocation = "None"
|
||||
tableAutofill = $false
|
||||
columns = $columns
|
||||
@@ -1003,6 +1004,7 @@ function Generate-InformationRegisterListDSL($meta, [hashtable]$p) {
|
||||
|
||||
$tableEl = [ordered]@{
|
||||
table = "Список"; path = "Список"
|
||||
rowPictureDataPath = "Список.DefaultPicture"
|
||||
commandBarLocation = "None"
|
||||
tableAutofill = $false
|
||||
columns = $columns
|
||||
@@ -1060,6 +1062,7 @@ function Generate-AccumulationRegisterListDSL($meta, [hashtable]$p) {
|
||||
|
||||
$tableEl = [ordered]@{
|
||||
table = "Список"; path = "Список"
|
||||
rowPictureDataPath = "Список.DefaultPicture"
|
||||
commandBarLocation = "None"
|
||||
tableAutofill = $false
|
||||
columns = $columns
|
||||
@@ -2680,7 +2683,7 @@ function HasCmdBarRecursive {
|
||||
}
|
||||
|
||||
function ApplyDynamicListTableHeuristic {
|
||||
param($el, [string]$listName)
|
||||
param($el, [string]$listName, [bool]$hasMainTable)
|
||||
if ($null -eq $el) { return }
|
||||
if ($el.PSObject.Properties["table"] -and $null -ne $el.table -and "$($el.path)" -eq $listName) {
|
||||
if ($null -eq $el.PSObject.Properties["tableAutofill"]) {
|
||||
@@ -2689,9 +2692,13 @@ function ApplyDynamicListTableHeuristic {
|
||||
if ($null -eq $el.PSObject.Properties["commandBarLocation"]) {
|
||||
$el | Add-Member -NotePropertyName "commandBarLocation" -NotePropertyValue "None" -Force
|
||||
}
|
||||
# DefaultPicture доступен только если у DynamicList есть основная таблица
|
||||
if ($hasMainTable -and ($null -eq $el.PSObject.Properties["rowPictureDataPath"] -or [string]::IsNullOrEmpty("$($el.rowPictureDataPath)"))) {
|
||||
$el | Add-Member -NotePropertyName "rowPictureDataPath" -NotePropertyValue "$listName.DefaultPicture" -Force
|
||||
}
|
||||
}
|
||||
if ($el.PSObject.Properties["children"] -and $el.children) {
|
||||
foreach ($child in $el.children) { ApplyDynamicListTableHeuristic $child $listName }
|
||||
foreach ($child in $el.children) { ApplyDynamicListTableHeuristic $child $listName $hasMainTable }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2780,8 +2787,17 @@ if ($def.attributes -and $def.elements) {
|
||||
if ($attr.main -eq $true) { $mainAttr = $attr; break }
|
||||
}
|
||||
if ($mainAttr -and "$($mainAttr.type)" -eq "DynamicList") {
|
||||
$mt = $null
|
||||
if ($mainAttr.PSObject.Properties["settings"] -and $null -ne $mainAttr.settings) {
|
||||
if ($mainAttr.settings -is [hashtable]) {
|
||||
if ($mainAttr.settings.ContainsKey("mainTable")) { $mt = $mainAttr.settings["mainTable"] }
|
||||
} elseif ($mainAttr.settings.PSObject.Properties["mainTable"]) {
|
||||
$mt = $mainAttr.settings.mainTable
|
||||
}
|
||||
}
|
||||
$hasMt = -not [string]::IsNullOrEmpty("$mt")
|
||||
foreach ($el in $def.elements) {
|
||||
ApplyDynamicListTableHeuristic $el $mainAttr.name
|
||||
ApplyDynamicListTableHeuristic $el $mainAttr.name $hasMt
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# form-compile v1.13 — Compile 1C managed form from JSON or object metadata
|
||||
# form-compile v1.14 — Compile 1C managed form from JSON or object metadata
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
import argparse
|
||||
import copy
|
||||
@@ -625,6 +625,7 @@ def generate_document_list_dsl(meta, p):
|
||||
|
||||
table_el = OrderedDict([
|
||||
('table', '\u0421\u043f\u0438\u0441\u043e\u043a'), ('path', '\u0421\u043f\u0438\u0441\u043e\u043a'),
|
||||
('rowPictureDataPath', '\u0421\u043f\u0438\u0441\u043e\u043a.DefaultPicture'),
|
||||
('commandBarLocation', 'None'),
|
||||
('tableAutofill', False),
|
||||
('columns', columns),
|
||||
@@ -938,6 +939,7 @@ def generate_information_register_list_dsl(meta, p):
|
||||
table_el = OrderedDict([
|
||||
('table', '\u0421\u043f\u0438\u0441\u043e\u043a'),
|
||||
('path', '\u0421\u043f\u0438\u0441\u043e\u043a'),
|
||||
('rowPictureDataPath', '\u0421\u043f\u0438\u0441\u043e\u043a.DefaultPicture'),
|
||||
('commandBarLocation', 'None'),
|
||||
('tableAutofill', False),
|
||||
('columns', columns_list),
|
||||
@@ -996,6 +998,7 @@ def generate_accumulation_register_list_dsl(meta, p):
|
||||
table_el = OrderedDict([
|
||||
('table', '\u0421\u043f\u0438\u0441\u043e\u043a'),
|
||||
('path', '\u0421\u043f\u0438\u0441\u043e\u043a'),
|
||||
('rowPictureDataPath', '\u0421\u043f\u0438\u0441\u043e\u043a.DefaultPicture'),
|
||||
('commandBarLocation', 'None'),
|
||||
('tableAutofill', False),
|
||||
('columns', columns_list),
|
||||
@@ -2599,7 +2602,7 @@ def main():
|
||||
return True
|
||||
return False
|
||||
|
||||
def _apply_dlist_table_heuristic(el, list_name):
|
||||
def _apply_dlist_table_heuristic(el, list_name, has_main_table):
|
||||
if not isinstance(el, dict):
|
||||
return
|
||||
if el.get('table') is not None and str(el.get('path', '')) == list_name:
|
||||
@@ -2607,9 +2610,12 @@ def main():
|
||||
el['tableAutofill'] = False
|
||||
if 'commandBarLocation' not in el:
|
||||
el['commandBarLocation'] = 'None'
|
||||
# DefaultPicture доступен только если у DynamicList есть основная таблица
|
||||
if has_main_table and not el.get('rowPictureDataPath'):
|
||||
el['rowPictureDataPath'] = f'{list_name}.DefaultPicture'
|
||||
if isinstance(el.get('children'), list):
|
||||
for child in el['children']:
|
||||
_apply_dlist_table_heuristic(child, list_name)
|
||||
_apply_dlist_table_heuristic(child, list_name, has_main_table)
|
||||
|
||||
def _is_object_like_type(t):
|
||||
if not t:
|
||||
@@ -2674,8 +2680,10 @@ def main():
|
||||
if isinstance(defn.get('attributes'), list) and isinstance(defn.get('elements'), list):
|
||||
main_attr = next((a for a in defn['attributes'] if isinstance(a, dict) and a.get('main') is True), None)
|
||||
if main_attr and str(main_attr.get('type', '')) == 'DynamicList':
|
||||
settings = main_attr.get('settings') or {}
|
||||
has_mt = bool(isinstance(settings, dict) and settings.get('mainTable'))
|
||||
for el in defn['elements']:
|
||||
_apply_dlist_table_heuristic(el, main_attr.get('name', ''))
|
||||
_apply_dlist_table_heuristic(el, main_attr.get('name', ''), has_mt)
|
||||
|
||||
# 1b.5: Compute main AutoCommandBar Autofill (B3)
|
||||
def _compute_main_acb_autofill():
|
||||
|
||||
+1
@@ -12,6 +12,7 @@
|
||||
<Table name="Список" id="1">
|
||||
<DataPath>Список</DataPath>
|
||||
<CommandBarLocation>None</CommandBarLocation>
|
||||
<RowPictureDataPath>Список.DefaultPicture</RowPictureDataPath>
|
||||
<ContextMenu name="СписокКонтекстноеМеню" id="2"/>
|
||||
<AutoCommandBar name="СписокКоманднаяПанель" id="3">
|
||||
<Autofill>false</Autofill>
|
||||
|
||||
+1
@@ -12,6 +12,7 @@
|
||||
<Table name="Список" id="1">
|
||||
<DataPath>Список</DataPath>
|
||||
<CommandBarLocation>None</CommandBarLocation>
|
||||
<RowPictureDataPath>Список.DefaultPicture</RowPictureDataPath>
|
||||
<ContextMenu name="СписокКонтекстноеМеню" id="2"/>
|
||||
<AutoCommandBar name="СписокКоманднаяПанель" id="3">
|
||||
<Autofill>false</Autofill>
|
||||
|
||||
+1
@@ -12,6 +12,7 @@
|
||||
<Table name="Список" id="1">
|
||||
<DataPath>Список</DataPath>
|
||||
<CommandBarLocation>None</CommandBarLocation>
|
||||
<RowPictureDataPath>Список.DefaultPicture</RowPictureDataPath>
|
||||
<ContextMenu name="СписокКонтекстноеМеню" id="2"/>
|
||||
<AutoCommandBar name="СписокКоманднаяПанель" id="3">
|
||||
<Autofill>false</Autofill>
|
||||
|
||||
+1
@@ -20,6 +20,7 @@
|
||||
<Table name="Список" id="3">
|
||||
<DataPath>Список</DataPath>
|
||||
<CommandBarLocation>None</CommandBarLocation>
|
||||
<RowPictureDataPath>Список.DefaultPicture</RowPictureDataPath>
|
||||
<ContextMenu name="СписокКонтекстноеМеню" id="4"/>
|
||||
<AutoCommandBar name="СписокКоманднаяПанель" id="5">
|
||||
<Autofill>false</Autofill>
|
||||
|
||||
+1
@@ -12,6 +12,7 @@
|
||||
<Table name="Список" id="1">
|
||||
<DataPath>Список</DataPath>
|
||||
<CommandBarLocation>None</CommandBarLocation>
|
||||
<RowPictureDataPath>Список.DefaultPicture</RowPictureDataPath>
|
||||
<ContextMenu name="СписокКонтекстноеМеню" id="2"/>
|
||||
<AutoCommandBar name="СписокКоманднаяПанель" id="3">
|
||||
<Autofill>false</Autofill>
|
||||
|
||||
Reference in New Issue
Block a user