mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-06-14 18:04:58 +03:00
feat(form-decompile,form-compile): события ExtendedTooltip-компаньона (переиспользование механизма событий элемента)
ExtendedTooltip (companion = LabelDecoration) может нести <Events> (напр. URLProcessing у hyperlink-подсказки — ОбработкаНавигационнойСсылки). Декомпилятор ловил own-content (layout/оформление/флаги/hyperlink), но НЕ события → весь блок Events LOST (топ list-iter: ExtendedTooltip>Events 492 impact). Был отложенный хвост кластера ExtendedTooltip own-content. Переиспользован механизм событий элемента: декомпилятор Get-Events → etObj['events']; компилятор Emit-Events (typeKey 'label', после Title) + 'events' в companionStructKeys (чтобы text+events шёл структурной веткой). Зеркало py. Round-trip формы НастройкиИнтеграцииМаркетплейс/ФормаЭлемента бит-в-бит (3 ExtendedTooltip с URLProcessing). Кейс input-fields (extendedTooltip +hyperlink +events URLProcessing) сертифицирован в 1С. Регресс 43/43 (ps1+py). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# form-compile v1.120 — Compile 1C managed form from JSON or object metadata
|
||||
# form-compile v1.121 — Compile 1C managed form from JSON or object metadata
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[string]$JsonPath,
|
||||
@@ -2356,7 +2356,7 @@ function Emit-Events {
|
||||
$script:companionStructKeys = @(
|
||||
'width','autoMaxWidth','maxWidth','height','autoMaxHeight','maxHeight','verticalAlign','titleHeight',
|
||||
'horizontalStretch','verticalStretch','horizontalAlign','groupHorizontalAlign','groupVerticalAlign',
|
||||
'visible','hidden','enabled','disabled','hyperlink',
|
||||
'visible','hidden','enabled','disabled','hyperlink','events',
|
||||
'textColor','backColor','borderColor','font','border','цветтекста','цветфона','цветрамки','шрифт','рамка'
|
||||
)
|
||||
function Test-CompanionStructured {
|
||||
@@ -2405,6 +2405,8 @@ function Emit-Companion {
|
||||
Emit-Layout -el $content -indent $inner
|
||||
Emit-Appearance -el $content -indent $inner -profile 'decoration'
|
||||
if ($txtPresent) { Emit-CompanionTitle -content $content -indent $inner }
|
||||
# События компаньона (ExtendedTooltip = LabelDecoration: напр. URLProcessing у hyperlink-подсказки)
|
||||
Emit-Events -el $content -elementName $name -indent $inner -typeKey 'label'
|
||||
} else {
|
||||
Emit-CompanionTitle -content $content -indent $inner
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# form-compile v1.120 — Compile 1C managed form from JSON or object metadata
|
||||
# form-compile v1.121 — Compile 1C managed form from JSON or object metadata
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
import argparse
|
||||
import copy
|
||||
@@ -2391,7 +2391,7 @@ def resolve_ml_formatted(val):
|
||||
COMPANION_STRUCT_KEYS = {
|
||||
'width', 'autoMaxWidth', 'maxWidth', 'height', 'autoMaxHeight', 'maxHeight', 'verticalAlign', 'titleHeight',
|
||||
'horizontalStretch', 'verticalStretch', 'horizontalAlign', 'groupHorizontalAlign', 'groupVerticalAlign',
|
||||
'visible', 'hidden', 'enabled', 'disabled', 'hyperlink',
|
||||
'visible', 'hidden', 'enabled', 'disabled', 'hyperlink', 'events',
|
||||
'textColor', 'backColor', 'borderColor', 'font', 'border', 'цветтекста', 'цветфона', 'цветрамки', 'шрифт', 'рамка',
|
||||
}
|
||||
|
||||
@@ -2420,6 +2420,8 @@ def emit_companion(lines, tag, name, indent, content=None):
|
||||
emit_appearance(lines, content, inner, 'decoration')
|
||||
if 'text' in content:
|
||||
emit_companion_title(lines, content, inner)
|
||||
# События компаньона (ExtendedTooltip = LabelDecoration: напр. URLProcessing у hyperlink-подсказки)
|
||||
emit_events(lines, content, name, inner, 'label')
|
||||
else:
|
||||
emit_companion_title(lines, content, inner)
|
||||
lines.append(f'{indent}</{tag}>')
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# form-decompile v0.96 — Decompile 1C managed Form.xml to JSON DSL (draft)
|
||||
# form-decompile v0.97 — Decompile 1C managed Form.xml to JSON DSL (draft)
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
# ВНИМАНИЕ: раундтрип не гарантируется. Навык исключён из авто-использования моделью.
|
||||
param(
|
||||
@@ -1895,8 +1895,7 @@ function Decompile-Element {
|
||||
Add-Layout $obj $node
|
||||
Add-GenericScalars $obj $node
|
||||
# extendedTooltip: companion <ExtendedTooltip> (это LabelDecoration). Текст-форма (только <Title>) →
|
||||
# строка/{text,formatted}. Own-content (layout/оформление/флаги/hyperlink) → объект { text?, … }.
|
||||
# Events компаньона пока НЕ захватываем (хвост — требует имя-обработчик).
|
||||
# строка/{text,formatted}. Own-content (layout/оформление/флаги/hyperlink/events) → объект { text?, … }.
|
||||
$etNode = $node.SelectSingleNode("lf:ExtendedTooltip", $ns)
|
||||
if ($etNode) {
|
||||
$etTitle = $etNode.SelectSingleNode("lf:Title", $ns)
|
||||
@@ -1908,6 +1907,8 @@ function Decompile-Element {
|
||||
if ((Get-Child $etNode 'Visible') -eq 'false') { $etObj['hidden'] = $true }
|
||||
if ((Get-Child $etNode 'Enabled') -eq 'false') { $etObj['disabled'] = $true }
|
||||
if ((Get-Child $etNode 'Hyperlink') -eq 'true') { $etObj['hyperlink'] = $true }
|
||||
# События компаньона (напр. URLProcessing у hyperlink-подсказки) — переиспользуем механизм событий элемента
|
||||
$etEv = Get-Events $etNode $name; if ($etEv) { $etObj['events'] = $etEv }
|
||||
if ($etObj.Count -gt 0) {
|
||||
if ($null -ne $textVal) {
|
||||
if ($textVal -is [System.Collections.IDictionary] -and $textVal.Contains('text')) { $etObj['text'] = $textVal['text']; if ($textVal['formatted']) { $etObj['formatted'] = $true } }
|
||||
|
||||
@@ -132,7 +132,7 @@
|
||||
| `tooltip` | string/object | Всплывающая подсказка элемента (`<ToolTip>`). Строка → ru, объект `{ "ru": …, "en": … }` → мультиязычный (как `title`). Эмитится сразу после `title` |
|
||||
| `tooltipRepresentation` | string | Режим показа подсказки (`<ToolTipRepresentation>`): `None`, `Button`, `ShowBottom`, `ShowTop`, `ShowLeft`, `ShowRight`, `ShowAuto`, `Balloon`. Эмитится при наличии |
|
||||
| `displayImportance` | string | Важность отображения (атрибут открывающего тега `DisplayImportance`): `VeryHigh`, `High`, `Usual`, `Low`, `VeryLow`. Адаптивная раскладка (моб./узкие формы). Применимо к любому элементу |
|
||||
| `extendedTooltip` | string/object | Расширенная подсказка (companion `<ExtendedTooltip>`, по сути LabelDecoration). **Текст-форма**: строка / ML / `{text, formatted}`. **Own-content форма** (объект с layout/оформлением/флагами): `{ text?, formatted?, width?, autoMaxWidth?, maxWidth?, height?, horizontalStretch?, verticalAlign?, titleHeight?, hyperlink?, visible?, enabled?, textColor?, font?, … }` — own-content эмитится перед `Title`. (События компаньона пока не поддержаны.) Синоним: `extTooltip` |
|
||||
| `extendedTooltip` | string/object | Расширенная подсказка (companion `<ExtendedTooltip>`, по сути LabelDecoration). **Текст-форма**: строка / ML / `{text, formatted}`. **Own-content форма** (объект с layout/оформлением/флагами): `{ text?, formatted?, width?, autoMaxWidth?, maxWidth?, height?, horizontalStretch?, verticalAlign?, titleHeight?, hyperlink?, visible?, enabled?, textColor?, font?, … }` — own-content эмитится перед `Title`. **События** компаньона — ключ `events` (та же грамматика, что у элемента; напр. `{ "URLProcessing": "Обработчик" }` у hyperlink-подсказки), эмитится после `Title`. Синоним: `extTooltip` |
|
||||
|
||||
#### Форма ML-текста и `formatted`
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
"input": {
|
||||
"title": "Поля ввода",
|
||||
"elements": [
|
||||
{ "input": "ОбычноеПоле", "path": "ОбычноеПоле", "title": "Обычное поле", "tooltip": "Введите значение поля", "tooltipRepresentation": "ShowBottom", "editMode": "EnterOnInput", "multiLine": false, "shortcut": "Ctrl+Shift+O", "horizontalStretch": false, "verticalStretch": false, "format": "ЧДЦ=2", "editFormat": "ЧДЦ=2; ЧН=", "extendedTooltip": { "width": 30, "autoMaxWidth": false, "text": "Расширенная подсказка поля" } },
|
||||
{ "input": "ОбычноеПоле", "path": "ОбычноеПоле", "title": "Обычное поле", "tooltip": "Введите значение поля", "tooltipRepresentation": "ShowBottom", "editMode": "EnterOnInput", "multiLine": false, "shortcut": "Ctrl+Shift+O", "horizontalStretch": false, "verticalStretch": false, "format": "ЧДЦ=2", "editFormat": "ЧДЦ=2; ЧН=", "extendedTooltip": { "width": 30, "autoMaxWidth": false, "hyperlink": true, "text": "Расширенная подсказка поля", "events": { "URLProcessing": "ОбычноеПолеРасширеннаяПодсказкаОбработкаНавигационнойСсылки" } } },
|
||||
{ "labelField": "Ссылка", "path": "ОбычноеПоле", "titleLocation": "left", "hyperlink": true, "format": { "ru": "ДЛФ=D", "en": "DLF=D" }, "warningOnEdit": "Поле только для чтения" },
|
||||
{ "input": "МногострочноеПоле", "path": "МногострочноеПоле", "multiLine": true, "height": 5, "title": "Комментарий", "wrap": false, "showInHeader": false, "showInFooter": false, "autoCellHeight": true, "footerHorizontalAlign": "Right", "openButton": false, "chooseType": false },
|
||||
{ "input": "ПолеПароля", "path": "ПолеПароля", "passwordMode": true, "title": "Пароль" },
|
||||
|
||||
+4
@@ -43,6 +43,7 @@
|
||||
</EditFormat>
|
||||
<ContextMenu name="ОбычноеПолеКонтекстноеМеню" id="2"/>
|
||||
<ExtendedTooltip name="ОбычноеПолеРасширеннаяПодсказка" id="3">
|
||||
<Hyperlink>true</Hyperlink>
|
||||
<AutoMaxWidth>false</AutoMaxWidth>
|
||||
<Width>30</Width>
|
||||
<Title formatted="false">
|
||||
@@ -51,6 +52,9 @@
|
||||
<v8:content>Расширенная подсказка поля</v8:content>
|
||||
</v8:item>
|
||||
</Title>
|
||||
<Events>
|
||||
<Event name="URLProcessing">ОбычноеПолеРасширеннаяПодсказкаОбработкаНавигационнойСсылки</Event>
|
||||
</Events>
|
||||
</ExtendedTooltip>
|
||||
</InputField>
|
||||
<LabelField name="Ссылка" id="4">
|
||||
|
||||
Reference in New Issue
Block a user