From 07567f76b8ffb6af5cbb4b9ee42e30b92307dc75 Mon Sep 17 00:00:00 2001 From: Steven Kearnes Date: Tue, 14 Jan 2025 13:29:31 -0500 Subject: [PATCH 1/3] Add missing texture fields to editor --- ord_interface/editor/html/reaction.html | 24 ++++++++++++++++++++++++ ord_interface/editor/js/compounds.js | 18 ++++++++++++++++++ ord_interface/editor/js/crudes.js | 17 +++++++++++++++++ ord_interface/editor/js/inputs.js | 18 ++++++++++++++++++ 4 files changed, 77 insertions(+) diff --git a/ord_interface/editor/html/reaction.html b/ord_interface/editor/html/reaction.html index 5877d766..977ee246 100644 --- a/ord_interface/editor/html/reaction.html +++ b/ord_interface/editor/html/reaction.html @@ -206,6 +206,18 @@
+
+ + + Input characteristics + +
+ + + +
texture
texture details
+
+
@@ -278,6 +290,18 @@
+
+ + + Component characteristics + +
+ + + +
texture
texture details
+
+
diff --git a/ord_interface/editor/js/compounds.js b/ord_interface/editor/js/compounds.js index f400c63e..27a5b2d3 100644 --- a/ord_interface/editor/js/compounds.js +++ b/ord_interface/editor/js/compounds.js @@ -58,6 +58,8 @@ const Data = goog.require('proto.ord.Data'); const ProductCompound = goog.require('proto.ord.ProductCompound'); const ReactionRoleType = goog.require('proto.ord.ReactionRole.ReactionRoleType'); +const Texture = goog.require('proto.ord.Texture'); +const TextureType = goog.require('proto.ord.Texture.TextureType'); /** * Adds and populates the form's fields describing multiple compounds for a @@ -119,6 +121,12 @@ function loadIntoCompound(node, compound) { const featureNode = addFeature(node); loadFeature(featureNode, name, feature); }); + + const texture = compound.getTexture(); + if (texture) { + utils.setSelector($('.component_texture_type', node), texture.getType()); + $('.component_texture_details', node).text(texture.getDetails()); + } } /** @@ -245,6 +253,16 @@ function unloadCompound(node) { } }); + const texture = new Texture(); + const textureType = + utils.getSelectorText($('.component_texture_type', node)[0]); + texture.setType(TextureType[textureType]); + texture.setDetails( + asserts.assertString($('.component_texture_details', node).text())); + if (!utils.isEmptyMessage(texture)) { + compound.setTexture(texture); + } + return compound; } diff --git a/ord_interface/editor/js/crudes.js b/ord_interface/editor/js/crudes.js index 463c99f2..2875484f 100644 --- a/ord_interface/editor/js/crudes.js +++ b/ord_interface/editor/js/crudes.js @@ -28,6 +28,8 @@ const amounts = goog.require('ord.amounts'); const utils = goog.require('ord.utils'); const CrudeComponent = goog.require('proto.ord.CrudeComponent'); +const Texture = goog.require('proto.ord.Texture'); +const TextureType = goog.require('proto.ord.Texture.TextureType'); /** * Adds and populates the crude components of a reaction input. @@ -56,6 +58,12 @@ function loadCrude(root, crude) { const amount = crude.getAmount(); amounts.load(node, amount); + + const texture = crude.getTexture(); + if (texture) { + utils.setSelector($('.crude_texture_type', node), texture.getType()); + $('.crude_texture_details', node).text(texture.getDetails()); + } } /** @@ -104,6 +112,15 @@ function unloadCrude(node) { crude.setAmount(amount); } + const texture = new Texture(); + const textureType = utils.getSelectorText($('.crude_texture_type', node)[0]); + texture.setType(TextureType[textureType]); + texture.setDetails( + asserts.assertString($('.crude_texture_details', node).text())); + if (!utils.isEmptyMessage(texture)) { + crude.setTexture(texture); + } + return crude; } diff --git a/ord_interface/editor/js/inputs.js b/ord_interface/editor/js/inputs.js index 457c4c3f..daa3407f 100644 --- a/ord_interface/editor/js/inputs.js +++ b/ord_interface/editor/js/inputs.js @@ -34,6 +34,8 @@ const AdditionSpeed = goog.require('proto.ord.ReactionInput.AdditionSpeed'); const AdditionSpeedType = goog.require('proto.ord.ReactionInput.AdditionSpeed.AdditionSpeedType'); const Temperature = goog.require('proto.ord.Temperature'); +const Texture = goog.require('proto.ord.Texture'); +const TextureType = goog.require('proto.ord.Texture.TextureType'); const Time = goog.require('proto.ord.Time'); exports = { @@ -156,6 +158,13 @@ function loadInputUnnamed(node, input) { if (flowRate) { utils.writeMetric('.input_flow_rate', flowRate, node); } + + const texture = input.getTexture(); + if (texture) { + utils.setSelector($('.input_texture_type', node), texture.getType()); + $('.input_texture_details', node).text(texture.getDetails()); + } + return node; } @@ -250,6 +259,15 @@ function unloadInputUnnamed(node) { input.setFlowRate(flowRate); } + const texture = new Texture(); + const textureType = utils.getSelectorText($('.input_texture_type', node)[0]); + texture.setType(TextureType[textureType]); + texture.setDetails( + asserts.assertString($('.input_texture_details', node).text())); + if (!utils.isEmptyMessage(texture)) { + input.setTexture(texture); + } + return input; } From f858d20f815bae1ea3585bd435f98e086a7b07a0 Mon Sep 17 00:00:00 2001 From: Steven Kearnes Date: Tue, 14 Jan 2025 13:30:29 -0500 Subject: [PATCH 2/3] undo changes to crudes --- ord_interface/editor/js/crudes.js | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/ord_interface/editor/js/crudes.js b/ord_interface/editor/js/crudes.js index 2875484f..463c99f2 100644 --- a/ord_interface/editor/js/crudes.js +++ b/ord_interface/editor/js/crudes.js @@ -28,8 +28,6 @@ const amounts = goog.require('ord.amounts'); const utils = goog.require('ord.utils'); const CrudeComponent = goog.require('proto.ord.CrudeComponent'); -const Texture = goog.require('proto.ord.Texture'); -const TextureType = goog.require('proto.ord.Texture.TextureType'); /** * Adds and populates the crude components of a reaction input. @@ -58,12 +56,6 @@ function loadCrude(root, crude) { const amount = crude.getAmount(); amounts.load(node, amount); - - const texture = crude.getTexture(); - if (texture) { - utils.setSelector($('.crude_texture_type', node), texture.getType()); - $('.crude_texture_details', node).text(texture.getDetails()); - } } /** @@ -112,15 +104,6 @@ function unloadCrude(node) { crude.setAmount(amount); } - const texture = new Texture(); - const textureType = utils.getSelectorText($('.crude_texture_type', node)[0]); - texture.setType(TextureType[textureType]); - texture.setDetails( - asserts.assertString($('.crude_texture_details', node).text())); - if (!utils.isEmptyMessage(texture)) { - crude.setTexture(texture); - } - return crude; } From 6595b712574969fcf908781b6eb7e8d33871a842 Mon Sep 17 00:00:00 2001 From: Steven Kearnes Date: Tue, 14 Jan 2025 13:44:08 -0500 Subject: [PATCH 3/3] update tests --- .../editor/db/680b0d9fe649417cb092d790907bd5a5/full.pbtxt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ord_interface/editor/db/680b0d9fe649417cb092d790907bd5a5/full.pbtxt b/ord_interface/editor/db/680b0d9fe649417cb092d790907bd5a5/full.pbtxt index 0ede50e0..d781b477 100644 --- a/ord_interface/editor/db/680b0d9fe649417cb092d790907bd5a5/full.pbtxt +++ b/ord_interface/editor/db/680b0d9fe649417cb092d790907bd5a5/full.pbtxt @@ -48,6 +48,10 @@ reactions { format: "txt" } } + texture { + type: POWDER + details: "121" + } } crude_components { reaction_id: "15.25" @@ -90,6 +94,10 @@ reactions { precision: 24.0 units: FAHRENHEIT } + texture { + type: POWDER + details: "123" + } } } inputs {