Skip to content

Commit

Permalink
fix: Float coordinates
Browse files Browse the repository at this point in the history
  • Loading branch information
ramedina86 committed Dec 11, 2024
1 parent 00464b0 commit 3bb930d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/ui/src/components/workflows/WorkflowsWorkflow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,8 @@ function moveNode(ev: MouseEvent) {
const component = wf.getComponentById(nodeId);
const { x, y } = getAdjustedCoordinates(ev);
const newX = x - offset.x;
const newY = y - offset.y;
const newX = Math.floor(x - offset.x);
const newY = Math.floor(y - offset.y);
if (component.x == newX && component.y == newY) return;
Expand Down
8 changes: 7 additions & 1 deletion src/writer/core_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from enum import Enum
from typing import Any, Dict, List, Literal, Optional, Union, cast

from pydantic import BaseModel, Field
from pydantic import BaseModel, Field, field_validator, validator
from typing_extensions import TypedDict

from writer.ss_types import ComponentDefinition, ServeMode
Expand Down Expand Up @@ -57,6 +57,12 @@ class Component(BaseModel):
x: Optional[int] = None
y: Optional[int] = None

@field_validator("x", "y", mode="before")
def cast_float_to_int(cls, v):
if isinstance(v, float):
return int(v)
return v

def to_dict(self) -> Dict:
"""
Wrapper for model_dump to ensure backward compatibility.
Expand Down

0 comments on commit 3bb930d

Please sign in to comment.