From c43ddfef2a4fe7a4a2a3df0679ad77b1a5b5476b Mon Sep 17 00:00:00 2001 From: Kumi Date: Thu, 28 Mar 2024 12:27:10 +0100 Subject: [PATCH] fix(editor): correct TeleportElement option and improve dropdown Correctly set the value for the Teleport option in the element creation form, ensuring that elements are correctly classified. Enhanced dynamic data fetching for scenes and categories to populate the destination dropdown based on the scene's category, improving user experience in specifying teleport destinations. Resolved an issue with event propagation by explicitly setting the button type for dropdown items, preventing form submission on selection. This change streamlines the process of creating teleport elements and selecting destinations within the editor, making it more intuitive and error-free. - Removed outdated TODO comment related to element drags handling. - Removed unused rotation input fields for a cleaner UI. - Added conversion function `thetaToCartesian` for future functionalities. --- assets/js/editor.js | 94 +++++++++++++++++++++--------------- assets/js/editor/teleport.js | 2 + 2 files changed, 58 insertions(+), 38 deletions(-) diff --git a/assets/js/editor.js b/assets/js/editor.js index 66e0676..0d1ea9f 100644 --- a/assets/js/editor.js +++ b/assets/js/editor.js @@ -30,7 +30,6 @@ function addEventListeners(element) { element.addEventListener("mouseup", function (event) { if (event.timeStamp - clickTimestamp > 200) { // Ignoring this, we only handle regular short clicks. - // TODO: Find a way to handle drags of elements return; } else { handleClick(event); @@ -73,7 +72,7 @@ function startCreateElement(event) { - + `; + var scene = findParentScene(event.target); + var scene_data_request = getScene(scene.getAttribute("id")); + document.getElementById("resetButton").classList.remove("hide"); document.getElementById("buttons").classList.remove("hide"); @@ -90,6 +92,14 @@ function startCreateElement(event) { .addEventListener("change", function () { var selectedType = document.getElementById("resourcetype").value; createElementPropertiesForm(selectedType, event, thetaStart); + + scene_data_request.then((scene_data) => { + var category_data_request = getCategory(scene_data.obj.category); + + category_data_request.then((category_data) => { + populateDestinationDropdown(null, category_data); + }); + }); }); } @@ -120,20 +130,6 @@ function createElementPropertiesForm(elementType) { -
- -
-
- -
-
- -
-
- -
-
-
`; if (elementType !== "MarkerElement") { inputFields += ` @@ -144,30 +140,30 @@ function createElementPropertiesForm(elementType) { } if (elementType === "TeleportElement") { inputFields += ` -