CenterForTheBuiltEnvironment / comfort-dash

Revision of the CBE Comfort Tool using Dash.
2 stars 12 forks source link

Feature Request: Store Only SI Variables in Local Storage #44

Closed Ha02hen closed 1 month ago

Ha02hen commented 1 month ago

Data Storage Approach

I think it might be more appropriate to store data based on units. From the current code implementation (as shown in the image), this approach handles unit conversion for labels, descriptions, and values.This part of the code handles unit conversion for label, description, and value. If we need to handle the value separately outside of the main code, it would require adding an additional method specifically for processing the value, and the convert_units() method would no longer handle value conversion. image

Current Code Logic

Additionally, the code segment in the image processes the content of the input fields. When the unit changes, the values are retrieved from here. Our current logic stores these values in the URL and updates the input fields based on URL changes. image image image

Impact of Storing Only SI Variables

If we only store SI variables in local storage, the code logic will change to: when the unit is switched, the content in the input fields will change, but the data in local storage and the URL will remain unchanged. This would significantly increase the complexity of the existing code.

Proposed Solution for Simplifying Code Expansion

To simplify future code expansion, we could add a units parameter to the relevant methods, allowing for easy conversion of data formats. This would require modifying only a single part of the code.

FedericoTartarini commented 1 month ago

Okay so we can implement your suggestion and store the values in the unit as selected in the application.