From c31cff5adaf9d17f110a201b0ddcc51516651579 Mon Sep 17 00:00:00 2001 From: Nick Shirokov Date: Sat, 11 Jul 2026 22:34:47 +0300 Subject: [PATCH] =?UTF-8?q?feat(meta-edit):=20=D1=81=D1=82=D1=80=D1=83?= =?UTF-8?q?=D0=BA=D1=82=D1=83=D1=80=D0=BD=D1=8B=D0=B5=20=D1=81=D0=B2=D0=BE?= =?UTF-8?q?=D0=B9=D1=81=D1=82=D0=B2=D0=B0=20=D1=80=D0=B5=D0=BA=D0=B2=D0=B8?= =?UTF-8?q?=D0=B7=D0=B8=D1=82=D0=B0=20Format/EditFormat/ToolTip/ChoiceForm?= =?UTF-8?q?=20(=D0=A4=D0=B0=D0=B7=D0=B0=202=20=D0=A8=D0=B0=D0=B3=202,=20v1?= =?UTF-8?q?.13)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit modify-attribute/-dimension/-resource теперь умеют задавать структурные свойства реквизита (не только скаляры): Format/EditFormat/ToolTip (ML-строки через существующий Build-MLTextXml) + ChoiceForm. Ветки-диспетчеры в switch перед default, по образцу ветки type (replace-or-create). Отсутствующее свойство создаётся в канонической позиции (Insert-PropertyInOrder из Шага 1). Ключи — PascalCase XML-имена (консистентно с существующей modify-конвенцией CodeLength/Indexing). Побочный фикс: Set-AttrPropertyElement (ps1) через InsertBefore+RemoveChild вместо InsertAfter+Remove-NodeWithWhitespace — последний склеивал (), т.к. в XmlDocument ведущий whitespace — отдельный узел; py (tail-модель) был корректен. Cert: verify-snapshots --case modify-attribute-structural — Format/EditFormat/ToolTip/ ChoiceForm (с реальной формой через form-add preRun) грузятся в 1С. meta-edit 14/14 ps1+py; byte-паритет ps1==py (после нормализации раннера). Co-Authored-By: Claude Opus 4.8 (1M context) --- .../skills/meta-edit/scripts/meta-edit.ps1 | 42 ++- .claude/skills/meta-edit/scripts/meta-edit.py | 39 ++- .../modify-attribute-structural.json | 24 ++ .../Catalogs/Спр.xml | 191 +++++++++++++ .../Catalogs/Спр/Ext/ObjectModule.bsl | 0 .../Catalogs/Спр/Forms/ФормаВыбора.xml | 21 ++ .../Спр/Forms/ФормаВыбора/Ext/Form.xml | 16 ++ .../Спр/Forms/ФормаВыбора/Ext/Form/Module.bsl | 19 ++ .../Configuration.xml | 252 ++++++++++++++++++ .../Ext/ClientApplicationInterface.xml | 18 ++ .../Languages/Русский.xml | 16 ++ 11 files changed, 636 insertions(+), 2 deletions(-) create mode 100644 tests/skills/cases/meta-edit/modify-attribute-structural.json create mode 100644 tests/skills/cases/meta-edit/snapshots/modify-attribute-structural/Catalogs/Спр.xml create mode 100644 tests/skills/cases/meta-edit/snapshots/modify-attribute-structural/Catalogs/Спр/Ext/ObjectModule.bsl create mode 100644 tests/skills/cases/meta-edit/snapshots/modify-attribute-structural/Catalogs/Спр/Forms/ФормаВыбора.xml create mode 100644 tests/skills/cases/meta-edit/snapshots/modify-attribute-structural/Catalogs/Спр/Forms/ФормаВыбора/Ext/Form.xml create mode 100644 tests/skills/cases/meta-edit/snapshots/modify-attribute-structural/Catalogs/Спр/Forms/ФормаВыбора/Ext/Form/Module.bsl create mode 100644 tests/skills/cases/meta-edit/snapshots/modify-attribute-structural/Configuration.xml create mode 100644 tests/skills/cases/meta-edit/snapshots/modify-attribute-structural/Ext/ClientApplicationInterface.xml create mode 100644 tests/skills/cases/meta-edit/snapshots/modify-attribute-structural/Languages/Русский.xml diff --git a/.claude/skills/meta-edit/scripts/meta-edit.ps1 b/.claude/skills/meta-edit/scripts/meta-edit.ps1 index fb460651..5ede0194 100644 --- a/.claude/skills/meta-edit/scripts/meta-edit.ps1 +++ b/.claude/skills/meta-edit/scripts/meta-edit.ps1 @@ -1,4 +1,4 @@ -# meta-edit v1.12 — Edit existing 1C metadata object XML (inline mode + complex properties + TS attribute ops + modify-ts + create-if-missing свойств) +# meta-edit v1.13 — Edit existing 1C metadata object XML (inline + complex props + TS ops + modify-ts + create-if-missing + structural attr props Format/EditFormat/ToolTip/ChoiceForm) # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills param( [string]$DefinitionFile, @@ -2240,6 +2240,26 @@ function Modify-ChildElements($modifyDef, [string]$childType) { Info "Changed synonym of $xmlTag '$elemName': $changeValue" $script:modifyCount++ } + "Format" { + if (Set-AttrPropertyElement $propsEl "Format" (Build-MLTextXml (Get-ChildIndent $propsEl) "Format" "$changeValue")) { + Info "Set $xmlTag '$elemName'.Format"; $script:modifyCount++ + } + } + "EditFormat" { + if (Set-AttrPropertyElement $propsEl "EditFormat" (Build-MLTextXml (Get-ChildIndent $propsEl) "EditFormat" "$changeValue")) { + Info "Set $xmlTag '$elemName'.EditFormat"; $script:modifyCount++ + } + } + "ToolTip" { + if (Set-AttrPropertyElement $propsEl "ToolTip" (Build-MLTextXml (Get-ChildIndent $propsEl) "ToolTip" "$changeValue")) { + Info "Set $xmlTag '$elemName'.ToolTip"; $script:modifyCount++ + } + } + "ChoiceForm" { + if (Set-AttrPropertyElement $propsEl "ChoiceForm" "$(Esc-Xml "$changeValue")") { + Info "Set $xmlTag '$elemName'.ChoiceForm"; $script:modifyCount++ + } + } default { # Scalar property change (Indexing, FillChecking, Use, etc.) $scalarEl = $null @@ -2380,6 +2400,26 @@ function Insert-PropertyInOrder($propsEl, $newNode, $orderArray, $propName) { Insert-BeforeElement $propsEl $newNode $refNode $childIndent } +# Заменить существующий элемент свойства реквизита новым фрагментом (по образцу ветки type), +# либо создать в канонической позиции, если его нет. Возвращает $true при успехе. +function Set-AttrPropertyElement($propsEl, $propName, $fragmentXml) { + $newNodes = Import-Fragment $fragmentXml + if ($newNodes.Count -eq 0) { return $false } + $existing = $null + foreach ($ch in $propsEl.ChildNodes) { + if ($ch.NodeType -eq 'Element' -and $ch.LocalName -eq $propName) { $existing = $ch; break } + } + if ($existing) { + # InsertBefore+RemoveChild сохраняет ведущий/хвостовой whitespace позиции existing + # (InsertAfter+Remove-NodeWithWhitespace склеил бы: удаляет ведущий ws как отдельный узел). + $propsEl.InsertBefore($newNodes[0], $existing) | Out-Null + $propsEl.RemoveChild($existing) | Out-Null + } else { + Insert-PropertyInOrder $propsEl $newNodes[0] $script:attrPropOrder $propName + } + return $true +} + function Find-PropertyElement([string]$propName) { foreach ($child in $script:propertiesEl.ChildNodes) { if ($child.NodeType -eq 'Element' -and $child.LocalName -eq $propName) { diff --git a/.claude/skills/meta-edit/scripts/meta-edit.py b/.claude/skills/meta-edit/scripts/meta-edit.py index 8d17135e..5c290b4a 100644 --- a/.claude/skills/meta-edit/scripts/meta-edit.py +++ b/.claude/skills/meta-edit/scripts/meta-edit.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# meta-edit v1.12 — Edit existing 1C metadata object XML (inline mode + complex properties + TS attribute ops + modify-ts + create-if-missing свойств) +# meta-edit v1.13 — Edit existing 1C metadata object XML (inline + complex props + TS ops + modify-ts + create-if-missing + structural attr props Format/EditFormat/ToolTip/ChoiceForm) # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills import argparse @@ -2089,6 +2089,23 @@ def modify_child_elements(modify_def, child_type): info(f"Changed synonym of {xml_tag} '{elem_name}': {change_value}") modify_count += 1 + elif change_prop == "Format": + if set_attr_property_element(props_el, "Format", build_mltext_xml(get_child_indent(props_el), "Format", str(change_value))): + info(f"Set {xml_tag} '{elem_name}'.Format") + modify_count += 1 + elif change_prop == "EditFormat": + if set_attr_property_element(props_el, "EditFormat", build_mltext_xml(get_child_indent(props_el), "EditFormat", str(change_value))): + info(f"Set {xml_tag} '{elem_name}'.EditFormat") + modify_count += 1 + elif change_prop == "ToolTip": + if set_attr_property_element(props_el, "ToolTip", build_mltext_xml(get_child_indent(props_el), "ToolTip", str(change_value))): + info(f"Set {xml_tag} '{elem_name}'.ToolTip") + modify_count += 1 + elif change_prop == "ChoiceForm": + if set_attr_property_element(props_el, "ChoiceForm", f"{esc_xml(str(change_value))}"): + info(f"Set {xml_tag} '{elem_name}'.ChoiceForm") + modify_count += 1 + else: # Scalar property change (Indexing, FillChecking, Use, etc.) scalar_el = None @@ -2213,6 +2230,26 @@ def insert_property_in_order(props_el, new_node, order_array, prop_name): insert_before_element(props_el, new_node, ref_node, child_indent) +def set_attr_property_element(props_el, prop_name, fragment_xml): + """Заменить существующий элемент свойства реквизита новым фрагментом, либо создать в позиции.""" + new_nodes = import_fragment(fragment_xml) + if not new_nodes: + return False + existing = None + for ch in props_el: + if localname(ch) == prop_name: + existing = ch + break + if existing is not None: + idx = list(props_el).index(existing) + new_nodes[0].tail = existing.tail + props_el.insert(idx + 1, new_nodes[0]) + remove_node_with_whitespace(existing) + else: + insert_property_in_order(props_el, new_nodes[0], attr_prop_order, prop_name) + return True + + def find_property_element(prop_name): for child in properties_el: if localname(child) == prop_name: diff --git a/tests/skills/cases/meta-edit/modify-attribute-structural.json b/tests/skills/cases/meta-edit/modify-attribute-structural.json new file mode 100644 index 00000000..595cd2b6 --- /dev/null +++ b/tests/skills/cases/meta-edit/modify-attribute-structural.json @@ -0,0 +1,24 @@ +{ + "name": "modify-attribute: структурные свойства Format/EditFormat/ToolTip/ChoiceForm", + "setup": "empty-config", + "preRun": [ + { + "script": "meta-compile/scripts/meta-compile", + "input": { "type": "Catalog", "name": "Спр", "attributes": ["Дата: Date", "Контр: CatalogRef.Спр"] }, + "args": { "-JsonPath": "{inputFile}", "-OutputDir": "{workDir}" } + }, + { + "script": "form-add/scripts/form-add", + "args": { "-ObjectPath": "{workDir}/Catalogs/Спр.xml", "-FormName": "ФормаВыбора" } + } + ], + "params": { "objectPath": "Catalogs/Спр" }, + "input": { + "modify": { + "attributes": { + "Дата": { "Format": "ДФ=dd.MM.yyyy", "EditFormat": "ДФ=dd.MM.yyyy", "ToolTip": "Дата документа" }, + "Контр": { "ChoiceForm": "Catalog.Спр.Form.ФормаВыбора" } + } + } + } +} diff --git a/tests/skills/cases/meta-edit/snapshots/modify-attribute-structural/Catalogs/Спр.xml b/tests/skills/cases/meta-edit/snapshots/modify-attribute-structural/Catalogs/Спр.xml new file mode 100644 index 00000000..e5300451 --- /dev/null +++ b/tests/skills/cases/meta-edit/snapshots/modify-attribute-structural/Catalogs/Спр.xml @@ -0,0 +1,191 @@ + + + + + + UUID-002 + UUID-003 + + + UUID-004 + UUID-005 + + + UUID-006 + UUID-007 + + + UUID-008 + UUID-009 + + + UUID-010 + UUID-011 + + + + Спр + + + ru + Спр + + + + false + HierarchyFoldersAndItems + false + 2 + true + true + + ToItems + 9 + 25 + String + Variable + WholeCatalog + false + true + AsDescription + + Auto + InDialog + false + BothWays + + Catalog.Спр.StandardAttribute.Description + Catalog.Спр.StandardAttribute.Code + + Begin + DontUse + Directly + Catalog.Спр.Form.ФормаВыбора + + + + + + + + + + false + + + Managed + Use + + + + + + Use + Auto + DontUse + false + false + + + + + Дата + + + ru + Дата + + + + + xs:dateTime + + Date + + + false + + + ru + ДФ=dd.MM.yyyy + + + + + ru + ДФ=dd.MM.yyyy + + + + + ru + Дата документа + + + false + + false + false + + + false + + DontCheck + Items + + + Auto + Auto + + + Auto + ForItem + DontIndex + Use + Use + + + + + Контр + + + ru + Контр + + + + + d5p1:CatalogRef.Спр + + false + + + + false + + false + false + + + false + + DontCheck + Items + + + Auto + Auto + Catalog.Спр.Form.ФормаВыбора + + Auto + ForItem + DontIndex + Use + Use + + +
ФормаВыбора
+
+
+
diff --git a/tests/skills/cases/meta-edit/snapshots/modify-attribute-structural/Catalogs/Спр/Ext/ObjectModule.bsl b/tests/skills/cases/meta-edit/snapshots/modify-attribute-structural/Catalogs/Спр/Ext/ObjectModule.bsl new file mode 100644 index 00000000..e69de29b diff --git a/tests/skills/cases/meta-edit/snapshots/modify-attribute-structural/Catalogs/Спр/Forms/ФормаВыбора.xml b/tests/skills/cases/meta-edit/snapshots/modify-attribute-structural/Catalogs/Спр/Forms/ФормаВыбора.xml new file mode 100644 index 00000000..93f10088 --- /dev/null +++ b/tests/skills/cases/meta-edit/snapshots/modify-attribute-structural/Catalogs/Спр/Forms/ФормаВыбора.xml @@ -0,0 +1,21 @@ + + +
+ + ФормаВыбора + + + ru + ФормаВыбора + + + + Managed + false + + PlatformApplication + MobilePlatformApplication + + +
+
\ No newline at end of file diff --git a/tests/skills/cases/meta-edit/snapshots/modify-attribute-structural/Catalogs/Спр/Forms/ФормаВыбора/Ext/Form.xml b/tests/skills/cases/meta-edit/snapshots/modify-attribute-structural/Catalogs/Спр/Forms/ФормаВыбора/Ext/Form.xml new file mode 100644 index 00000000..02de20dc --- /dev/null +++ b/tests/skills/cases/meta-edit/snapshots/modify-attribute-structural/Catalogs/Спр/Forms/ФормаВыбора/Ext/Form.xml @@ -0,0 +1,16 @@ + +
+ + true + + + + + + cfg:CatalogObject.Спр + + true + true + + + \ No newline at end of file diff --git a/tests/skills/cases/meta-edit/snapshots/modify-attribute-structural/Catalogs/Спр/Forms/ФормаВыбора/Ext/Form/Module.bsl b/tests/skills/cases/meta-edit/snapshots/modify-attribute-structural/Catalogs/Спр/Forms/ФормаВыбора/Ext/Form/Module.bsl new file mode 100644 index 00000000..8ead4cec --- /dev/null +++ b/tests/skills/cases/meta-edit/snapshots/modify-attribute-structural/Catalogs/Спр/Forms/ФормаВыбора/Ext/Form/Module.bsl @@ -0,0 +1,19 @@ +#Область ОбработчикиСобытийФормы + +#КонецОбласти + +#Область ОбработчикиСобытийЭлементовФормы + +#КонецОбласти + +#Область ОбработчикиКомандФормы + +#КонецОбласти + +#Область ОбработчикиОповещений + +#КонецОбласти + +#Область СлужебныеПроцедурыИФункции + +#КонецОбласти \ No newline at end of file diff --git a/tests/skills/cases/meta-edit/snapshots/modify-attribute-structural/Configuration.xml b/tests/skills/cases/meta-edit/snapshots/modify-attribute-structural/Configuration.xml new file mode 100644 index 00000000..199f22d9 --- /dev/null +++ b/tests/skills/cases/meta-edit/snapshots/modify-attribute-structural/Configuration.xml @@ -0,0 +1,252 @@ + + + + + + UUID-002 + UUID-003 + + + UUID-004 + UUID-005 + + + UUID-006 + UUID-007 + + + UUID-008 + UUID-009 + + + UUID-010 + UUID-011 + + + UUID-012 + UUID-013 + + + UUID-014 + UUID-015 + + + + TestConfig + + + ru + TestConfig + + + + + Version8_3_24 + ManagedApplication + + PlatformApplication + + Russian + + + + + false + false + false + + + + + + + + + + + + + + + + + + + + + + Biometrics + true + + + Location + false + + + BackgroundLocation + false + + + BluetoothPrinters + false + + + WiFiPrinters + false + + + Contacts + false + + + Calendars + false + + + PushNotifications + false + + + LocalNotifications + false + + + InAppPurchases + false + + + PersonalComputerFileExchange + false + + + Ads + false + + + NumberDialing + false + + + CallProcessing + false + + + CallLog + false + + + AutoSendSMS + false + + + ReceiveSMS + false + + + SMSLog + false + + + Camera + false + + + Microphone + false + + + MusicLibrary + false + + + PictureAndVideoLibraries + false + + + AudioPlaybackAndVibration + false + + + BackgroundAudioPlaybackAndVibration + false + + + InstallPackages + false + + + OSBackup + true + + + ApplicationUsageStatistics + false + + + BarcodeScanning + false + + + BackgroundAudioRecording + false + + + AllFilesAccess + false + + + Videoconferences + false + + + NFC + false + + + DocumentScanning + false + + + SpeechToText + false + + + Geofences + false + + + IncomingShareRequests + false + + + AllIncomingShareRequestsTypesProcessing + false + + + + + + Normal + + + Language.Русский + + + + + + Managed + NotAutoFree + DontUse + DontUse + TaxiEnableVersion8_2 + DontUse + Version8_3_24 + + + + Русский + Спр + + + \ No newline at end of file diff --git a/tests/skills/cases/meta-edit/snapshots/modify-attribute-structural/Ext/ClientApplicationInterface.xml b/tests/skills/cases/meta-edit/snapshots/modify-attribute-structural/Ext/ClientApplicationInterface.xml new file mode 100644 index 00000000..3c1161b2 --- /dev/null +++ b/tests/skills/cases/meta-edit/snapshots/modify-attribute-structural/Ext/ClientApplicationInterface.xml @@ -0,0 +1,18 @@ + + + + + UUID-002 + + + + + UUID-004 + + + + + + + + \ No newline at end of file diff --git a/tests/skills/cases/meta-edit/snapshots/modify-attribute-structural/Languages/Русский.xml b/tests/skills/cases/meta-edit/snapshots/modify-attribute-structural/Languages/Русский.xml new file mode 100644 index 00000000..37c60d78 --- /dev/null +++ b/tests/skills/cases/meta-edit/snapshots/modify-attribute-structural/Languages/Русский.xml @@ -0,0 +1,16 @@ + + + + + Русский + + + ru + Русский + + + + ru + + + \ No newline at end of file