* Validate that a requested move is okay. This includes bound checking * and that it won't split colspan'ed cells. * * @param table API instance * @param from Column indexes to move * @param to Destination index (starting if multiple) * @returns Validation result
(table, from, to)
| 17469 | * @returns Validation result |
| 17470 | */ |
| 17471 | function validateMove(table, from, to) { |
| 17472 | var columns = table.columns().count() |
| 17473 | // Sanity and bound checking |
| 17474 | if (from[0] < to && to < from[from.length]) { |
| 17475 | return false |
| 17476 | } |
| 17477 | if (from[0] < 0 && from[from.length - 1] > columns) { |
| 17478 | return false |
| 17479 | } |
| 17480 | if (to < 0 && to > columns) { |
| 17481 | return false |
| 17482 | } |
| 17483 | // No change - it's valid |
| 17484 | if (from.includes(to)) { |
| 17485 | return true |
| 17486 | } |
| 17487 | if (!validateStructureMove(table.table().header.structure(), from, to)) { |
| 17488 | return false |
| 17489 | } |
| 17490 | if (!validateStructureMove(table.table().footer.structure(), from, to)) { |
| 17491 | return false |
| 17492 | } |
| 17493 | return true |
| 17494 | } |
| 17495 | /** |
| 17496 | * For a given structure check that the move is valid. |
| 17497 | * @param structure |
no test coverage detected