* Update view position when dragging * @param dragId The id of the view being dragged * @param targetId The id of the target view * @param direction The direction relative to target ("up" | "down") * @param tableId The table id that these views belong to
(props: {
dragId: string
targetId: string
direction: "up" | "down"
tableId: string
})
| 236 | * @param tableId The table id that these views belong to |
| 237 | */ |
| 238 | public async movePosition(props: { |
| 239 | dragId: string |
| 240 | targetId: string |
| 241 | direction: "up" | "down" |
| 242 | tableId: string |
| 243 | }): Promise<void> { |
| 244 | const { dragId, targetId, direction, tableId } = props |
| 245 | |
| 246 | // Don't do anything if dragging onto itself |
| 247 | if (dragId === targetId) { |
| 248 | return |
| 249 | } |
| 250 | |
| 251 | try { |
| 252 | // Get new position |
| 253 | const newPosition = await this.getPosition({ |
| 254 | tableId, |
| 255 | targetId, |
| 256 | targetDirection: direction, |
| 257 | }) |
| 258 | |
| 259 | // Update the position in database |
| 260 | await this.updatePosition(dragId, newPosition) |
| 261 | |
| 262 | await this.checkAndReorderIfNeeded(tableId) |
| 263 | } catch (error) { |
| 264 | console.error("Failed to move view position:", error) |
| 265 | throw new Error("Failed to update view position") |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | /** |
| 270 | * Batch reorder views |
no test coverage detected