|
2233 | 2233 |
|
2234 | 2234 | // и напоследок.. выделение/показ только что добавленного клиента/строки |
2235 | 2235 | setTimeout(() => { |
2236 | | - // TODO: |
2237 | | - // movingToLastNewTableRow(); |
| 2236 | + movingToLastNewTableRow(); // перемещение фокуса |
2238 | 2237 | }, 300); // временная задержка, больше.. чтобы модальное окно успело закрыться |
2239 | 2238 | }, 200); |
2240 | 2239 | } catch (error) { |
|
2296 | 2295 | saveButton.style.opacity = saveButton.disabled ? '0.5' : '1'; |
2297 | 2296 | saveButton.style.cursor = saveButton.disabled ? 'help' : 'pointer'; |
2298 | 2297 | } |
| 2298 | + |
| 2299 | + // ** перемещение/фиксация области просмотра на только что добавленном клиенте/на последней строке (выделение цветом) |
| 2300 | + function movingToLastNewTableRow() { |
| 2301 | + if (!outputTable) { |
| 2302 | + console.error('Таблица НЕ обнаружена!'); |
| 2303 | + return; |
| 2304 | + } |
| 2305 | + |
| 2306 | + const lastNewTableRow = outTableBody.lastElementChild; |
| 2307 | + const defaultRowCellColors = []; |
| 2308 | + |
| 2309 | + if (lastNewTableRow) { |
| 2310 | + // перемещение к "новому" клиенту/к последней строке таблицы |
| 2311 | + lastNewTableRow.scrollIntoView({ |
| 2312 | + behavior: 'smooth', |
| 2313 | + block: 'center', |
| 2314 | + }); |
| 2315 | + |
| 2316 | + // изменение цвета/выделение строки |
| 2317 | + lastNewTableRow.querySelectorAll('td').forEach((td) => { |
| 2318 | + defaultRowCellColors.push(td.style.color); |
| 2319 | + td.style.fontWeight = 'bold'; |
| 2320 | + // td.style.color = '#e10c22'; // красный |
| 2321 | + td.style.color = '#198754'; // или.. зелёный |
| 2322 | + }); |
| 2323 | + |
| 2324 | + // возврат к default цвету, через несколько секунды |
| 2325 | + setTimeout(() => { |
| 2326 | + lastNewTableRow.querySelectorAll('td').forEach((td, index) => { |
| 2327 | + td.style.fontWeight = 'normal'; |
| 2328 | + td.style.color = defaultRowCellColors[index]; |
| 2329 | + }); |
| 2330 | + }, 2000); |
| 2331 | + } |
| 2332 | + } |
2299 | 2333 | })(); |
0 commit comments