mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-07-29 16:11:01 +03:00
feat(web-test): normalize navigateLink URLs
- Auto-prepend e1cib/list/ when missing - Translate English type names to Russian (AccumulationRegister → РегистрНакопления, etc.) - Accepts: full e1cib/..., short Тип.Имя, or English Type.Имя Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
e58f5c1f82
commit
a17a81fe98
@@ -218,13 +218,17 @@ Hint: if `readTable()` returns `hierarchical: true`, the list has groups.
|
|||||||
### Navigation links
|
### Navigation links
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// Open any form directly by 1C navigation link (e1cib/...)
|
// Full e1cib link
|
||||||
await navigateLink('e1cib/list/РегистрНакопления.ЗаказыКлиентов');
|
await navigateLink('e1cib/list/РегистрНакопления.ЗаказыКлиентов');
|
||||||
await navigateLink('e1cib/list/Документ.ЗаказКлиента');
|
// Short form — auto-prepends e1cib/list/
|
||||||
await navigateLink('e1cib/list/Справочник.Контрагенты');
|
await navigateLink('Документ.ЗаказКлиента');
|
||||||
|
// English type names — auto-translated to Russian
|
||||||
|
await navigateLink('AccumulationRegister.ЗаказыКлиентов');
|
||||||
|
await navigateLink('Catalog.Контрагенты');
|
||||||
```
|
```
|
||||||
|
|
||||||
Bypasses section/command navigation. Useful for registers, journals, and any form with a known path.
|
Bypasses section/command navigation. Useful for registers, journals, and any form with a known path.
|
||||||
|
Auto-normalizes: `e1cib/list/` prefix + English→Russian type translation.
|
||||||
|
|
||||||
### Submenu navigation
|
### Submenu navigation
|
||||||
|
|
||||||
|
|||||||
@@ -340,14 +340,50 @@ export async function switchTab(name) {
|
|||||||
return await getFormState();
|
return await getFormState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// English → Russian metadata type mapping for e1cib navigation links
|
||||||
|
const E1CIB_TYPE_MAP = {
|
||||||
|
'catalog': 'Справочник', 'catalogs': 'Справочник',
|
||||||
|
'document': 'Документ', 'documents': 'Документ',
|
||||||
|
'commonmodule': 'ОбщийМодуль',
|
||||||
|
'enum': 'Перечисление', 'enums': 'Перечисление',
|
||||||
|
'dataprocessor': 'Обработка', 'dataprocessors': 'Обработка',
|
||||||
|
'report': 'Отчет', 'reports': 'Отчет',
|
||||||
|
'accumulationregister': 'РегистрНакопления',
|
||||||
|
'informationregister': 'РегистрСведений',
|
||||||
|
'accountingregister': 'РегистрБухгалтерии',
|
||||||
|
'calculationregister': 'РегистрРасчета',
|
||||||
|
'chartofaccounts': 'ПланСчетов',
|
||||||
|
'chartofcharacteristictypes': 'ПланВидовХарактеристик',
|
||||||
|
'chartofcalculationtypes': 'ПланВидовРасчета',
|
||||||
|
'businessprocess': 'БизнесПроцесс',
|
||||||
|
'task': 'Задача',
|
||||||
|
'exchangeplan': 'ПланОбмена',
|
||||||
|
'constant': 'Константа',
|
||||||
|
};
|
||||||
|
|
||||||
|
function normalizeE1cibUrl(url) {
|
||||||
|
// Already a full e1cib link
|
||||||
|
if (url.startsWith('e1cib/')) return url;
|
||||||
|
// "ТипОбъекта.Имя" or "EnglishType.Имя" — prepend e1cib/list/ and translate type if needed
|
||||||
|
const dot = url.indexOf('.');
|
||||||
|
if (dot > 0) {
|
||||||
|
const typePart = url.substring(0, dot);
|
||||||
|
const namePart = url.substring(dot + 1);
|
||||||
|
const ruType = E1CIB_TYPE_MAP[typePart.toLowerCase()] || typePart;
|
||||||
|
return `e1cib/list/${ruType}.${namePart}`;
|
||||||
|
}
|
||||||
|
return `e1cib/list/${url}`;
|
||||||
|
}
|
||||||
|
|
||||||
/** Navigate to a 1C navigation link via Shift+F11 dialog. Returns new form state. */
|
/** Navigate to a 1C navigation link via Shift+F11 dialog. Returns new form state. */
|
||||||
export async function navigateLink(url) {
|
export async function navigateLink(url) {
|
||||||
ensureConnected();
|
ensureConnected();
|
||||||
await dismissPendingErrors();
|
await dismissPendingErrors();
|
||||||
|
const link = normalizeE1cibUrl(url);
|
||||||
const formBefore = await page.evaluate(detectFormScript());
|
const formBefore = await page.evaluate(detectFormScript());
|
||||||
|
|
||||||
// Copy link to clipboard, press Shift+F11 (opens "Go to link" dialog with clipboard content)
|
// Copy link to clipboard, press Shift+F11 (opens "Go to link" dialog with clipboard content)
|
||||||
await page.evaluate(`navigator.clipboard.writeText(${JSON.stringify(url)})`);
|
await page.evaluate(`navigator.clipboard.writeText(${JSON.stringify(link)})`);
|
||||||
await page.keyboard.press('Shift+F11');
|
await page.keyboard.press('Shift+F11');
|
||||||
await waitForStable();
|
await waitForStable();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user