From 3bb930de82ebf5186196054fdebb187dad77058f Mon Sep 17 00:00:00 2001 From: Ramiro Medina <64783088+ramedina86@users.noreply.github.com> Date: Wed, 11 Dec 2024 20:35:25 +0000 Subject: [PATCH 1/2] fix: Float coordinates --- src/ui/src/components/workflows/WorkflowsWorkflow.vue | 4 ++-- src/writer/core_ui.py | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/ui/src/components/workflows/WorkflowsWorkflow.vue b/src/ui/src/components/workflows/WorkflowsWorkflow.vue index 6d2cb2166..8df276866 100644 --- a/src/ui/src/components/workflows/WorkflowsWorkflow.vue +++ b/src/ui/src/components/workflows/WorkflowsWorkflow.vue @@ -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; diff --git a/src/writer/core_ui.py b/src/writer/core_ui.py index a380a07a0..63d23e329 100644 --- a/src/writer/core_ui.py +++ b/src/writer/core_ui.py @@ -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 @@ -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. From 27b4e8a4ad9d7054dcb4dde63e3f7f71834d5e93 Mon Sep 17 00:00:00 2001 From: Ramiro Medina <64783088+ramedina86@users.noreply.github.com> Date: Wed, 11 Dec 2024 20:35:44 +0000 Subject: [PATCH 2/2] chore: Bump version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 7ec18f681..ab7e2d602 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "writer" -version = "0.8.3rc1" +version = "0.8.3rc2" description = "An open-source, Python framework for building feature-rich apps that are fully integrated with the Writer platform." authors = ["Writer, Inc."] readme = "README.md"