Merge branch 'dev'

This commit is contained in:
Nick Shirokov
2026-03-14 18:10:41 +03:00
2 changed files with 32 additions and 25 deletions
+2 -1
View File
@@ -1560,7 +1560,8 @@ export async function clickElement(text, { dblclick, table } = {}) {
// Tree node: click the tree expand/collapse icon [tree="true"] for toggle // Tree node: click the tree expand/collapse icon [tree="true"] for toggle
const treeIconCoords = await page.evaluate(`(() => { const treeIconCoords = await page.evaluate(`(() => {
const p = ${JSON.stringify(`form${formNum}_`)}; const p = ${JSON.stringify(`form${formNum}_`)};
const grid = document.querySelector('[id^="' + p + '"].grid'); const gridSel = ${JSON.stringify(target.gridId ? '#' + target.gridId : null)};
const grid = gridSel ? document.querySelector(gridSel) : document.querySelector('[id^="' + p + '"].grid');
const body = grid?.querySelector('.gridBody'); const body = grid?.querySelector('.gridBody');
if (!body) return null; if (!body) return null;
const lines = [...body.querySelectorAll('.gridLine')]; const lines = [...body.querySelectorAll('.gridLine')];
+30 -24
View File
@@ -685,31 +685,37 @@ export function findClickTargetScript(formNum, text, { tableName, gridSelector }
} }
// Grid rows — fallback: search in table rows (for hierarchical/tree navigation) // Grid rows — fallback: search in table rows (for hierarchical/tree navigation)
const grid = document.querySelector('[id^="' + p + '"].grid'); // Search ALL visible grids (or specific grid when table parameter is set)
if (grid) { let grids;
if (gridSelector) {
const g = document.querySelector(gridSelector);
grids = g ? [g] : [];
} else {
grids = [...document.querySelectorAll('[id^="' + p + '"].grid')].filter(g => g.offsetWidth > 0);
}
for (const grid of grids) {
const body = grid.querySelector('.gridBody'); const body = grid.querySelector('.gridBody');
if (body) { if (!body) continue;
const lines = [...body.querySelectorAll('.gridLine')]; const lines = [...body.querySelectorAll('.gridLine')];
for (const line of lines) { for (const line of lines) {
const textBoxes = [...line.querySelectorAll('.gridBoxText')].filter(b => b.offsetWidth > 0); const textBoxes = [...line.querySelectorAll('.gridBoxText')].filter(b => b.offsetWidth > 0);
const rowTexts = textBoxes.map(b => b.innerText?.trim() || '').filter(Boolean); const rowTexts = textBoxes.map(b => b.innerText?.trim() || '').filter(Boolean);
const firstCell = rowTexts[0]?.toLowerCase() || ''; const firstCell = rowTexts[0]?.toLowerCase() || '';
const rowText = rowTexts.join(' ').toLowerCase(); const rowText = rowTexts.join(' ').toLowerCase();
if (firstCell === target || rowText === target || (target.length >= 4 && (firstCell.includes(target) || rowText.includes(target)))) { if (firstCell === target || rowText === target || (target.length >= 4 && (firstCell.includes(target) || rowText.includes(target)))) {
const imgBox = line.querySelector('.gridBoxImg'); const imgBox = line.querySelector('.gridBoxImg');
const isGroup = imgBox?.querySelector('.gridListH') !== null; const isGroup = imgBox?.querySelector('.gridListH') !== null;
const isParent = imgBox?.querySelector('.gridListV') !== null; const isParent = imgBox?.querySelector('.gridListV') !== null;
const isTreeNode = line.querySelector('.gridBoxTree') !== null; const isTreeNode = line.querySelector('.gridBoxTree') !== null;
const hasChildren = imgBox?.querySelector('[tree="true"]') !== null; const hasChildren = imgBox?.querySelector('[tree="true"]') !== null;
let kind; let kind;
if (isGroup) kind = 'gridGroup'; if (isGroup) kind = 'gridGroup';
else if (isParent) kind = 'gridParent'; else if (isParent) kind = 'gridParent';
else if (isTreeNode && hasChildren) kind = 'gridTreeNode'; else if (isTreeNode && hasChildren) kind = 'gridTreeNode';
else kind = 'gridRow'; else kind = 'gridRow';
const r = line.getBoundingClientRect(); const r = line.getBoundingClientRect();
return { id: '', kind, name: rowTexts[0] || '', return { id: '', kind, name: rowTexts[0] || '', gridId: grid.id,
x: Math.round(r.x + r.width / 2), y: Math.round(r.y + r.height / 2) }; x: Math.round(r.x + r.width / 2), y: Math.round(r.y + r.height / 2) };
}
} }
} }
} }